From ae3faec86bee6b5d4b91d0ba7f554c148eb22f2c Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Mon, 26 Oct 2026 21:18:30 +0100 Subject: [PATCH] fix: help names only keys the route sends --- install.py | 15 ++++++++++--- tests/fixtures/tui/route-evmapy.txt | 6 ++--- tests/fixtures/tui/route-gptokeyb.txt | 8 +++---- tests/fixtures/tui/route-gptokeyb_muxterm.txt | 8 +++---- tests/fixtures/tui/route-miyoo.txt | 8 +++---- tests/fixtures/tui/route-muxterm.txt | 6 ++--- tests/test_install_tui.py | 22 +++++++++++++++++++ 7 files changed, 52 insertions(+), 21 deletions(-) diff --git a/install.py b/install.py index 883ab3164..715771444 100644 --- a/install.py +++ b/install.py @@ -12758,7 +12758,7 @@ def _help_lines(state: TuiState) -> list[tuple[str, str]]: if screen == "installing": return [(names["stop"], "Stop: what is done stays done"), *([(names["kill"], "Stop")] if names["kill"] else []), - *_route_extras(state), ("?, F1", "This help")] + *_route_extras(state), *_help_key(state)] if screen == "path": return [(names["enter"], "Use this folder"), ("Backspace", "Delete a character"), ("Ctrl-U", "Clear"), (names["esc"], "Back"), ("Ctrl-C", "Quit"), @@ -12786,10 +12786,16 @@ def _help_lines(state: TuiState) -> list[tuple[str, str]]: keys.append((names["options"], "Options")) back = "Quit" if len(state.stack) == 1 else "Back" keys += [(names["back"], back), ("q, Ctrl-C", "Quit"), *kill, *_route_extras(state), - ("?, F1", "This help")] + *_help_key(state)] return keys +def _help_key(state: TuiState) -> list[tuple[str, str]]: + """? and F1, named only where a keyboard may send them: no pad route + maps a button to either.""" + return [("?, F1", "This help")] if state.pad in ("both", "keys") else [] + + def _primary(state: TuiState) -> str | None: """What A does on the row in focus, for the first entry of the bar.""" if state.screen in _PAGERS: @@ -12805,7 +12811,10 @@ def _primary(state: TuiState) -> str | None: def _view_help(state: TuiState, width: int, height: int) -> tuple: keys = _help_lines(state) column = min(22, max(cell_width(key) for key, _what in keys) + 2) - lines = [f"{_pad(key, column)}{what}" for key, what in keys] + # Two spaces at least: a key as wide as the column touched its text + # ("Select Keyboard on or off" on muxterm). + lines = [f"{_pad(key, column)}{what}" if cell_width(key) <= column - 2 + else f"{key} {what}" for key, what in keys] if state.screen in ("setup", "plan", "browse", "folder") and state.dest is not None: lines += ["", f"BIOS folder: {state.dest}"] return ("Keys", _compose(state, width, height, lines, []), ("Any key closes this help",)) diff --git a/tests/fixtures/tui/route-evmapy.txt b/tests/fixtures/tui/route-evmapy.txt index c9f54b1b5..0a1bcb769 100644 --- a/tests/fixtures/tui/route-evmapy.txt +++ b/tests/fixtures/tui/route-evmapy.txt @@ -1140,10 +1140,10 @@ Y, Tab, o Options B, Select, Esc Back q, Ctrl-C Quit - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system + Any key closes this help === help 40x15 RetroBIOS: Keys @@ -1153,13 +1153,13 @@ Y, Tab, o Options B, Select, Esc Back q, Ctrl-C Quit - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system + Any key closes this help === help 80x24 RetroBIOS: Keys @@ -1169,7 +1169,6 @@ Y, Tab, o Options B, Select, Esc Back q, Ctrl-C Quit - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system @@ -1185,4 +1184,5 @@ + Any key closes this help diff --git a/tests/fixtures/tui/route-gptokeyb.txt b/tests/fixtures/tui/route-gptokeyb.txt index 9812144e8..133c20d34 100644 --- a/tests/fixtures/tui/route-gptokeyb.txt +++ b/tests/fixtures/tui/route-gptokeyb.txt @@ -1141,9 +1141,9 @@ B, Select, Esc Back q, Ctrl-C Quit Select, then Start Quit at once - ?, F1 This help - + BIOS folder: + /home/user/.config/retroarch/system Any key closes this help === help 40x15 RetroBIOS: Keys @@ -1154,12 +1154,12 @@ B, Select, Esc Back q, Ctrl-C Quit Select, then Start Quit at once - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system + Any key closes this help === help 80x24 RetroBIOS: Keys @@ -1170,7 +1170,6 @@ B, Select, Esc Back q, Ctrl-C Quit Select, then Start Quit at once - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system @@ -1185,4 +1184,5 @@ + Any key closes this help diff --git a/tests/fixtures/tui/route-gptokeyb_muxterm.txt b/tests/fixtures/tui/route-gptokeyb_muxterm.txt index 9812144e8..133c20d34 100644 --- a/tests/fixtures/tui/route-gptokeyb_muxterm.txt +++ b/tests/fixtures/tui/route-gptokeyb_muxterm.txt @@ -1141,9 +1141,9 @@ B, Select, Esc Back q, Ctrl-C Quit Select, then Start Quit at once - ?, F1 This help - + BIOS folder: + /home/user/.config/retroarch/system Any key closes this help === help 40x15 RetroBIOS: Keys @@ -1154,12 +1154,12 @@ B, Select, Esc Back q, Ctrl-C Quit Select, then Start Quit at once - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system + Any key closes this help === help 80x24 RetroBIOS: Keys @@ -1170,7 +1170,6 @@ B, Select, Esc Back q, Ctrl-C Quit Select, then Start Quit at once - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system @@ -1185,4 +1184,5 @@ + Any key closes this help diff --git a/tests/fixtures/tui/route-miyoo.txt b/tests/fixtures/tui/route-miyoo.txt index faaed9394..65bcc4bcf 100644 --- a/tests/fixtures/tui/route-miyoo.txt +++ b/tests/fixtures/tui/route-miyoo.txt @@ -1141,9 +1141,9 @@ R2, Esc, Backspace Back q, Ctrl-C Quit B Sends no key here - ?, F1 This help - + BIOS folder: + /home/user/.config/retroarch/system Any key closes this help === help 40x15 RetroBIOS: Keys @@ -1154,12 +1154,12 @@ R2, Esc, Backspace Back q, Ctrl-C Quit B Sends no key here - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system + Any key closes this help === help 80x24 RetroBIOS: Keys @@ -1170,7 +1170,6 @@ R2, Esc, Backspace Back q, Ctrl-C Quit B Sends no key here - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system @@ -1185,4 +1184,5 @@ + Any key closes this help diff --git a/tests/fixtures/tui/route-muxterm.txt b/tests/fixtures/tui/route-muxterm.txt index 8394f7eaf..f381ab561 100644 --- a/tests/fixtures/tui/route-muxterm.txt +++ b/tests/fixtures/tui/route-muxterm.txt @@ -1142,7 +1142,7 @@ q, Ctrl-C Quit Select Keyboard on or off Menu Close the terminal - ?, F1 This help + Any key closes this help === help 40x15 @@ -1155,11 +1155,11 @@ q, Ctrl-C Quit Select Keyboard on or off Menu Close the terminal - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system + Any key closes this help === help 80x24 RetroBIOS: Keys @@ -1171,7 +1171,6 @@ q, Ctrl-C Quit Select Keyboard on or off Menu Close the terminal - ?, F1 This help BIOS folder: /home/user/.config/retroarch/system @@ -1185,4 +1184,5 @@ + Any key closes this help diff --git a/tests/test_install_tui.py b/tests/test_install_tui.py index 740dba734..1d5dd4086 100644 --- a/tests/test_install_tui.py +++ b/tests/test_install_tui.py @@ -3940,6 +3940,28 @@ class GameDataIsNoFirmwareAlarm(unittest.TestCase): self.assertIn("Anims.j2a (Jazz Jackrabbit 2)", lines[1]) +class TheHelpNamesKeysThatCome(unittest.TestCase): + """Every route's help listed "?, F1 This help", which no pad sends, and + a key as wide as the column touched its text.""" + + def test_pad_routes_name_no_help_key(self): + for pad in ROUTES: + with self.subTest(route=pad): + state = checked_state() + state.pad = pad + keys = [key for key, _what in install._help_lines(state)] + self.assertEqual("?, F1" in keys, pad == "keys") + + def test_a_wide_key_keeps_two_spaces(self): + state = checked_state() + state.help = True + with mock.patch.object(install, "_help_lines", + return_value=[("A, Start, Enter, Space, x", "Choose"), + ("q", "Quit")]): + lines = install._view_help(state, 80, 24)[1] + self.assertTrue(any("A, Start, Enter, Space, x Choose" in line for line in lines)) + + class NothingFoundIsSaid(unittest.TestCase): """With nothing detected the first screen was the list of 18 setups, with no line at 40x15 saying nothing was found, which the beginner's