From 08ad5c26ea7ab172fb5853d4f81c9c306c0eeef5 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 26 Sep 2025 12:40:43 +0200 Subject: [PATCH] Give scroll-forward a less confusing name ECMA-48 calls CSI S "scroll up", so use something like that but try to avoid ambiguity. --- doc_src/terminal-compatibility.rst | 2 +- src/input_common.rs | 8 ++++---- src/reader.rs | 6 +++--- src/screen.rs | 6 +++--- src/terminal.rs | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc_src/terminal-compatibility.rst b/doc_src/terminal-compatibility.rst index 1da7e61c9..7634f576d 100644 --- a/doc_src/terminal-compatibility.rst +++ b/doc_src/terminal-compatibility.rst @@ -198,7 +198,7 @@ Optional Commands ``\e[ Ps S`` - indn - - Scroll up Ps lines (aka ``SU`` but terminfo calls it "scroll forward") + - Scroll up the content (not the viewport) Ps lines (aka ``SU`` but terminfo calls it "scroll forward") This enables the :ref:`scrollback-push ` special input function which is used by :kbd:`ctrl-l`. - ECMA-48 * - ``\e[= Ps u``, ``\e[? Ps u`` diff --git a/src/input_common.rs b/src/input_common.rs index 6a799a1a2..87f6efc88 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -11,7 +11,7 @@ function_key, shift, Key, Modifiers, ViewportPosition, }; use crate::reader::reader_test_and_clear_interrupted; -use crate::terminal::{SCROLL_FORWARD_SUPPORTED, SCROLL_FORWARD_TERMINFO_CODE}; +use crate::terminal::{SCROLL_CONTENT_UP_SUPPORTED, SCROLL_CONTENT_UP_TERMINFO_CODE}; use crate::threads::iothread_port; use crate::tty_handoff::{ get_kitty_keyboard_capability, maybe_set_kitty_keyboard_capability, XTVERSION, @@ -1505,9 +1505,9 @@ fn parse_dcs(&mut self, buffer: &mut Vec) -> Option { format!("Received XTGETTCAP response: {}", str2wcstring(&key)) ); } - if key == SCROLL_FORWARD_TERMINFO_CODE.as_bytes() { - SCROLL_FORWARD_SUPPORTED.store(true); - FLOG!(reader, "Scroll forward is supported"); + if key == SCROLL_CONTENT_UP_TERMINFO_CODE.as_bytes() { + SCROLL_CONTENT_UP_SUPPORTED.store(true); + FLOG!(reader, "SCROLL UP is supported"); } return None; } diff --git a/src/reader.rs b/src/reader.rs index 68268851f..5cf7f219d 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -134,7 +134,7 @@ QueryCursorPosition, QueryKittyKeyboardProgressiveEnhancements, QueryPrimaryDeviceAttribute, QueryXtgettcap, QueryXtversion, }; -use crate::terminal::{SCROLL_FORWARD_SUPPORTED, SCROLL_FORWARD_TERMINFO_CODE}; +use crate::terminal::{SCROLL_CONTENT_UP_SUPPORTED, SCROLL_CONTENT_UP_TERMINFO_CODE}; use crate::termsize::{termsize_invalidate_tty, termsize_last, termsize_update}; use crate::text_face::parse_text_face; use crate::text_face::TextFace; @@ -2678,7 +2678,7 @@ fn query_capabilities_via_dcs(out: &mut impl Output) { return; } out.write_command(DecsetAlternateScreenBuffer); // enable alternative screen buffer - send_xtgettcap_query(out, SCROLL_FORWARD_TERMINFO_CODE); + send_xtgettcap_query(out, SCROLL_CONTENT_UP_TERMINFO_CODE); out.write_command(DecrstAlternateScreenBuffer); // disable alternative screen buffer } @@ -3946,7 +3946,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { self.clear_screen_and_repaint(); } rl::ScrollbackPush => { - if !SCROLL_FORWARD_SUPPORTED.load() { + if !SCROLL_CONTENT_UP_SUPPORTED.load() { return; } let query = self.blocking_query(); diff --git a/src/screen.rs b/src/screen.rs index 87a77f0b3..6cb992f89 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -34,7 +34,7 @@ use crate::highlight::{HighlightColorResolver, HighlightSpec}; use crate::terminal::TerminalCommand::{ self, ClearToEndOfLine, ClearToEndOfScreen, CursorDown, CursorLeft, CursorMove, CursorRight, - CursorUp, EnterDimMode, ExitAttributeMode, Osc133PromptStart, ScrollForward, + CursorUp, EnterDimMode, ExitAttributeMode, Osc133PromptStart, ScrollContentUp, }; use crate::terminal::{use_terminfo, BufferedOutputter, CardinalDirection, Output, Outputter}; use crate::termsize::{termsize_last, Termsize}; @@ -588,8 +588,8 @@ pub fn push_to_scrollback(&mut self, cursor_y: usize) { return; } let mut out = BufferedOutputter::new(self.outp); - // Scroll down. - out.write_command(ScrollForward(lines_to_scroll)); + // Move everything to scrollback. + out.write_command(ScrollContentUp(lines_to_scroll)); // Reposition cursor. out.write_command(CursorMove(CardinalDirection::Up, lines_to_scroll)); } diff --git a/src/terminal.rs b/src/terminal.rs index 4005b5059..301326d8c 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -109,7 +109,7 @@ pub(crate) enum TerminalCommand<'a> { // Other terminal features QueryCursorPosition, - ScrollForward(usize), + ScrollContentUp(usize), DecsetShowCursor, DecrstMouseTracking, @@ -182,7 +182,7 @@ fn write(out: &mut impl Output, sequence: &'static [u8]) -> bool { Osc133CommandStart(command) => osc_133_command_start(self, command), Osc133CommandFinished(s) => osc_133_command_finished(self, s), QueryCursorPosition => write(self, b"\x1b[6n"), - ScrollForward(lines) => scroll_forward(self, lines), + ScrollContentUp(lines) => scroll_content_up(self, lines), DecsetShowCursor => write(self, b"\x1b[?25h"), DecrstMouseTracking => write(self, b"\x1b[?1000l"), DecsetFocusReporting => write(self, b"\x1b[?1004h"), @@ -216,8 +216,8 @@ fn maybe_terminfo( true } -pub(crate) static SCROLL_FORWARD_SUPPORTED: RelaxedAtomicBool = RelaxedAtomicBool::new(false); -pub(crate) static SCROLL_FORWARD_TERMINFO_CODE: &str = "indn"; +pub(crate) static SCROLL_CONTENT_UP_SUPPORTED: RelaxedAtomicBool = RelaxedAtomicBool::new(false); +pub(crate) static SCROLL_CONTENT_UP_TERMINFO_CODE: &str = "indn"; pub(crate) fn use_terminfo() -> bool { !future_feature_flags::test(FeatureFlag::ignore_terminfo) && TERM.lock().unwrap().is_some() @@ -412,8 +412,8 @@ fn osc_133_command_finished(out: &mut impl Output, exit_status: libc::c_int) -> true } -fn scroll_forward(out: &mut impl Output, lines: usize) -> bool { - assert!(SCROLL_FORWARD_SUPPORTED.load()); +fn scroll_content_up(out: &mut impl Output, lines: usize) -> bool { + assert!(SCROLL_CONTENT_UP_SUPPORTED.load()); write_to_output!(out, "\x1b[{}S", lines); true }