From fa06681a8418b7e31af96e010bb424e178402f4d Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 17:19:09 +0200 Subject: tty + vt terminal split, rsdosedit editor (1:1 UNIX console) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kernel now has the classic UNIX console split, so full-screen ANSI apps can run in ring 0: - vt.rs: terminal emulator owning the text screen — cell grid (char + fg/bg), logical cursor (inverse-video), scrolling, and a small ANSI CSI parser (cursor position H/f, erase J/K, moves A-D, SGR 16-colour with correct ANSI→VGA mapping, cursor show/hide ?25). Blits only changed cells; scroll shifts cell grids + pixels and re-rasterises only the exposed bottom row. gop_println!/clear_screen now render through the vt; gop.rs is the raw rasteriser (colored glyph blits, pixel shift). - tty.rs: line discipline — canonical read_line (echo, line buffer, ^C cancel, ^D EOF) moved out of the shell, and raw read_byte that translates KeyEvents to the terminal byte protocol (arrows → ESC[A-D, Backspace → 0x7f, ^X → 0x18, Ctrl+arrows → ESC[1;5A-D, Home/End/PgUp/ PgDn/Delete). interrupt_pressed() stays for streaming commands. - ps2: generic Ctrl(char) + CtrlArrow events (was: only CtrlC/CtrlD). - rsdosedit: no_std port of the RNG rsedit editor as the first real app — undo, syntax highlighting (verified green/gray/yellow on the framebuffer), search, word nav, smart indent, ^S save / ^X exit / ^X again to discard. termios → tty raw, stdout → vt, std::fs → VFS (ramfs), SIGWINCH → fixed geometry, force-exit window → key counter. - shell: 'edit ' command; read_line/strbuf moved to rsnix. - CONTEXT.md: layout + milestones + known-issue perf notes. Verified in QEMU: full edit → type → arrow-move → insert → save → exit round trip with byte-exact file content; ANSI colors via screendump. --- CONTEXT.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index 66ab320..b557192 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -101,10 +101,20 @@ Single Rust crate (`x86_64-unknown-uefi` target). Module breakdown: - `fs.rs` — VFS: dirs, ramfs files, char devices (`/dev/mem`, `rtc`, `pci`, `version`, `meminfo`, `null`, `zero`, `console`, `serial`; `/tmp` ramfs; `/etc/motd`) -- `gop.rs` — framebuffer access and text rendering +- `gop.rs` — framebuffer rasteriser (glyph blits, pixel shifts); the text + surface itself lives in `vt` +- `vt.rs` — terminal emulator: cell grid, cursor, ANSI CSI parser (H/J/K, + cursor moves, SGR 16-colour, `?25l/h`), dirty-cell blitting +- `tty.rs` — line discipline: canonical `read_line` (echo, line buffer, + ^C/^D) and raw `read_byte` (terminal byte protocol: arrows → `ESC [ A–D`, + ^X → `0x18`, …) +- `strbuf.rs` — stack fixed-capacity ASCII string (moved from shell) - `font.rs` — 8×16 bitmap font data -- `ps2.rs` — PS/2 keyboard driver (polling) +- `ps2.rs` — PS/2 keyboard driver (polling); generic `Ctrl(char)` and + `CtrlArrow` events - `shell.rs` — command loop and built-in commands +- `rsdosedit/` — kernel-native port of the RNG `rsedit` terminal editor + (no_std; talks to `tty` raw mode + `vt` ANSI; saves via the VFS) ## Milestone status (v0.1) @@ -133,6 +143,30 @@ Single Rust crate (`x86_64-unknown-uefi` target). Module breakdown: ✅ **^C / ^D** — Ctrl+C cancels the line or aborts a running stream (`cat`/`hexdump` check between chunks), Ctrl+D on an empty line powers off (EOF) +✅ **tty + vt (terminal) — the 1:1 UNIX console split**: `tty` owns the + line discipline (canonical echo/buffer/^C/^D for the shell; raw mode + translates keys to the classic terminal byte protocol), `vt` owns the + screen (cell grid + ANSI CSI parser + 16-colour SGR + dirty-cell blits + into the GOP framebuffer). `gop_println!` etc. now render through `vt`. +✅ **rsdosedit** — the RNG `rsedit` editor ported to the kernel (no_std, + no libc): `edit ` opens a full-screen editor with undo, syntax + highlighting, search (^W), save (^S), exit (^X, twice to discard), word + nav (Ctrl+arrows), smart indent. Files live in the ramfs. Termios → + `tty` raw mode, stdout → `vt`, `std::fs` → VFS, SIGWINCH → fixed + geometry. Verified in QEMU: edit/type/navigate/insert/save/exit, exact + bytes via `cat`/`hexdump`, syntax colours via framebuffer dump. + +## Known issues / perf notes + +- **Scroll is slow under QEMU without KVM**: each scroll shifts the whole + framebuffer up (~3 MB copy at 1280×800) with TCG-emulated stores. + Deferred optimisation: ring-buffer rows / deferred pan so scrolling + never touches the whole framebuffer. The vt's cell grid already avoids + re-rasterising on scroll (only the exposed bottom row is blitted). +- **Editor redraw** re-blits changed cells per keystroke (fine at 1280×800); + the "optimize drawing someday" item. +- **ramfs only**: edited files live in memory, lost on reboot until disk + support (AHCI/FAT32) lands. ## Target audience -- cgit v1.2.3