diff options
| author | Gabriel Schneider <[email protected]> | 2026-06-29 20:17:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-06-29 21:37:01 -0300 |
| commit | b52e1e7274770fdfdf859938cb01095a8cc1a320 (patch) | |
| tree | e6aad47c2b5c80037c026653fbd204ad387f49a5 /term.zig | |
| parent | 3c1fef20894772e0cb48c7c2ae2c1a7ded48970d (diff) | |
| download | pardes-b52e1e7274770fdfdf859938cb01095a8cc1a320.tar.gz pardes-b52e1e7274770fdfdf859938cb01095a8cc1a320.zip | |
vibes acme-like text editing?
Diffstat (limited to 'term.zig')
| -rw-r--r-- | term.zig | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -11,6 +11,19 @@ pub const Sel = struct { r1: i32 = 0, }; +pub const EDIT_CAP = 128; // max chars in one insertion run +pub const MAX_EDITS = 16; // max concurrent insertion runs per window + +/// A run of inserted ("char mode") text. `col` is the ORIGINAL tty column it is +/// spliced in *before* — the run shifts the underlying row right, it doesn't +/// overwrite. `row`/`col` are pane-local (row carries the BOX_H tag offset). +pub const Edit = struct { + row: i32 = 0, + col: i32 = 0, + len: u16 = 0, + text: [EDIT_CAP]u8 = undefined, +}; + /// Persistent per-terminal state: the pty handle, the ghostty emulator and its /// (stateful) VT parser, the background reader task, plus its layout weight and /// text selection. @@ -36,6 +49,20 @@ vweight: f32 = 1, /// One independent selection per mouse button: 0=left, 1=middle, 2=right. sel: [3]Sel = .{ .{}, .{}, .{} }, +/// modal input. false = "sym" mode (keys -> pty as terminal sequences), +/// true = "char" mode (keys insert text at the cursor). a left-click enters +/// char mode and anchors the cursor; Esc leaves it. +/// +/// The cursor and edits are anchored at ABSOLUTE body rows (visual row + scroll +/// offset) so they ride the scrollback, not the screen. `cur_off` is the offset +/// into the run sitting at (cur_row, cur_col). +editing: bool = false, +cur_row: i32 = 0, +cur_col: i32 = 0, +cur_off: u16 = 0, +nedits: usize = 0, +edits: [MAX_EDITS]Edit = @splat(.{}), + pub fn deinit(self: *Term, io: std.Io, gpa: std.mem.Allocator) void { _ = self.reader.cancel(io) catch {}; self.stream.deinit(); |
