feat: add g/G to jump to first/last item
This commit is contained in:
parent
4dc693a9a4
commit
e0ca81802e
2 changed files with 14 additions and 0 deletions
|
|
@ -30,6 +30,8 @@ class Input:
|
||||||
"search": self._search,
|
"search": self._search,
|
||||||
"search_next": self._search_next,
|
"search_next": self._search_next,
|
||||||
"search_previous": self._search_previous,
|
"search_previous": self._search_previous,
|
||||||
|
"go_top": self._go_top,
|
||||||
|
"go_bottom": self._go_bottom,
|
||||||
}
|
}
|
||||||
|
|
||||||
def handle(self, key: str) -> bool:
|
def handle(self, key: str) -> bool:
|
||||||
|
|
@ -78,6 +80,16 @@ class Input:
|
||||||
self.app.navigator.cursor.up()
|
self.app.navigator.cursor.up()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _go_top(self) -> bool:
|
||||||
|
self.app.navigator.cursor.set(0)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _go_bottom(self) -> bool:
|
||||||
|
navigator = self.app.navigator
|
||||||
|
if navigator.items:
|
||||||
|
navigator.cursor.set(len(navigator.items) - 1)
|
||||||
|
return True
|
||||||
|
|
||||||
def _maybe_show_error(self) -> None:
|
def _maybe_show_error(self) -> None:
|
||||||
error = self.app.navigator.error
|
error = self.app.navigator.error
|
||||||
if error:
|
if error:
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ DEFAULT_KEYBINDS: dict[str, list[str]] = {
|
||||||
"search": ["/"],
|
"search": ["/"],
|
||||||
"search_next": ["n"],
|
"search_next": ["n"],
|
||||||
"search_previous": ["N"],
|
"search_previous": ["N"],
|
||||||
|
"go_top": ["g"],
|
||||||
|
"go_bottom": ["G"],
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_CURSOR_RESET = "top"
|
DEFAULT_CURSOR_RESET = "top"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue