diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-01-15 17:36:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-15 17:36:33 +0100 |
commit | 7d1edf01c2d16eedbbfb652b1e57db0f819f12c0 (patch) | |
tree | f44acb48c984076c0f9cc727d1ffd5cb8e5defed /alacritty_terminal/src/term | |
parent | 7dc406252b06a19b8d5c4f2a2fdebe90a5ad65e2 (diff) | |
download | alacritty-7d1edf01c2d16eedbbfb652b1e57db0f819f12c0.tar.gz alacritty-7d1edf01c2d16eedbbfb652b1e57db0f819f12c0.zip |
Expand line selection across wrapped lines
Diffstat (limited to 'alacritty_terminal/src/term')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 3e8d8618..8edf3d3f 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -56,6 +56,10 @@ pub trait Search { fn semantic_search_left(&self, _: Point<usize>) -> Point<usize>; /// Find the nearest semantic boundary _to the point_ of provided point. fn semantic_search_right(&self, _: Point<usize>) -> Point<usize>; + /// Find the beginning of a line, following line wraps. + fn line_search_left(&self, _: Point<usize>) -> Point<usize>; + /// Find the end of a line, following line wraps. + fn line_search_right(&self, _: Point<usize>) -> Point<usize>; /// Find the nearest matching bracket. fn bracket_search(&self, _: Point<usize>) -> Option<Point<usize>>; } @@ -109,6 +113,28 @@ impl<T> Search for Term<T> { point } + fn line_search_left(&self, mut point: Point<usize>) -> Point<usize> { + while point.line + 1 < self.grid.len() + && self.grid[point.line + 1][self.grid.num_cols() - 1].flags.contains(Flags::WRAPLINE) + { + point.line += 1; + } + + point.col = Column(0); + + point + } + + fn line_search_right(&self, mut point: Point<usize>) -> Point<usize> { + while self.grid[point.line][self.grid.num_cols() - 1].flags.contains(Flags::WRAPLINE) { + point.line -= 1; + } + + point.col = self.grid.num_cols() - 1; + + point + } + fn bracket_search(&self, point: Point<usize>) -> Option<Point<usize>> { let start_char = self.grid[point.line][point.col].c; @@ -973,7 +999,7 @@ impl<T> Term<T> { tab_mode = true; } - if !cell.flags.contains(cell::Flags::WIDE_CHAR_SPACER) { + if !cell.flags.contains(Flags::WIDE_CHAR_SPACER) { // Push cells primary character text.push(cell.c); @@ -986,7 +1012,7 @@ impl<T> Term<T> { if cols.end >= self.cols() - 1 && (line_end == Column(0) - || !self.grid[line][line_end - 1].flags.contains(cell::Flags::WRAPLINE)) + || !self.grid[line][line_end - 1].flags.contains(Flags::WRAPLINE)) { text.push('\n'); } |