summaryrefslogtreecommitdiff
path: root/src/keys.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 07:44:55 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit0db7861d9da09e059fa1b9e40fff5cd52add27f2 (patch)
tree6e95dfa36e07b3234b1d5cdb990b11f95c184a3f /src/keys.zig
parentd3742ddf2b3a85eb3935cb35e958fa27f1293a6b (diff)
parentdee94c740bdaea61ff35b4e0a7f1d2815c9ee441 (diff)
downloadpardes-0db7861d9da09e059fa1b9e40fff5cd52add27f2.tar.gz
pardes-0db7861d9da09e059fa1b9e40fff5cd52add27f2.zip
integration: the text pane a library (pardes-editor), with the GPU move, the terminal, the plumber and the diff work
A merge of pardes-next (wmrtztwl) and editor-lib (rlumrxuq), no conflicts. Gated against the baseline of the integration line (.scratch/sketch/gpu/mbase): the merge with the library before its follow-up, in full: frame corpus 77/77 identical in Debug and in ReleaseFast, the gated window -0.019% instructions (threshold 0.5%), unit-test on gui 1584/1592 with no failure the baseline has not; this merge: corpus 77/77 in Debug, unit-test on gui 1584/1592, on tui core-test 811/950 (139 skipped), shell-test 990/993, lib-test, hxdiff 658, parity 738, hxgolf 124, hxlib 538 and its parity 618, all 0 mismatches, replicas pass. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/keys.zig')
-rw-r--r--src/keys.zig24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/keys.zig b/src/keys.zig
index 8b67a9d1..05148fed 100644
--- a/src/keys.zig
+++ b/src/keys.zig
@@ -43,9 +43,9 @@ pub fn cycleMode(p: *Pardes, id: usize) void {
pane.body.mode = .normal;
pane.body.normal.clear();
},
- .normal => edit.enterInsert(p, &pane.body, .at, 1) catch |err| p.reportError(id, "edit", err),
+ .normal => edit.enterInsert(p.editor(), &pane.body, .at, 1) catch |err| p.reportError(id, "edit", err),
.insert => {
- edit.exitInsert(p, &pane.body);
+ edit.exitInsert(p.editor(), &pane.body);
if (pane.isTerminal()) enterTty(p, id);
},
}
@@ -232,7 +232,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
pane.focus = .body;
}
for ([_]*Text{ &pane.body, &pane.tag }) |t| {
- if (t.mode == .insert) edit.exitInsert(p, t);
+ if (t.mode == .insert) edit.exitInsert(p.editor(), t);
t.normal.clear();
t.select = false;
}
@@ -342,7 +342,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
p.setMessage(p.view().active, "name drafted: Enter renames the buffer, Esc drops the draft");
return;
}
- edit.handleInsert(p, &pane.input, key);
+ edit.handleInsert(p.editor(), &pane.input, key);
return;
}
if (header == null and pane.prompt != .none) {
@@ -365,7 +365,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
}
return;
}
- edit.handleInsert(p, &pane.input, key);
+ edit.handleInsert(p.editor(), &pane.input, key);
if (normal.selRegexArmed(pane)) |a| if (panes.promptTarget(p, pane)) |answered| normal.applySelRegex(p, pane, answered, a.pat, a.mode);
return;
}
@@ -381,7 +381,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
if (t.what != .body) {
// An explicit selection, else the word under the cursor in the
// text as it is shown: a tag's prefix is part of what a word is.
- const shown = p.scratch.allocator().dupe(u8, edit.flatSurface(p, t) catch |err| return p.reportError(p.view().active, "exec", err)) catch |err| return p.reportError(p.view().active, "exec", err);
+ const shown = p.scratch.allocator().dupe(u8, edit.flatSurface(p.editor(), t) catch |err| return p.reportError(p.view().active, "exec", err)) catch |err| return p.reportError(p.view().active, "exec", err);
const range = t.primaryRange(shown, 0);
const lo = @min(range.anchor, range.head);
const hi = @max(range.anchor, range.head);
@@ -408,7 +408,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
exec.runBuiltin(p, cmd, p.view().active, "", txt);
return;
}
- edit.pinPaneCursor(p, &pane.body);
+ edit.pinPaneCursor(p.editor(), &pane.body);
const explicit = (if (pane.addon) |k| k.selection.len > 0 else false) or
(pane.body.vsel.active and pane.body.vsel.explicit);
if (explicit) {
@@ -442,11 +442,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
};
const was = t.mode;
switch (t.mode) {
- .normal => normal.handleNormal(p, t, key),
- .insert => if (hit(key, config.escape) and !t.reg_wait)
- edit.exitInsert(p, t)
- else
- edit.handleInsert(p, t, key),
+ .normal, .insert => _ = normal.textKey(p.editor(), t, key),
.tty => forwardKey(p, p.view().active, key),
}
// `.`'s log: the keys of the normal command that entered insert
@@ -771,7 +767,7 @@ test "raw tty forwards Ctrl letters and former global shortcuts to the child" {
defer p.deinit();
var buf: [256]u8 = undefined;
_ = test_api.ptyBytes(p, null, &buf);
- try edit.setYank(p, "register text");
+ try edit.setYank(p.editor(), "register text");
for ('a'..'z' + 1) |letter| {
if (letter == p.tty_toggle) continue; // editor/TTY mode shortcut
if (letter == 'v') continue; // the window's paste, asserted just below
@@ -826,7 +822,7 @@ test "s in a header selects in the header's own text" {
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expect(p.view().header != null and pane.prompt == .none);
var ranges: [Text.max_selections]modal.Selection = undefined;
- const text = try edit.flatSurface(p, &p.global_tag);
+ const text = try edit.flatSurface(p.editor(), &p.global_tag);
const got = p.global_tag.ranges(text, 0, &ranges);
try std.testing.expectEqual(@as(usize, 2), got.n); // Newcol, Joincol
try std.testing.expectEqual(@as(u16, 0), pane.body.nsel);