Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(tui): remove /reload command, unify /config, and fix details footer mouse hitboxes
Samir Hossainsdcde6348fc78
diff --git a/src/service.rs b/src/service.rsindex 9a3bfdc..b559d43 100644--- a/src/service.rs+++ b/src/service.rs@@ -80,7 +80,7 @@ impl MovieBoxService {if catalog_addons.is_empty() {return Err(- "No catalog/metadata addon enabled. Open /addons to configure one."+ "No catalog/metadata addon enabled. Open /config to configure one.".to_string(),);}diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rsindex 96cdd00..c543177 100644--- a/src/tui/app/mouse.rs+++ b/src/tui/app/mouse.rs@@ -538,8 +538,8 @@ impl App {let bottom_area = chunks[2];let footer_area = chunks[3];- if row == footer_area.y {- self.handle_details_footer_click(col, area.width);+ if row >= footer_area.y && row < footer_area.bottom() {+ self.handle_details_footer_click(col, row - footer_area.y, area.width);return None;}@@ -718,99 +718,109 @@ impl App {None}- fn handle_details_footer_click(&mut self, col: u16, width: u16) {+ fn handle_details_footer_click(&mut self, col: u16, line_idx: u16, width: u16) {let is_streams = self.state.details_pane == DetailsPane::Streams;let is_seasons = self.state.details_pane == DetailsPane::Seasons;let is_languages = self.state.details_pane == DetailsPane::Languages;+ let compact = width < 80;+ let very_compact = width < 45;- let mut btn_widths = vec![16_u16, 10_u16];- let action_label = if is_streams { 11_u16 } else { 13_u16 };- btn_widths.push(action_label);-- if is_streams {- btn_widths.push(14_u16);- }- if !is_languages {- btn_widths.push(15_u16);+ enum FooterAction {+ Tab,+ Move,+ PlaySelect,+ OpenWith,+ Download,+ Refresh,+ Back,}- btn_widths.push(14_u16);- btn_widths.push(11_u16);- let sep = 3_u16;- let total_w: u16 = btn_widths.iter().sum::<u16>() + (btn_widths.len() as u16 - 1) * sep;- let mut curr_x = width.saturating_sub(total_w) / 2;+ let mut primary: Vec<(FooterAction, u16)> = Vec::new();+ let tab_label_len = if compact { 4 } else { 9 };+ primary.push((FooterAction::Tab, 5 + 1 + tab_label_len));+ primary.push((FooterAction::Move, 4 + 1 + 4));- let mut hitboxes = Vec::new();- for w in &btn_widths {- hitboxes.push((curr_x, curr_x + w));- curr_x += w + sep;+ if !very_compact {+ let enter_label_len = if is_streams { 4 } else { 6 };+ primary.push((FooterAction::PlaySelect, 7 + 1 + enter_label_len));}- let mut idx = 0;- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col < e + 2 {- self.action_sender.send(Action::TabPane).ok();- return;+ let mut secondary: Vec<(FooterAction, u16)> = Vec::new();+ if very_compact {+ let enter_label_len = if is_streams { 4 } else { 6 };+ secondary.push((FooterAction::PlaySelect, 7 + 1 + enter_label_len));+ } else {+ if is_streams {+ let o_label_len = if compact { 4 } else { 9 };+ secondary.push((FooterAction::OpenWith, 3 + 1 + o_label_len));}- }- idx += 1;-- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col < e + 2 {- self.action_sender.send(Action::MoveDown).ok();- return;+ if !is_languages {+ let d_label_len = if compact { 4 } else { 8 };+ secondary.push((FooterAction::Download, 3 + 1 + d_label_len));+ }+ if !very_compact {+ let r_label_len = if compact { 5 } else { 7 };+ secondary.push((FooterAction::Refresh, 3 + 1 + r_label_len));}}- idx += 1;+ secondary.push((FooterAction::Back, 5 + 1 + 4));- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col < e + 2 {- if is_streams {- self.action_sender.send(Action::PlayStream(false)).ok();- } else {- self.action_sender.send(Action::Submit).ok();- }+ let active_buttons = if width >= 70 {+ if line_idx > 0 {return;}- }- idx += 1;+ let mut combined = primary;+ combined.extend(secondary);+ combined+ } else if line_idx == 0 {+ primary+ } else {+ secondary+ };- if is_streams {- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col < e + 2 {- self.action_sender.send(Action::PlayStream(true)).ok();- return;- }- }- idx += 1;- }+ let sep = 3_u16;+ let total_w: u16 = active_buttons.iter().map(|(_, w)| *w).sum::<u16>()+ + (active_buttons.len().saturating_sub(1) as u16) * sep;+ let mut curr_x = width.saturating_sub(total_w) / 2;- if !is_languages {- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col < e + 2 {- if is_seasons {- self.action_sender.send(Action::PromptDownloadSeason).ok();- } else {- self.action_sender.send(Action::PromptDownloadEpisode).ok();+ for (action, w) in active_buttons {+ let start = curr_x;+ let end = start + w;+ if col >= start && col < end + sep {+ match action {+ FooterAction::Tab => {+ self.action_sender.send(Action::TabPane).ok();+ }+ FooterAction::Move => {+ self.action_sender.send(Action::MoveDown).ok();+ }+ FooterAction::PlaySelect => {+ if is_streams {+ self.action_sender.send(Action::PlayStream(false)).ok();+ } else {+ self.action_sender.send(Action::Submit).ok();+ }+ }+ FooterAction::OpenWith => {+ self.action_sender.send(Action::PlayStream(true)).ok();+ }+ FooterAction::Download => {+ if is_seasons {+ self.action_sender.send(Action::PromptDownloadSeason).ok();+ } else {+ self.action_sender.send(Action::PromptDownloadEpisode).ok();+ }+ }+ FooterAction::Refresh => {+ self.action_sender.send(Action::Refresh).ok();+ }+ FooterAction::Back => {+ self.action_sender.send(Action::GoBack).ok();}- return;}- }- idx += 1;- }-- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col < e + 2 {- self.action_sender.send(Action::Refresh).ok();return;}- }- idx += 1;-- if let Some(&(s, e)) = hitboxes.get(idx) {- if col >= s && col <= e + 3 {- self.action_sender.send(Action::GoBack).ok();- }+ curr_x += w + sep;}}}diff --git a/src/tui/app/requests.rs b/src/tui/app/requests.rsindex 68f0484..91aa7f1 100644--- a/src/tui/app/requests.rs+++ b/src/tui/app/requests.rs@@ -1481,7 +1481,7 @@ impl App {id,season,episode,- "No streaming addons are currently installed or enabled.\nPress Ctrl+P or open /addons to install/enable a stream provider.".into(),+ "No streaming addons are currently installed or enabled.\nPress Ctrl+P or open /config to install/enable a stream provider.".into(),)).ok();return;@@ -1521,7 +1521,7 @@ impl App {id,season,episode,- "No HTTP streams found from active addons for this title.\nPress r to retry or install additional stream addons via /addons.".into(),+ "No HTTP streams found from active addons for this title.\nPress r to retry or install additional stream addons via /config.".into(),)).ok();}diff --git a/src/tui/app/search.rs b/src/tui/app/search.rsindex a0af8a2..e0b03cb 100644--- a/src/tui/app/search.rs+++ b/src/tui/app/search.rs@@ -207,16 +207,6 @@ impl App {None}}- crate::tui::commands::ParsedCommand::Reload => {- self.state.search_query.clear();- self.state.input_mode = InputMode::Normal;- if current_mode == crate::tui::state::AppMode::Tv {- self.action_sender.send(Action::TvReloadPlaylists).ok();- } else {- self.action_sender.send(Action::Refresh).ok();- }- Some(true)- }crate::tui::commands::ParsedCommand::List => {if current_mode == crate::tui::state::AppMode::Tv {self.apply_tv_search_results(query, lower_query);diff --git a/src/tui/commands.rs b/src/tui/commands.rsindex be7a7f2..d7817ac 100644--- a/src/tui/commands.rs+++ b/src/tui/commands.rs@@ -5,7 +5,6 @@ pub enum SlashCommand {Browse,History,List,- Reload,Config,DownloadDir,Theme,@@ -28,7 +27,6 @@ pub enum ParsedCommand<'a> {Browse,History,List,- Reload,Config,DownloadDir(&'a str),Theme,@@ -47,11 +45,10 @@ pub enum ParsedCommand<'a> {}impl SlashCommand {- pub const ALL: [Self; 19] = [+ pub const ALL: [Self; 18] = [Self::Browse,Self::History,Self::List,- Self::Reload,Self::Config,Self::DownloadDir,Self::Theme,@@ -74,7 +71,6 @@ impl SlashCommand {Self::Browse => "/browse",Self::History => "/history",Self::List => "/list",- Self::Reload => "/reload",Self::Config => "/config",Self::DownloadDir => "/download-dir",Self::Theme => "/theme",@@ -93,18 +89,11 @@ impl SlashCommand {}}- pub fn description(self, state: &AppState) -> &'static str {+ pub fn description(self, _state: &AppState) -> &'static str {match self {Self::Browse => "Curated, rated & most-watched views",Self::History => "Watch history",Self::List => "Show all TV channels",- Self::Reload => {- if state.is_tv_mode {- "Reload IPTV playlists"- } else {- "Refresh catalog & streams"- }- }Self::Config => "Configure IPTV playlists",Self::DownloadDir => "View or change download folder",Self::Theme => "Theme picker",@@ -131,7 +120,6 @@ impl SlashCommand {}Self::History => state.streaming_enabled && !state.is_tv_mode && !state.is_addon_mode,Self::List | Self::Config => state.tv_enabled && state.is_tv_mode,- Self::Reload => state.is_tv_mode,Self::EnableBdix => {state.streaming_enabled&& !state.is_tv_mode@@ -197,7 +185,6 @@ impl SlashCommand {"/browse" => Some(ParsedCommand::Browse),"/history" => Some(ParsedCommand::History),"/list" => Some(ParsedCommand::List),- "/reload" => Some(ParsedCommand::Reload),"/config" => Some(ParsedCommand::Config),"/download-dir" => Some(ParsedCommand::DownloadDir(arg)),"/theme" => Some(ParsedCommand::Theme),diff --git a/src/tui/screens/help.rs b/src/tui/screens/help.rsindex 28ef74a..cde4125 100644--- a/src/tui/screens/help.rs+++ b/src/tui/screens/help.rs@@ -83,7 +83,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {Span::styled("Open Alternative Player Picker", theme.text),]));help_text.push(Line::from(vec![- Span::styled(" [r] / /reload ", theme.header),+ Span::styled(" [r] ", theme.header),Span::styled("Reload TV Playlists", theme.text),]));help_text.push(Line::from(vec![@@ -103,10 +103,6 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {Span::styled(" [Ctrl+P] ", theme.header),Span::styled("Open Addons Manager", theme.text),]));- help_text.push(Line::from(vec![- Span::styled(" /addons ", theme.header),- Span::styled("Open Addons Manager", theme.text),- ]));help_text.push(Line::from(vec![Span::styled(" [Enter] ", theme.header),Span::styled("Select Movie / Play Stream", theme.text),