feat(ui): improve row selection highlighting in grid

Add a subtle dark-gray background color constant for row highlighting.

Apply the highlight background across the entire selected row area,
including gaps between columns and the margin after the last column.

Apply the highlight background to individual cells in the selected row,
using DarkGray for empty values and White for non-empty values.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
Edward Langley
2026-04-05 12:30:15 -07:00
parent f56ca2c66a
commit 94bc3ca282

View File

@ -15,6 +15,8 @@ const ROW_HEADER_WIDTH: u16 = 16;
const COL_WIDTH: u16 = 10;
const MIN_COL_WIDTH: u16 = 6;
const MAX_COL_WIDTH: u16 = 32;
/// Subtle dark-gray background used to highlight the row containing the cursor.
const ROW_HIGHLIGHT_BG: Color = Color::Indexed(237);
const GROUP_EXPANDED: &str = "";
const GROUP_COLLAPSED: &str = "";
@ -322,14 +324,29 @@ impl<'a> GridWidget<'a> {
let ri = data_row_idx;
data_row_idx += 1;
let row_style = if ri == sel_row {
let is_sel_row = ri == sel_row;
let row_style = if is_sel_row {
Style::default()
.fg(Color::Cyan)
.bg(ROW_HIGHLIGHT_BG)
.add_modifier(Modifier::BOLD)
} else {
Style::default()
};
// Paint row-highlight background across the entire row
// (data area + any trailing space) so gaps between columns
// and the margin after the last column share the highlight.
if is_sel_row {
let row_w = (area.x + area.width).saturating_sub(area.x);
buf.set_string(
area.x + ROW_HEADER_WIDTH,
y,
" ".repeat(row_w.saturating_sub(ROW_HEADER_WIDTH) as usize),
Style::default().bg(ROW_HIGHLIGHT_BG),
);
}
// Multi-level row header — one sub-column per row category
let mut hx = area.x;
for d in 0..n_row_levels {
@ -392,6 +409,13 @@ impl<'a> GridWidget<'a> {
.add_modifier(Modifier::BOLD)
} else if is_search_match {
Style::default().fg(Color::Black).bg(Color::Yellow)
} else if is_sel_row {
let fg = if value.is_none() {
Color::DarkGray
} else {
Color::White
};
Style::default().fg(fg).bg(ROW_HIGHLIGHT_BG)
} else if value.is_none() {
Style::default().fg(Color::DarkGray)
} else {