From 06c9a4168eb39f17bbb94066164c2442e3c3efcd Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Fri, 10 Jan 2025 11:25:39 +0530 Subject: [PATCH] refact: minor fixes (#971) * Fix unused float handle mouse function, pub mod appstate Fix unnecessary usage of pub mod for appstate and resolve unused float handle mouse function * Resolve clippy warnings Remove explicit lifetime for floatcontent impl. Use div_ceil instead of manually calculating the rows for hints --- tui/src/floating_text.rs | 2 +- tui/src/hint.rs | 2 +- tui/src/main.rs | 2 +- tui/src/state.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tui/src/floating_text.rs b/tui/src/floating_text.rs index c2077de5..13ae33d7 100644 --- a/tui/src/floating_text.rs +++ b/tui/src/floating_text.rs @@ -171,7 +171,7 @@ impl<'a> FloatingText<'a> { } } -impl<'a> FloatContent for FloatingText<'a> { +impl FloatContent for FloatingText<'_> { fn draw(&mut self, frame: &mut Frame, area: Rect, _theme: &Theme) { let block = Block::default() .borders(Borders::ALL) diff --git a/tui/src/hint.rs b/tui/src/hint.rs index 0f77f7a5..2849961f 100644 --- a/tui/src/hint.rs +++ b/tui/src/hint.rs @@ -36,7 +36,7 @@ pub fn create_shortcut_list( .unwrap_or(0); let columns = (render_width as usize / (max_shortcut_width + 4)).max(1); - let rows = (shortcut_spans.len() + columns - 1) / columns; + let rows = shortcut_spans.len().div_ceil(columns); let mut lines: Vec> = Vec::with_capacity(rows); diff --git a/tui/src/main.rs b/tui/src/main.rs index ee0c3235..76ef584f 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -5,7 +5,7 @@ mod floating_text; mod hint; mod root; mod running_command; -pub mod state; +mod state; mod theme; #[cfg(feature = "tips")] diff --git a/tui/src/state.rs b/tui/src/state.rs index cec9cc3c..aee17b97 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -480,7 +480,7 @@ impl AppState { } match &mut self.focus { Focus::FloatingWindow(float) => { - float.content.handle_mouse_event(event); + float.handle_mouse_event(event); } Focus::ConfirmationPrompt(confirm) => { confirm.content.handle_mouse_event(event);