aboutsummaryrefslogtreecommitdiff
path: root/src/term/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-08-15 20:09:59 +0000
committerGitHub <noreply@github.com>2018-08-15 20:09:59 +0000
commit8e8ecdd0f98dd8005cd940d19dc0a922661d64fc (patch)
tree2061b533138505273c9578acd35e7833a9d4d308 /src/term/mod.rs
parent7717bd7c168be30b4bfeb2ab67bddee63fb9bdae (diff)
downloadalacritty-8e8ecdd0f98dd8005cd940d19dc0a922661d64fc.tar.gz
alacritty-8e8ecdd0f98dd8005cd940d19dc0a922661d64fc.zip
Scroll visible area when growing window
Since Alacritty never had any scrollback history, the behavior when the window height was increased was to just keep the prompt on the same line it has been before the resize. However the usual behavior of terminal emulators is to keep the distance from the prompt to the bottom of the screen consistent whenever possible. This fixes this behavior by loading lines from the scrollback buffer when the window height is increased. This is only done when scrollback is available, so there are only N lines available, the maximum amount of lines which will be loaded when growing the height is N. Since the number of lines available in the alternate screen buffer is 0, it still behaves the same way it did before this patch. Different terminal emulators have different behaviors when this is done in the alt screen buffer, XTerm for example loads history from the normal screen buffer when growing the height of the window from the alternate screen buffer. Since this seems wrong (the alt screen is not supposed to have any scrollback), the behavior of Termite (VTE) has been chosen instead. In Termite the alt screen buffer never loads any scrollback history itself, however when the terminal height is grown while the alternate screen is active, the normal screen's scrollback history lines are loaded. This fixes #1502.
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r--src/term/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 1b78c39c..ff7a53e9 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -1144,6 +1144,18 @@ impl Term {
let lines = self.cursor_save_alt.point.line - num_lines + 1;
self.alt_grid.scroll_up(&(Line(0)..old_lines), lines, &self.cursor_save_alt.template);
}
+
+ // Move prompt down when growing if scrollback lines are available
+ if num_lines > old_lines {
+ if self.mode.contains(TermMode::ALT_SCREEN) {
+ let growage = min(num_lines - old_lines, Line(self.alt_grid.scroll_limit()));
+ self.cursor_save.point.line += growage;
+ } else {
+ let growage = min(num_lines - old_lines, Line(self.grid.scroll_limit()));
+ self.cursor.point.line += growage;
+ }
+ }
+
debug!("num_cols, num_lines = {}, {}", num_cols, num_lines);
// Resize grids to new size