From 2bdfbe25d5c24c9866c371653ead3a0a1f493b1b Mon Sep 17 00:00:00 2001 From: Saky Date: Sun, 15 Mar 2026 12:03:11 +0100 Subject: [PATCH] debug: add temporary history overlay --- src/app/ui.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/app/ui.py b/src/app/ui.py index d0b6141..496ffae 100644 --- a/src/app/ui.py +++ b/src/app/ui.py @@ -60,6 +60,9 @@ def build_render_lines(navigator: Navigator) -> list[RenderLine]: class TerminalUI: """Minimal curses UI for the directory navigator MVP.""" + def __init__(self) -> None: + self._show_history_debug = False + def run(self, navigator: Navigator) -> Path: """Start the interactive session and return the final directory path.""" @@ -114,6 +117,10 @@ class TerminalUI: navigator.go_forward() continue + if key == ord("h"): + self._show_history_debug = not self._show_history_debug + continue + if key in (curses.KEY_ENTER, 10, 13): navigator.enter_selected_directory() @@ -131,8 +138,26 @@ class TerminalUI: attributes = curses.A_REVERSE if line.is_selected else curses.A_NORMAL stdscr.addnstr(row, 0, line.text, width - 1, attributes) + if self._show_history_debug: + self._render_history_debug(stdscr, navigator, width=width, height=height) + stdscr.refresh() + def _render_history_debug( + self, stdscr: curses.window, navigator: Navigator, width: int, height: int + ) -> None: + history_entries = navigator.history.entries() + start_row = 1 + + stdscr.addnstr(start_row, 0, "History:", width - 1, curses.A_BOLD) + + for index, path in enumerate(history_entries, start=1): + row = start_row + index + if row >= height: + break + + stdscr.addnstr(row, 0, str(path), width - 1) + @contextmanager def open_terminal_streams() -> Iterator[tuple[TextIO, TextIO]]: