Repository navigation
Commit aae2d50
fix redrawing & vanishing last column (#145)
* fix(frame): Clear the rows the previous frame used and the current one does not.
* test(frame): test the correct bytes when redrawing
writer.writeAll(ansi.cursor_home)
prints the byte \x1b[H (go to row 1, column 1 but ommit params)
I changed it to:
ansi.cursorTo0(writer, @intcast(line_count), 0)
which prints the byte \x1b[1;1H (go to row 1, column 1, exclicit params)
(it actually prints \x1b[{row+1};1H, but you get the idea)
* fix(frame): bound row addressing, and erase when the width is unknown
Addressing rows absolutely removes the scroll that #143 reported, and
skipping `EL` on a line that fills the row removes the erased border that
#144 reported. Both need bounds the original change did not apply.
A `CUP` row is a `u16`, and the terminal clamps it to the screen:
* A view of 65536 lines or more overflowed the row counter and
panicked. `writeFull` is the path that absorbs oversized frames, so
the crash sat on exactly the input it exists to handle, and `.full`
mode never bounds the line count at all.
* Rows past the bottom clamped onto the last row, so each overflow
line overwrote the one before it: six lines on a three-row screen
left `a`, `b`, `f` rather than the top three. Count those lines, so
`last_line_count` still describes the frame, but do not draw them.
`writeDiff` bounds its trailing clear the same way. It cannot reach a
`last_line_count` past the screen today — an oversized frame marks the
renderer dirty, which routes the next frame through `writeFull` — but
two paths clearing to different limits is a trap, not an invariant.
The erase predicate needs two corrections of its own, both in `fillsRow`:
* `width < size.width` is never true when the width is zero, which
suppressed every erase and left stale text on screen. `TIOCGWINSZ`
reports 0x0 for a terminal whose window size was never set, and the
80x24 fallback in `getSize` only covers the non-TTY case. An unknown
width says nothing about which lines fill a row, so erase.
* A line that wraps returns to the edge at every multiple of the row
width, not only when it fills one row exactly. Ten columns of text
on a five-column screen parks the cursor on the edge a second time,
where `EL` eats the last character just the same. Test the width
modulo the row rather than against it.
* test(frame): model autowrap, and assert repaints by content
Two gaps let the renderer's own regressions through.
`VirtualScreen` counted bytes, not columns, and knew nothing of the
screen it was modelling. It could not represent the bug behind #144 at
all: a character written to the last column parks the cursor there with
its wrap deferred, and `EL` erases from the column the cursor occupies —
taking that character with it. A frame drawn to the full width of the
screen modelled perfectly and still lost its right-hand border on a real
terminal. Model columns, autowrap, wrap-pending and `CUP` clamping, so
the harness can show what a terminal would.
`\x1b[H` used to be proof of a full repaint, because only `writeFull`
emitted it. Absolute addressing made it `\x1b[1;1H`, which `writeDiff`
also emits whenever row 0 is the row that changed. Every rewritten
assertion still discriminated by luck — each left row 0 untouched — but
they no longer tested what their names claimed. Assert instead that a
row which did *not* change was rewritten, which is the actual difference
between the two paths.
Covers what neither path had: a frame that fills the width, a wrapped
line that ends on the edge, truncation past the bottom row, a view too
tall for a `u16` row, and an unknown terminal width.
---------
Co-authored-by: Matthew Meszaros <meszmatew@gmail.com>1 parent 99dd623 commit aae2d50
2 files changed
Lines changed: 336 additions & 60 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
117 | 122 | | |
118 | 123 | | |
119 | | - | |
120 | 124 | | |
121 | 125 | | |
122 | | - | |
123 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
124 | 134 | | |
125 | | - | |
126 | | - | |
| 135 | + | |
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
| |||
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
161 | | - | |
| 168 | + | |
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
165 | 172 | | |
166 | | - | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
182 | 189 | | |
183 | 190 | | |
184 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
185 | 222 | | |
186 | 223 | | |
187 | 224 | | |
| |||
384 | 421 | | |
385 | 422 | | |
386 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
387 | 453 | | |
388 | 454 | | |
389 | 455 | | |
| |||
0 commit comments