diff --git a/CHANGELOG.md b/CHANGELOG.md index f47a013..fd802b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Wayland primary selection clipboard not storing text when selection is stopped outside of the window - Block URL highlight while a selection is active - Bindings for Alt + F1-F12 +- Discard scrolling region escape with bottom above top ### Removed diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs index f95dc35..6939161 100644 --- a/alacritty_terminal/src/ansi.rs +++ b/alacritty_terminal/src/ansi.rs @@ -14,7 +14,6 @@ // //! ANSI Terminal Stream Parsing use std::io; -use std::ops::Range; use std::str; use crate::index::{Column, Contains, Line}; @@ -296,7 +295,7 @@ pub trait Handler { fn unset_mode(&mut self, _: Mode) {} /// DECSTBM - Set the terminal scrolling region - fn set_scrolling_region(&mut self, _: Range) {} + fn set_scrolling_region(&mut self, _top: usize, _bottom: usize) {} /// DECKPAM - Set keypad to applications mode (ESCape instead of digits) fn set_keypad_application_mode(&mut self) {} @@ -1079,16 +1078,10 @@ where handler.set_cursor_style(style); }, ('r', None) => { - let arg0 = arg_or_default!(idx: 0, default: 1) as usize; - let top = Line(arg0 - 1); - // Bottom should be included in the range, but range end is not - // usually included. One option would be to use an inclusive - // range, but instead we just let the open range end be 1 - // higher. - let arg1 = arg_or_default!(idx: 1, default: handler.lines().0 as _) as usize; - let bottom = Line(arg1); + let top = arg_or_default!(idx: 0, default: 1) as usize; + let bottom = arg_or_default!(idx: 1, default: handler.lines().0 as _) as usize; - handler.set_scrolling_region(top..bottom); + handler.set_scrolling_region(top, bottom); }, ('s', None) => handler.save_cursor_position(), ('u', None) => handler.restore_cursor_position(), diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 11e0af4..6829c7d 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1260,8 +1260,7 @@ impl Term { fn deccolm(&mut self) { // Setting 132 column font makes no sense, but run the other side effects // Clear scrolling region - let scroll_region = Line(0)..self.grid.num_lines(); - self.set_scrolling_region(scroll_region); + self.set_scrolling_region(1, self.grid.num_lines().0); // Clear grid let template = self.cursor.template; @@ -2118,10 +2117,23 @@ impl ansi::Handler for Term { } #[inline] - fn set_scrolling_region(&mut self, region: Range) { - trace!("Setting scrolling region: {:?}", region); - self.scroll_region.start = min(region.start, self.grid.num_lines()); - self.scroll_region.end = min(region.end, self.grid.num_lines()); + fn set_scrolling_region(&mut self, top: usize, bottom: usize) { + if top >= bottom { + debug!("Invalid scrolling region: ({};{})", top, bottom); + return; + } + + // Bottom should be included in the range, but range end is not + // usually included. One option would be to use an inclusive + // range, but instead we just let the open range end be 1 + // higher. + let start = Line(top - 1); + let end = Line(bottom); + + trace!("Setting scrolling region: ({};{})", start, end); + + self.scroll_region.start = min(start, self.grid.num_lines()); + self.scroll_region.end = min(end, self.grid.num_lines()); self.goto(Line(0), Column(0)); } diff --git a/alacritty_terminal/src/window.rs b/alacritty_terminal/src/window.rs index 3e3f47f..f18fda3 100644 --- a/alacritty_terminal/src/window.rs +++ b/alacritty_terminal/src/window.rs @@ -32,7 +32,7 @@ use glutin::{ #[cfg(not(target_os = "macos"))] use image::ImageFormat; #[cfg(not(any(target_os = "macos", windows)))] -use x11_dl::xlib::{Xlib, Display as XDisplay, PropModeReplace, XErrorEvent}; +use x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib}; use crate::config::{Config, Decorations, StartupMode, WindowConfig}; use crate::gl;