diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 05:45:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 779ff8cc27014b8c2f2f078985ab2ca9cf285740 (patch) | |
| tree | 8b05d0404544b9efd92e88c7b727d3ba8f6a37f5 /src/Editor.zig | |
| parent | 55dbff5aced5c62f47be39fbc01276b6e36d7dd5 (diff) | |
| download | pardes-779ff8cc27014b8c2f2f078985ab2ca9cf285740.tar.gz pardes-779ff8cc27014b8c2f2f078985ab2ca9cf285740.zip | |
Editor: what an edit of a text runs with, out of Pardes (docs/next-editor.md, R1): src/Editor.zig is a context of the allocators and pointers to the registers, the register the running command names, the replay's multi_* and the retired text, and the core (`p`), gathered per call by `p.editor()` from where they are, so no field of Pardes or its view moves and a dump crosses builds as before (an embedded `ed: Editor` would have renamed `registers` in the dump, matched by name, and lost them at an Upgrade); setYank, registerValue, retireEditText and normal.multiOnce take it, their callers hand `p.editor()`; core-test 810 of 949, shell-test 989 of 992, hxdiff 658 / parity 738 / hxgolf 124 with 0 mismatches, replicas pass
Diffstat (limited to 'src/Editor.zig')
| -rw-r--r-- | src/Editor.zig | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Editor.zig b/src/Editor.zig new file mode 100644 index 00000000..559ea196 --- /dev/null +++ b/src/Editor.zig @@ -0,0 +1,54 @@ +//! What an edit of a text runs with (normal.zig, edit.zig): the allocators, +//! the registers, the register the running command names, the replay of a +//! key across the ranges, the text an edit made that nothing kept, and the +//! core the text's pane is in. Gathered for each call from where pardes +//! keeps them (`Pardes.editor`); the library gathers it from the value a +//! sketch stores (src/lib_editor.zig). Nothing here is kept between calls. +const std = @import("std"); +const Registers = @import("Registers.zig"); +const Pardes = @import("Core.zig"); + +const Editor = @This(); + +gpa: std.mem.Allocator, +/// What an edit makes and drops: the update's scratch. +scratch: std.mem.Allocator, +registers: *Registers, +/// The register the running normal command names (`"<reg>`); 0 for the +/// default one. +register: *u21, +/// While a key is replayed across the ranges (normal.replaySels): whether +/// this is the first pass, whether a pass stopped the replay, which range +/// this pass is, in document order, and how many there are; outside a +/// replay, the one range and its first pass. A register value belongs to +/// its range by `multi_index`. +multi_first: *bool, +multi_stop: *bool, +multi_index: *usize, +multi_count: *usize, +/// An edited text nothing kept (a tag's shown text): see +/// edit.retireEditText. +retired_edit: *?[]u8, +/// The core the text's pane is in: what an edit reaches past its text with. +p: *Pardes, + +pub fn of(p: *Pardes) Editor { + return .{ + .gpa = p.gpa, + .scratch = p.scratch.allocator(), + .registers = &p.registers, + .register = &p.view().register, + .multi_first = &p.multi_first, + .multi_stop = &p.multi_stop, + .multi_index = &p.multi_index, + .multi_count = &p.multi_count, + .retired_edit = &p.retired_edit, + .p = p, + }; +} + +/// An edit that failed, said on the message row of the pane the keyboard +/// is in. +pub fn reportError(e: Editor, err: anyerror) void { + e.p.reportError(e.p.view().active, "edit", err); +} |
