feat: add detailed keyboard help
Rust CI fader_master passed its selected CI mode.
MadGobblins/fader_master/pipeline/head This commit looks good Details

Open orientation-aware keyboard help with h or ?, move fader hiding to Shift+H, and update footer reminders and documentation.

Tests: cargo fmt --all -- --check; cargo check --workspace --all-targets --all-features; cargo test --workspace --all-targets --all-features; cargo test --workspace --doc --all-features; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo build --workspace --release --all-features; cargo check --workspace; cargo check --workspace --no-default-features; cargo check -p midi --no-default-features --features midir; cargo check -p volume_lib --no-default-features --features pulse
This commit is contained in:
Dandaedre 2026-10-15 23:00:29 +02:00
parent 488cb200df
commit f37e16fa7d
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 103 additions and 8 deletions

View File

@ -57,8 +57,9 @@ The mixer arrow keys follow its orientation. In Vertical mode, use Up/Down to
select a configured fader or separator and Left/Right to change its volume. In
Horizontal mode, use Left/Right to select and Up/Down to change volume. J/K
remain selection aliases in either mode, and Shift plus the selection arrows
reorders an entry. M toggles mute, T cycles the profile's theme draft, and Q
opens the quit confirmation. Escape cancels the active editor or dialog and
reorders an entry. M toggles mute, Shift+H hides the selected fader, and `h` or
`?` opens detailed keyboard help. T cycles the profile's theme draft, and Q opens
the quit confirmation. Escape cancels the active editor or dialog and
does not quit from the main screen. Pass `--theme dracula`, `nord`,
`gruvbox-dark`, `catppuccin-mocha`, or `solarized-dark` to choose an initial
session theme. Save from Config to persist a theme selected with T. Offline

View File

@ -442,6 +442,9 @@ with Up/Down and changes volume with Left/Right, while horizontal mode selects
with Left/Right and changes volume with Up/Down. Holding Shift reorders entries
along the active selection axis; J/K remain orientation-independent selection
aliases.
Lowercase `h` and `?` open an orientation-aware keyboard-help popup with mixer,
configuration, and global controls. Hiding is deliberately assigned to Shift+H
so the common help key does not perform a destructive presentation edit.
The selected main-list entry can be moved directly, and separators can be
added, renamed, moved, or removed. Adding or renaming a separator uses a

View File

@ -420,7 +420,8 @@ Dependencies: M8, M2, M1.
state. Hidden restoration uses one settings action that opens a popup listing
every hidden fader rather than expanding the settings page with one row per
fader. MIDI-device status rows are selectable and open a details popup where
the profile's default-controller assignment can be set or cleared.
the profile's default-controller assignment can be set or cleared. `h` and `?`
open detailed keyboard help; Shift+H hides the selected mixer fader.
Keep this item open until any remaining required object-creation workflow is
available from the mixer and its small-terminal acceptance passes.

View File

