starkernel: REPL scrollback, ~1000 lines (FABRIC.md item 4.4q)
Scope decided with Captain Bob before implementation: ring buffer + recall on today's full-screen vt100 grid, not also confining REPL text to the 4.4o 640x480 box (that confinement stays open as its own future item, not a third silent deferral). No keyboard input path exists yet (M8 unstarted), so the trigger is two new FORTH words, SCROLL-BACK ( n -- ) / SCROLL-FWD ( n -- ), exercised via serial injection. vt100.c gains a text-only 1000-line ring buffer (kmalloc'd, tens of KB -- not pixel snapshots, which would be ~1000x larger for no benefit) plus a shadow buffer mirroring the current screen. scroll_up() now pushes evicted rows into the ring before the pixel scroll. History is one continuous sequence (ring then shadow); scrolling always redraws from that sequence -- no separate pixel-scroll path for scrollback, decided up front to avoid retrofitting later. New src/word_source/scroll_words.c (Module 31), thin wrappers over console_fb_scroll_back()/_fwd() -> vt100_scroll_back()/_fwd(). Bug caught during live testing: both words initially used an off-by-one underflow check (dsp < 1) copied from a different, older dsp convention elsewhere in this codebase; vm_pop() (which these words actually call) uses dsp as a 0-based top-of-stack index, so the check rejected every legitimate single-argument call. Fixed by removing the separate precheck and relying on vm_pop()'s own guard. Live-verified on all three architectures (exceeds this item's amd64-minimum bar): generated 50+ lines via a FORTH loop, confirmed SCROLL-BACK recovers correctly older content, and on amd64 confirmed SCROLL-FWD returns to genuinely live state (not a frozen snapshot) by showing the injected commands' own echo. Known limitation confirmed by direct pixel measurement: redrawn lines lose their original SGR color (not stored per-cell) -- text recovers exactly, color does not. Three-arch verified: Failed: 0, dict-hashes identical across all three (values changed correctly from prior items -- two new words were added). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
277845e3bf
commit
1f3ec3554e
@@ -82,6 +82,14 @@ void console_fb_init(const FramebufferInfo *info, FbPixelFormat fmt);
|
||||
*/
|
||||
void console_fb_enable_ttf(void);
|
||||
|
||||
/**
|
||||
* FABRIC.md item 4.4q: thin wrappers over vt100_scroll_back()/
|
||||
* vt100_scroll_fwd() -- see those functions' doc comments for the full
|
||||
* contract. No-op if the framebuffer console was never initialized.
|
||||
*/
|
||||
void console_fb_scroll_back(uint32_t n);
|
||||
void console_fb_scroll_fwd(uint32_t n);
|
||||
|
||||
/**
|
||||
* Write a single character to serial console
|
||||
*/
|
||||
|
||||
@@ -67,12 +67,29 @@ void vt100_init(void);
|
||||
* Lazily loads the font capsule and its raster cache on first call
|
||||
* (no-op on later calls). Recomputes cols/rows for the new cell size and
|
||||
* clears the screen, since the two glyph backends use different cell
|
||||
* dimensions. Provisional TTF point size/cell dimensions -- FABRIC.md
|
||||
* item 4.4m owns the final decision. No-op if the font capsule fails to
|
||||
* load (stays on font_8x16.c; logged, not fatal).
|
||||
* dimensions. TTF point size/cell dimensions decided final by FABRIC.md
|
||||
* item 4.4m (20px text, 96px REPL strip). No-op if the font capsule
|
||||
* fails to load (stays on font_8x16.c; logged, not fatal).
|
||||
*/
|
||||
void vt100_enable_ttf(void);
|
||||
|
||||
/**
|
||||
* FABRIC.md item 4.4q: move the REPL scrollback view back/forward by
|
||||
* @p n lines and redraw. Offset 0 (the default, and where every call
|
||||
* eventually returns to) is the live view -- the same content already on
|
||||
* screen. Clamped at both ends: back cannot pass the oldest stored line,
|
||||
* forward cannot pass the live view. No-op (including no redraw) if the
|
||||
* scrollback buffers failed to allocate at vt100_enable_ttf() time, or
|
||||
* before TTF mode is active at all.
|
||||
*
|
||||
* Known limitation: redraw uses the terminal's current default fg/bg,
|
||||
* not each line's original SGR color state at the time it was printed
|
||||
* (colors aren't stored per-cell) -- text content is recovered exactly,
|
||||
* color is not.
|
||||
*/
|
||||
void vt100_scroll_back(uint32_t n);
|
||||
void vt100_scroll_fwd(uint32_t n);
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* Character output
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user