From 0d04bc9214cccce42d74862b31376d49bdda3956 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 09:05:35 -0300 Subject: Let s, S and | pressed in a tag answer for the tag's own text A tag is a text like the body, so selecting on a regex and piping act on the text they are pressed in: a prompt records the text it answers for, the tag keeps the keyboard while it is typed, and a header's prompt goes on the active pane's band. `/` still searches the body from anywhere, as acme's Look from a tag searches the body. Co-Authored-By: Claude Opus 5.5 --- src/edit.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/edit.zig') diff --git a/src/edit.zig b/src/edit.zig index 837a22c6..e21352e1 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -74,10 +74,12 @@ pub fn typeToTty(p: *Pardes, id: usize, pane: *const Pane, text: []const u8) voi } pub fn applyPaste(p: *Pardes, bytes: []const u8) void { - if (tagline.focusedHeader(p)) |t| { + // A prompt answering for a header takes the paste, as it takes keys. + const asking = if (p.panes[p.active]) |active| active.prompt != .none else false; + if (!asking) if (tagline.focusedHeader(p)) |t| { p.clip_pending = null; return pasteInto(p, t, bytes); - } + }; const req = p.clip_pending; p.clip_pending = null; if (bytes.len == 0) return; @@ -94,7 +96,7 @@ pub fn applyPaste(p: *Pardes, bytes: []const u8) void { n += 1; }; if (n > 0) insertKey(p, &pane.input, .{ .cp = line[0], .text = line[0..n] }); - if (normal.selRegexArmed(pane)) |a| normal.applySelRegex(p, pane, a.pat, a.split); + if (normal.selRegexArmed(pane)) |a| if (p.promptTarget(pane)) |t| normal.applySelRegex(p, pane, t, a.pat, a.split); return; } if (pane.focus == .tag) return pasteInto(p, &pane.tag, bytes); @@ -400,7 +402,7 @@ fn editTextEol(p: *Pardes, t: *Text, b: Bounds) ?panes.EditText { } /// install a rewritten editable text (frees the old one) -fn setEditText(p: *Pardes, t: *Text, new: []u8) void { +pub fn setEditText(p: *Pardes, t: *Text, new: []u8) void { if (t.what != .body) { if (t.own) |old| p.gpa.free(old); t.own = new; -- cgit v1.3