diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-19 01:46:16 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-19 01:47:47 -0500 |
commit | 1cd72ddb88037d25c5b31dc0fb634ab79dc0491d (patch) | |
tree | ad8d512f52559e7f1f34aca43e6e439ece36cb53 | |
parent | f973230cb32cf8a397f2456950e1463104e65101 (diff) | |
download | vt100-rust-1cd72ddb88037d25c5b31dc0fb634ab79dc0491d.tar.gz vt100-rust-1cd72ddb88037d25c5b31dc0fb634ab79dc0491d.zip |
remove special casing for combined character wrapping
the comment here is just... not true? not really sure why i thought it
was, but testing on all of alacritty, xterm, and tmux show the opposite
behavior to what is in the comment, so i'm going to assume this is just
wrong
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/screen.rs | 15 | ||||
-rw-r--r-- | tests/data/fixtures/combining/11.json | 4 | ||||
-rw-r--r-- | tests/data/fixtures/ri.in | 3 | ||||
-rw-r--r-- | tests/data/fixtures/ri/4.json | 8 | ||||
-rw-r--r-- | tests/data/fixtures/ri/4.typescript | 1 | ||||
-rw-r--r-- | tests/data/fixtures/ri/5.json | 15 | ||||
-rw-r--r-- | tests/data/fixtures/ri/5.typescript | 1 | ||||
-rw-r--r-- | tests/data/fixtures/ri/6.json | 15 | ||||
-rw-r--r-- | tests/data/fixtures/ri/6.typescript | 1 |
10 files changed, 50 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 123fd37..c863506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ## Fixed * Fixed some line wrapping state issues with `contents_diff` +* Fixed cursor positioning after writing zero width characters at the end of + the line ## [0.13.0] - 2021-11-17 diff --git a/src/screen.rs b/src/screen.rs index e3581b9..56bd963 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -807,17 +807,6 @@ impl Screen { let width = c.width().unwrap_or(0).try_into().unwrap(); - // 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) - let wrap_width = if width == 0 { 1 } else { width }; - // it doesn't make any sense to wrap if the last column in a row // didn't already have contents. don't try to handle the case where a // character wraps because there was only one column left in the @@ -827,7 +816,7 @@ impl Screen { // (xterm handles this by introducing the concept of triple width // cells, which i really don't want to do). let mut wrap = false; - if pos.col > size.cols - wrap_width { + if pos.col > size.cols - width { let last_cell = self .drawing_cell(crate::grid::Pos { row: pos.row, @@ -838,7 +827,7 @@ impl Screen { wrap = true; } } - self.grid_mut().col_wrap(wrap_width, wrap); + self.grid_mut().col_wrap(width, wrap); let pos = self.grid().pos(); if width == 0 { diff --git a/tests/data/fixtures/combining/11.json b/tests/data/fixtures/combining/11.json index 6757b45..14822ed 100644 --- a/tests/data/fixtures/combining/11.json +++ b/tests/data/fixtures/combining/11.json @@ -243,7 +243,7 @@ } }, "cursor_position": [ - 1, - 0 + 0, + 80 ] }
\ No newline at end of file diff --git a/tests/data/fixtures/ri.in b/tests/data/fixtures/ri.in index 124a807..9e8d246 100644 --- a/tests/data/fixtures/ri.in +++ b/tests/data/fixtures/ri.in @@ -1,3 +1,6 @@ foo\nbar\x1bMbaz \x1bc1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24 \x1b[H\x1bM +\x1bc +\x1b[1;80Ha\x7f\x1b[3Hb\x1b[H +\x1bM diff --git a/tests/data/fixtures/ri/4.json b/tests/data/fixtures/ri/4.json new file mode 100644 index 0000000..bb83ae4 --- /dev/null +++ b/tests/data/fixtures/ri/4.json @@ -0,0 +1,8 @@ +{ + "contents": "", + "cells": {}, + "cursor_position": [ + 0, + 0 + ] +}
\ No newline at end of file diff --git a/tests/data/fixtures/ri/4.typescript b/tests/data/fixtures/ri/4.typescript new file mode 100644 index 0000000..c10be54 --- /dev/null +++ b/tests/data/fixtures/ri/4.typescript @@ -0,0 +1 @@ +c
\ No newline at end of file diff --git a/tests/data/fixtures/ri/5.json b/tests/data/fixtures/ri/5.json new file mode 100644 index 0000000..e70e9fa --- /dev/null +++ b/tests/data/fixtures/ri/5.json @@ -0,0 +1,15 @@ +{ + "contents": " a\n\nb", + "cells": { + "0,79": { + "contents": "a" + }, + "2,0": { + "contents": "b" + } + }, + "cursor_position": [ + 0, + 0 + ] +}
\ No newline at end of file diff --git a/tests/data/fixtures/ri/5.typescript b/tests/data/fixtures/ri/5.typescript new file mode 100644 index 0000000..69d759d --- /dev/null +++ b/tests/data/fixtures/ri/5.typescript @@ -0,0 +1 @@ +[1;80Ha[3Hb[H
\ No newline at end of file diff --git a/tests/data/fixtures/ri/6.json b/tests/data/fixtures/ri/6.json new file mode 100644 index 0000000..b58e830 --- /dev/null +++ b/tests/data/fixtures/ri/6.json @@ -0,0 +1,15 @@ +{ + "contents": "\n a\n\nb", + "cells": { + "1,79": { + "contents": "a" + }, + "3,0": { + "contents": "b" + } + }, + "cursor_position": [ + 0, + 0 + ] +}
\ No newline at end of file diff --git a/tests/data/fixtures/ri/6.typescript b/tests/data/fixtures/ri/6.typescript new file mode 100644 index 0000000..f963eed --- /dev/null +++ b/tests/data/fixtures/ri/6.typescript @@ -0,0 +1 @@ +M
\ No newline at end of file |