refactor(tui): one page window and one filter editor for every list

Four panes had grown the same dance around ratatui's table: clamp the
selection, take the visible page, hand the table a page-local state,
keep the page start. It is now page_window and render_page in a paging
module beside page_of, and the two popups page by the same count they
draw, tab bar or header included.

Five typed filters had grown the same key handling too. edit_filter now
takes a key for all of them, which also stops a control or alt chord
from typing its letter into a filter, stops Enter, which keeps a filter,
from resetting the view it is over, and lets the results and room-list
filters page like the others. Their titles and the typing shortcuts
come from one place as well.
This commit is contained in:
Michel de Graaf
2026-09-08 11:24:59 +02:00
parent 607532cc44
commit 0cacc8cc10
13 changed files with 293 additions and 299 deletions
+15 -27
View File
@@ -114,6 +114,17 @@ const HELP_RIGHT: &[(&str, &[(&str, &str)])] = &[
),
];
/// What the bar offers while a filter is being typed, wherever that is,
/// with the keys that still move around there.
fn filter_keys(
moves: &[(&'static str, &'static str)],
) -> Vec<(&'static str, &'static str)> {
let mut keys = vec![("Type", "filter")];
keys.extend_from_slice(moves);
keys.extend([("Enter", "keep filter"), ("Esc", "clear filter")]);
keys
}
impl MainTui {
pub(super) fn render(&mut self, frame: &mut Frame) {
let shortcuts = self.shortcut_rows(frame.area().width);
@@ -497,13 +508,7 @@ impl MainTui {
}
}
RoomsView::Chat if self.state.rooms.filtering.is_some() => {
vec![
("Type", "filter"),
("PgUp/PgDn", "scroll"),
("↑↓", "pick user"),
("Enter", "keep filter"),
("Esc", "clear filter"),
]
filter_keys(&[("PgUp/PgDn", "scroll"), ("↑↓", "pick user")])
}
RoomsView::Chat => vec![
("Enter", "say"),
@@ -565,12 +570,7 @@ impl MainTui {
("Esc", "stop typing"),
]
} else if self.state.chat_filtering {
vec![
("Type", "filter"),
("PgUp/PgDn", "scroll"),
("Enter", "keep filter"),
("Esc", "clear filter"),
]
filter_keys(&[("PgUp/PgDn", "scroll")])
} else {
vec![
("Enter", "type"),
@@ -586,13 +586,7 @@ impl MainTui {
} else if self.state.show_browse {
if self.state.browse.active_tab().is_some_and(|b| b.filtering) {
// Typing goes to the filter, so no letter keys are on offer.
vec![
("Type", "filter"),
("↑/↓", "navigate"),
("PgUp/PgDn", "page"),
("Enter", "keep filter"),
("Esc", "clear filter"),
]
filter_keys(&[("↑/↓", "navigate"), ("PgUp/PgDn", "page")])
} else {
vec![
("↑↓", "move"),
@@ -632,13 +626,7 @@ impl MainTui {
&& self.state.focused_pane == FocusedPane::Results
{
// Typing goes to the filter, so no letter keys are on offer here.
vec![
("Type", "filter"),
("↑/↓", "navigate"),
("PgUp/PgDn", "page"),
("Enter", "keep filter"),
("Esc", "clear filter"),
]
filter_keys(&[("↑/↓", "navigate"), ("PgUp/PgDn", "page")])
} else {
let mut keys = match self.state.focused_pane {
FocusedPane::Searches => vec![