summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-27 23:06:11 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit95a3a1bb822e583988bfe0f312d0ef219b27a454 (patch)
tree95306e8d3f36f8af05b3ea919f6cdef1e94a028b /src/exec.zig
parentc8f0c25a854b8e169db08a84d1fdcd915a70aaa0 (diff)
downloadpardes-95a3a1bb822e583988bfe0f312d0ef219b27a454.tar.gz
pardes-95a3a1bb822e583988bfe0f312d0ef219b27a454.zip
Give a pane's body its own Text holding the cursor, selections, mode and undo
acme keeps what edits a text in its Text (dat.h:171-190) and the window holds a body and a tag of that type. The cursor, the selections, the modal state and the edit-buffer undo move off Pane into Text.zig, Pane holds them as its body, and the edit and normal-mode operations take the Text they edit. Nothing changes in behaviour; this is the step that lets the tag become a second Text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/exec.zig b/src/exec.zig
index 75d07441..0a9d6f31 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -38,13 +38,13 @@ pub fn takesCommandLine(p: *const Pardes, id: usize) bool {
}
pub fn chordEachSel(p: *Pardes, pane: *Pane, cmd: Builtin) bool {
- if (pane.nsel == 0) return false;
- const text = edit.flatSurface(p, pane) catch return false;
- var ranges: [Pane.max_selections]modal.Selection = undefined;
- const got = pane.ranges(text, 0, &ranges);
+ if (pane.body.nsel == 0) return false;
+ const text = edit.flatSurface(p, &pane.body) catch return false;
+ var ranges: [panes.Text.max_selections]modal.Selection = undefined;
+ const got = pane.body.ranges(text, 0, &ranges);
if (got.n < 2) return false;
- var texts: [Pane.max_selections][]u8 = undefined;
+ var texts: [panes.Text.max_selections][]u8 = undefined;
var made: usize = 0;
defer for (texts[0..made]) |t| p.gpa.free(t);
for (ranges[0..got.n]) |range| {
@@ -59,10 +59,10 @@ pub fn chordEachSel(p: *Pardes, pane: *Pane, cmd: Builtin) bool {
const id = p.active;
const serial = pane.serial;
- pane.vsel.active = false;
- pane.msel.active = false;
- pane.select = false;
- pane.nsel = 0; // the chord consumed them, exactly as it consumes one
+ pane.body.vsel.active = false;
+ pane.body.msel.active = false;
+ pane.body.select = false;
+ pane.body.nsel = 0; // the chord consumed them, exactly as it consumes one
var primary_active: ?usize = null;
for (texts[0..made], 0..) |txt, i| {
@@ -96,7 +96,7 @@ pub const PointerOperand = struct {
pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand {
const visible = clicked.r0 - @as(i32, BOX_H);
const wrapped = pane.wrapAt(visible);
- const raw = pane.isTerminal() and pane.mode == .tty and clicked.r0 >= BOX_H;
+ const raw = pane.isTerminal() and pane.body.mode == .tty and clicked.r0 >= BOX_H;
const row = if (raw) panes.Terminal.gridOffset(pane) + visible else wrapped.line;
const raw_line = if (raw) modal.lineSlice(body_layer.bodyText(p, p.scratch.allocator(), pane) catch "", @intCast(@max(0, visible))) else "";
const col = if (raw)
@@ -104,7 +104,7 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand
else if (clicked.r0 >= BOX_H)
edit.paneByteAtDisplay(
p,
- pane,
+ &pane.body,
wrapped.line,
wrapped.at,
clicked.c0 - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0),
@@ -143,14 +143,14 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand
result.preview = kept;
return result;
}
- if (pane.vsel.active and pane.vsel.explicit and
- edit.spanHas(row, col, pane.vsel.row, pane.vsel.col, pane.cur_row, pane.cur_col))
+ if (pane.body.vsel.active and pane.body.vsel.explicit and
+ edit.spanHas(row, col, pane.body.vsel.row, pane.body.vsel.col, pane.body.cur_row, pane.body.cur_col))
{
result.text = edit.currentSelText(p, pane);
return result;
}
- if (pane.msel.active and row >= @min(pane.msel.r0, pane.msel.r1) and
- row <= @max(pane.msel.r0, pane.msel.r1))
+ if (pane.body.msel.active and row >= @min(pane.body.msel.r0, pane.body.msel.r1) and
+ row <= @max(pane.body.msel.r0, pane.body.msel.r1))
{
result.text = edit.currentSelText(p, pane);
return result;
@@ -202,7 +202,7 @@ pub fn heldSelection(p: *Pardes, first: usize) ?[]const u8 {
};
if (t.sel[sel_slot].state == .done) {
if (edit.selectionText(p, t, t.sel[sel_slot]) catch null) |tx| return tx;
- } else if ((t.vsel.active and t.vsel.explicit) or t.msel.active) {
+ } else if ((t.body.vsel.active and t.body.vsel.explicit) or t.body.msel.active) {
if (edit.currentSelText(p, t)) |tx| return tx;
}
}
@@ -302,7 +302,7 @@ fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) void {
const nt = p.newShell(free, Pardes.paneDir(src)) catch return;
nt.greet = !v9fs;
nt.v9fs_on_spawn = v9fs;
- nt.mode = .tty;
+ nt.body.mode = .tty;
const parent = layout.splitParent(p, from);
const f = layout.findPane(p, parent).?;
layout.insert(p, f.col, f.idx + 1, free);
@@ -558,8 +558,8 @@ test "the acme chords act once per selection, not once on the primary" {
.{ .anchor = 0, .head = 6 },
.{ .anchor = 7, .head = 13 },
};
- pane.setRanges(pane.file.?.content, &ranges, &.{}, 0, true);
- try std.testing.expectEqual(@as(u8, 1), pane.nsel);
+ pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true);
+ try std.testing.expectEqual(@as(u8, 1), pane.body.nsel);
const before = p.ncol;
p.update(.{ .key = .{ .cp = Key.tab } }); // config.exec_key: Exec
@@ -567,5 +567,5 @@ test "the acme chords act once per selection, not once on the primary" {
// other cursor, so one keystroke over two cursors made one column.
try std.testing.expectEqual(before + 2, p.ncol);
// ...and the chord consumed the selection exactly as it does with one.
- try std.testing.expectEqual(@as(u8, 0), p.panes[0].?.nsel);
+ try std.testing.expectEqual(@as(u8, 0), p.panes[0].?.body.nsel);
}