debug: add temporary history overlay

This commit is contained in:
2026-03-15 12:03:11 +01:00
parent 12d2577a31
commit 2bdfbe25d5

View File

@@ -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]]: