Coverage for src/lilbee/cli/tui/browse_bindings.py: 100%
5 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-09-28 17:20 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-09-28 17:20 +0000
1"""Shared key vocabulary for the browse screens.
3One fragment so sibling screens cannot drift: q goes back, Escape
4dismisses-or-goes-back, j/k walk the list, g/G jump to the ends. Screens
5spread these into ``BINDINGS`` and implement the actions against their own
6list widget; a widget that owns its list may bind them itself instead. A
7focused Input or TextArea consumes printable keys before any binding fires,
8priority bindings included, so the letters are typing-safe without focus guards.
9"""
11from __future__ import annotations
13from textual.binding import Binding, BindingType
15BROWSE_LIST_BINDINGS: list[Binding] = [
16 Binding("j", "cursor_down", "Nav", show=False),
17 Binding("k", "cursor_up", "Nav", show=False),
18 Binding("g", "jump_top", "Top", show=False),
19 Binding("G", "jump_bottom", "End", show=False),
20]
23def browse_back_bindings(*, escape_action: str = "go_back") -> list[BindingType]:
24 """The back pair. Screens with a search overlay pass ``dismiss_or_back``
25 so Escape clears the overlay first and leaves on the second press."""
26 return [
27 Binding("q", "go_back", "Back", show=True),
28 Binding("escape", escape_action, "Back", show=False),
29 ]