Skip to main content

max / alloy_tui

1.4 KB · 37 lines History Blame Raw
1 //! Selection chrome: the marker glyph and the selected-row style.
2 //!
3 //! Ported from sysop-tui's `selection.rs`, retinted from the theme. The marker
4 //! stays a plain triangle rather than a Nerd Font glyph so selection survives
5 //! a console without the patched font — the TTY before the session starts, a
6 //! remote shell, `alloy` over SSH. Per docs/ICONOGRAPHY.md, Nerd Font glyphs
7 //! decorate; they never carry state on their own.
8
9 use ratatui::style::{Modifier, Style};
10
11 use crate::theme::Theme;
12
13 /// The selected-row marker. Rendered in the gutter, one cell plus a space.
14 pub const MARKER: &str = "";
15
16 /// Blank gutter for unselected rows — the same width as [`MARKER`], so rows do
17 /// not shift horizontally as selection moves.
18 pub const MARKER_BLANK: &str = " ";
19
20 /// Style for the selected row.
21 ///
22 /// Uses `surface.raised` as the selection field rather than an accent fill:
23 /// DESIGN-LANGUAGE.md keeps color off chrome, so selection reads as a *raised*
24 /// surface plus weight, and any `Severity` color already on the row survives
25 /// unchanged instead of being drowned by an accent background.
26 pub fn selected_style(theme: &Theme) -> Style {
27 Style::default()
28 .bg(theme.surface_raised)
29 .fg(theme.content_primary)
30 .add_modifier(Modifier::BOLD)
31 }
32
33 /// Style for an unselected row.
34 pub fn unselected_style(theme: &Theme) -> Style {
35 Style::default().fg(theme.content_secondary)
36 }
37