From 94bc3ca282d50d3e4e351dcb6e9b19cc1dbf0113 Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Sun, 5 Apr 2026 12:30:15 -0700 Subject: [PATCH] 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) --- src/ui/grid.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ui/grid.rs b/src/ui/grid.rs index 469c83a..b5099fc 100644 --- a/src/ui/grid.rs +++ b/src/ui/grid.rs @@ -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 {