aboutsummaryrefslogtreecommitdiff
path: root/src/event_loop.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-03-23 01:01:55 +0100
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:56:50 -0700
commit688cabefc0bfc3224189c10235668eae5e5b0101 (patch)
tree7579612ed4a2d22e897918f6f678bce272745109 /src/event_loop.rs
parent4333b2fb1992b8185dc7041d9d3df8eee86717bc (diff)
downloadr-alacritty-688cabefc0bfc3224189c10235668eae5e5b0101.tar.gz
r-alacritty-688cabefc0bfc3224189c10235668eae5e5b0101.tar.bz2
r-alacritty-688cabefc0bfc3224189c10235668eae5e5b0101.zip
Rework auto-scrolling options
This changes two things, the first thing it does is that now whenever a keybinding sends an escape sequence, the viewport is automatically scrolled to the bottom. This is enabled by default and fixes #1187. The second thing is automatic scrolling when a command writes to the terminal. So when running a command like `sleep 3; ls -lah`, alacritty will scroll to the bottom once the output is sent, even if the viewport is currently not at the bottom of the scrollback. Because this can have an impact on performance, and is not enabled by default in terminals like iTerm or Termite (VTE), it is an opt-in setting in the config.
Diffstat (limited to 'src/event_loop.rs')
-rw-r--r--src/event_loop.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/event_loop.rs b/src/event_loop.rs
index 18d48a52..d7d27243 100644
--- a/src/event_loop.rs
+++ b/src/event_loop.rs
@@ -255,6 +255,9 @@ impl<Io> EventLoop<Io>
let mut processed = 0;
let mut terminal = None;
+ // Flag to keep track if wakeup has already been sent
+ let mut send_wakeup = false;
+
loop {
match self.pty.read(&mut buf[..]) {
Ok(0) => break,
@@ -272,10 +275,14 @@ impl<Io> EventLoop<Io>
// Get reference to terminal. Lock is acquired on initial
// iteration and held until there's no bytes left to parse
// or we've reached MAX_READ.
- if terminal.is_none() {
+ let terminal = if terminal.is_none() {
terminal = Some(self.terminal.lock());
- }
- let terminal = terminal.as_mut().unwrap();
+ let terminal = terminal.as_mut().unwrap();
+ send_wakeup = !terminal.dirty;
+ terminal
+ } else {
+ terminal.as_mut().unwrap()
+ };
// Run the parser
for byte in &buf[..got] {
@@ -301,7 +308,7 @@ impl<Io> EventLoop<Io>
// Only request a draw if one hasn't already been requested.
if let Some(mut terminal) = terminal {
- if !terminal.dirty {
+ if send_wakeup {
self.display.notify();
terminal.dirty = true;
}