From 654cd615cfd9f1e13d29bb85b9a8f04d7ddd2431 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Mon, 4 Nov 2024 12:36:14 +0530 Subject: [PATCH] feat: mouse hori scrolls --- tui/src/floating_text.rs | 2 ++ tui/src/state.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tui/src/floating_text.rs b/tui/src/floating_text.rs index 12e0e197..bb1c9744 100644 --- a/tui/src/floating_text.rs +++ b/tui/src/floating_text.rs @@ -268,6 +268,8 @@ impl FloatContent for FloatingText { match event.kind { MouseEventKind::ScrollDown => self.scroll_down(), MouseEventKind::ScrollUp => self.scroll_up(), + MouseEventKind::ScrollLeft => self.scroll_left(), + MouseEventKind::ScrollRight => self.scroll_right(), _ => {} } false diff --git a/tui/src/state.rs b/tui/src/state.rs index b5ff9377..b7934feb 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -424,18 +424,24 @@ impl AppState { match &mut self.focus { Focus::TabList => match event.kind { MouseEventKind::ScrollDown => { - self.current_tab.select_next(); + if self.current_tab.selected().unwrap() != self.tabs.len() - 1 { + self.current_tab.select_next(); + } self.refresh_tab(); } MouseEventKind::ScrollUp => { - self.current_tab.select_next(); + if self.current_tab.selected().unwrap() != 0 { + self.current_tab.select_previous(); + } self.refresh_tab(); } + MouseEventKind::ScrollRight => self.focus = Focus::List, _ => {} }, Focus::List => match event.kind { MouseEventKind::ScrollDown => self.selection.select_next(), MouseEventKind::ScrollUp => self.selection.select_previous(), + MouseEventKind::ScrollLeft => self.focus = Focus::TabList, _ => {} }, Focus::FloatingWindow(float) => {