Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

tui: make hn's chrome follow the terminal's native theme

Tim6f4d0604549a
diff --git a/tui/src/app.rs b/tui/src/app.rs
index 22f2ea64f..d94fe46ff 100644
--- a/tui/src/app.rs
+++ b/tui/src/app.rs
@@ -1188,6 +1188,22 @@ impl App {
state.retry_at = Some(Instant::now() + wait);
}
+ /// Tell every connected machine's daemon the terminal's own colours (`theme_set`), so it
+ /// paints the panes to match and the agents in them read the right light/dark. Called when
+ /// the terminal answers OSC 11 and again when a machine connects; the daemon restyles the
+ /// existing sessions too, as the desktop app's `theme_set` does.
+ pub fn push_theme(&mut self) {
+ let Some((bg, fg)) = crate::term_out::terminal_colours() else { return };
+ let machines: Vec<String> = self.fleet.machines.iter()
+ .filter(|m| self.link(&m.id).is_some())
+ .map(|m| m.id.clone()).collect();
+ for machine_id in machines {
+ let Some(link) = self.link(&machine_id) else { continue };
+ let bg = bg.clone(); let fg = fg.clone();
+ self.spawn(async move { link.rpc("theme_set", json!({ "background": bg, "foreground": fg }), Duration::from_secs(5)).await }, |_app, _reply| {});
+ }
+ }
+
// ── machine events ───────────────────────────────────────────────────────
pub fn on_machine(&mut self, machine_id: String, generation: u64, event: MachineEvent) {
@@ -1202,6 +1218,7 @@ impl App {
if let Some(machine) = self.fleet.machine_mut(&machine_id) { machine.reach = Reach::Ready }
if machine_id == self.fleet.local_id && !crate::local::is_local(&machine_id) { self.daemon_down = false; crate::dial::reconnected(self) }
self.relist(&machine_id);
+ self.push_theme();
// Its home folder, so its paths read `~/…` like this machine's do.
if !self.homes.contains_key(&machine_id) {
if let Some(link) = self.link(&machine_id) {
@@ -3570,15 +3587,35 @@ impl App {
/// where they are not `default` (NO_COLOR or not: tmux doesn't read it).
pub fn status_style(&self) -> Style {
let mut s = self.style_of("status-style", self.active, None);
+ let mut own = !self.look.status_bg.is_none() || !self.look.status_fg.is_none();
for (name, fg) in [("status-fg", true), ("status-bg", false)] {
let c = self.options.get(name, "", None).and_then(|v| crate::tmuxconf::colour(&v)).filter(|c| *c != Color::Reset);
- if let Some(c) = c { s = if fg { s.fg(c) } else { s.bg(c) } }
+ if let Some(c) = c { own = true; s = if fg { s.fg(c) } else { s.bg(c) } }
+ }
+ // No status colours of its own and the terminal has told us what it looks like: the bar
+ // takes the theme's own colours — its background the terminal's background, its text the
+ // readable opposite — so it is a visible bar in the theme (a dark bar, light text on a
+ // dark terminal), not a transparent one, and not tmux's stock green.
+ if !own {
+ let (bg, fg, _) = crate::theme::palette();
+ s = s.bg(bg).fg(fg);
}
s
}
/// message-style (tmux's yellow), for messages and prompts.
- pub fn message_style(&self) -> Style { self.style_of("message-style", self.active, None) }
+ pub fn message_style(&self) -> Style {
+ let mut s = self.style_of("message-style", self.active, None);
+ let own = self.look.message_fg.is_some() || self.look.message_bg.is_some();
+ // No message colours of its own and the terminal has told us what it looks like: the
+ // message line shows the theme's readable text on the terminal's own background (left
+ // transparent), so it blends with the theme instead of tmux's stock yellow.
+ if !own {
+ let (_, fg, _) = crate::theme::palette();
+ s = s.bg(Color::Reset).fg(fg);
+ }
+ s
+ }
/// mode-keys as it stands (tmux's default: emacs, unless $VISUAL or $EDITOR is a vi).
pub fn mode_keys_emacs(&self) -> bool {
diff --git a/tui/src/options/mod.rs b/tui/src/options/mod.rs
index 22bd558eb..f5f7d368b 100644
--- a/tui/src/options/mod.rs
+++ b/tui/src/options/mod.rs
@@ -92,7 +92,7 @@ pub fn defaults() -> &'static BTreeMap<String, String> {
// Each pane's title row: the harness's symbol in its state's colour, the pane's title
// (the harness's name), [watching — who has it] when another window has the pane to type
// in, and at the far end, as far as there is room, its project and branch.
- m.insert("pane-border-format".into(), " #{?pane_agent_icon,#{pane_agent_mark} ,}#{pane_title}#{?pane_watched, #[fg=yellow][watching#{?pane_watcher, — #{pane_watcher} has it,}]#[fg=default],} #[align=right]#{?pane_where,#[dim] #{pane_where} #[nodim],}".into());
+ m.insert("pane-border-format".into(), " #{?pane_agent_icon,#{pane_agent_mark} ,}#{pane_title}#{?pane_watched, #[fg=yellow][watching#{?pane_watcher, — #{pane_watcher} has it,}]#[fg=default],}#{?pane_where, #[dim]· #{pane_where} #[nodim],}".into());
// The status line: tmux's, with what Harness adds — the name reversed while the prefix
// waits; on the right, the fleet in counts (#{fleet}: ?2 ✗1 ✓5 ⠹41), the focused pane's machine (a far one, as
// scp writes it: gpu-box:ml-lab), project and branch (as zsh's robbyrussell prompt writes
@@ -106,9 +106,10 @@ pub fn defaults() -> &'static BTreeMap<String, String> {
for name in ["window-status-format", "window-status-current-format"] {
m.insert(name.into(), "#I:#{?window_agent_icon,#{window_agent_icon} ,}#{window_short_name}#{?window_flags,#{window_flags}, }".into());
}
- // The terminal's title: the harnesses waiting on you, and the one in front.
+ // The terminal's title: the harnesses waiting on you, and the one in front with its state,
+ // so a terminal tab says what is in it (the status changing in the title as it works).
m.insert("set-titles".into(), "on".into());
- m.insert("set-titles-string".into(), "#{?fleet_needs,?#{fleet_needs} ,}#{pane_title} — Harness".into());
+ m.insert("set-titles-string".into(), "#{?fleet_needs,?#{fleet_needs} ,}#{pane_title}#{?pane_agent_state, (#{pane_agent_state}),} — Harness".into());
// A session is a machine, named as the machine is (tmux's are 0, 1, …): room for its name.
m.insert("status-left-length".into(), "24".into());
m.insert("status-right-length".into(), "72".into());
diff --git a/tui/src/term_input.rs b/tui/src/term_input.rs
index 8089969a6..e12562848 100644
--- a/tui/src/term_input.rs
+++ b/tui/src/term_input.rs
@@ -11,7 +11,7 @@ mod parse;
enum InternalEvent { Event(Event), CursorPosition(u16, u16), KeyboardEnhancementFlags(KeyboardEnhancementFlags), PrimaryDeviceAttributes }
#[derive(Debug, PartialEq)]
-enum Item { Input(Event), Terminal(Option<String>) }
+enum Item { Input(Event), Terminal(Option<String>), Background(Option<String>) }
#[derive(Default)]
struct Decoder { pending: Vec<u8> }
@@ -28,6 +28,15 @@ impl Decoder {
if let Some(end) = end { out.push(Item::Terminal(Some(String::from_utf8_lossy(&p[4..end]).into_owned()))); self.pending.clear(); }
continue;
}
+ // OSC 11 default-background answer from `ask_terminal`, `\x1b]11;rgb:…\x07`
+ // (or `#rrggbb`). Same hold-till-terminator rule as XDA, so a query reply never
+ // becomes a key, and interleaved typeahead stays typeahead.
+ if b"\x1b]11;".starts_with(p) { continue }
+ if p.starts_with(b"\x1b]11;") && p.len() < 4096 {
+ let end = if p.ends_with(b"\x1b\\") { Some(p.len() - 2) } else if p.ends_with(b"\x07") { Some(p.len() - 1) } else { None };
+ if let Some(end) = end { out.push(Item::Background(parse_osc11(&String::from_utf8_lossy(&p[5..end])))); self.pending.clear(); }
+ continue;
+ }
// If the apparent XDA prefix turned out to be Alt-P, replay through the exact
// byte decoder rather than letting its first event discard the following bytes.
if p.starts_with(b"\x1bP") {
@@ -60,6 +69,39 @@ impl Decoder {
}
}
+/// The `#rrggbb` from an OSC 11 answer body: `rgb:RRRR/GGGG/BBBB` (an Alacritty- or xterm-style
+/// request joined into a short string as a 24-bit colour) or `#rrggbb`. None when it is a string
+/// a 24-bit answer cannot be (a terminal answers `rgb:0000/0000/0000` only for unset).
+fn parse_osc11(body: &str) -> Option<String> {
+ let body = body.trim();
+ if let Some(hex) = body.strip_prefix('#') {
+ if hex.len() == 6 && hex.bytes().all(|b| b.is_ascii_hexdigit()) {
+ let mut h = String::with_capacity(7);
+ h.push('#');
+ for c in hex.bytes() { h.push((c as char).to_ascii_lowercase()); }
+ return Some(h);
+ }
+ return None;
+ }
+ if let Some(rgb) = body.strip_prefix("rgb:") {
+ let parts: Vec<&str> = rgb.split('/').collect();
+ if parts.len() == 3 {
+ let conv = |s: &str| -> Option<u8> {
+ let v = u32::from_str_radix(s, 16).ok()?;
+ let max = (1u32 << (4 * s.len())) - 1;
+ Some(((v * 255) / max) as u8)
+ };
+ let (r, g, b) = (conv(parts[0])?, conv(parts[1])?, conv(parts[2])?);
+ return Some(format!("#{:02x}{:02x}{:02x}", r, g, b));
+ }
+ // `rgb:RRGGBB` (six digits, as some terminals answer) or `rgb:RRRR`-style in one token.
+ if let Some(hex) = parts.first().filter(|s| s.len() == 6 && s.bytes().all(|b| b.is_ascii_hexdigit())) {
+ return Some(format!("#{}", hex.to_lowercase()));
+ }
+ }
+ None
+}
+
/// Blocking reader thread. The initial queries never delay drawing or shell startup;
/// terminal replies can arrive after ordinary input and do not become keystrokes.
pub fn read(keys: tokio::sync::mpsc::UnboundedSender<crate::event::Event>) {
@@ -88,6 +130,10 @@ pub fn read(keys: tokio::sync::mpsc::UnboundedSender<crate::event::Event>) {
if !crate::term_out::terminal_answer(name) { continue }
crate::event::Event::Apply(Box::new(|app| app.redraw_all = true))
}
+ Item::Background(bg) => {
+ crate::term_out::set_terminal_colours(bg, None);
+ crate::event::Event::Apply(Box::new(|app| { app.push_theme(); app.redraw_all = true; }))
+ }
};
if keys.send(event).is_err() { return }
}
@@ -133,4 +179,22 @@ mod tests {
assert!(decoder.push(b"\x1bP", true).is_empty());
assert_eq!(decoder.escape(), vec![Item::Input(Event::Key(KeyEvent::new(KeyCode::Char('P'), KeyModifiers::SHIFT | KeyModifiers::ALT)))]);
}
+ #[test]
+ fn osc11_background_answers_become_theme_and_spare_typeahead() {
+ let mut decoder = Decoder::default();
+ let mut items = Vec::new();
+ for b in b"ls\r\x1b]11;rgb:ffff/ffff/ffff\x07echo done" { items.extend(decoder.push(&[*b], true)); }
+ let bgs: Vec<_> = items.iter().filter_map(|i| if let Item::Background(n) = i { Some(n.clone()) } else { None }).collect();
+ assert_eq!(bgs, vec![Some("#ffffff".into())]);
+ let text: String = items.iter().filter_map(|i| match i { Item::Input(Event::Key(k)) => match k.code { KeyCode::Char(c) => Some(c), KeyCode::Enter => Some('\r'), _ => None }, _ => None }).collect();
+ assert_eq!(text, "ls\recho done");
+ }
+ #[test]
+ fn osc11_parses_slash_hex_and_hash_forms() {
+ assert_eq!(parse_osc11("rgb:ffff/0000/ffff"), Some("#ff00ff".into()));
+ assert_eq!(parse_osc11("rgb:00ff00"), Some("#00ff00".into()));
+ assert_eq!(parse_osc11("#1a1A1a"), Some("#1a1a1a".into()));
+ assert_eq!(parse_osc11("rgb:0000/0000/0000"), Some("#000000".into())); // a terminal's black
+ assert_eq!(parse_osc11("garbage"), None);
+ }
}
diff --git a/tui/src/term_out.rs b/tui/src/term_out.rs
index 358fe5fbf..dc5bfb01b 100644
--- a/tui/src/term_out.rs
+++ b/tui/src/term_out.rs
@@ -195,9 +195,11 @@ static TERMINAL: std::sync::OnceLock<String> = std::sync::OnceLock::new();
static TERMINAL_ANSWERED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
/// Query without waiting: the normal input reader separates replies from typeahead.
+/// OSC 11 (default background) is asked too: hn reports it to each machine's daemon
+/// (`theme_set`) so agent panes are painted to match, exactly as the desktop app does.
pub fn ask_terminal() {
let mut out = io::stdout();
- let _ = out.write_all(b"\x1b[>q\x1b[c");
+ let _ = out.write_all(b"\x1b[>q\x1b[c\x1b]11;?\x07");
let _ = out.flush();
}
@@ -223,6 +225,50 @@ static COLOURS: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new
pub fn set_colours(n: u32) { COLOURS.store(n, std::sync::atomic::Ordering::Relaxed) }
+/// The terminal's own default background and foreground, from its OSC 10/11 answers, as
+/// `#rrggbb` (bg, fg). None until the terminal answers. hn starts on top of the terminal, so
+/// these are asked directly and answer reliably; the daemon uses them to paint agent panes.
+static TERMINAL_FG_BG: std::sync::RwLock<Option<(String, String)>> = std::sync::RwLock::new(None);
+
+fn hex_rgb(hex: &str) -> Option<(u8, u8, u8)> {
+ let h = hex.trim_start_matches('#');
+ if h.len() != 6 { return None }
+ let v = u32::from_str_radix(h, 16).ok()?;
+ Some(((v >> 16) as u8, ((v >> 8) & 0xff) as u8, (v & 0xff) as u8))
+}
+
+/// A foreground that reads on the background: dark on light, light on dark.
+fn companion_fg(bg: &str) -> String {
+ let Some((r, g, b)) = hex_rgb(bg) else { return "#f5f5f5".into() };
+ let lum = 0.299 * r as f64 + 0.587 * g as f64 + 0.114 * b as f64;
+ if lum > 128.0 { "#1a1a1a".into() } else { "#f5f5f5".into() }
+}
+
+/// What the terminal answered for its default colours, (bg, fg) hex, when it answered.
+pub fn terminal_colours() -> Option<(String, String)> {
+ TERMINAL_FG_BG.read().ok()?.clone()
+}
+
+/// Record an OSC 10/11 answer. A half left blank keeps the other (a terminal may answer bg only);
+/// a missing foreground is chosen for contrast on the background.
+pub fn set_terminal_colours(bg: Option<String>, fg: Option<String>) {
+ if let Ok(mut guard) = TERMINAL_FG_BG.write() {
+ let existing = guard.clone();
+ let bg = bg.or(existing.as_ref().map(|(b, _)| b.clone()));
+ let fg = fg.or(existing.as_ref().map(|(_, f)| f.clone()));
+ if let Some(bg) = bg {
+ *guard = Some((bg.clone(), fg.unwrap_or_else(|| companion_fg(&bg))));
+ }
+ }
+}
+
+/// Whether the terminal's background is light, from its OSC 11 answer, when it answered.
+pub fn terminal_is_light() -> Option<bool> {
+ let (bg, _) = terminal_colours()?;
+ let (r, g, b) = hex_rgb(&bg)?;
+ Some(0.299 * r as f64 + 0.587 * g as f64 + 0.114 * b as f64 > 128.0)
+}
+
/// The terminal's colours from its name and what it says of itself, and what the config says of
/// it: 24-bit with COLORTERM truecolor or 24bit, a `-direct` terminal, an explicit RGB
/// feature/override, or a recognized terminal name. A query still awaiting a reply leaves
diff --git a/tui/src/theme.rs b/tui/src/theme.rs
index 87192f41b..0fabced67 100644
--- a/tui/src/theme.rs
+++ b/tui/src/theme.rs
@@ -409,6 +409,19 @@ pub const MUTED: Color = Color::Indexed(8);
pub const SOFT: Color = Color::Indexed(7);
pub const TEXT: Color = Color::Reset;
+/// hn's chrome from the terminal's OSC 10/11 answer: `(background, foreground, is_light)`.
+/// Every piece of hn's chrome — the status bar, the message line, the pane borders — takes its
+/// colours from this one palette, so none of it disagrees with the theme. The foreground is made
+/// readable on the background; a deterministic dark default holds until the terminal answers.
+pub fn palette() -> (Color, Color, bool) {
+ let (bg, fg) = crate::term_out::terminal_colours()
+ .unwrap_or_else(|| ("#201f26".to_string(), "#f5f5f5".to_string()));
+ let light = crate::term_out::terminal_is_light().unwrap_or(false);
+ let bg = crate::tmuxconf::colour(&bg).unwrap_or(Color::Reset);
+ let fg = crate::tmuxconf::colour(&fg).unwrap_or(Color::Reset);
+ (bg, fg, light)
+}
+
/// fzf's colours — its dark256 default, or what `--color=light|16|bw` in `$FZF_DEFAULT_OPTS` asks
/// for (and bw under NO_COLOR), so a list here looks like fzf does on this terminal.
#[derive(Clone)]
@@ -517,7 +530,14 @@ fn fzf_base() -> &'static Fzf {
i += 1;
}
// No base named: the renderer's own — 256 colours, or the 16 on a terminal without them.
- let base = base.unwrap_or(if depth() < 256 { DEFAULT16 } else { DARK256 });
+ // The terminal's own background (when it answered) chooses light over dark, so a light
+ // terminal gets the light palette rather than the stock dark one.
+ let base = base.unwrap_or_else(|| {
+ if let Some(light) = crate::term_out::terminal_is_light() {
+ return if light { LIGHT256 } else { DARK256 };
+ }
+ if depth() < 256 { DEFAULT16 } else { DARK256 }
+ });
if black { theme.bg.col = Col::Idx(0) }
let pal = init(theme, base, bold);
let fg = |p: P| p.style().fg.unwrap_or(Color::Reset);
@@ -1036,7 +1056,14 @@ pub const TMUX_DISPLAY_PANES_ACTIVE: Color = Color::Red;
pub fn fg(color: Color) -> Style {
match color {
- MUTED | SOFT => Style::default().add_modifier(Modifier::DIM),
+ MUTED | SOFT if no_color() => Style::default().add_modifier(Modifier::DIM),
+ // MUTED/SOFT are emphasis (the theme's dim), so they dim the theme's own readable text —
+ // not the terminal's raw default foreground, which can disagree with the theme (the mixed
+ // colour source that made hn's chrome read teal on some terminals).
+ MUTED | SOFT => {
+ let (_, fg, _) = palette();
+ Style::default().fg(depth_fit(fg)).add_modifier(Modifier::DIM)
+ }
_ if no_color() => Style::default(),
c => Style::default().fg(depth_fit(c)),
}
@@ -1197,3 +1224,38 @@ mod opts_tests {
assert_eq!(parse_label_pos("bottom"), (0, true));
}
}
+
+#[cfg(test)]
+mod palette_tests {
+ use super::palette;
+ use ratatui::style::Color;
+
+ /// The schema: a dark terminal answers a dark background and a light text; the palette must
+ /// keep them, mark the terminal dark, and the readable text must come back as the light one.
+ /// A light terminal inverts both. This is the invariant every piece of chrome uses, so none
+ /// of it disagrees with the theme.
+ #[test]
+ fn palette_follows_the_terminal_answer() {
+ crate::term_out::set_terminal_colours(Some("#201f26".into()), Some("#f5f5f5".into()));
+ let (bg, fg, light) = palette();
+ assert_eq!(bg, Color::Rgb(0x20, 0x1f, 0x26), "dark bg must map to the terminal's rgb");
+ assert_eq!(fg, Color::Rgb(0xf5, 0xf5, 0xf5), "the readable text on dark is light");
+ assert!(!light, "a dark background must not read as light");
+
+ // MUTED/SOFT are emphasis, so they must dim the theme's readable text (the palette fg), never
+ // dip into the terminal's raw default foreground — the mixed colour source that made hn's
+ // chrome read as teal on some terminals while the status bar was light.
+ for c in [super::MUTED, super::SOFT] {
+ let s = super::fg(c);
+ assert_eq!(s.fg, Some(super::depth_fit(fg)), "{c:?} carries the theme's foreground, not the terminal default");
+ assert!(s.add_modifier.contains(ratatui::style::Modifier::DIM), "{c:?} stays emphasis (dim)");
+ }
+
+ // A light terminal, in the same thread.
+ crate::term_out::set_terminal_colours(Some("#f7f7f7".into()), Some("#1a1a1a".into()));
+ let (bg, fg, light) = palette();
+ assert_eq!(bg, Color::Rgb(0xf7, 0xf7, 0xf7));
+ assert_eq!(fg, Color::Rgb(0x1a, 0x1a, 0x1a));
+ assert!(light, "a light background reads as light");
+ }
+}
diff --git a/tui/src/ui.rs b/tui/src/ui.rs
index 9b1a9588e..91d982324 100644
--- a/tui/src/ui.rs
+++ b/tui/src/ui.rs
@@ -71,12 +71,13 @@ pub fn draw(frame: &mut Frame, app: &mut App) {
}
if let Some(Modal::DisplayPanes { .. }) = &app.modal { display_panes(buf, app) }
let search_busy = app.said_due.is_some() || app.said_pending > 0;
+ let msg_style = app.message_style();
if let Some(modal) = &mut app.modal {
match modal {
// (--no-input: no prompt, no cursor.)
// (Too small to hold a list — a window being dragged, a drop-down terminal opening: none
// drawn until it has the room, as fzf clamps and tmux draws what fits; never a crash.)
- Modal::Picker { kind, picker } if body.height >= 1 && body.width >= 2 => { let at = fzf(buf, body, picker, kind, search_busy); cursor = (!theme::fzf_opts().no_input).then_some(at) }
+ Modal::Picker { kind, picker } if body.height >= 1 && body.width >= 2 => { let at = fzf(buf, body, picker, kind, search_busy, msg_style); cursor = (!theme::fzf_opts().no_input).then_some(at) }
_ => {}
}
}
@@ -302,8 +303,18 @@ fn borders(buf: &mut Buffer, app: &App, body: Rect) {
/// pane-border-style, or for the active pane pane-active-border-style (tmux's: yellow while the
/// pane is in copy mode, red while the window's panes are synchronized, else green), as the
/// window has them: colours, background and attributes, a format in them expanded for the pane.
+/// hn leaves a stock border — tmux's green active border — alone only when you set one yourself;
+/// otherwise it takes the theme's readable foreground (the active pane dimmed), so the selected
+/// pane reads as the theme rather than tmux's green.
fn border_style(app: &App, active: bool) -> Style {
- app.style_of(if active { "pane-active-border-style" } else { "pane-border-style" }, app.active, app.focused())
+ let mut s = app.style_of(if active { "pane-active-border-style" } else { "pane-border-style" }, app.active, app.focused());
+ let own = if active { app.look.active_border.is_some() } else { app.look.border.is_some() };
+ if !own {
+ let (_, fg, _) = crate::theme::palette();
+ s = s.fg(fg);
+ if !active { s = s.add_modifier(Modifier::DIM) }
+ }
+ s
}
/// A pane's status line over its border characters: its pane-border-format (hn's: the harness's
@@ -325,6 +336,7 @@ const WORDMARK: [&str; 2] = ["█ █ ▄▀█ █▀█ █▄ █ █▀▀
fn empty_window(buf: &mut Buffer, app: &App, area: Rect) {
let rows = home_rows(app);
+ let (_, theme_fg, _) = crate::theme::palette();
let width = area.width.min(84).saturating_sub(4);
let left = area.x + (area.width.saturating_sub(width)) / 2;
let compact = area.height < 22;
@@ -379,12 +391,12 @@ fn empty_window(buf: &mut Buffer, app: &App, area: Rect) {
let selected = app.home_moved && index == app.home_cursor;
// The chosen row as fzf draws its current line (reverse video where there is no colour).
let bg = match (selected, theme::fzf().bw) { (true, true) => Style::default().add_modifier(Modifier::REVERSED), (true, false) => Style::default().bg(theme::fzf().bg_plus), _ => Style::default() };
- let tint = |c: Color| if c == theme::MUTED || c == theme::SOFT { bg.add_modifier(Modifier::DIM) } else { bg.fg(theme::paint(c)) };
+ let tint = |c: Color| if c == theme::MUTED || c == theme::SOFT { bg.fg(theme::paint(theme_fg)).add_modifier(Modifier::DIM) } else { bg.fg(theme::paint(c)) };
lines.push(Line::from(vec![
Span::styled(format!("{} ", index + 1), tint(theme::ACCENT)),
Span::styled(format!("{dot} "), tint(color)),
Span::styled(format!("{mark} "), tint(mark_color)),
- Span::styled(format!("{name} "), bg.add_modifier(Modifier::BOLD)),
+ Span::styled(format!("{name} "), bg.fg(theme::paint(theme_fg)).add_modifier(Modifier::BOLD)),
Span::styled(detail_text, tint(detail.1)),
Span::styled(" ".repeat(pad), bg),
Span::styled(right, tint(theme::MUTED)),
@@ -958,7 +970,7 @@ fn fzf_split(inner: Rect, picker: &Picker) -> (Rect, Option<PreviewBox>, bool) {
/// fzf 0.67's default layout, measured: rows bottom-up (best nearest the prompt), `▌` gutter
/// (236; the current row's in 161 on 236), matches in 108 (151 on the current row), the info line
/// ` 4/7 ───` (144, separator 59), the prompt `> ` (110). Returns where the cursor goes.
-fn fzf(buf: &mut Buffer, body: Rect, picker: &mut Picker, kind: &PickerKind, search_busy: bool) -> Position {
+fn fzf(buf: &mut Buffer, body: Rect, picker: &mut Picker, kind: &PickerKind, search_busy: bool, msg_style: Style) -> Position {
let frame = fzf_frame(body, picker);
crate::term_out::clear_extras(frame.screen);
picker.screen_area.set(frame.screen);
@@ -1221,7 +1233,7 @@ fn fzf(buf: &mut Buffer, body: Rect, picker: &mut Picker, kind: &PickerKind, sea
if let Some(flash) = picker.flash.as_ref().map(|f| f.0.clone()) {
let text = format!(" {flash} ");
let fx = (ia.x + ia.width).saturating_sub(text.width() as u16 + 1);
- buf.set_string(fx, info_y, &text, Style::default().fg(Color::Black).bg(Color::Yellow));
+ buf.set_string(fx, info_y, &text, msg_style);
}
let header_y = if !o.no_input || in_header.is_some() { header_y } else if prompt_top { area.y } else { bottom.saturating_sub(1) };
if let Some(h) = &header { let (hx, hw) = in_header.map(|r| (r.x, r.width)).unwrap_or((area.x, area.width)); buf.set_line(hx, header_y, h, hw); }
@@ -2543,7 +2555,7 @@ mod fzf_list_tests {
fn screen(p: &mut Picker) -> String {
let area = Rect::new(0, 0, 40, 10);
let mut buf = Buffer::empty(area);
- fzf(&mut buf, area, p, &PickerKind::Output { title: String::new(), lines: vec![] }, false);
+ fzf(&mut buf, area, p, &PickerKind::Output { title: String::new(), lines: vec![] }, false, Style::default());
(0..area.height).map(|y| (0..area.width).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")
}