@ -814,6 +814,7 @@ pub struct LiveTui<C> {
theme_override: bool,
exit: bool,
quit_confirmation: bool,
show_help: bool,
client_error: Option<String>,
tab: Tab,
editor: Option<EditorInput>,
@ -995,6 +996,7 @@ impl<C: MixerClient> LiveTui<C> {
theme_override,
exit: false,
quit_confirmation: false,
show_help: false,
client_error: None,
tab: Tab::Mixer,
editor: None,
@ -1119,6 +1121,12 @@ impl<C: MixerClient> LiveTui<C> {
}
return;
}
if self.show_help {
if matches!(key_event.code, KeyCode::Esc | KeyCode::Char('h' | '?')) {
self.show_help = false;
}
return;
}
if self.snapshot.configuration.learning.is_some() {
if matches!(key_event.code, KeyCode::Esc | KeyCode::Char('c')) {
self.cancel_midi_learn();
@ -1154,6 +1162,7 @@ impl<C: MixerClient> LiveTui<C> {
return;
}
match key_event.code {
KeyCode::Char('h' | '?') => self.show_help = true,
KeyCode::Char('t') => self.change_theme(self.theme.next()),
KeyCode::Tab => {
self.tab = match self.tab {
@ -1196,6 +1205,7 @@ impl<C: MixerClient> LiveTui<C> {
self.snapshot.configuration.mixer_orientation == MixerOrientation::Horizontal;
if key_event.modifiers.contains(KeyModifiers::SHIFT) {
match (horizontal, key_event.code) {
(_, KeyCode::Char('H' | 'h')) => self.toggle_selected_visibility(),
(true, KeyCode::Left) | (false, KeyCode::Up) => {
self.move_selected_layout(-1);
}
@ -1237,7 +1247,7 @@ impl<C: MixerClient> LiveTui<C> {
KeyCode::Home => self.set_selected_volume(0.0),
KeyCode::End => self.set_selected_volume(1.0),
KeyCode::Char('m') => self.toggle_selected_mute(),
KeyCode::Char('h') => self.toggle_selected_visibility(),
KeyCode::Char('H') => self.toggle_selected_visibility(),
KeyCode::Char('a') => self.start_separator_editor(),
KeyCode::Char('e') => self.edit_selected_entry(),
KeyCode::Char('d') => self.remove_selected_separator(),
@ -2205,8 +2215,10 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
"move".fg(theme.secondary),
" A/E/D ".fg(theme.foreground),
"separator".fg(theme.secondary),
" h ".fg(theme.foreground),
" ⇧H ".fg(theme.foreground),
"hide".fg(theme.secondary),
" h/? ".fg(theme.foreground),
"help".fg(theme.secondary),
]),
(Tab::Mixer, MixerOrientation::Vertical) => Line::from(vec![
" ↑↓/jk ".fg(theme.foreground),
@ -2227,8 +2239,10 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
"move".fg(theme.secondary),
" A/E/D ".fg(theme.foreground),
"separator".fg(theme.secondary),
" h ".fg(theme.foreground),
" ⇧H ".fg(theme.foreground),
"hide".fg(theme.secondary),
" h/? ".fg(theme.foreground),
"help".fg(theme.secondary),
]),
(Tab::Configuration, _) => Line::from(vec![
" ↑↓ ".fg(theme.foreground),
@ -2243,6 +2257,8 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
"theme".fg(theme.secondary),
" Q ".fg(theme.foreground),
"quit".fg(theme.secondary),
" h/? ".fg(theme.foreground),
"help".fg(theme.secondary),
]),
};
Paragraph::new(footer_line)
@ -2278,6 +2294,9 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
if self.snapshot.configuration.learning.is_some() {
self.render_midi_learn_waiting(area, buf);
}
if self.show_help {
self.render_help(area, buf);
}
if self.quit_confirmation {
let width = area.width.min(46);
let height = area.height.min(5);
@ -2787,6 +2806,47 @@ impl<C: MixerClient> LiveTui<C> {
.render(popup, buf);
}
fn render_help(&self, area: Rect, buf: &mut Buffer) {
let theme = self.theme.palette();
let (selection, volume, movement) = match self.snapshot.configuration.mixer_orientation {
MixerOrientation::Horizontal => ("Left/Right", "Up/Down", "Shift+Left/Right"),
MixerOrientation::Vertical => ("Up/Down", "Left/Right", "Shift+Up/Down"),
};
let popup = centered_rect(area, 78, 22);
Clear.render(popup, buf);
Paragraph::new(Text::from(vec![
Line::from("Mixer").fg(theme.accent).bold(),
Line::from(format!(" {selection:<18} Select a fader or separator")),
Line::from(format!(" {volume:<18} Change the selected fader volume")),
Line::from(format!(" {movement:<18} Reorder the selected entry")),
Line::from(" J/K Select next/previous in either orientation"),
Line::from(" M Toggle mute"),
Line::from(" Shift+H Hide the selected fader"),
Line::from(" E Edit the selected fader or separator"),
Line::from(" A Add a separator after the selection"),
Line::from(" D Remove the selected separator"),
Line::from(""),
Line::from("Configuration").fg(theme.accent).bold(),
Line::from(" Up/Down or J/K Select a setting or MIDI device"),
Line::from(" Left/Right/Enter Change a setting or open its popup"),
Line::from(" S Save the configuration"),
Line::from(""),
Line::from("Global").fg(theme.accent).bold(),
Line::from(" 1 / 2 / Tab Switch Mixer and Config views"),
Line::from(" T Cycle theme Q Confirm quit"),
]))
.wrap(Wrap { trim: false })
.block(
Block::bordered()
.title(" Keyboard help ".fg(theme.accent).bold())
.title_bottom(" Esc / h / ? close ".fg(theme.muted))
.border_set(border::DOUBLE)
.border_style(Style::default().fg(theme.accent))
.style(Style::default().bg(theme.background)),
)
.render(popup, buf);
}
fn render_configuration(&self, area: Rect, buf: &mut Buffer) {
let theme = self.theme.palette();
let config = &self.snapshot.configuration;
@ -3669,6 +3729,37 @@ mod tests {
assert!(app.exit);
}
#[test]
fn help_keys_open_detailed_keyboard_help_without_hiding() {
let mut app = LiveTui::new(DemoClient::default()).unwrap();
app.handle_key_event(press(KeyCode::Char('h')));
let area = Rect::new(0, 0, 100, 24);
let mut buffer = Buffer::empty(area);
(&app).render(area, &mut buffer);
let rendered = buffer
.content
.iter()
.map(|cell| cell.symbol())
.collect::<String>();
assert!(rendered.contains("Keyboard help"));
assert!(rendered.contains("Shift+H"));
assert!(rendered.contains("Add a separator"));
assert!(rendered.contains("Save the configuration"));
app.handle_key_event(press(KeyCode::Esc));
assert!(!app.exit);
app.handle_key_event(press(KeyCode::Char('?')));
let mut question_buffer = Buffer::empty(area);
(&app).render(area, &mut question_buffer);
let question_rendered = question_buffer
.content
.iter()
.map(|cell| cell.symbol())
.collect::<String>();
assert!(question_rendered.contains("Keyboard help"));
}
#[test]
fn separator_name_is_edited_in_a_centered_popup() {
let mut app = LiveTui::new(DemoClient::default()).unwrap();
@ -3882,8 +3973,7 @@ mod tests {
app.handle_key_event(shift(KeyCode::Down));
app.handle_key_event(press(KeyCode::Up));
app.handle_key_event(press(KeyCode::Char('h')));
app.handle_key_event(press(KeyCode::Char('H')));
app.handle_key_event(shift(KeyCode::Char('H')));
app.handle_key_event(press(KeyCode::Tab));
let mut hidden_buffer = Buffer::empty(area);
(&app).render(area, &mut hidden_buffer);