aboutsummaryrefslogtreecommitdiff
path: root/src/term/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-03-13 18:55:18 +0000
committerGitHub <noreply@github.com>2019-03-13 18:55:18 +0000
commitb1032bcc6b79135f87f327548e43563da05657fb (patch)
tree94915b15d11094006dcd3381b8ff0d0d3ed5de9b /src/term/mod.rs
parent0b9ae4ce936dfafbf5ea1929a170c97391cdea0b (diff)
downloadalacritty-b1032bcc6b79135f87f327548e43563da05657fb.tar.gz
alacritty-b1032bcc6b79135f87f327548e43563da05657fb.zip
Add text reflow
Alacritty will now automatically reflow lines and shrink them when they would usually exceed the new width of the terminal instead of truncation. If a line had to be truncated, it will also be reflown into the previous line after growing the terminal width. The reflow behavior when not at the bottom of the history is similar to that of VTE and aims to keep the viewport stationary whenever possible. Opposed to VTE, reflow will also be performed in the alternate screen buffer. There will be bugs when resizing the terminal emulator to a size smaller than the prompt, though these issues were present in all terminal emulators with reflow support. This fixes #591.
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r--src/term/mod.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index f48ad699..f2c0b18b 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -23,7 +23,10 @@ use unicode_width::UnicodeWidthChar;
use font::{self, Size};
use crate::ansi::{self, Color, NamedColor, Attr, Handler, CharsetIndex, StandardCharset, CursorStyle};
-use crate::grid::{BidirectionalIterator, Grid, Indexed, IndexRegion, DisplayIter, Scroll, ViewportPosition};
+use crate::grid::{
+ BidirectionalIterator, DisplayIter, Grid, GridCell, IndexRegion, Indexed, Scroll,
+ ViewportPosition,
+};
use crate::index::{self, Point, Column, Line, IndexRange, Contains, RangeInclusive, Linear};
use crate::selection::{self, Selection, Locations};
use crate::config::{Config, VisualBellAnimation};
@@ -1246,8 +1249,13 @@ impl Term {
debug!("New num_cols is {} and num_lines is {}", num_cols, num_lines);
// Resize grids to new size
- self.grid.resize(num_lines, num_cols, &Cell::default());
- self.alt_grid.resize(num_lines, num_cols, &Cell::default());
+ let alt_cursor_point = if self.mode.contains(TermMode::ALT_SCREEN) {
+ &mut self.cursor_save.point
+ } else {
+ &mut self.cursor_save_alt.point
+ };
+ self.grid.resize(num_lines, num_cols, &mut self.cursor.point, &Cell::default());
+ self.alt_grid.resize(num_lines, num_cols, alt_cursor_point, &Cell::default());
// Reset scrolling region to new size
self.scroll_region = Line(0)..self.grid.num_lines();