Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
feat(tui): status strip, scrollable help, adaptive caps, poster placeholder
Samir Hossains2d58a77eb56e
diff --git a/src/tui/app/keyboard.rs b/src/tui/app/keyboard.rsindex c924676..12ef6b7 100644--- a/src/tui/app/keyboard.rs+++ b/src/tui/app/keyboard.rs@@ -9,6 +9,23 @@ impl App {pub(super) async fn handle_key(&mut self, key: KeyEvent) -> Option<()> {use crossterm::event::{KeyCode, KeyModifiers};+ if self.state.show_help {+ match key.code {+ KeyCode::Up | KeyCode::PageUp => {+ self.state.help_scroll = self.state.help_scroll.saturating_sub(1);+ }+ KeyCode::Down | KeyCode::PageDown => {+ self.state.help_scroll = self.state.help_scroll.saturating_add(1);+ }+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('?') => {+ self.state.show_help = false;+ self.state.help_scroll = 0;+ }+ _ => {}+ }+ return None;+ }+if key.modifiers.contains(KeyModifiers::CONTROL) {if let KeyCode::Char('c') = key.code {self.action_sender.send(Action::Quit).ok();diff --git a/src/tui/app/run.rs b/src/tui/app/run.rsindex ef1ef6a..856d5aa 100644--- a/src/tui/app/run.rs+++ b/src/tui/app/run.rs@@ -305,6 +305,12 @@ impl App {}Action::WheelScroll { up } => {+ if self.state.show_help {+ let delta = 3 * if up { -1i32 } else { 1 };+ self.state.help_scroll =+ (self.state.help_scroll as i32 + delta).max(0) as usize;+ return None;+ }let steps = if self.state.active_screen == Screen::Home&& !self.state.favorites_focus&& !self.state.search_results.is_empty()@@ -541,6 +547,26 @@ impl App {if self.state.show_help {crate::tui::screens::help::draw(frame, main_area, &self.state, &self.theme);}+ if self.state.status_timer > 0 && !self.state.status_message.is_empty() {+ let bottom = frame.area().height.saturating_sub(1);+ let message = crate::tui::text::truncate_width(+ &self.state.status_message.clone(),+ (frame.area().width as usize).saturating_sub(4),+ );+ let strip_area = ratatui::layout::Rect {+ x: 0,+ y: bottom,+ width: frame.area().width,+ height: 1,+ };+ frame.render_widget(+ ratatui::widgets::Paragraph::new(format!(" {message} "))+ .alignment(ratatui::layout::Alignment::Center)+ .style(self.theme.accent),+ strip_area,+ );+ }+if let Some(prog) = self.state.download_progress {if let Some(dl_area) = download_area {use ratatui::widgets::{Block, Borders, Gauge};diff --git a/src/tui/app/system.rs b/src/tui/app/system.rsindex c5c7b71..aa923a5 100644--- a/src/tui/app/system.rs+++ b/src/tui/app/system.rs@@ -131,6 +131,9 @@ impl App {Action::ToggleHelp => {if matches!(self.state.active_screen, Screen::Home | Screen::Details) {self.state.show_help = !self.state.show_help;+ if self.state.show_help {+ self.state.help_scroll = 0;+ }if self.state.show_help {self.state.show_theme_popup = false;self.state.show_browse_popup = false;diff --git a/src/tui/overlay.rs b/src/tui/overlay.rsindex 3b7bca9..eacbe0b 100644--- a/src/tui/overlay.rs+++ b/src/tui/overlay.rs@@ -11,7 +11,11 @@ use ratatui::{use crate::tui::theme::Theme;-const MAX_PICKER_ROWS: usize = 8;+const MAX_PICKER_ROWS_CAP: usize = 14;++fn max_picker_rows(area: Rect) -> usize {+ (area.height.saturating_sub(6) as usize / 2).clamp(4, MAX_PICKER_ROWS_CAP)+}pub use crate::models::{Notification, NotificationKind};@@ -27,7 +31,7 @@ pub fn picker_layout(confirm_label: &str,minimum_width: u16,) -> Rect {- let visible_rows = items.len().clamp(1, MAX_PICKER_ROWS);+ let visible_rows = items.len().clamp(1, max_picker_rows(area));let footer_str = format!("[↑↓] Move [Enter] {confirm_label} [Esc] Back");let footer_width = crate::tui::text::width(&footer_str);let content_width = items@@ -111,7 +115,7 @@ pub fn picker(.selected().unwrap_or(0).min(items.len().saturating_sub(1));- let visible_rows = items.len().clamp(1, MAX_PICKER_ROWS);+ let visible_rows = items.len().clamp(1, max_picker_rows(area));let popup = picker_layout(area, items, spec.confirm_label, spec.minimum_width);clear_modal_area(frame, area, popup, theme);diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rsindex f3d4c60..6a8f2e1 100644--- a/src/tui/screens/details.rs+++ b/src/tui/screens/details.rs@@ -537,7 +537,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)language_count.max(state.available_seasons.len()).max(episode_count)- .min(4) as u16+ .min((bottom_area.height / 3).clamp(4, 10) as usize) as u16+ 2};diff --git a/src/tui/screens/help.rs b/src/tui/screens/help.rsindex 5516b19..fcd6748 100644--- a/src/tui/screens/help.rs+++ b/src/tui/screens/help.rs@@ -236,9 +236,42 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {let content_width = help_text.iter().map(Line::width).max().unwrap_or(42) as u16;let total_lines = help_text.len() as u16;- let available_height = area.height.saturating_sub(4);+ let capacity = area.height.saturating_sub(6).max(4) as usize;- let two_columns = total_lines > available_height;+ if total_lines as usize > capacity {+ let max_scroll = help_text.len().saturating_sub(capacity);+ let scroll = state.help_scroll.min(max_scroll);+ let window: Vec<Line> = help_text[scroll..scroll + capacity.min(help_text.len())].to_vec();+ let position = if max_scroll > 0 {+ format!(" · {}/{scroll_max}", scroll + 1, scroll_max = max_scroll)+ } else {+ String::new()+ };+ let title = format!(" Help · {mode_title}{position} ");+ let block = Block::default()+ .title(title)+ .title_alignment(Alignment::Center)+ .title_style(theme.title)+ .borders(Borders::ALL)+ .border_type(crate::tui::overlay::border_type(state.basic_terminal))+ .border_style(theme.border_focus);+ let p = Paragraph::new(window)+ .block(block)+ .alignment(Alignment::Left);+ frame.render_widget(+ p,+ crate::tui::overlay::centered(+ area,+ (content_width + 8).min(area.width.saturating_sub(2)),+ capacity as u16 + 2,+ 46,+ 120,+ ),+ );+ return;+ }++ let two_columns = total_lines as usize > capacity;let desired_width = if two_columns {content_width.saturating_mul(2).saturating_add(8)diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rsindex 53cc50d..d226355 100644--- a/src/tui/screens/home.rs+++ b/src/tui/screens/home.rs@@ -58,6 +58,14 @@ pub(crate) fn slash_command_description(cmd: &str, state: &AppState) -> Option<&crate::tui::commands::SlashCommand::description_for(cmd, state)}+pub(crate) fn poster_placeholder_lines(basic: bool) -> &'static str {+ if basic {+ "[ no poster ]"+ } else {+ "┌──────┐\n│ ▓ ▓ │\n│ ── │\n│ ▓ ▓ │\n└──────┘"+ }+}+pub(crate) fn search_deck_width(area: Rect, state: &AppState, landing: bool) -> u16 {let query_width = if state.search_query.is_empty() {crate::tui::text::width(if state.is_tv_mode {@@ -762,9 +770,10 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)frame.render_widget(ratatui_image::Image::new(proto), p_area);}} else {- let placeholder = Paragraph::new("No\nPoster")- .style(theme.text_dim)- .alignment(Alignment::Center);+ let placeholder =+ Paragraph::new(poster_placeholder_lines(state.basic_terminal))+ .style(theme.text_dim)+ .alignment(Alignment::Center);frame.render_widget(placeholder, poster_area);}} else {diff --git a/src/tui/state.rs b/src/tui/state.rsindex 8a270ee..7a215f6 100644--- a/src/tui/state.rs+++ b/src/tui/state.rs@@ -134,6 +134,7 @@ pub struct AppState {pub image_cache: lru::LruCache<String, std::sync::Arc<image::DynamicImage>>,pub show_help: bool,+ pub help_scroll: usize,pub last_result_metrics: Option<ResultMetrics>,pub result_scroll: usize,@@ -286,6 +287,7 @@ impl Default for AppState {poster_rows: 3,image_cache: lru::LruCache::new(cache_capacity(10)),show_help: false,+ help_scroll: 0,last_result_metrics: None,result_scroll: 0,active_resource_request: 0,