Skip to content

Commit bea5cc0

Browse files
committed
feat(actions): add SelectNextHalfPage & SelectPrevHalfPage actions
1 parent 5c770ec commit bea5cc0

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

television/action.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ pub enum Action {
5555
SelectNextPage,
5656
/// Select the previous page of entries in the currently focused list.
5757
SelectPrevPage,
58+
/// Select the next half page of entries in the currently focused list.
59+
SelectNextHalfPage,
60+
/// Select the previous half page of entries in the currently focused list.
61+
SelectPrevHalfPage,
5862
/// Copy the currently selected entry to the clipboard.
5963
CopyEntryToClipboard,
6064
// preview actions
@@ -368,6 +372,8 @@ impl Action {
368372
Action::SelectPrevEntry => "Navigate up",
369373
Action::SelectNextPage => "Page down",
370374
Action::SelectPrevPage => "Page up",
375+
Action::SelectNextHalfPage => "Half page down",
376+
Action::SelectPrevHalfPage => "Half page up",
371377
Action::CopyEntryToClipboard => "Copy to clipboard",
372378

373379
// Preview actions

television/config/keybindings.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ mod tests {
523523
"ctrl-k" = "select_prev_entry"
524524
"pagedown" = "select_next_page"
525525
"pageup" = "select_prev_page"
526+
"ctrl-f" = "select_next_half_page"
527+
"ctrl-b" = "select_prev_half_page"
526528
"ctrl-d" = "scroll_preview_half_page_down"
527529
"ctrl-u" = "scroll_preview_half_page_up"
528530
"tab" = "toggle_selection_down"
@@ -547,6 +549,9 @@ mod tests {
547549
(Key::Ctrl('p'), Action::SelectPrevEntry),
548550
(Key::Ctrl('k'), Action::SelectPrevEntry),
549551
(Key::PageDown, Action::SelectNextPage),
552+
(Key::Ctrl('f'), Action::SelectNextHalfPage),
553+
(Key::Ctrl('b'), Action::SelectPrevHalfPage),
554+
(Key::PageUp, Action::SelectPrevPage),
550555
(Key::PageUp, Action::SelectPrevPage),
551556
(Key::Ctrl('d'), Action::ScrollPreviewHalfPageDown),
552557
(Key::Ctrl('u'), Action::ScrollPreviewHalfPageUp),

television/screen/help_panel.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ fn is_action_relevant_for_mode(action: &Action, mode: Mode) -> bool {
7878
| Action::SelectPrevEntry
7979
| Action::SelectNextPage
8080
| Action::SelectPrevPage
81+
| Action::SelectNextHalfPage
82+
| Action::SelectPrevHalfPage
8183
// Selection actions - channel specific (multi-select)
8284
| Action::ToggleSelectionDown
8385
| Action::ToggleSelectionUp
@@ -143,6 +145,8 @@ fn is_action_relevant_for_mode(action: &Action, mode: Mode) -> bool {
143145
| Action::SelectPrevEntry
144146
| Action::SelectNextPage
145147
| Action::SelectPrevPage
148+
| Action::SelectNextHalfPage
149+
| Action::SelectPrevHalfPage
146150
// Selection in remote mode - just confirm (no multi-select)
147151
| Action::ConfirmSelection
148152
// UI toggles - global

television/television.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ impl Television {
599599
| Action::SelectPrevEntry
600600
| Action::SelectNextPage
601601
| Action::SelectPrevPage
602+
| Action::SelectNextHalfPage
603+
| Action::SelectPrevHalfPage
602604
| Action::ScrollPreviewDown
603605
| Action::ScrollPreviewUp
604606
| Action::ScrollPreviewHalfPageDown
@@ -985,6 +987,36 @@ impl Television {
985987
);
986988
}
987989
}
990+
Action::SelectNextHalfPage => {
991+
if matches!(self.mode, Mode::Channel) {
992+
self.move_cursor(
993+
Movement::Next,
994+
(self
995+
.ui_state
996+
.layout
997+
.results
998+
.height
999+
.saturating_sub(2)
1000+
/ 2)
1001+
.into(),
1002+
);
1003+
}
1004+
}
1005+
Action::SelectPrevHalfPage => {
1006+
if matches!(self.mode, Mode::Channel) {
1007+
self.move_cursor(
1008+
Movement::Prev,
1009+
(self
1010+
.ui_state
1011+
.layout
1012+
.results
1013+
.height
1014+
.saturating_sub(2)
1015+
/ 2)
1016+
.into(),
1017+
);
1018+
}
1019+
}
9881020
Action::ScrollPreviewDown => self.preview_state.scroll_down(1),
9891021
Action::ScrollPreviewUp => self.preview_state.scroll_up(1),
9901022
Action::ScrollPreviewHalfPageDown => {

0 commit comments

Comments
 (0)