summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kuznetsov <zummenix@gmail.com>2019-10-16 00:13:58 +0500
committerChristian Duerr <contact@christianduerr.com>2019-10-15 21:13:58 +0200
commit49380bffd24203f139dc32c7bdc9958e64d9dd4d (patch)
tree0d4bfb3cb7f66868983a6ed5a22695749502995f
parent124e98e94e66d5790d4523adb9cd75f85a4691f4 (diff)
downloadalacritty-49380bffd24203f139dc32c7bdc9958e64d9dd4d.tar.gz
alacritty-49380bffd24203f139dc32c7bdc9958e64d9dd4d.zip
Add support for alternate scroll escape
Fixes #2727.
-rw-r--r--CHANGELOG.md3
-rw-r--r--alacritty.yml9
-rw-r--r--alacritty/src/config/mod.rs9
-rw-r--r--alacritty/src/input.rs17
-rw-r--r--alacritty/src/logging.rs3
-rw-r--r--alacritty_terminal/src/ansi.rs3
-rw-r--r--alacritty_terminal/src/config/scrolling.rs10
-rw-r--r--alacritty_terminal/src/term/mod.rs38
8 files changed, 54 insertions, 38 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44d36a41..efdd7bbc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Live reload font size from config
- New CLI flag `--hold` for keeping Alacritty opened after its child process exits
- Escape sequence to save and restore window title from stack
+- Alternate scroll escape sequence (`CSI ? 1007 h` / `CSI ? 1007 l`)
### Changed
@@ -76,6 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bindings for Super/Command + F1-F12
- Automatic config generation
+- Deprecated `scrolling.faux_multiplier`, the alternate scroll escape can now be used to disable it
+ and `scrolling.multiplier` controls the number of scrolled lines
## 0.3.3
diff --git a/alacritty.yml b/alacritty.yml
index 1b709d65..5e9ca2af 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -87,15 +87,6 @@
# scrollback is enabled (history > 0).
#multiplier: 3
- # Faux Scrolling
- #
- # The `faux_multiplier` setting controls the number of lines the terminal
- # should scroll when the alternate screen buffer is active. This is used
- # to allow mouse scrolling for applications like `man`.
- #
- # Specifying `0` will disable faux scrolling.
- #faux_multiplier: 3
-
# Scroll to the bottom when new text is written to the terminal.
#auto_scroll: false
diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs
index 8b881fca..beaffd87 100644
--- a/alacritty/src/config/mod.rs
+++ b/alacritty/src/config/mod.rs
@@ -202,6 +202,15 @@ fn print_deprecation_warnings(config: &Config) {
"Config persistent_logging is deprecated; please use debug.persistent_logging instead"
);
}
+
+ if config.scrolling.faux_multiplier().is_some() {
+ warn!(
+ target: LOG_TARGET_CONFIG,
+ "Config scrolling.faux_multiplier is deprecated; the alternate scroll escape can now \
+ be used to disable it and `scrolling.multiplier` controls the number of scrolled \
+ lines"
+ );
+ }
}
#[cfg(test)]
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs
index be6a030e..a3148820 100644
--- a/alacritty/src/input.rs
+++ b/alacritty/src/input.rs
@@ -551,11 +551,9 @@ impl<'a, T: EventListener, A: ActionContext<T> + 'a> Processor<'a, T, A> {
fn scroll_terminal(&mut self, modifiers: ModifiersState, new_scroll_px: i32) {
let mouse_modes =
TermMode::MOUSE_REPORT_CLICK | TermMode::MOUSE_DRAG | TermMode::MOUSE_MOTION;
+ let alt_scroll_modes = TermMode::ALT_SCREEN | TermMode::ALTERNATE_SCROLL;
let height = self.ctx.size_info().cell_height as i32;
- // Make sure the new and deprecated setting are both allowed
- let faux_multiplier = self.config.scrolling.faux_multiplier() as usize;
-
if self.ctx.terminal().mode().intersects(mouse_modes) {
self.ctx.mouse_mut().scroll_px += new_scroll_px;
@@ -565,11 +563,14 @@ impl<'a, T: EventListener, A: ActionContext<T> + 'a> Processor<'a, T, A> {
for _ in 0..lines {
self.mouse_report(code, ElementState::Pressed, modifiers);
}
- } else if self.ctx.terminal().mode().contains(TermMode::ALT_SCREEN)
- && faux_multiplier > 0
- && !modifiers.shift
- {
- self.ctx.mouse_mut().scroll_px += new_scroll_px * faux_multiplier as i32;
+ } else if self.ctx.terminal().mode().contains(alt_scroll_modes) && !modifiers.shift {
+ let multiplier = i32::from(
+ self.config
+ .scrolling
+ .faux_multiplier()
+ .unwrap_or_else(|| self.config.scrolling.multiplier()),
+ );
+ self.ctx.mouse_mut().scroll_px += new_scroll_px * multiplier;
let cmd = if new_scroll_px > 0 { b'A' } else { b'B' };
let lines = (self.ctx.mouse().scroll_px / height).abs();
diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs
index ea44637b..9d837a78 100644
--- a/alacritty/src/logging.rs
+++ b/alacritty/src/logging.rs
@@ -172,7 +172,8 @@ impl OnDemandLogFile {
Ok(file) => {
self.file = Some(io::LineWriter::new(file));
self.created.store(true, Ordering::Relaxed);
- let _ = writeln!(io::stdout(), "Created log file at \"{}\"", self.path.display());
+ let _ =
+ writeln!(io::stdout(), "Created log file at \"{}\"", self.path.display());
},
Err(e) => {
let _ = writeln!(io::stdout(), "Unable to create log file: {}", e);
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index 493b02aa..d989b78e 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -408,6 +408,8 @@ pub enum Mode {
ReportFocusInOut = 1004,
/// ?1006
SgrMouse = 1006,
+ /// ?1007
+ AlternateScroll = 1007,
/// ?1049
SwapScreenAndSetRestoreCursor = 1049,
/// ?2004
@@ -438,6 +440,7 @@ impl Mode {
1003 => Mode::ReportAllMouseMotion,
1004 => Mode::ReportFocusInOut,
1006 => Mode::SgrMouse,
+ 1007 => Mode::AlternateScroll,
1049 => Mode::SwapScreenAndSetRestoreCursor,
2004 => Mode::BracketedPaste,
_ => {
diff --git a/alacritty_terminal/src/config/scrolling.rs b/alacritty_terminal/src/config/scrolling.rs
index 8471fcd7..1746266f 100644
--- a/alacritty_terminal/src/config/scrolling.rs
+++ b/alacritty_terminal/src/config/scrolling.rs
@@ -12,9 +12,11 @@ pub struct Scrolling {
#[serde(deserialize_with = "failure_default")]
multiplier: ScrollingMultiplier,
#[serde(deserialize_with = "failure_default")]
- faux_multiplier: ScrollingMultiplier,
- #[serde(deserialize_with = "failure_default")]
pub auto_scroll: bool,
+
+ // TODO: DEPRECATED
+ #[serde(deserialize_with = "failure_default")]
+ faux_multiplier: Option<ScrollingMultiplier>,
}
impl Scrolling {
@@ -26,8 +28,8 @@ impl Scrolling {
self.multiplier.0
}
- pub fn faux_multiplier(self) -> u8 {
- self.faux_multiplier.0
+ pub fn faux_multiplier(self) -> Option<u8> {
+ self.faux_multiplier.map(|sm| sm.0)
}
// Update the history size, used in ref tests
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 382b10a9..bc7235cb 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -457,28 +457,29 @@ pub mod mode {
bitflags! {
pub struct TermMode: u16 {
- const SHOW_CURSOR = 0b00_0000_0000_0001;
- const APP_CURSOR = 0b00_0000_0000_0010;
- const APP_KEYPAD = 0b00_0000_0000_0100;
- const MOUSE_REPORT_CLICK = 0b00_0000_0000_1000;
- const BRACKETED_PASTE = 0b00_0000_0001_0000;
- const SGR_MOUSE = 0b00_0000_0010_0000;
- const MOUSE_MOTION = 0b00_0000_0100_0000;
- const LINE_WRAP = 0b00_0000_1000_0000;
- const LINE_FEED_NEW_LINE = 0b00_0001_0000_0000;
- const ORIGIN = 0b00_0010_0000_0000;
- const INSERT = 0b00_0100_0000_0000;
- const FOCUS_IN_OUT = 0b00_1000_0000_0000;
- const ALT_SCREEN = 0b01_0000_0000_0000;
- const MOUSE_DRAG = 0b10_0000_0000_0000;
- const ANY = 0b11_1111_1111_1111;
+ const SHOW_CURSOR = 0b000_0000_0000_0001;
+ const APP_CURSOR = 0b000_0000_0000_0010;
+ const APP_KEYPAD = 0b000_0000_0000_0100;
+ const MOUSE_REPORT_CLICK = 0b000_0000_0000_1000;
+ const BRACKETED_PASTE = 0b000_0000_0001_0000;
+ const SGR_MOUSE = 0b000_0000_0010_0000;
+ const MOUSE_MOTION = 0b000_0000_0100_0000;
+ const LINE_WRAP = 0b000_0000_1000_0000;
+ const LINE_FEED_NEW_LINE = 0b000_0001_0000_0000;
+ const ORIGIN = 0b000_0010_0000_0000;
+ const INSERT = 0b000_0100_0000_0000;
+ const FOCUS_IN_OUT = 0b000_1000_0000_0000;
+ const ALT_SCREEN = 0b001_0000_0000_0000;
+ const MOUSE_DRAG = 0b010_0000_0000_0000;
+ const ALTERNATE_SCROLL = 0b100_0000_0000_0000;
+ const ANY = 0b111_1111_1111_1111;
const NONE = 0;
}
}
impl Default for TermMode {
fn default() -> TermMode {
- TermMode::SHOW_CURSOR | TermMode::LINE_WRAP
+ TermMode::SHOW_CURSOR | TermMode::LINE_WRAP | TermMode::ALTERNATE_SCROLL
}
}
}
@@ -913,6 +914,9 @@ impl<T> Term<T> {
}
}
self.visual_bell.update_config(config);
+ if let Some(0) = config.scrolling.faux_multiplier() {
+ self.mode.remove(TermMode::ALTERNATE_SCROLL);
+ }
self.default_cursor_style = config.cursor.style;
self.dynamic_title = config.dynamic_title();
self.auto_scroll = config.scrolling.auto_scroll;
@@ -2008,6 +2012,7 @@ impl<T: EventListener> ansi::Handler for Term<T> {
ansi::Mode::ReportFocusInOut => self.mode.insert(TermMode::FOCUS_IN_OUT),
ansi::Mode::BracketedPaste => self.mode.insert(TermMode::BRACKETED_PASTE),
ansi::Mode::SgrMouse => self.mode.insert(TermMode::SGR_MOUSE),
+ ansi::Mode::AlternateScroll => self.mode.insert(TermMode::ALTERNATE_SCROLL),
ansi::Mode::LineWrap => self.mode.insert(TermMode::LINE_WRAP),
ansi::Mode::LineFeedNewLine => self.mode.insert(TermMode::LINE_FEED_NEW_LINE),
ansi::Mode::Origin => self.mode.insert(TermMode::ORIGIN),
@@ -2048,6 +2053,7 @@ impl<T: EventListener> ansi::Handler for Term<T> {
ansi::Mode::ReportFocusInOut => self.mode.remove(TermMode::FOCUS_IN_OUT),
ansi::Mode::BracketedPaste => self.mode.remove(TermMode::BRACKETED_PASTE),
ansi::Mode::SgrMouse => self.mode.remove(TermMode::SGR_MOUSE),
+ ansi::Mode::AlternateScroll => self.mode.remove(TermMode::ALTERNATE_SCROLL),
ansi::Mode::LineWrap => self.mode.remove(TermMode::LINE_WRAP),
ansi::Mode::LineFeedNewLine => self.mode.remove(TermMode::LINE_FEED_NEW_LINE),
ansi::Mode::Origin => self.mode.remove(TermMode::ORIGIN),