mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
Three things Lucas caught running it. THE SHINE WAS ON THE WRONG SIDE. glitter() computed the moon's column itself, as a hardcoded 0.72 of the width, while moon() painted at s.moonX. They agreed for as long as the moon never moved. Mirroring the composition moved it to 0.28 and left the moonlight behind at 0.72 -- a reflection with no source, on the opposite side of the frame from the thing casting it. MoonPos exists precisely so callers can anchor to the moon "without recomputing the position and drifting out of sync", which is what its comment says and what this function did anyway. It reads s.moonX now. While there: the shine is tied to how much of the moon is lit, so a nearly-exhausted context dims the water as well as the moon, and a sliver stops laying a path across the sea. RESIZING TORE WHILE DRAGGING. The size check ran off SIGWINCH and drained one signal per frame; a drag fires dozens, so the canvas chased the window a step behind the whole way down. Now that the size is an ioctl rather than a subprocess it costs microseconds, so the loop simply asks every frame and the whole drag coalesces for free. The full-screen clear is also gone except when the window SHRINKS -- growing paints strictly more cells than the frame before it, so clearing was a blank flash on every step of the drag. THE SCENE NOW OWNS ITS SCREEN. It runs on the alternate screen buffer, so nothing of the shell shows through and quitting restores the terminal exactly instead of leaving a beach in the scrollback. On looking the same in every terminal profile: proved rather than assumed. Indices 0-15 are the ANSI slots the profile editor repaints; 16 and up are fixed by the xterm-256 standard. TestNeverEmitsAThemeableColour walks all 16.7M colours and confirms the quantiser never returns one of the sixteen. Every cell also paints its own background, so the profile's background never shows through. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AU2ieNpECMF7S4go2CwcDX
26 lines
953 B
Go
26 lines
953 B
Go
package term
|
|
|
|
import "testing"
|
|
|
|
// The scene must look the same in every terminal profile.
|
|
//
|
|
// Indices 0-15 are the ANSI slots, and those ARE user-editable -- they are the
|
|
// sixteen swatches in Terminal.app's profile editor, and they differ between
|
|
// Solid Colors, Grass, Man Page and the rest. Everything from 16 up is fixed by
|
|
// the xterm-256 standard and cannot be themed. So the whole promise of "the
|
|
// same picture on every profile" rests on never emitting an index below 16.
|
|
//
|
|
// Exhaustive over all 16.7M colours, because "by construction" is a claim about
|
|
// code I wrote and this is a claim about output.
|
|
func TestNeverEmitsAThemeableColour(t *testing.T) {
|
|
for r := 0; r < 256; r++ {
|
|
for g := 0; g < 256; g++ {
|
|
for b := 0; b < 256; b++ {
|
|
if i := (RGB{uint8(r), uint8(g), uint8(b)}).Index256(); i < 16 || i > 255 {
|
|
t.Fatalf("rgb(%d,%d,%d) -> index %d, which the user's profile can repaint", r, g, b, i)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|