Skip to content

Commit

Permalink
feat: Top/Bottom via g/G keybind
Browse files Browse the repository at this point in the history
  • Loading branch information
janbuchar committed May 10, 2024
1 parent 873e81d commit 7cc84b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rorqual/ui/album_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def __init__(self, album: AlbumWithSongsId3) -> None:
("l", "expand", "Expand"),
("h", "collapse", "Collapse"),
("a", "add_to_playlist", "Add to playlist"),
("g", "go_to_top", "Go to top"),
("G", "go_to_bottom", "Go to bottom"),
]

DEFAULT_CSS = """
Expand Down Expand Up @@ -80,6 +82,12 @@ def action_down(self) -> None:
def action_up(self) -> None:
self.query_one(Tree).action_cursor_up()

def action_go_to_top(self) -> None:
self.query_one(Tree).action_scroll_home()

def action_go_to_bottom(self) -> None:
self.query_one(Tree).action_scroll_end()

def action_expand(self) -> None:
tree = self.query_one(Tree)
if tree.cursor_node:
Expand Down
8 changes: 8 additions & 0 deletions src/rorqual/ui/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def __init__(self, stream_manager: StreamManager):
BINDINGS = [
("j", "down", "Down"),
("k", "up", "Up"),
("g", "go_to_top", "Go to top"),
("G", "go_to_bottom", "Go to bottom"),
("space", "toggle", "Play/Pause"),
("enter", "play", "Play"),
("c", "clear", "Clear playlist"),
Expand Down Expand Up @@ -239,6 +241,12 @@ def action_down(self) -> None:
def action_up(self) -> None:
self._highlighted_row = max(self._highlighted_row - 1, 0)

def action_go_to_top(self) -> None:
self._highlighted_row = 0

def action_go_to_bottom(self) -> None:
self._highlighted_row = len(self.tracks) - 1

def action_toggle(self) -> None:
self.post_message(self.PlayPause())

Expand Down

0 comments on commit 7cc84b0

Please sign in to comment.