nex_squid/crates
mula.liu ca53d1d140 Ask the console what it holds, and what it charges per cell
Both numbers an interface is laid out against used to be taken on trust: the
size the terminal reported, and the one column per glyph that a layout measured
in columns pays for. On the Windows console in front of us, both were wrong,
and both failures arrive at the same place — cells written past the end of a row
reappear at the start of the next one, so the screen becomes several copies of
itself at several offsets and looks like a renderer that cannot count.

`squid-platform::console` measures instead of trusting. It asks three questions
because a console has three ways to be too optimistic — the window, the buffer
behind it, and the largest window it could show at all — and it asks them of the
buffer being *shown*, because entering the alternate screen on a legacy console
activates a second buffer while the process keeps holding the handle it started
with, which then describes a screen nobody is looking at. A window wider than
the cells that exist is where the wrapping starts, so `repair` asks the console
for the cells it does have; a window that slid down its own scrollback moves the
picture without moving the size, which is why the renderer watches the offset too
and wipes rather than diffs when the screen moved under it.

The second measurement is what makes a whole screen break at once. East Asian
Ambiguous characters have no agreed price, and a console left on a Far-Eastern
code page charges two cells for exactly the class of characters an interface is
built out of: the rules, the shading, the arrows, the ticks, the middot. ratatui
charges one, so every row of the layout is longer than the glass by the symbols
it contains. `symbol_cells` writes one box-drawing bar and reads how far the
cursor moved, because the two things that decide the price — code page and
font — are both set outside this program, and `chcp 65001` moves the same bar
back to one cell on the box that charges two.

`squid-tui::glyphs` then rewrites the finished frame one column for one column:
the rules become `|-+`, the gauges `#`, the arrows `<^>v`, so the rows fit
without the layout moving at all. Chinese text and ordinary letters are left
alone — neither is ambiguous, so neither caused the overflow, and a person's
paths and process names are not what an alignment bug should be allowed to
rewrite. `SQUID_SYMBOL_CELLS` overrides the measurement for the case the
measurement cannot reach: over ssh this program measures the console sshd made
for it, not the one on the glass. `SQUID_CONSOLE_TRACE` writes the two buffer
answers side by side, since a hand-made resize leaves no other evidence.
2026-10-15 21:20:14 +08:00
..
squid-cli Give the formatter the lines it had been asking for 2026-10-15 21:19:33 +08:00
squid-core Measure long paths, and clean up after a failing fixture 2026-10-15 18:53:31 +08:00
squid-engine Stop matching path separators in suffixes 2026-10-15 16:51:00 +08:00
squid-platform Ask the console what it holds, and what it charges per cell 2026-10-15 21:20:14 +08:00
squid-rules Windows: safety layer, rule engine fixes, and 30 built-in cleanup rules 2026-10-15 15:23:19 +08:00
squid-stats Windows: real platform layer, recycle-bin trash backend, cross-compile CI 2026-10-15 14:56:55 +08:00
squid-tui Ask the console what it holds, and what it charges per cell 2026-10-15 21:20:14 +08:00