mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
Two things his afternoon of testing turned up, both measured in windows a script opened, with his OK. A resize that changed the WIDTH left the band's last column painted from rows below: Terminal.app's alternate screen keeps every row at the widest the window has been, clips the display, shows the retained cells again on a widening, and its erase-line reaches the visible width only -- and his window was 123.6 columns wide, so the partial 124th column drew retained cells from the 130-wide layout. The screen model learns the rule as screen.retainWidth (TRACE_RETAIN=1 for a replay), with the erase clipped to match; notes/width-audit.md and notes/widthprobe hold the record. Nothing in the host can paint or clear a hidden column, so this is documented. The moon looked sloppy in Terminal.app because U+2580's ink starts five pixels below the cell top; his saved screenshot of a printf test, sampled stripe by stripe, shows U+2584's ink flush with the bottom edge. Split cells are now drawn as the lower half block with the colours the other way up there: term.LowerHalf, DetectSplit on TERM_PROGRAM, XSCAPES_SPLIT to override, set before dispatch so the host's painter sees it; -info prints it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package host
|
|
|
|
import "testing"
|
|
|
|
// Terminal.app's alternate screen on a WIDTH change, measured 2026-09-05
|
|
// (notes/width-audit.md): rows keep every cell at the widest the window has
|
|
// been, a narrower window clips, a wider one shows the retained cells again,
|
|
// and an erase-line reaches the visible width only. Under the default rule a
|
|
// row is cut and padded, which is what the model assumed before.
|
|
func TestTerminalAppRetainsCellsBeyondTheWidth(t *testing.T) {
|
|
for _, retain := range []bool{true, false} {
|
|
sc := newScreen(20, 3)
|
|
sc.retainWidth = retain
|
|
sc.feed("\x1b[1;1HAAAAAAAAAAAAAAAAAAA<\x1b[2;1HBBBBBBBBBBBBBBBBBBB<")
|
|
sc.resizeAlt(12, 3)
|
|
sc.feed("\x1b[2;1H\x1b[2K") // erase row 2 while narrow
|
|
sc.resizeAlt(20, 3)
|
|
r1, r2 := sc.rowAt(0), sc.rowAt(1)
|
|
if retain {
|
|
if r1 != "AAAAAAAAAAAAAAAAAAA<" {
|
|
t.Errorf("retain: row 1 after narrow and widen = %q, want the whole row back", r1)
|
|
}
|
|
if r2 != " BBBBBBB<" {
|
|
t.Errorf("retain: erased row 2 = %q, want 12 blanks then the retained tail", r2)
|
|
}
|
|
} else {
|
|
// rowAt trims trailing blanks, so the padding is not visible here.
|
|
if r1 != "AAAAAAAAAAAA" {
|
|
t.Errorf("cut: row 1 = %q, want cut to 12", r1)
|
|
}
|
|
if r2 != "" {
|
|
t.Errorf("cut: erased row 2 = %q, want blank", r2)
|
|
}
|
|
}
|
|
}
|
|
}
|