aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-28 14:57:07 -0500
committerJesse Luehrs <doy@tozt.net>2019-12-05 12:54:34 -0500
commit971b744c9c7c2c3dc9f055f69c5630ca11f0a09e (patch)
tree8b8c8e88d6dbd809cc6bcd5a82ef512c6e3d9f65 /src/screen.rs
parent42b25717605bcb8206f71722f09d02ef4b4275f2 (diff)
downloadvt100-rust-971b744c9c7c2c3dc9f055f69c5630ca11f0a09e.tar.gz
vt100-rust-971b744c9c7c2c3dc9f055f69c5630ca11f0a09e.zip
fix a couple more issues with end of line behavior
Diffstat (limited to 'src/screen.rs')
-rw-r--r--src/screen.rs46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/screen.rs b/src/screen.rs
index ec4d204..07363b1 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -588,19 +588,45 @@ impl Screen {
}
}
+ let mut wrap = true;
+ // it doesn't make any sense to wrap if the last column in a row
+ // didn't already have contents
+ if pos.col > 1 {
+ let mut prev_cell = self
+ .drawing_cell_mut(crate::grid::Pos {
+ row: pos.row,
+ col: pos.col - 2,
+ })
+ .unwrap();
+ if !prev_cell.is_wide() {
+ prev_cell = self
+ .drawing_cell_mut(crate::grid::Pos {
+ row: pos.row,
+ col: pos.col - 1,
+ })
+ .unwrap();
+ }
+ if !prev_cell.has_contents() {
+ wrap = false;
+ }
+ }
+
let width = c.width().unwrap_or(0).try_into().unwrap();
let attrs = self.attrs;
- // zero width characters still cause the cursor to wrap - this doesn't
- // affect which cell they go into (the "previous cell" for both (row,
- // max_col + 1) and (row + 1, 0) is (row, max_col)), but does affect
- // further movement afterwards - writing an `a` at (row, max_col)
- // followed by a crlf puts the cursor at (row + 1, 0), but writing a
- // `à` (specifically `a` followed by a combining grave accent - the
- // normalized U+00E0 "latin small letter a with grave" behaves the
- // same as `a`) at (row, max_col) followed by a crlf puts the cursor
- // at (row + 2, 0)
- self.grid_mut().col_wrap(if width == 0 { 1 } else { width });
+ self.grid_mut().col_wrap(
+ // zero width characters still cause the cursor to wrap - this
+ // doesn't affect which cell they go into (the "previous cell" for
+ // both (row, max_col + 1) and (row + 1, 0) is (row, max_col)),
+ // but does affect further movement afterwards - writing an `a` at
+ // (row, max_col) followed by a crlf puts the cursor at (row + 1,
+ // 0), but writing a `à` (specifically `a` followed by a combining
+ // grave accent - the normalized U+00E0 "latin small letter a with
+ // grave" behaves the same as `a`) at (row, max_col) followed by a
+ // crlf puts the cursor at (row + 2, 0)
+ if width == 0 { 1 } else { width },
+ wrap,
+ );
if width == 0 {
if pos.col > 0 {