From 1508938fed4e3800dcf45c807f67e87ebe8ca30b Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 28 Apr 2024 23:21:13 +0200 Subject: [PATCH] Highlight the active filter --- src/list/state.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/list/state.rs b/src/list/state.rs index 77f0936..0f2a1c8 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -2,7 +2,7 @@ use anyhow::{Context, Result}; use ratatui::{ layout::{Constraint, Rect}, style::{Style, Stylize}, - text::Span, + text::{Line, Span}, widgets::{Block, Borders, HighlightSpacing, Paragraph, Row, Table, TableState}, Frame, }; @@ -193,11 +193,25 @@ impl<'a> UiState<'a> { let message = if self.message.is_empty() { // Help footer. - Span::raw( - "↓/j ↑/k home/g end/G │ ontinue at │ eset │ filter one/

ending │ uit", - ) + let mut spans = Vec::with_capacity(4); + spans.push(Span::raw( + "↓/j ↑/k home/g end/G │ ontinue at │ eset │ filter ", + )); + match self.filter { + Filter::Done => { + spans.push("one".underlined().magenta()); + spans.push(Span::raw("/

ending")); + } + Filter::Pending => { + spans.push(Span::raw("one/")); + spans.push("

ending".underlined().magenta()); + } + Filter::None => spans.push(Span::raw("one/

ending")), + } + spans.push(Span::raw(" │ uit")); + Line::from(spans) } else { - self.message.as_str().light_blue() + Line::from(self.message.as_str().light_blue()) }; frame.render_widget( message,