summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-11 18:30:13 -0300
committerGabriel Schneider <[email protected]>2026-08-12 13:04:32 -0300
commitb424164922842796619cb6894ec46d729a8a6826 (patch)
treebd4653accfaeb67012f4e7257c61eaf4fb12c892 /src/builtins.zig
parent08f32cdde672740b71608f3dfccd629dcbac78f7 (diff)
downloadpardes-b424164922842796619cb6894ec46d729a8a6826.tar.gz
pardes-b424164922842796619cb6894ec46d729a8a6826.zip
clipboard, n/N and the tty prompt: three things that were half-wired
Three changes that all turned out to be the same shape -- a feature that worked in one direction, or for one pane kind, and quietly did not in the others. CLIPBOARD. Every register write emitted set_clipboard, so deleting one character threw away whatever the desktop was holding; multi-cursor yank took the join's early return and emitted nothing at all, so the same key reached the clipboard on one cursor and not on two. Nothing could READ the clipboard: the SDL shell had no SDL_GetClipboardText anywhere in it, and the tty shell never asked for OSC 52, so `p` from another application was dead in both. Now it is helix's split. y/d/c/p/P/R and the acme chords are the DEFAULT REGISTER and nothing else; the system clipboard is five words on helix's own letters -- SPC y, SPC Y, SPC p, SPC P, SPC R -- spelled as builtins so they land in Help and are executable like every other verb. The one exception is the tag `y` chord, which still mirrors out because a tag is always insert, so SPC cannot be pressed there, and copying the path out is the whole point of the chord. Reading is a new read_clipboard effect answered by an ordinary Event.paste, so the round trip is honest about being one: SDL and NSPasteboard answer inside the same drain, the browser answers a promise, and a terminal answers over OSC 52 or -- far more often -- refuses. A refused read is a paste that does not happen, and the request dies at the next keystroke rather than landing minutes late in whatever pane is focused by then. The tty shell also enables BRACKETED PASTE now and coalesces paste_start..paste_end into one event. Before this a paste arrived as a flood of individual key presses: plausible in insert mode, and in normal mode every pasted character ran as a command. n/N. They stepped the armed results buffer and immediately Looked each row, so you could not walk past a hit without opening it. They are a MOTION now: select the next look-able text, open nothing, and let Enter decide. What they step is the largest whitespace-delimited run look.resolve can act on (look.lookableSpan, wrapper punctuation peeled), over a RING of panes -- every pane that has performed a look, most recent first, then the output buffers that have not, newest first, and only if both are empty the pane in front of you. N is the exact inverse of n, computed rather than remembered: both directions ask the same question about the same spans and compare against the column the walk parks on, so x presses one way and x back land exactly where you started, pane boundaries and the ring's seam included. A ring rather than a list with two ends because a shell's cursor sits at the prompt, below everything it has printed, so a walk that could not come round would have nowhere to go on the very first press -- which is the case n/N were written for. One motion everywhere, no pane-kind or buffer-kind special case. The only thing a buffer may change is the GRAIN of what a step selects, and it does it with one flag rather than a branch: output_pane.Traits.commands (renamed from `executes`, which named one reader's behaviour rather than the fact) makes a row select WHOLE, because a ThemeSel line is a word to run and has no path inside it to pick out. `]d`/`[d` are not n/N -- they are helix's diagnostic motions, their job is to ARRIVE, and they still reach searchStep. THE TTY PROMPT. Leaving raw tty blanked the prompt row, and the command you had typed at that prompt shares the row, so it went too -- a shell out of tty read as output only. OSC 133 marks the row CELL by cell, so the two are separable: config.tty_blank = .prompt cuts the prompt's own columns and leaves the command, left-hugged at column 0 in line with the output under it rather than in a bay of blanks. .prompt_and_input is the old behaviour, kept. Because the row is now something you can put a cursor in, enterTty adds the hidden prompt width back before asking ghostty to walk the shell's own cursor to it -- the modal column on a cut row is short by exactly that much. Verified: unit-test 186/186 (nine new), snap 87/87 (new ttyprompt.snap), hxdiff 481 and hxparity 561 with 0 mismatches, tty and gui both build. And against the real binaries rather than the harness: in a pty, SPC y emits OSC 52 carrying exactly the selection while plain y emits nothing, SPC p issues the read and pastes the reply, and a bracketed paste of "dd..." inserts text instead of deleting two lines. In a real SDL window, SPC y then SPC p round trips through the system clipboard while the default register holds different text. Setting tty_blank back to .prompt_and_input reproduces all 86 old goldens byte for byte.
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig70
1 files changed, 63 insertions, 7 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index f207ed9f..39a147fa 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -107,7 +107,7 @@ pub const OutputTraits = struct {
name: []const u8,
steps: bool = false,
jumps: bool = false,
- executes: bool = false,
+ commands: bool = false,
};
/// The enum: field name = struct name, value = index into `all()`. Everything
@@ -297,12 +297,13 @@ pub const Shell = struct {
};
/// ...and the list of what Theme takes, as a buffer you walk. Its rows are
-/// `Theme <name>` COMMANDS rather than locations, so n/N execute them instead
-/// of looking them (output_pane.Traits.executes) and stepping the list wears
-/// each theme in turn — the picker is the list, and there is nothing to
-/// confirm because arriving already applied it.
+/// `Theme <name>` COMMANDS rather than locations, which is one flag on the
+/// buffer (output_pane.Traits.commands) and changes what a step SELECTS: the
+/// whole line, since there is no path inside it to pick out. Tab on what n
+/// selected wears that theme — the same middle click on the row is — so
+/// walking the list with n/Tab is trying them on, and stopping is choosing.
pub const ThemeSel = struct {
- pub const output: OutputTraits = .{ .name = config.themes_buffer, .steps = true, .executes = true };
+ pub const output: OutputTraits = .{ .name = config.themes_buffer, .steps = true, .commands = true };
pub fn run(c: Ctx) void {
output_pane.openThemes(c.p, c.id) catch |err| c.p.reportError(c.id, "themes", err);
}
@@ -368,7 +369,7 @@ pub const Font = struct {
/// unreadable one — and this picker EXECUTES what it steps onto, so listing
/// them would mean the list wearing one on the way past. See fonts.monospaced.
pub const FontSel = struct {
- pub const output: OutputTraits = .{ .name = config.fonts_buffer, .steps = true, .executes = true };
+ pub const output: OutputTraits = .{ .name = config.fonts_buffer, .steps = true, .commands = true };
pub const enabled = pardes.font_picker;
pub fn run(c: Ctx) void {
if (comptime enabled) apply(c) else unreachable;
@@ -455,6 +456,61 @@ pub const Ascii = struct {
}
};
+// ---- the system clipboard ----
+
+// helix's `<space>` clipboard menu, and the ONLY five words in pardes that
+// touch the desktop's clipboard. Everything else — `y`, `d`, `c`, `p`, `P`,
+// `R`, the acme cut/paste chords — lives entirely in the internal register,
+// which is helix's arrangement and, less abstractly, the reason deleting a
+// character no longer throws away whatever you had copied from a browser.
+//
+// They are builtins rather than bare chords because the leader table is the
+// remapping surface and a leader path names a builtin: spelling them here
+// puts them in Help's index, makes them executable words like every other
+// verb, and costs no second mechanism. Their paths ARE helix's letters, on
+// the same leader helix uses — see config.leader_path.
+//
+// The two directions are not symmetric, and cannot be. Writing is a fire-off:
+// the core owns the bytes and the shell copies them out. READING has to leave
+// the core and come back — SDL and NSPasteboard answer inside the same drain,
+// a browser answers a promise later, and a terminal answers over OSC 52 or,
+// far more often, refuses outright. So a paste is a REQUEST (the
+// read_clipboard effect) that may simply never be answered, and a `SPC p`
+// that does nothing in a locked-down terminal is the honest outcome rather
+// than a bug to paper over with the internal register.
+
+pub const ClipYank = struct {
+ pub fn run(c: Ctx) void {
+ c.p.clipYank(c.pane, false);
+ }
+};
+
+/// helix `<space>Y`: the PRIMARY selection alone, where `SPC y` joins every
+/// cursor's. One cursor makes them the same word.
+pub const ClipYankMain = struct {
+ pub fn run(c: Ctx) void {
+ c.p.clipYank(c.pane, true);
+ }
+};
+
+pub const ClipPaste = struct {
+ pub fn run(c: Ctx) void {
+ c.p.clipRequest(c.id, .after);
+ }
+};
+
+pub const ClipPasteBefore = struct {
+ pub fn run(c: Ctx) void {
+ c.p.clipRequest(c.id, .before);
+ }
+};
+
+pub const ClipReplace = struct {
+ pub fn run(c: Ctx) void {
+ c.p.clipRequest(c.id, .replace);
+ }
+};
+
// ---- panes and columns ----
pub const Save = struct {