summaryrefslogtreecommitdiff
path: root/src/Term.zig
Commit message (Collapse)AuthorAge
* Term: a core without a terminal boots to a scratch pane, and a test skips ↵Gabriel Schneider16 hours
| | | | only where it needs a terminal (docs/next-terminal.md, Phase 1, the no-terminal core): Pardes.init's shell boots (.shell, .classic, .tty, .tty_shell) are one scratch pane when Term.ops is null, so a test that booted a shell for convenience runs on it, where every one of them skipped before (Term.open refused with SkipZigTest under a test); Term.open refuses with error.NoTerminal, said by errorWords as Term.none, so Term and an exec no shell can take (a command pane) refuse in words (`Term: no terminal in this build`, `exec: ...`), and takesCommandLine is false with no terminal pane; a +Pager pages the bytes as they are (Term.page, unchanged); no boot message: the no-terminal core is a test build alone, read by no person, and a message at boot put seven core tests (the message log, the notice bands, the Del question's wake, a press on a column's rule) out of core-test; a test that fails for want of a terminal says so on its first line (`if (pardes.Term.ops == null) return error.SkipZigTest; // a shell`: a shell, a command pane, the classic boot's three shells, it reads the emulator, ...), 99 tests in 25 files, and ninep/testing.zig's withTerm, the fixture of 29 that assert a terminal pane, once; each attributed by its failure on the scratch boot (NoTerminal from newShell or newCommand, a shell's pane, prompt, pty bytes or tag asserted, the classic boot's panes indexed) and by reading its body; no assertion changes; test: Term.zig ends with the no-terminal core's three (each boot a scratch pane and no terminal; Term, newShell and an exec refused in words, no line typed at a shell; a program's output paged as plain text); core-test (no terminal) 411 passed / 535 skipped of 946 to 810 passed / 139 skipped of 949, shell-test 992: 989 passed, the three no-terminal tests skipped
* term: the terminal a module of its own (docs/next-terminal.md, Phase 1): ↵Gabriel Schneider16 hours
| | | | src/term/term.zig roots it, importing std, ghostty-vt, wuffs, zstbi and plain, never the core, and gives the core one table, `ops` (plain.term.Ops: about 60 entries, the records they take and give and the opaque handles State, Encoder, Track and Replica, in src/plain/term.zig), its own functions put in it through a cast refused at compile time unless each parameter and result matches the table's but for the handles and every error is one the table names; src/Term.zig, the core's side, takes `ops` from the term module when the build's term_options say the core has one (every core module but core-test's), null otherwise, and Term.State is a handle with the walk's hooks, so a dump keeps a terminal as it did (its Parts by name through walk.save, then ghostty's snapshot) and the digest is the emulator's; echo.zig comes back to the core (src/echo.zig: predicted echo is the replica's presentation, its five reads of the emulator through Term.grid, modes, prompt and Term.echoCell); screen_state's Peer is a plain record both sides name (its noteSent a function of screen_state's), its Encoder, Track and Replica handles made and freed through the table (replica.Screens makes its encoder at the first encode); a prompt's cut is told in columns and measured in its row's text by the core (Term.promptPrefix, File.rawAtDisplay); TerminalImages' decode bound moves from memory.limits to the decoder it bounds; build.zig: core_lean, the core module without the terminal, is core-test's, and wireCore no longer gives any core module ghostty-vt, wuffs or zstbi (the term module has them), so core-test's compile names none of ghostty, wuffs, zstbi, simdutf, highway or -lc++ (from --verbose); term-test runs the module's own tests (the pager's, screen_state's, the luminance table's); the tests of a terminal through a core move as they were to test/terminal.zig, in pane-test, which imports both (`of` reads the emulator behind a handle; the dump round trip frees through State.dumpFree), and tests elsewhere that read the emulator do it through Term.emulatorOf, a test in core-test skipping first; core-test skips a test whose terminal Term.open refuses; Authority.init releases its tape when the core it boots fails (it leaked); tests: core-test (no terminal) 409 of 941, 532 skipped, shell-test (the same tests with the terminal) 984 of 984, pane-test 180 of 181 (1 skipped, as before), term-test 15 of 15, kitty-test 45 of 45, replicas checked/wrong 0, hxdiff 658 cases 0 mismatches, behaviour-test 268 of 272 (the base's four addon ABI tests), lib-test
* Term: the draw group as plain data (docs/next-terminal.md, Phase 1): the ↵Gabriel Schneider16 hours
| | | | terminal paints its view into a plain cell buffer and the core lays it over the body's rows; Term.paint gives each of its view's rows (Term.PaintedRow: the prompt cut a shell's marks make of it, its kitty placeholders, how many cells it has) and each cell (Term.Painted: its style in the theme's colours, through the filter when the pane has it on, the bytes it spells, its width) for a theme handed in as Term.Ink; src/ansi.zig, new, is the core's half of what was terminal.zig's recolorAnsi, moved: the body walk, the edit copy's anchors (EditAnchors, its rows from Term.editRows) and the grapheme-to-cell alignment, now reading the buffer instead of the emulator's pages, and drawImages' body walk (Term.images takes the rows it maps and appends placements to the frame's list, blanking placeholder cells in its cells, as TerminalImages.draw did through Pardes); the filter stays the terminal's (it wraps ghostty's generate256Color), its record plain (Term.Filter, Term.FilterPalette in src/plain/term.zig, [3]u8 for ghostty's RGB), so a +Pager's spans are drawn through Term.filter and Term.spanColor, and palColor is Ink.palColor; config.tty_filter_min_contrast goes to the filter it bounds; Term.Grid gains the grid's cols; the filter tests reach the plain record's fields through asGhostRgb, asserting what they did; perf --terminal-mib (tail-style line off, ReleaseFast, instructions:u, 3 runs each, ±30k): 8 MiB 4,347.9M -> 3,949.8M (4.51M -> 4.09M a batch), 32 MiB 14,729.1M -> 13,294.4M (3.82M -> 3.45M a batch), the copy costs nothing that shows and the frame got cheaper; core-test 985/985, kitty-test 45/45, pane-test 151/152 (1 skipped), behaviour-test 268/272 (the four addon ABI 3.0 tests the base fails), replicas checked/wrong 0
* Term: the replica half and the seam's last reaches: screen_state.zig's ↵Gabriel Schneider16 hours
| | | | terminal half is reached through the interface (Term.encode, Term.encodeRows and Term.untrack on the authority, Term.wasRead and Term.clearRead for the rows a step read, Term.apply with the prompt marks riding a delta, Term.applyRows, Term.shown and Term.blank on a replica, Term.Encoder, Track, Peer and Replica its handles), so replica.zig reaches no emulator state; its kind half (a kind's frame as a Shadow, its strips and Blobs, encodeShadow) is the core's and moves, as it is, with its tests, to Kind.zig beside the Slot it shadows; predicted echo is Term.Echo; the draw entries (Term.recolor, Term.images, Term.petscii, Term.togglePetscii, Term.hasImages, Term.Filter, Term.FilterPalette, Term.palColor) are reached through the interface with their signatures as they were, not yet plain data (Term.zig says so); src/Term.zig is the one file outside src/term/ that imports one inside it (fs.zig embeds terminal.zig's text as a served source), panes.terminal, pardes.screen_state and pardes.echo go, the comments that named ghostty for the emulator say the emulator, and the tests that read emulator state read the records but three (Core.zig's palette, pty.zig's output pin and page limit); the changelog says so; nothing else changes
* pager: one parser, the terminal's: a +Pager's page is read through the ↵Gabriel Schneider16 hours
| | | | interface (Term.page, bytes in, its printed text and SGR spans out, Term.Page and Term.Span plain records), by ghostty-vt's stream as before kqrzvrmm, the handler that keeps the text, the spans and the overstrike moving with it to src/term/pager.zig; pager.zig's own parser (its ECMA-48 states, CSI limits and SGR reading) and src/pager.zig go, so two parsers cannot drift apart, and its tests stay with the page (the colon colours, 8-bit CSI, REP, CHT and CNL test kept, true by construction now); a 32 MiB coloured log pages in 2,074M instructions through the interface against 2,292M with the parser it replaces (ReleaseFast, a bench run once then removed; the same text and spans); Term.zig's tests take term/pager.zig's in; the changelog says the pager's own parser no more; pagercolor and every golden unchanged
* Term: text through the interface, the editing of the copy back to the core: ↵Gabriel Schneider16 hours
| | | | Term.scrollback and Term.scrollbackLen are its whole history as plain text (its body, Save), Term.textRows its rows as text with a prompt's own cells cut off (a plain Term.Rows), Term.viewport the rows its view shows, Term.promptPrefix how many bytes of a row are its prompt and Term.markRead says a step read them; the editing of the copy of a terminal's rows is the core's again, in edit.zig beside the text it edits: shellRows and the rows' cache (edit.RowsCache, edit.drawing), terminalLines (the rows with the copy spliced in), and in edit.zig's own flatSurface, editText, setEditText, pushUndo and undoStep the terminal's arms written out where they were dispatched to terminal.zig; the body's walk over the rows and the copy (BodyWalk) is body_layer.zig's, beside the bodyText it makes; screenTextAlloc, screenTextLen, cursorLines, flatSurface, editText, setEditText, pushUndo, undoStep and bodyText leave terminal.zig; nothing else changes
* Term: prompt and commands through the interface: Term.prompt is the plain ↵Gabriel Schneider16 hours
| | | | record of where the shell is in its command cycle (its phase, commands started, prompts drawn, lines declined, a continuation, the last command to finish and its status, input ready, input empty, the cursor at a prompt), Term.commandOutput what the newest command printed and Term.endOutputHere ends a command's output at the cursor; the pending command queue is the core's (Pane.pending_command, Pane.queuePendingCommand and Pane.releasePendingCommand, released at the shell's start or its prompt where Core.zig hears of them), and so are Pane.greeting, Pane.noteCommand, Kill's "the command pardes typed runs" (builtins.zig) and the newlines that keep a command's output below the edit copy (exec.zig); /pty/status, /pty/run and predicted echo read the record; promptInputReady, promptInputEmpty, commandRunning, armShellSpawn, shellSpawned, deinitPendingCommand and padOutputBelowEdits go; nothing else changes
* Term: input through the interface: Term.key writes a key's bytes as its ↵Gabriel Schneider16 hours
| | | | program's keyboard protocol and modes ask, Term.mouse and Term.wheel a mouse event's and a wheel turn's, Term.paste a paste as xterm makes one, Term.modes is the plain record of the modes the core decides by (mouse, all motion, the wheel, focus, bracketed paste, the alternate screen) and Term.promptMoves how far a click on the prompt line moves the shell's cursor; the mouse's records (MouseMods, MouseButton, MouseAction) are the interface's; keys.forwardKey (the bytes queued, an error reported) and keys.enterTty (raw mode, the cursor handed to the shell) are the core's, in keys.zig, pardes.keys for the tests; bracketedPaste, reportsMouse, reportsFocus, ownsWheel, tracksAllMotion and onAlternateScreen go into the record; the tests that called them follow; nothing else changes
* Term: output and view through the interface: Term.feed takes one read and ↵Gabriel Schneider16 hours
| | | | the rows the core keeps positions on and gives back a Term.Told (where each went, erased or not, cleared, alive, a pin missed), Term.grid is the plain record of the view and the cursor (total, offset, len, the cursor, whether it shows, the view's row or null while it follows), Term.scroll, Term.follow, Term.viewTo, Term.resize (now or for later) and Term.resizeDeferred move it, Term.cellPixels sizes its cells in pixels and Term.replies hands over what it answered its program; the core's half is the core's: Pane.feedOutput and its row tracking (the edit copy's rows, the cursors and selections, their undo and the pointer's rows, gathered as rows and moved as the feed told, ingestWithPositions's core) and Pane.followOutput, Pane.resizeGrid and Pane.panFor in panes.zig with panes.resizeDeferred, the cursor a program shows read from the grid where the body draws it, tape.viewOnly beside tape.authorityOnly; scrollbar, gridOffset, gridCursor, visibleCursor, viewOf, atBottom and their types go; nothing else changes
* Term: the terminal as the core calls it, src/Term.zig, its lifecycle first ↵Gabriel Schneider16 hours
(docs/next-terminal.md, Phase 0): Term.open makes an emulator and Term.close frees it, Term.due says when its next kitty frame is due, Term.revive resets a restored terminal's modes under its banner, Term.start and Term.stop run the PNG resize workers; the pane half of each is the core's: panes.createDoc and panes.createTerminal make the pane (the speculation guard there), emulatorGpa and emulator_gpa are the core's choice of allocator, teardownPane closes the emulator, dump.zig's revivePane resets what the old shell was and ensureKind opens an emulator straight into the pane; tape.authorityOnly is the one guard Kind.zig and the terminal both had a copy of; nothing else changes