Coverage for src/lilbee/cli/tui/browse_bindings.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-14 11:46 +0000

1"""Shared key vocabulary for the browse screens. 

2 

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 focused Input or TextArea consumes printable keys before any 

7binding fires, so the letters are typing-safe without focus guards. 

8""" 

9 

10from __future__ import annotations 

11 

12from textual.binding import Binding, BindingType 

13 

14BROWSE_LIST_BINDINGS: list[BindingType] = [ 

15 Binding("j", "cursor_down", "Nav", show=False), 

16 Binding("k", "cursor_up", "Nav", show=False), 

17 Binding("g", "jump_top", "Top", show=False), 

18 Binding("G", "jump_bottom", "End", show=False), 

19] 

20 

21 

22def browse_back_bindings(*, escape_action: str = "go_back") -> list[BindingType]: 

23 """The back pair. Screens with a search overlay pass ``dismiss_or_back`` 

24 so Escape clears the overlay first and leaves on the second press.""" 

25 return [ 

26 Binding("q", "go_back", "Back", show=True), 

27 Binding("escape", escape_action, "Back", show=False), 

28 ]