From f5e528c90b1011a40943b20084e827651381e5c7 Mon Sep 17 00:00:00 2001 From: veksha Date: Mon, 13 Jul 2026 14:21:08 +0300 Subject: [PATCH] Added mouse_scroll_lines option --- config/ratty.toml | 1 + src/config.rs | 3 +++ src/mouse.rs | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/ratty.toml b/config/ratty.toml index d2f42b6..a624622 100644 --- a/config/ratty.toml +++ b/config/ratty.toml @@ -8,6 +8,7 @@ opacity = 0.8 default_cols = 104 default_rows = 32 scrollback = 2000 +mouse_scroll_lines = 3 # [shell] # program = "/bin/bash" diff --git a/src/config.rs b/src/config.rs index 92280ea..050cfc3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -159,6 +159,8 @@ pub struct TerminalConfig { pub default_rows: u16, /// Scrollback line count. pub scrollback: usize, + /// Number of lines scrolled per mouse wheel tick in flat 2D mode. + pub mouse_scroll_lines: usize, } impl Default for TerminalConfig { @@ -167,6 +169,7 @@ impl Default for TerminalConfig { default_cols: 104, default_rows: 32, scrollback: 2_000, + mouse_scroll_lines: 3, } } } diff --git a/src/mouse.rs b/src/mouse.rs index 7701e94..42caaba 100644 --- a/src/mouse.rs +++ b/src/mouse.rs @@ -8,6 +8,7 @@ use bevy::prelude::*; use bevy::window::{CursorMoved, PrimaryWindow, Window}; use vt100::{MouseProtocolEncoding, MouseProtocolMode}; +use crate::config::AppConfig; use crate::runtime::TerminalRuntime; use crate::scene::{ MobiusTransition, TerminalPlaneView, TerminalPresentation, TerminalPresentationMode, @@ -245,6 +246,7 @@ pub struct MouseSystemParams<'w, 's> { plane_view: ResMut<'w, TerminalPlaneView>, selection: ResMut<'w, TerminalSelection>, redraw: ResMut<'w, crate::terminal::TerminalRedrawState>, + app_config: Res<'w, AppConfig>, } /// Handles terminal mouse input. @@ -266,6 +268,7 @@ pub(crate) fn handle_mouse_input( plane_view, selection, redraw, + app_config, } = &mut params; let Ok((primary_window, window)) = primary_window.single() else { return; @@ -507,7 +510,10 @@ pub(crate) fn handle_mouse_input( && !runtime.parser.screen().alternate_screen() { let amount = match event.unit { - MouseScrollUnit::Line => event.y.round() as isize, + MouseScrollUnit::Line => { + app_config.terminal.mouse_scroll_lines as isize + * (if delta < 0.0 { -1 } else { 1 }) + } MouseScrollUnit::Pixel => { let char_height = terminal.char_dimensions().y; local_scroll.pixel_remainder += event.y / char_height;