tty: the grid was 80x24 on a 160x50 screen, and wrapping was eager
Three symptoms, two causes, both in the terminal layer.
**The grid and TIOCGWINSZ disagreed about the size.** vt_init() sizes every
grid from gfx_cols()/gfx_rows(), and it runs at main.c:75 -- while the display
driver attaches its scanout from the PCI bus walk at main.c:99. So the grids
were the 80x24 fallback, and TIOCGWINSZ, which computed its own answer live,
said 160x50.
That one disagreement produced all three things visible in the report: text
stopped two thirds of the way down the screen, `ls` laid out 160 columns into
an 80-column grid so words split across the wrap ("vers" / "ion"), and zsh's
cursor tracking was wrong on every line.
Fixed in two places, because either alone would leave the trap set:
gfx_attach_scanout() now calls vt_resize(), so the grids learn the real screen
the moment there is one; and TIOCGWINSZ reports v->cols/v->rows rather than
measuring again. One number, from the terminal being asked.
**Wrapping was eager.** A glyph printed in the last column moved the cursor to
the next line immediately. Real terminals set a pending-wrap flag and wrap when
the *next* glyph arrives -- which is why a line exactly as wide as the screen
takes one row and not two, and why a program can write the bottom-right cell
without scrolling.
zsh's partial-line marker depends on that rule directly: it writes exactly
COLUMNS-1 spaces and expects to still be on the line. With eager wrap it left a
reverse-video '#' above every prompt, which is the hashtag in the report. Both
are gone.
Verified by screendump: `ls /proc` now fits one line with "version" intact, no
markers, and output fills the screen to the last row. schfs-check passes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
This commit is contained in:
parent
1c1b0c9570
commit
a5b0d5a0ef
5 changed files with 137 additions and 25 deletions
|
|
@ -1061,22 +1061,24 @@ addr_t sys_ioctl(void)
|
|||
if (request == TIOCGWINSZ) {
|
||||
struct winsize *ws = (struct winsize*)user_ptr(argp, sizeof(*ws));
|
||||
if (!ws) return -EFAULT;
|
||||
// The console's real geometry, not a VT100's.
|
||||
// The terminal's own grid, and nothing else.
|
||||
//
|
||||
// This used to answer 24x80 unconditionally -- the size of a terminal
|
||||
// SchOS has never drawn. Every program that lays out a screen asks
|
||||
// this one question first: a line editor to decide where to wrap, `ls`
|
||||
// to pick a column count, fastfetch to place its logo beside the text.
|
||||
// At 1024x768 with the 8x16 font the console is 128x48, so all of them
|
||||
// were formatting for a screen a third the area of the real one, and
|
||||
// each looked like a separate bug in a separate program.
|
||||
int cols = gfx_cols(), rows = gfx_rows();
|
||||
// Serial-only boot, with no framebuffer attached: 80x24 is then a
|
||||
// stated default rather than a wrong measurement.
|
||||
ws->ws_col = cols > 0 ? (uint16)cols : 80;
|
||||
ws->ws_row = rows > 0 ? (uint16)rows : 24;
|
||||
ws->ws_xpixel = (uint16)gfx_width();
|
||||
ws->ws_ypixel = (uint16)gfx_height();
|
||||
// SchOS has never drawn -- and was then fixed to compute the answer
|
||||
// live from gfx_cols()/gfx_rows(). That was a second source of truth,
|
||||
// and it disagreed with the first: the grids are sized once at
|
||||
// vt_init(), which runs before the display driver is found on the PCI
|
||||
// bus, so they were 80x24 while this reported 160x50. Programs
|
||||
// formatted for a screen the grid did not have -- `ls` split words
|
||||
// across the wrap, text stopped two thirds of the way down, and zsh's
|
||||
// cursor tracking was wrong on every line.
|
||||
//
|
||||
// One number, from the terminal being asked. They cannot disagree.
|
||||
struct vt *v = vt_for_minor(f->ip->minor);
|
||||
ws->ws_col = (uint16)v->cols;
|
||||
ws->ws_row = (uint16)v->rows;
|
||||
ws->ws_xpixel = (uint16)(v->cols * gfx_char_w());
|
||||
ws->ws_ypixel = (uint16)(v->rows * gfx_char_h());
|
||||
return 0;
|
||||
}
|
||||
// The console's size is a property of the framebuffer, so a request to
|
||||
|
|
|
|||
Loading…
Reference in a new issue