From d20dbadd02e6e392042840c25f021df9759dffe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Thu, 6 Nov 2025 12:40:37 +0100 Subject: [PATCH] chore: clippy --- src/mouse_reporter.rs | 4 +-- src/terminal_box.rs | 68 +++++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/mouse_reporter.rs b/src/mouse_reporter.rs index 9e861d5..3d32b70 100644 --- a/src/mouse_reporter.rs +++ b/src/mouse_reporter.rs @@ -224,8 +224,8 @@ impl MouseReporter { }; //Generate term codes - let x_iter = std::iter::repeat(button_no_x).take(lines_x.unsigned_abs() as _); - let y_iter = std::iter::repeat(button_no_y).take(lines_y.unsigned_abs() as _); + let x_iter = std::iter::repeat_n(button_no_x, lines_x.unsigned_abs() as _); + let y_iter = std::iter::repeat_n(button_no_y, lines_y.unsigned_abs() as _); x_iter .chain(y_iter) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 965121a..3b84c4b 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -1260,44 +1260,42 @@ where let col = x / terminal.size().cell_width; let row = y / terminal.size().cell_height; terminal.scroll_mouse(delta, &state.modifiers, col as u32, row as u32); + } else if terminal.term.lock().mode().contains(TermMode::ALT_SCREEN) { + MouseReporter::report_mouse_wheel_as_arrows( + &terminal, + terminal.size().cell_width, + terminal.size().cell_height, + delta, + ); + status = Status::Captured; } else { - if terminal.term.lock().mode().contains(TermMode::ALT_SCREEN) { - MouseReporter::report_mouse_wheel_as_arrows( - &terminal, - terminal.size().cell_width, - terminal.size().cell_height, - delta, - ); - status = Status::Captured; - } else { - match delta { - ScrollDelta::Lines { x: _, y } => { - //TODO: this adjustment is just a guess! - state.scroll_pixels = 0.0; - let lines = (-y * 6.0) as i32; - if lines != 0 { - terminal.scroll(TerminalScroll::Delta(-lines)); - } - status = Status::Captured; + match delta { + ScrollDelta::Lines { x: _, y } => { + //TODO: this adjustment is just a guess! + state.scroll_pixels = 0.0; + let lines = (-y * 6.0) as i32; + if lines != 0 { + terminal.scroll(TerminalScroll::Delta(-lines)); } - ScrollDelta::Pixels { x: _, y } => { - //TODO: this adjustment is just a guess! - state.scroll_pixels -= y * 6.0; - let mut lines = 0; - let metrics = terminal.with_buffer(|buffer| buffer.metrics()); - while state.scroll_pixels <= -metrics.line_height { - lines -= 1; - state.scroll_pixels += metrics.line_height; - } - while state.scroll_pixels >= metrics.line_height { - lines += 1; - state.scroll_pixels -= metrics.line_height; - } - if lines != 0 { - terminal.scroll(TerminalScroll::Delta(-lines)); - } - status = Status::Captured; + status = Status::Captured; + } + ScrollDelta::Pixels { x: _, y } => { + //TODO: this adjustment is just a guess! + state.scroll_pixels -= y * 6.0; + let mut lines = 0; + let metrics = terminal.with_buffer(|buffer| buffer.metrics()); + while state.scroll_pixels <= -metrics.line_height { + lines -= 1; + state.scroll_pixels += metrics.line_height; } + while state.scroll_pixels >= metrics.line_height { + lines += 1; + state.scroll_pixels -= metrics.line_height; + } + if lines != 0 { + terminal.scroll(TerminalScroll::Delta(-lines)); + } + status = Status::Captured; } } }