romm_cli/tui/
keyboard_help.rs1use ratatui::layout::Rect;
4use ratatui::widgets::{Block, Borders, Clear, Paragraph, Wrap};
5use ratatui::Frame;
6
7pub const KEYBOARD_HELP_TEXT: &str = "\
8Global
9 F1 This help (anywhere)
10 ? This help (when not typing in a field)
11 d Downloads overlay (toggle; disabled while typing in a field)
12
13Main menu
14 Up / k, Down / j Move
15 Enter Open selected item
16 Esc / q Quit
17
18Library (consoles / games)
19 Up / k, Down / j Move in list or game rows
20 Left / h Back to console list (games view)
21 Right / l, Tab Switch panel or view
22 / Filter (focused pane: console/collection list or games)
23 Enter After typing a filter: browse matches; Esc clears filter
24 f Jump to match (focused pane: list or games)
25 Tab Next jump match (jump mode)
26 Enter Open games list or game detail
27 t Switch consoles / collections
28 Ctrl-u Upload ROM (Consoles list only; type path; Tab: scan after upload)
29 Ctrl-r Rescan library on server (waits until done; refreshes games list)
30 Esc Back or main menu
31 q Quit
32
33Search
34 Arrows, typing Edit query and move in results
35 Enter Run search; open game only if the query matches the last search
36 Esc Clear results or main menu
37
38Game detail
39 Enter Download
40 o Open cover image
41 m Toggle technical details
42 Esc Back
43 q Quit
44
45Downloads overlay
46 Esc / d Close
47
48Settings
49 Up / k, Down / j Move
50 Enter Edit row or open auth wizard
51 s Save config to disk
52 Esc Main menu
53 q Quit
54
55Execute request
56 Tab / Shift+Tab Next / previous field
57 Typing Edit fields
58 Enter Send request
59 Esc Back to browse
60
61JSON / table result
62 Up / k, Down / j, PgUp / PgDn Scroll
63 t Toggle JSON / table (when applicable)
64 Enter Open selected row (table)
65 Esc Back to browse
66 q Quit
67
68Result detail
69 Arrows, PgUp / PgDn Scroll
70 o Open image URL
71 Esc Back
72 q Quit
73
74Setup wizard
75 Follow on-screen prompts; Esc returns when offered.
76
77Press Esc, Enter, F1, or ? to close this help.
78";
79
80pub fn render_keyboard_help(f: &mut Frame, area: Rect) {
81 let popup_w = (area.width * 4 / 5).max(40).min(area.width);
82 let popup_h = (area.height * 4 / 5).max(15).min(area.height);
83 let popup_area = Rect {
84 x: area.width.saturating_sub(popup_w) / 2,
85 y: area.height.saturating_sub(popup_h) / 2,
86 width: popup_w,
87 height: popup_h,
88 };
89 f.render_widget(Clear, popup_area);
90 let block = Block::default()
91 .title("Keyboard shortcuts")
92 .borders(Borders::ALL);
93 let paragraph = Paragraph::new(KEYBOARD_HELP_TEXT)
94 .block(block)
95 .wrap(Wrap { trim: true });
96 f.render_widget(paragraph, popup_area);
97}