mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-07 12:05:34 +00:00
fixing various issues
This commit is contained in:
parent
f5cba5b33c
commit
e6c59658ae
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2673,7 +2673,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "television"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"better-panic",
|
||||
|
@ -42,9 +42,7 @@ fn get_current_shell() -> Option<String> {
|
||||
}
|
||||
|
||||
fn get_raw_aliases(shell: &str) -> Vec<String> {
|
||||
match shell {
|
||||
"bash" => {
|
||||
let output = std::process::Command::new("bash")
|
||||
let output = std::process::Command::new(shell)
|
||||
.arg("-i")
|
||||
.arg("-c")
|
||||
.arg("alias")
|
||||
@ -52,20 +50,6 @@ fn get_raw_aliases(shell: &str) -> Vec<String> {
|
||||
.expect("failed to execute process");
|
||||
let aliases = String::from_utf8(output.stdout).unwrap();
|
||||
aliases.lines().map(ToString::to_string).collect()
|
||||
}
|
||||
"zsh" => {
|
||||
let output = std::process::Command::new("zsh")
|
||||
.arg("-i")
|
||||
.arg("-c")
|
||||
.arg("alias")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
let aliases = String::from_utf8(output.stdout).unwrap();
|
||||
aliases.lines().map(ToString::to_string).collect()
|
||||
}
|
||||
// TODO: add more shells
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
|
@ -85,9 +85,9 @@ impl Picker {
|
||||
self.view_offset = self.view_offset.saturating_sub(1);
|
||||
}
|
||||
} else {
|
||||
self.view_offset = total_items.saturating_sub(height - 2);
|
||||
self.view_offset = total_items.saturating_sub(height.saturating_sub(2));
|
||||
self.select(Some(total_items.saturating_sub(1)));
|
||||
self.relative_select(Some(height - 3));
|
||||
self.relative_select(Some(height.saturating_sub(3)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,10 +99,10 @@ impl Picker {
|
||||
self.relative_select(Some(0));
|
||||
return;
|
||||
}
|
||||
if self.relative_selected().unwrap_or(0) == height - 3 {
|
||||
if self.relative_selected().unwrap_or(0) == height.saturating_sub(3) {
|
||||
self.view_offset += 1;
|
||||
self.relative_select(Some(
|
||||
self.selected().unwrap_or(0).min(height - 3),
|
||||
self.selected().unwrap_or(0).min(height.saturating_sub(3)),
|
||||
));
|
||||
} else {
|
||||
self.relative_select(Some(
|
||||
|
@ -426,6 +426,9 @@ impl Television {
|
||||
.style(Style::default());
|
||||
|
||||
let input_block_inner = input_block.inner(layout.input);
|
||||
if input_block_inner.area() == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
f.render_widget(input_block, layout.input);
|
||||
|
||||
|
@ -61,7 +61,7 @@ impl Layout {
|
||||
// split the main block into two vertical chunks (help bar + rest)
|
||||
let hz_chunks = layout::Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Length(9), Constraint::Fill(1)])
|
||||
.constraints([Constraint::Max(9), Constraint::Fill(1)])
|
||||
.split(main_block);
|
||||
|
||||
// split the help bar into three horizontal chunks (left + center + right)
|
||||
@ -95,13 +95,13 @@ impl Layout {
|
||||
// left block: results + input field
|
||||
let left_chunks = layout::Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Min(10), Constraint::Length(3)])
|
||||
.constraints([Constraint::Min(3), Constraint::Length(3)])
|
||||
.split(vt_chunks[0]);
|
||||
|
||||
// right block: preview title + preview
|
||||
let right_chunks = layout::Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Length(3), Constraint::Min(10)])
|
||||
.constraints([Constraint::Length(3), Constraint::Min(3)])
|
||||
.split(vt_chunks[1]);
|
||||
|
||||
Self::new(
|
||||
@ -145,5 +145,5 @@ fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
|
||||
}
|
||||
|
||||
// UI size
|
||||
const UI_WIDTH_PERCENT: u16 = 90;
|
||||
const UI_HEIGHT_PERCENT: u16 = 90;
|
||||
const UI_WIDTH_PERCENT: u16 = 95;
|
||||
const UI_HEIGHT_PERCENT: u16 = 95;
|
||||
|
@ -3,8 +3,8 @@ use crate::previewers::{
|
||||
Preview, PreviewContent, FILE_TOO_LARGE_MSG, PREVIEW_NOT_SUPPORTED_MSG,
|
||||
};
|
||||
use crate::television::Television;
|
||||
use crate::ui::BORDER_COLOR;
|
||||
use crate::ui::layout::Layout;
|
||||
use crate::ui::BORDER_COLOR;
|
||||
use crate::utils::strings::{shrink_with_ellipsis, EMPTY_STRING};
|
||||
use color_eyre::eyre::Result;
|
||||
use ratatui::layout::{Alignment, Rect};
|
||||
@ -235,6 +235,9 @@ impl Television {
|
||||
return paragraph.clone();
|
||||
}
|
||||
let message_len = message.len();
|
||||
if message_len + 8 > inner.width as usize {
|
||||
return Paragraph::new(Text::from(EMPTY_STRING));
|
||||
}
|
||||
let fill_char_str = fill_char.to_string();
|
||||
let fill_line = fill_char_str.repeat(inner.width as usize);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user