diff options
| author | historia <historiavg@proton.me> | 2026-08-30 04:29:13 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-30 04:29:13 -0400 |
| commit | d31e9149c7f141b2d3c14a79e9f067d524c8c420 (patch) | |
| tree | 89b2232facac9cbe06cb17e279e664e9a3a37284 /app/ui | |
| parent | df4a81c6101d33fe745b6ac249c736e088760c85 (diff) | |
| download | tts-audiobook-generator-d31e9149c7f141b2d3c14a79e9f067d524c8c420.tar.gz | |
fix: menu highlight numbering in tui
Diffstat (limited to 'app/ui')
| -rw-r--r-- | app/ui/tui.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/ui/tui.py b/app/ui/tui.py index 19764ab..a4854b0 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -348,7 +348,9 @@ class Frame: # Optional scroll-indicator formatter: called as # scroll_label(scroll, total_lines, visible) whenever the frame # draws its border while the content overflows. None keeps the - # compact default " x/y " (used by menus, trees, the browser). + # compact default (used by menus, forms, trees, the browser): + # with a cursor it reads " highlighted/entries ", without one + # " first-visible-line/total-lines ". self.scroll_label = None try: curses.curs_set(0) @@ -543,7 +545,16 @@ class Frame: indicator = self.scroll_label(self.scroll, total_lines, visible) else: - indicator = f" {self.scroll + 1}/{total_lines} " + # With a cursor the label counts selectable rows: which + # entry is highlighted (the Nth option of a menu, the + # Nth field of a form, a tree node). Frames without a + # cursor keep the first-visible-line reading. + selectable = self.selectable() + if self.cursor is not None and self.cursor in selectable: + indicator = f" {selectable.index(self.cursor) + 1}/" \ + f"{len(selectable)} " + else: + indicator = f" {self.scroll + 1}/{total_lines} " _addstr(scr, y0, max(x0 + 1, x0 + dialog_w - 1 - len(indicator)), indicator, theme["dim"]) |
