Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/ratty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ opacity = 0.8
default_cols = 104
default_rows = 32
scrollback = 2000
mouse_scroll_lines = 3

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can rename this to mouse_scrollback? Just to align with the scrollback option above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or scrollback_speed, or something like that. choose what you wish :)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked some LLM:

Examples: Alacritty uses scrolling.multiplier, kitty uses wheel_scroll_multiplier, Ghostty uses mouse-scroll-multiplier, WezTerm uses scrollback_lines for retained history.

• For this PR, I’d keep mouse_scroll_lines.

It’s better than both options you were considering:

  • mouse_scrollback sounds like the size of the scrollback buffer, especially since ratty already has scrollback = 2000.
  • mouse_speed is too broad and could mean cursor movement, sensitivity, selection speed, drag speed, etc.
  • mouse_scroll_lines says exactly what the PR does: number of lines scrolled per mouse wheel tick.

If you want to align more with other terminal naming, mouse_scroll_multiplier is also defensible, but since the value is literally line count and the PR says “scrolls screen by 3 lines,”
mouse_scroll_lines is the clearest name for this implementation.

so yeah, I think it's all good to go :)


# [shell]
# program = "/bin/bash"
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -167,6 +169,7 @@ impl Default for TerminalConfig {
default_cols: 104,
default_rows: 32,
scrollback: 2_000,
mouse_scroll_lines: 3,
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading