mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-22 05:52:23 -05:00
Highlight the active filter
This commit is contained in:
parent
aedeff8b24
commit
1508938fed
1 changed files with 19 additions and 5 deletions
|
@ -2,7 +2,7 @@ use anyhow::{Context, Result};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Constraint, Rect},
|
layout::{Constraint, Rect},
|
||||||
style::{Style, Stylize},
|
style::{Style, Stylize},
|
||||||
text::Span,
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, HighlightSpacing, Paragraph, Row, Table, TableState},
|
widgets::{Block, Borders, HighlightSpacing, Paragraph, Row, Table, TableState},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
@ -193,11 +193,25 @@ impl<'a> UiState<'a> {
|
||||||
|
|
||||||
let message = if self.message.is_empty() {
|
let message = if self.message.is_empty() {
|
||||||
// Help footer.
|
// Help footer.
|
||||||
Span::raw(
|
let mut spans = Vec::with_capacity(4);
|
||||||
"↓/j ↑/k home/g end/G │ <c>ontinue at │ <r>eset │ filter <d>one/<p>ending │ <q>uit",
|
spans.push(Span::raw(
|
||||||
)
|
"↓/j ↑/k home/g end/G │ <c>ontinue at │ <r>eset │ filter ",
|
||||||
|
));
|
||||||
|
match self.filter {
|
||||||
|
Filter::Done => {
|
||||||
|
spans.push("<d>one".underlined().magenta());
|
||||||
|
spans.push(Span::raw("/<p>ending"));
|
||||||
|
}
|
||||||
|
Filter::Pending => {
|
||||||
|
spans.push(Span::raw("<d>one/"));
|
||||||
|
spans.push("<p>ending".underlined().magenta());
|
||||||
|
}
|
||||||
|
Filter::None => spans.push(Span::raw("<d>one/<p>ending")),
|
||||||
|
}
|
||||||
|
spans.push(Span::raw(" │ <q>uit"));
|
||||||
|
Line::from(spans)
|
||||||
} else {
|
} else {
|
||||||
self.message.as_str().light_blue()
|
Line::from(self.message.as_str().light_blue())
|
||||||
};
|
};
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
message,
|
message,
|
||||||
|
|
Loading…
Reference in a new issue