diff options
Diffstat (limited to 'src/term')
-rw-r--r-- | src/term/cell.rs | 36 | ||||
-rw-r--r-- | src/term/mod.rs | 14 |
2 files changed, 38 insertions, 12 deletions
diff --git a/src/term/cell.rs b/src/term/cell.rs index 5d3b7036..88f9d7a1 100644 --- a/src/term/cell.rs +++ b/src/term/cell.rs @@ -14,7 +14,7 @@ use bitflags::bitflags; use crate::ansi::{NamedColor, Color}; -use crate::grid; +use crate::grid::{self, GridCell}; use crate::index::Column; // Maximum number of zerowidth characters which will be stored per cell. @@ -62,6 +62,32 @@ impl Default for Cell { } +impl GridCell for Cell { + #[inline] + fn is_empty(&self) -> bool { + (self.c == ' ' || self.c == '\t') + && self.extra[0] == ' ' + && self.bg == Color::Named(NamedColor::Background) + && !self + .flags + .intersects(Flags::INVERSE | Flags::UNDERLINE | Flags::STRIKEOUT | Flags::WRAPLINE) + } + + #[inline] + fn is_wrap(&self) -> bool { + self.flags.contains(Flags::WRAPLINE) + } + + #[inline] + fn set_wrap(&mut self, wrap: bool) { + if wrap { + self.flags.insert(Flags::WRAPLINE); + } else { + self.flags.remove(Flags::WRAPLINE); + } + } +} + /// Get the length of occupied cells in a line pub trait LineLength { /// Calculate the occupied line length @@ -114,14 +140,6 @@ impl Cell { } #[inline] - pub fn is_empty(&self) -> bool { - (self.c == ' ' || self.c == '\t') - && self.extra[0] == ' ' - && self.bg == Color::Named(NamedColor::Background) - && !self.flags.intersects(Flags::INVERSE | Flags::UNDERLINE | Flags::STRIKEOUT) - } - - #[inline] pub fn reset(&mut self, template: &Cell) { // memcpy template to self *self = *template; 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(); |