Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

feat(tui): optimize halfblocks poster engine and elevate terminal themes

Samir Hossains346b41b8bb30
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b242690..d69aefe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,17 @@
## [Unreleased]
### Added
+- **Optimized Halfblocks Poster Engine & Universal Windows PowerShell Support**:
+ - Implemented 24-bit TrueColor Unicode Halfblocks poster graphics engine (`▀`/`▄`) with dedicated 11x6 cell resolution (132 sub-pixels) and selection highlight isolation.
+ - Added interactive `Poster Graphics` configuration to Settings Hub (`/settings` $\to$ Appearance) with `[ Auto | Halfblocks | Off ]` modes, persisted to `config.json`.
+ - Added `MOVIEBOX_IMAGE_PROTOCOL=halfblocks` environment variable override to force character-cell posters in standard Windows PowerShell, legacy consoles, and basic terminals.
+ - Added explicit buffer clearing (`clear_area`) before rasterizing posters on search results and details screens, preventing ghost character tearing during fast list scrolling.
+- **Windows TrueColor & High-Contrast Terminal Theming**:
+ - Enabled 24-bit TrueColor auto-detection by default on Windows 10/11 (`conhost.exe`, Windows Terminal, PowerShell, CMD), ensuring Windows users receive rich Catppuccin themes out of the box.
+ - Overhauled 16-color ANSI dark fallback palette (`Theme::fallback`), replacing low-contrast dark blue and magenta with high-contrast cyan accents for borders, titles, headers, and highlights.
+ - Added background row selection suppression in Settings Hub when modal popups (media player picker, theme picker, download directory input) are active, directing 100% of user focus to floating dialogs.
+ - Added solid opaque backdrops to `ModalFrame` and clamped popup picker minimum height to 7 rows, eliminating bleed-through and visual crowding on single-item selections.
+ - Elevated active selection surface styling to `theme.surface1` with accent-highlighted cursor indicators (`▌ ` / `▸ `) across lists and settings rows.
- **In-App Self-Update Engine Hardening**:
- Added deterministic fallback download URL generation for GitHub release assets and `SHA256SUMS` when unauthenticated API requests encounter HTTP 403 rate limits.
- Added active in-flight self-update progress modal (`draw_updating_modal`) featuring animated Braille spinners, version upgrade indicators (`v{old} → v{new}`), and real-time status steps.
diff --git a/docs/config.md b/docs/config.md
index 05a26ac..91b9ed4 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -18,6 +18,7 @@ macOS `~/Library/Application Support/moviebox-tui`, Linux `~/.config/moviebox-tu
| `addons_enabled` | bool | Enable Addon Mode navigation in bottom dock (`/settings` $\to$ Content Modes). |
| `default_player` | string or null | Preferred player: `mpv`, `iina`, `vlc`, `android`; absent/null until you choose one from the in-app picker. |
| `download_dir` | string or null | Custom directory for video and subtitle downloads (null uses OS default). |
+| `poster_mode` | string | Poster graphics mode: `auto` (default), `halfblocks` (character cells), `off` (disabled). |
## Interactive Settings Hub (`/settings`)
@@ -25,7 +26,7 @@ All settings in `config.json` can be configured interactively inside the applica
- **General**: Toggle automatic update checks, choose default media player (`mpv`, `VLC`, `IINA`, `Android`), and edit download folder path.
- **Content Modes**: Enable or disable Streaming Mode, BDIX FTP sources, Live TV (IPTV), and HTTP Addons with safety guards (preventing 0 active modes).
-- **Appearance**: Cycle color themes live with real-time palette swatches or launch the visual theme swatch picker.
+- **Appearance**: Cycle color themes live with real-time palette swatches, select poster graphics mode (`Auto`, `Halfblocks`, `Off`), or launch the visual theme swatch picker.
- **Maintenance**: Purge disk cache, query GitHub for release updates, and view repository information.
## Other persisted files
@@ -49,7 +50,7 @@ All settings in `config.json` can be configured interactively inside the applica
| `MOVIEBOX_FOURKHDHUB_URL` | Override the 4KHDHub base URL. |
| `MOVIEBOX_THEME` | Force a theme (e.g. `Mocha`, `Latte`, `Macchiato`, `Frappe`, `Nord`, `TokyoNight`, `Dracula`, `Gruvbox`, `RosePine`). When unset and no saved theme exists, the app auto-detects: `NO_COLOR` wins, truecolor terminals get full palettes, 256-color terminals get quantized palettes, and the OSC 11 background query picks light/dark variants with WCAG AA contrast. |
| `MOVIEBOX_NO_IMAGE` | Disable poster image queries (set to `1` or `true`). |
-| `MOVIEBOX_IMAGE_PROTOCOL` | Force poster graphics protocol: `kitty`, `sixel`, `iterm2`, or `none`. |
+| `MOVIEBOX_IMAGE_PROTOCOL` | Override image protocol (`kitty`, `sixel`, `iterm2`, `halfblocks`, or `none`/`off`). |
| `MOVIEBOX_CELL_SIZE` | Override terminal cell size as `WxH` (e.g. `10x20`) for poster scaling. |
## CLI
diff --git a/docs/cross-platform.md b/docs/cross-platform.md
index 8c1109b..b5cfe5a 100644
--- a/docs/cross-platform.md
+++ b/docs/cross-platform.md
@@ -27,19 +27,26 @@ prevent escape sequence probe leakage (`Gi=31...`):
- **Poster rendering**: Sixel, Kitty, and iTerm2 protocols where the probe
detects them. Terminals that report kitty/sixel capability but no cell
size (Windows Terminal sixel, iTerm2 over SSH) are salvaged with default
- cell metrics. True Halfblocks-only terminals show a compact filmstrip
- placeholder instead. All poster image rendering is automatically gated
- behind `has_active_modal()` to prevent image protocol graphic bleed
+ cell metrics. In `Auto` mode, non-graphics terminals (e.g. standard Windows
+ PowerShell / conhost, macOS Apple_Terminal) gracefully display clean text
+ placeholders (`· ·` on Home, `No Art` on Details) to prevent scroll tearing.
+ Users can opt in to 24-bit TrueColor Unicode character-cell posters (`▀`/`▄`)
+ by setting `Poster Graphics: Halfblocks` in `/settings` (Appearance) or
+ `MOVIEBOX_IMAGE_PROTOCOL=halfblocks`. All poster image rendering is
+ automatically gated behind `has_active_modal()` to prevent graphic bleed
through modal popups and overlays. `MOVIEBOX_NO_IMAGE=1` disables queries;
`MOVIEBOX_IMAGE_PROTOCOL` forces a protocol; `MOVIEBOX_CELL_SIZE=WxH`
overrides metrics.
- **Colors & Themes**: With no explicit theme, `NO_COLOR` wins, then truecolor RGB
(auto-detected across Ghostty, Kitty, WezTerm, iTerm2, Alacritty, Foot, Windows Terminal,
- Hyper, Tabby, Warp, and VSCode), quantized 256-color palettes for strict terminals,
- and a 16-color ANSI fallback palette (`Theme::fallback`); an OSC 11 background query
+ Hyper, Tabby, Warp, and VSCode; enabled by default on Windows 10/11 console host and Windows Terminal),
+ quantized 256-color palettes for strict terminals, and a tuned high-contrast 16-color ANSI
+ fallback palette (`Theme::fallback`) using crisp cyan accents; an OSC 11 background query
picks light/dark variants. Light mode themes (including Catppuccin Latte) are tuned for
WCAG AA compliance, ensuring high-contrast readability across light terminal backgrounds.
- An explicit `MOVIEBOX_THEME` or saved theme always wins over autodetection.
+ Modal pickers feature solid opaque backdrops, minimum 7-row breathing room, and background
+ selection suppression to isolate dialog focus. An explicit `MOVIEBOX_THEME` or saved theme
+ always wins over autodetection.
- **Keyboard & Cursor**: The kitty keyboard protocol (disambiguated escapes, event
types) is requested at start and popped on exit; unsupported terminals
ignore it. Real input cursor styling (`SetCursorStyle::SteadyBar`) activates
diff --git a/src/config.rs b/src/config.rs
index a913e39..631a18e 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -18,6 +18,7 @@ pub struct Config {
pub addons_enabled: bool,
pub default_player: Option<String>,
pub download_dir: Option<String>,
+ pub poster_mode: String,
}
impl Default for Config {
fn default() -> Self {
@@ -33,6 +34,7 @@ impl Default for Config {
addons_enabled: false,
default_player: None,
download_dir: None,
+ poster_mode: "auto".to_string(),
}
}
}
@@ -262,5 +264,6 @@ mod tests {
let json = serde_json::to_string(&config).expect("serialize");
let deserialized: Config = serde_json::from_str(&json).expect("deserialize");
assert_eq!(deserialized.active_mode, config.active_mode);
+ assert_eq!(deserialized.poster_mode, "auto");
}
}
diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rs
index aee8bba..823fe99 100644
--- a/src/tui/app/mod.rs
+++ b/src/tui/app/mod.rs
@@ -125,6 +125,7 @@ impl App {
}
}
state.active_theme_kind = config.active_theme;
+ state.poster_mode = config.poster_mode;
state.default_player = config.default_player;
state.download_dir = config.download_dir.map(std::path::PathBuf::from);
state.installed_addons = crate::config::load_addons();
@@ -219,6 +220,7 @@ impl App {
.download_dir
.as_ref()
.map(|p| p.to_string_lossy().to_string()),
+ poster_mode: self.state.poster_mode.clone(),
};
crate::tui::config::save(&config);
}
diff --git a/src/tui/app/run.rs b/src/tui/app/run.rs
index 81ef3bc..38f4d39 100644
--- a/src/tui/app/run.rs
+++ b/src/tui/app/run.rs
@@ -21,7 +21,10 @@ impl App {
where
std::io::Error: From<<B as ratatui::backend::Backend>::Error>,
{
- if self.state.image_picker.is_none() && self.state.image_supported {
+ let should_probe = (self.state.image_supported
+ || self.state.poster_mode.eq_ignore_ascii_case("halfblocks"))
+ && !self.state.poster_mode.eq_ignore_ascii_case("off");
+ if self.state.image_picker.is_none() && should_probe {
self.probe_terminal().await;
}
@@ -137,6 +140,17 @@ impl App {
pub(super) async fn probe_terminal(&mut self) {
use ratatui_image::picker::{Capability, ProtocolType};
+ if self.state.poster_mode.eq_ignore_ascii_case("off") {
+ self.state.image_supported = false;
+ self.state.image_picker = None;
+ return;
+ }
+
+ let is_halfblocks_forced = matches!(
+ Self::forced_protocol(),
+ Some(ForcedProtocol::Type(ProtocolType::Halfblocks))
+ ) || self.state.poster_mode.eq_ignore_ascii_case("halfblocks");
+
match Self::forced_protocol() {
Some(ForcedProtocol::None) => {
self.state.image_supported = false;
@@ -160,6 +174,18 @@ impl App {
}
}
+ if is_halfblocks_forced {
+ let font_size = Self::cell_size_override().unwrap_or(ratatui_image::FontSize {
+ width: 10,
+ height: 20,
+ });
+ #[allow(deprecated)]
+ let mut picker = ratatui_image::picker::Picker::from_fontsize(font_size);
+ picker.set_protocol_type(ProtocolType::Halfblocks);
+ self.accept_picker(picker);
+ return;
+ }
+
let picker = self.query_picker().await;
if self.state.theme_is_auto
@@ -218,7 +244,7 @@ impl App {
}
}
- if matches!(picker.protocol_type(), ProtocolType::Halfblocks) {
+ if matches!(picker.protocol_type(), ProtocolType::Halfblocks) && !is_halfblocks_forced {
self.state.image_supported = false;
self.state.image_picker = None;
return;
@@ -231,6 +257,12 @@ impl App {
if cell_h > 0 {
self.state.poster_rows = (96_u16.div_ceil(cell_h)).max(3);
}
+ if matches!(
+ picker.protocol_type(),
+ ratatui_image::picker::ProtocolType::Halfblocks
+ ) {
+ self.state.poster_rows = self.state.poster_rows.clamp(5, 7);
+ }
self.state.image_picker = Some(picker);
self.state.image_supported = true;
}
@@ -258,6 +290,9 @@ impl App {
.as_str()
{
"none" | "off" | "false" => Some(ForcedProtocol::None),
+ "halfblocks" => Some(ForcedProtocol::Type(
+ ratatui_image::picker::ProtocolType::Halfblocks,
+ )),
"sixel" => Some(ForcedProtocol::Type(
ratatui_image::picker::ProtocolType::Sixel,
)),
diff --git a/src/tui/app/system.rs b/src/tui/app/system.rs
index 81ce1bf..6af8360 100644
--- a/src/tui/app/system.rs
+++ b/src/tui/app/system.rs
@@ -432,6 +432,12 @@ impl App {
self.theme = crate::tui::theme::Theme::from_kind(kind);
self.persist_config();
self.state.dirty = true;
+ } else if self.state.settings_selected_row == 1 {
+ self.state.cycle_poster_mode(forward);
+ self.state.image_picker = None;
+ self.action_sender.send(Action::ProbeTerminal).ok();
+ self.persist_config();
+ self.state.dirty = true;
}
}
crate::tui::state::SettingsCategory::StorageInfo => {}
@@ -591,6 +597,12 @@ impl App {
} else {
self.state.theme_list_state.select(Some(0));
}
+ } else if self.state.settings_selected_row == 1 {
+ self.state.cycle_poster_mode(true);
+ self.state.image_picker = None;
+ self.action_sender.send(Action::ProbeTerminal).ok();
+ self.persist_config();
+ self.state.dirty = true;
}
}
crate::tui::state::SettingsCategory::StorageInfo => {
diff --git a/src/tui/overlay.rs b/src/tui/overlay.rs
index b29effa..0ad03ea 100644
--- a/src/tui/overlay.rs
+++ b/src/tui/overlay.rs
@@ -41,7 +41,7 @@ pub fn picker_layout(
centered(
area,
content_width as u16,
- visible_rows as u16 + 4,
+ (visible_rows as u16 + 4).max(7),
minimum_width,
64,
)
@@ -447,14 +447,24 @@ pub(crate) fn key_hint(key: &str, action: &str, theme: &Theme) -> Span<'static>
}
pub(crate) fn selection_style(theme: &Theme, basic_terminal: bool) -> Style {
- let mut style = theme.text.add_modifier(Modifier::BOLD);
+ let style = if theme.is_light {
+ theme.text
+ } else {
+ theme.highlight
+ }
+ .add_modifier(Modifier::BOLD);
if crate::tui::theme::ColorSupport::current() == crate::tui::theme::ColorSupport::NoColor {
- style = style.add_modifier(Modifier::REVERSED);
+ return style.add_modifier(Modifier::REVERSED);
}
if basic_terminal {
style.add_modifier(Modifier::UNDERLINED)
} else {
- style.bg(theme.surface0.fg.unwrap_or(theme.base))
+ let bg_color = if theme.is_light {
+ theme.surface1.fg.unwrap_or(ratatui::style::Color::DarkGray)
+ } else {
+ theme.surface1.fg.unwrap_or(theme.base)
+ };
+ style.bg(bg_color)
}
}
@@ -812,4 +822,11 @@ mod tests {
assert!(content.contains("[MOVIES]"));
assert!(content.contains("Popular Movies"));
}
+ #[test]
+ fn test_picker_layout_minimum_height_clamped_to_seven() {
+ let area = Rect::new(0, 0, 80, 24);
+ let items = vec!["Single Item".to_string()];
+ let layout = picker_layout(area, &items, "Open", 20);
+ assert!(layout.height >= 7);
+ }
}
diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rs
index 0011059..e0c980a 100644
--- a/src/tui/screens/details.rs
+++ b/src/tui/screens/details.rs
@@ -358,13 +358,20 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
.as_ref()
.zip(state.image_picker.as_ref())
.map(|(image, picker)| {
- let font_size = picker.font_size();
- let font_w = font_size.width.max(1);
- let font_h = font_size.height.max(1);
- let area_h_px = (inner_area.height as f32) * (font_h as f32);
- let aspect = image.width() as f32 / (image.height() as f32).max(1.0);
- let area_w_px = area_h_px * aspect;
- ((area_w_px / font_w as f32).round() as u16).max(1)
+ if matches!(
+ picker.protocol_type(),
+ ratatui_image::picker::ProtocolType::Halfblocks
+ ) {
+ ((inner_area.height as f32 * 0.75).round() as u16).clamp(8, 20)
+ } else {
+ let font_size = picker.font_size();
+ let font_w = font_size.width.max(1);
+ let font_h = font_size.height.max(1);
+ let area_h_px = (inner_area.height as f32) * (font_h as f32);
+ let aspect = image.width() as f32 / (image.height() as f32).max(1.0);
+ let area_w_px = area_h_px * aspect;
+ ((area_w_px / font_w as f32).round() as u16).max(1)
+ }
})
.unwrap_or_else(|| ((inner_area.height as f32 * (4.0 / 3.0)).round() as u16).max(6));
width_for_height.clamp(8, 22)
@@ -394,6 +401,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
let img_width = poster_area.width;
let img_height = poster_area.height;
if img_width > 0 && img_height > 0 {
+ crate::tui::clear_area(frame, poster_area, theme);
if let Some((proto_area, proto)) = &mut state.poster_protocol {
if proto_area.width == img_width && proto_area.height == img_height {
let image_widget = ratatui_image::Image::new(proto);
@@ -1479,7 +1487,7 @@ fn with_selection_surface(style: Style, basic_terminal: bool, theme: &Theme) ->
if basic_terminal {
style
} else {
- style.bg(theme_color(theme.surface0, theme.base))
+ style.bg(theme_color(theme.surface1, theme.base))
}
}
diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rs
index 700008d..d411a45 100644
--- a/src/tui/screens/home.rs
+++ b/src/tui/screens/home.rs
@@ -1480,13 +1480,20 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
.image_picker
.as_ref()
.map(|picker| {
- let font = picker.font_size();
- let pixel_height =
- u64::from(state.poster_rows.max(3)) * u64::from(font.height.max(1));
- let pixel_width = pixel_height * 2 / 3;
- u16::try_from(pixel_width.div_ceil(u64::from(font.width.max(1))))
- .unwrap_or(u16::MAX)
- .max(6)
+ if matches!(
+ picker.protocol_type(),
+ ratatui_image::picker::ProtocolType::Halfblocks
+ ) {
+ 11_u16
+ } else {
+ let font = picker.font_size();
+ let pixel_height =
+ u64::from(state.poster_rows.max(3)) * u64::from(font.height.max(1));
+ let pixel_width = pixel_height * 2 / 3;
+ u16::try_from(pixel_width.div_ceil(u64::from(font.width.max(1))))
+ .unwrap_or(u16::MAX)
+ .max(6)
+ }
})
.unwrap_or_else(|| state.poster_rows.saturating_mul(4).div_ceil(3).max(6))
} else {
@@ -1542,18 +1549,22 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
height: metrics.poster_rows_eff,
};
+ let (highlight_area, poster_area, text_area) =
+ item_slot_rects(item_area, poster_width);
+
let is_selected = Some(i) == selected_idx;
if is_selected && !is_editing {
let selected_bg = theme.surface0.fg.unwrap_or(theme.base);
frame.render_widget(
Block::default().style(Style::default().bg(selected_bg)),
- item_area,
+ text_area,
+ );
+ frame.render_widget(
+ Block::default().style(Style::default().bg(selected_bg)),
+ highlight_area,
);
}
- let (highlight_area, poster_area, text_area) =
- item_slot_rects(item_area, poster_width);
-
if is_selected {
let (indicator_sym, indicator_style) = if is_editing {
(
@@ -1608,6 +1619,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
}
if let Some((_, proto)) = state.search_poster_protocols.peek(&res.id) {
if !state.has_active_modal() {
+ crate::tui::clear_area(frame, p_area, theme);
frame.render_widget(ratatui_image::Image::new(proto), p_area);
}
}
diff --git a/src/tui/state.rs b/src/tui/state.rs
index 55dc8ac..fb65b45 100644
--- a/src/tui/state.rs
+++ b/src/tui/state.rs
@@ -71,7 +71,7 @@ impl SettingsCategory {
match self {
Self::General => 3,
Self::ContentModes => 4,
- Self::Appearance => 1,
+ Self::Appearance => 2,
Self::StorageInfo => 3,
}
}
@@ -277,6 +277,7 @@ pub struct AppState {
pub poster_protocol: Option<(ratatui::layout::Rect, ratatui_image::protocol::Protocol)>,
pub image_picker: Option<ratatui_image::picker::Picker>,
+ pub poster_mode: String,
pub image_supported: bool,
pub clear_terminal_before_draw: bool,
pub poster_rows: u16,
@@ -436,6 +437,7 @@ impl Default for AppState {
poster_protocol: None,
image_picker: None,
+ poster_mode: "auto".to_string(),
image_supported: crate::tui::terminal::should_query_images(),
clear_terminal_before_draw: false,
poster_rows: 3,
@@ -894,6 +896,30 @@ impl AppState {
self.theme_is_auto = false;
next_theme
}
+ pub fn cycle_poster_mode(&mut self, forward: bool) -> String {
+ let modes = ["auto", "halfblocks", "off"];
+ let total = modes.len();
+ let current_idx = modes
+ .iter()
+ .position(|&m| m.eq_ignore_ascii_case(&self.poster_mode))
+ .unwrap_or(0);
+ let next_idx = if forward {
+ (current_idx + 1) % total
+ } else {
+ (current_idx + total - 1) % total
+ };
+ let next_mode = modes[next_idx].to_string();
+ self.poster_mode = next_mode.clone();
+ next_mode
+ }
+
+ pub fn poster_mode_label(&self) -> &'static str {
+ match self.poster_mode.to_ascii_lowercase().as_str() {
+ "halfblocks" => "Halfblocks",
+ "off" => "Off",
+ _ => "Auto",
+ }
+ }
pub fn can_disable_streaming_mode(&self) -> bool {
self.tv_enabled || self.addons_enabled
diff --git a/src/tui/terminal.rs b/src/tui/terminal.rs
index fc6acee..26a9dbb 100644
--- a/src/tui/terminal.rs
+++ b/src/tui/terminal.rs
@@ -92,6 +92,9 @@ mod tests {
std::env::set_var("TERM", "dumb");
assert!(!should_query_images());
std::env::remove_var("TERM");
+ std::env::set_var("MOVIEBOX_IMAGE_PROTOCOL", "halfblocks");
+ assert!(should_query_images());
+ std::env::remove_var("MOVIEBOX_IMAGE_PROTOCOL");
}
}
}
diff --git a/src/tui/theme.rs b/src/tui/theme.rs
index d2a5fd8..5c94f32 100644
--- a/src/tui/theme.rs
+++ b/src/tui/theme.rs
@@ -151,6 +151,7 @@ pub(crate) fn classify_terminal(colorterm: &str, term: &str, term_program: &str)
|| term.starts_with("foot")
|| term.contains("alacritty")
|| std::env::var("WT_SESSION").is_ok()
+ || cfg!(target_os = "windows")
|| term_program == "iTerm.app"
|| term_program == "Hyper"
|| term_program == "Tabby"
@@ -158,14 +159,14 @@ pub(crate) fn classify_terminal(colorterm: &str, term: &str, term_program: &str)
|| term_program == "WarpTerminal"
|| term_program == "vscode"
|| term_program == "ghostty";
- if truecolor {
- return ColorSupport::Truecolor;
- }
- let basic = term == "dumb" || term == "linux" || term.contains("fbterm");
+ let basic =
+ term == "dumb" || term == "linux" || term.contains("fbterm") || term.starts_with("vt");
let apple_term = term.contains("apple") || term_program == "Apple_Terminal";
let has_256 = term.contains("256") || term.contains("xterm") || term.contains("screen");
if basic || (apple_term && !has_256) || term == "xterm" {
ColorSupport::Basic
+ } else if truecolor {
+ ColorSupport::Truecolor
} else if has_256 {
ColorSupport::Color256
} else {
@@ -467,18 +468,18 @@ impl Theme {
Self {
border: Style::default().fg(Color::DarkGray),
border_focus: Style::default()
- .fg(Color::Blue)
+ .fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
text: Style::default().fg(Color::White),
text_dim: Style::default().fg(Color::Gray),
title: Style::default()
- .fg(Color::Magenta)
+ .fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
highlight: Style::default()
- .fg(Color::Blue)
+ .fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
header: Style::default()
- .fg(Color::Magenta)
+ .fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
error: Style::default().fg(Color::Red).add_modifier(Modifier::BOLD),
success: Style::default().fg(Color::Green),
@@ -490,7 +491,7 @@ impl Theme {
.add_modifier(Modifier::BOLD),
muted: Style::default().fg(Color::DarkGray),
teal: Style::default().fg(Color::Cyan),
- lavender: Style::default().fg(Color::Blue),
+ lavender: Style::default().fg(Color::Cyan),
sapphire: Style::default().fg(Color::Cyan),
subtext1: Style::default().fg(Color::White),
base: Color::Black,
@@ -1035,6 +1036,37 @@ mod tests {
);
}
}
+ #[test]
+ fn fallback_dark_uses_high_contrast_ansi_palette() {
+ let fallback_dark = Theme::fallback(false);
+ assert!(!fallback_dark.is_light);
+ assert_eq!(fallback_dark.text.fg, Some(Color::White));
+ assert_eq!(fallback_dark.base, Color::Black);
+ assert_eq!(fallback_dark.border_focus.fg, Some(Color::Cyan));
+ assert_eq!(fallback_dark.title.fg, Some(Color::Cyan));
+ assert_eq!(fallback_dark.highlight.fg, Some(Color::Cyan));
+
+ for style in [
+ fallback_dark.border,
+ fallback_dark.border_focus,
+ fallback_dark.text,
+ fallback_dark.text_dim,
+ fallback_dark.title,
+ fallback_dark.highlight,
+ fallback_dark.header,
+ fallback_dark.error,
+ fallback_dark.success,
+ fallback_dark.shortcut,
+ fallback_dark.accent,
+ ] {
+ assert!(
+ style
+ .fg
+ .map(|c| !matches!(c, Color::Rgb(..)))
+ .unwrap_or(true)
+ );
+ }
+ }
#[test]
fn test_palette_swatch_spans() {
diff --git a/src/tui/widgets/modal.rs b/src/tui/widgets/modal.rs
index c5676ec..dab490a 100644
--- a/src/tui/widgets/modal.rs
+++ b/src/tui/widgets/modal.rs
@@ -32,12 +32,18 @@ impl<'a> ModalFrame<'a> {
pub fn render(&self, frame: &mut Frame, area: Rect, full_area: Rect) -> Rect {
overlay::clear_modal_area(frame, full_area, area, self.theme);
+ let block_style = if self.basic_terminal {
+ Style::default()
+ } else {
+ Style::default().bg(self.theme.mantle.fg.unwrap_or(self.theme.base))
+ };
let block = Block::default()
.title(format!(" {} ", self.title.trim()))
.title_style(self.theme.title)
.borders(Borders::ALL)
.border_type(overlay::border_type(self.basic_terminal))
- .border_style(self.border_style.unwrap_or(self.theme.lavender));
+ .border_style(self.border_style.unwrap_or(self.theme.lavender))
+ .style(block_style);
let inner = block.inner(area);
frame.render_widget(block, area);
inner
diff --git a/src/tui/widgets/settings.rs b/src/tui/widgets/settings.rs
index babab46..0027bcf 100644
--- a/src/tui/widgets/settings.rs
+++ b/src/tui/widgets/settings.rs
@@ -278,14 +278,21 @@ fn render_category_rows(
SettingsCategory::StorageInfo => render_storage_settings(frame, rows_area, state, theme),
}
}
+fn has_active_settings_popup(state: &AppState) -> bool {
+ state.settings_player_picker
+ || state.show_theme_popup
+ || state.player_picker_popup
+ || state.show_browse_popup
+ || state.settings_download_dir_input.is_some()
+}
struct SettingRow<'a> {
is_selected: bool,
+ has_active_popup: bool,
label: &'a str,
subtext: &'a str,
value_spans: Vec<Span<'a>>,
}
-
fn on_off_spans<'a>(enabled: bool, theme: &Theme, basic_terminal: bool) -> Vec<Span<'a>> {
if enabled {
vec![Span::styled(
@@ -318,13 +325,14 @@ fn render_row(
if area.height == 0 || area.width == 0 {
return;
}
- let cursor = if row.is_selected {
+ let is_active_selection = row.is_selected && !row.has_active_popup;
+ let cursor = if is_active_selection {
if basic_terminal { "> " } else { "▸ " }
} else {
" "
};
- let cursor_style = if row.is_selected {
+ let cursor_style = if is_active_selection {
if basic_terminal {
theme.text.add_modifier(Modifier::BOLD)
} else {
@@ -334,14 +342,16 @@ fn render_row(
Style::default()
};
- let label_style = if row.is_selected {
+ let label_style = if is_active_selection {
theme.highlight.add_modifier(Modifier::BOLD)
+ } else if row.is_selected {
+ theme.text.add_modifier(Modifier::BOLD)
} else {
theme.text
};
- let row_bg = if row.is_selected && !basic_terminal {
- Style::default().bg(theme.surface0.fg.unwrap_or(theme.base))
+ let row_bg = if is_active_selection && !basic_terminal {
+ Style::default().bg(theme.surface1.fg.unwrap_or(theme.base))
} else {
Style::default()
};
@@ -397,6 +407,7 @@ fn render_row(
fn render_general_settings(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {
let row_rects = settings_row_rects_in_area(area, 3);
+ let has_active_popup = has_active_settings_popup(state);
if let Some(&row_area) = row_rects.first() {
let is_selected = state.settings_selected_row == 0;
@@ -406,6 +417,7 @@ fn render_general_settings(frame: &mut Frame, area: Rect, state: &AppState, them
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Automatic Updates",
subtext: "Check GitHub for new releases on startup",
value_spans,
@@ -441,6 +453,7 @@ fn render_general_settings(frame: &mut Frame, area: Rect, state: &AppState, them
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Default Media Player",
subtext: "Preferred player launched for video streams",
value_spans,
@@ -502,6 +515,7 @@ fn render_general_settings(frame: &mut Frame, area: Rect, state: &AppState, them
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Download Folder",
subtext: "Directory for saving downloaded videos & subtitles",
value_spans,
@@ -514,6 +528,7 @@ fn render_general_settings(frame: &mut Frame, area: Rect, state: &AppState, them
fn render_content_modes_settings(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {
let row_rects = settings_row_rects_in_area(area, 4);
+ let has_active_popup = has_active_settings_popup(state);
if let Some(&row_area) = row_rects.first() {
let is_selected = state.settings_selected_row == 0;
@@ -523,6 +538,7 @@ fn render_content_modes_settings(frame: &mut Frame, area: Rect, state: &AppState
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Streaming Mode",
subtext: "MovieBox & 4KHDHub streaming catalog",
value_spans,
@@ -540,6 +556,7 @@ fn render_content_modes_settings(frame: &mut Frame, area: Rect, state: &AppState
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "BDIX FTP Mirrors",
subtext: "Local high-speed BDIX optical mirrors for streaming",
value_spans,
@@ -557,6 +574,7 @@ fn render_content_modes_settings(frame: &mut Frame, area: Rect, state: &AppState
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Live TV Mode",
subtext: "Live IPTV channels and custom M3U playlists",
value_spans,
@@ -574,6 +592,7 @@ fn render_content_modes_settings(frame: &mut Frame, area: Rect, state: &AppState
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Addon Mode",
subtext: "Community HTTP Stremio addons and metadata",
value_spans,
@@ -585,7 +604,8 @@ fn render_content_modes_settings(frame: &mut Frame, area: Rect, state: &AppState
}
fn render_appearance_settings(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {
- let row_rects = settings_row_rects_in_area(area, 1);
+ let row_rects = settings_row_rects_in_area(area, 2);
+ let has_active_popup = has_active_settings_popup(state);
let theme_name = if state.active_theme_kind.is_empty() {
"Mocha"
@@ -609,6 +629,7 @@ fn render_appearance_settings(frame: &mut Frame, area: Rect, state: &AppState, t
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Theme",
subtext: "Active color theme and palette styling",
value_spans,
@@ -618,8 +639,34 @@ fn render_appearance_settings(frame: &mut Frame, area: Rect, state: &AppState, t
);
}
- if area.height >= 5 {
- let info_y = area.y + 3;
+ if let Some(&row_area) = row_rects.get(1) {
+ let is_selected = state.settings_selected_row == 1;
+ let value_spans = vec![Span::styled(
+ state.poster_mode_label(),
+ if state.basic_terminal {
+ theme.text.add_modifier(Modifier::BOLD)
+ } else {
+ theme.accent.add_modifier(Modifier::BOLD)
+ },
+ )];
+
+ render_row(
+ frame,
+ row_area,
+ SettingRow {
+ is_selected,
+ has_active_popup,
+ label: "Poster Graphics",
+ subtext: "Native terminal protocols, Halfblocks or disabled",
+ value_spans,
+ },
+ theme,
+ state.basic_terminal,
+ );
+ }
+
+ if area.height >= 7 {
+ let info_y = area.y + 5;
let info_area = Rect {
x: area.x,
y: info_y,
@@ -648,19 +695,21 @@ fn render_appearance_settings(frame: &mut Frame, area: Rect, state: &AppState, t
fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, theme: &Theme) {
let row_rects = settings_row_rects_in_area(area, 3);
+ let has_active_popup = has_active_settings_popup(state);
if let Some(&row_area) = row_rects.first() {
let is_selected = state.settings_selected_row == 0;
+ let is_active_selected = is_selected && !has_active_popup;
let glyph = if state.basic_terminal { ">" } else { "▸" };
let value_spans = vec![Span::styled(
format!("Purge {glyph}"),
if state.basic_terminal {
- if is_selected {
+ if is_active_selected {
theme.text.add_modifier(Modifier::BOLD)
} else {
theme.text_dim
}
- } else if is_selected {
+ } else if is_active_selected {
theme.error.add_modifier(Modifier::BOLD)
} else {
theme.error
@@ -671,6 +720,7 @@ fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, them
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Clear Disk Cache",
subtext: "Remove temporary cached images and responses",
value_spans,
@@ -682,6 +732,7 @@ fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, them
if let Some(&row_area) = row_rects.get(1) {
let is_selected = state.settings_selected_row == 1;
+ let is_active_selected = is_selected && !has_active_popup;
let value_spans = if state.is_checking_updates {
vec![Span::styled(
"Checking...",
@@ -696,12 +747,12 @@ fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, them
vec![Span::styled(
format!("Check {glyph}"),
if state.basic_terminal {
- if is_selected {
+ if is_active_selected {
theme.text.add_modifier(Modifier::BOLD)
} else {
theme.text_dim
}
- } else if is_selected {
+ } else if is_active_selected {
theme.sapphire.add_modifier(Modifier::BOLD)
} else {
theme.sapphire
@@ -713,6 +764,7 @@ fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, them
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "Check for Updates",
subtext: "Query GitHub API for latest binary releases",
value_spans,
@@ -724,16 +776,17 @@ fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, them
if let Some(&row_area) = row_rects.get(2) {
let is_selected = state.settings_selected_row == 2;
+ let is_active_selected = is_selected && !has_active_popup;
let glyph = if state.basic_terminal { "->" } else { "↗" };
let value_spans = vec![Span::styled(
format!("Open {glyph}"),
if state.basic_terminal {
- if is_selected {
+ if is_active_selected {
theme.text.add_modifier(Modifier::BOLD)
} else {
theme.text_dim
}
- } else if is_selected {
+ } else if is_active_selected {
theme.lavender.add_modifier(Modifier::BOLD)
} else {
theme.lavender
@@ -744,6 +797,7 @@ fn render_storage_settings(frame: &mut Frame, area: Rect, state: &AppState, them
row_area,
SettingRow {
is_selected,
+ has_active_popup,
label: "GitHub Repository",
subtext: "Open project homepage in default web browser",
value_spans,
@@ -1057,4 +1111,74 @@ mod tests {
settings_row_at(popup, SettingsCategory::General, 40, row_rects[0].y + 1);
assert_eq!(clicked_subtext, Some(0));
}
+ #[test]
+ fn test_render_settings_modal_suppresses_selection_during_popup() {
+ let backend = TestBackend::new(80, 24);
+ let mut terminal = Terminal::new(backend).unwrap();
+ let theme = Theme::mocha();
+ let mut state = AppState {
+ show_settings_popup: true,
+ settings_player_picker: true,
+ settings_category: SettingsCategory::General,
+ settings_selected_row: 1,
+ ..Default::default()
+ };
+
+ terminal
+ .draw(|frame| {
+ let area = frame.area();
+ draw(frame, area, &mut state, &theme);
+ })
+ .unwrap();
+
+ let buffer = terminal.backend().buffer();
+ let rendered = (0..buffer.area.height)
+ .map(|y| {
+ (0..buffer.area.width)
+ .map(|x| buffer[(x, y)].symbol())
+ .collect::<String>()
+ })
+ .collect::<Vec<_>>()
+ .join("\n");
+
+ assert!(rendered.contains("Default Media Player"));
+ assert!(!rendered.contains("▸ Default Media Player"));
+ }
+ #[test]
+ fn test_render_appearance_labels() {
+ let backend = TestBackend::new(80, 24);
+ let mut terminal = Terminal::new(backend).unwrap();
+ let theme = Theme::mocha();
+ let mut state = AppState {
+ show_settings_popup: true,
+ settings_category: SettingsCategory::Appearance,
+ settings_selected_row: 0,
+ ..Default::default()
+ };
+
+ terminal
+ .draw(|frame| {
+ let area = frame.area();
+ draw(frame, area, &mut state, &theme);
+ })
+ .unwrap();
+
+ let buffer = terminal.backend().buffer();
+ let rendered = (0..buffer.area.height)
+ .map(|y| {
+ (0..buffer.area.width)
+ .map(|x| buffer[(x, y)].symbol())
+ .collect::<String>()
+ })
+ .collect::<Vec<_>>()
+ .join("\n");
+
+ assert!(rendered.contains("Theme"));
+ assert!(rendered.contains("Poster Graphics"));
+ assert!(rendered.contains("Auto"));
+
+ let popup = Rect::new(4, 4, 76, 17);
+ let rows = settings_row_rects(popup, SettingsCategory::Appearance);
+ assert_eq!(rows.len(), 2);
+ }
}
diff --git a/tests/settings_hub.rs b/tests/settings_hub.rs
index 3aec2d1..5c5443e 100644
--- a/tests/settings_hub.rs
+++ b/tests/settings_hub.rs
@@ -285,6 +285,22 @@ async fn test_settings_appearance_theme_cycle_and_popup() {
.await;
assert!(app.state().show_settings_popup);
assert!(!app.state().show_theme_popup);
+ app.handle_action(Action::Key(KeyEvent::new(
+ KeyCode::Down,
+ KeyModifiers::empty(),
+ )))
+ .await;
+ assert_eq!(app.state().settings_selected_row, 1);
+ assert_eq!(app.state().poster_mode, "auto");
+
+ app.handle_action(Action::SettingsAdjustValue(true)).await;
+ assert_eq!(app.state().poster_mode, "halfblocks");
+
+ app.handle_action(Action::SettingsAdjustValue(true)).await;
+ assert_eq!(app.state().poster_mode, "off");
+
+ app.handle_action(Action::SettingsAdjustValue(true)).await;
+ assert_eq!(app.state().poster_mode, "auto");
app.handle_action(Action::CloseSettingsPopup).await;
assert!(!app.state().show_settings_popup);