diff options
| author | mo8it <mo8it@proton.me> | 2024-08-24 17:45:02 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-08-24 17:45:02 +0200 |
| commit | 28d0b0a21ec2d916309733dcce8aecdbdf305d46 (patch) | |
| tree | 5a8a37cbe2a05d22f7ff6ea9a5f96588e63fceb3 | |
| parent | b779c431268da50989257056d21a870a61a1702e (diff) | |
Highlight selected row
| -rw-r--r-- | src/list/state.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/list/state.rs b/src/list/state.rs index d874435..4ba3d4e 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result}; use crossterm::{ cursor::{MoveTo, MoveToNextLine}, - style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, + style::{Attribute, Color, ResetColor, SetAttribute, SetBackgroundColor, SetForegroundColor}, terminal::{self, BeginSynchronizedUpdate, Clear, ClearType, EndSynchronizedUpdate}, QueueableCommand, }; @@ -115,6 +115,11 @@ impl<'a> ListState<'a> { let mut n_displayed_rows = 0; for (exercise_ind, exercise) in displayed_exercises { if self.selected == Some(n_displayed_rows) { + stdout.queue(SetBackgroundColor(Color::Rgb { + r: 50, + g: 50, + b: 50, + }))?; stdout.write_all("🦀".as_bytes())?; } else { stdout.write_all(b" ")?; @@ -135,7 +140,7 @@ impl<'a> ListState<'a> { stdout.write_all(b"PENDING ")?; } - stdout.queue(ResetColor)?; + stdout.queue(SetForegroundColor(Color::Reset))?; stdout.write_all(exercise.name.as_bytes())?; stdout.write_all(&SPACE[..self.name_col_width + 2 - exercise.name.len()])?; @@ -143,6 +148,7 @@ impl<'a> ListState<'a> { stdout.write_all(exercise.path.as_bytes())?; next_ln::<true>(stdout)?; + stdout.queue(ResetColor)?; n_displayed_rows += 1; } |
