summaryrefslogtreecommitdiff
path: root/src/body_layer.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/body_layer.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/body_layer.zig')
-rw-r--r--src/body_layer.zig44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/body_layer.zig b/src/body_layer.zig
index 6bac7018..71529326 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -132,7 +132,7 @@ test "compact context borders separate source gaps and preserve multiline header
fn paintTerminalSelection(p: *Pardes, pane: *Pane, r: Rect, rows: []const Pane.PointerRow, bg: [3]u8, fg: ?[3]u8) void {
const body = bodyText(p, p.scratch.allocator(), pane) catch return;
- const raw = pane.mode == .tty;
+ const raw = pane.body.mode == .tty;
const tx = r.x + config.GUTTER;
const width = r.w -| config.GUTTER;
const body_y = p.bodyTop(r);
@@ -366,14 +366,14 @@ pub fn renderBody(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id
paintPointerSelection(p, pane, r, tx, tw, tag_y, body_y, sl, sel_btn[b], th.sel_fg);
}
// modal line selection (helix `x`): whole body rows, normal mode only
- if ((pane.mode == .normal or modal_hover) and pane.msel.active) {
- const hover_only = modal_hover and pane.mode != .normal;
+ if ((pane.body.mode == .normal or modal_hover) and pane.body.msel.active) {
+ const hover_only = modal_hover and pane.body.mode != .normal;
const modal_bg = if (hover_only)
colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg))
else
th.sel_bg;
- const lo = @min(pane.msel.r0, pane.msel.r1);
- const hi = @max(pane.msel.r0, pane.msel.r1);
+ const lo = @min(pane.body.msel.r0, pane.body.msel.r1);
+ const hi = @max(pane.body.msel.r0, pane.body.msel.r1);
var row: u16 = BOX_H; // never paint the tag row
while (row < body_bottom) : (row += 1) {
const ar = pane.wrapAt(@as(i32, row) - @as(i32, BOX_H)).line;
@@ -388,23 +388,23 @@ pub fn renderBody(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id
}
}
const preview = normal.selRegexArmed(pane) != null;
- const show_prim = (pane.mode == .normal and pane.vsel.active) or preview or
- (modal_hover and pane.vsel.active);
- const show_extra = pane.mode != .tty and pane.nsel > 0;
+ const show_prim = (pane.body.mode == .normal and pane.body.vsel.active) or preview or
+ (modal_hover and pane.body.vsel.active);
+ const show_extra = pane.body.mode != .tty and pane.body.nsel > 0;
if (show_prim or show_extra) {
const vpfx: i32 = if (pane.file != null) panes.File.gutterWidth(pane) else 0;
var si: usize = 0;
- while (si <= pane.nsel) : (si += 1) {
- const primary = si == pane.nsel;
+ while (si <= pane.body.nsel) : (si += 1) {
+ const primary = si == pane.body.nsel;
if (if (primary) !show_prim else !show_extra) continue;
- const sr = if (primary) Pane.SelRange{
- .row = pane.cur_row,
- .col = pane.cur_col,
- .arow = if (pane.vsel.active) pane.vsel.row else pane.cur_row,
- .acol = if (pane.vsel.active) pane.vsel.col else pane.cur_col,
- } else pane.sels[si];
+ const sr = if (primary) panes.Text.SelRange{
+ .row = pane.body.cur_row,
+ .col = pane.body.cur_col,
+ .arow = if (pane.body.vsel.active) pane.body.vsel.row else pane.body.cur_row,
+ .acol = if (pane.body.vsel.active) pane.body.vsel.col else pane.body.cur_col,
+ } else pane.body.sels[si];
const bnd = edit.cellBounds(sr);
- const hover_only = primary and modal_hover and pane.mode != .normal and !preview;
+ const hover_only = primary and modal_hover and pane.body.mode != .normal and !preview;
const bg = if (hover_only)
colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg))
else if (primary)
@@ -462,18 +462,18 @@ pub fn renderBody(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id
// cursor: tracks the shell cursor until pinned by a click or a key
// (the tag cursor above wins while the tag is focused)
if (active and !pane.tag_edit) {
- if (pane.mode != .tty) {
+ if (pane.body.mode != .tty) {
const cur = panes.Terminal.gridCursor(pane);
const goff = panes.Terminal.gridOffset(pane);
- const crow = if (pane.cur_pinned) pane.cur_row else pane.surfRow(@as(i32, @intCast(cur.y)) + goff);
- const ccol = if (pane.cur_pinned) pane.cur_col else @as(i32, @intCast(cur.x));
+ const crow = if (pane.body.cur_pinned) pane.body.cur_row else pane.surfRow(@as(i32, @intCast(cur.y)) + goff);
+ const ccol = if (pane.body.cur_pinned) pane.body.cur_col else @as(i32, @intCast(cur.x));
const cwp = pane.wrapRow(crow, ccol);
const prow = cwp.row + @as(i32, BOX_H);
// Files store source-byte columns; the Surface stores display
// cells, so account for every expanded tab before the cursor.
const cx = if (pane.file != null)
@as(i32, panes.File.gutterWidth(pane)) + panes.File.displayOffset(pane, crow, cwp.at, ccol)
- else if (pane.cur_pinned)
+ else if (pane.body.cur_pinned)
panes.File.lineDisplayOffset(
modal.lineSlice(body, @intCast(@max(0, cwp.row))),
@intCast(@max(0, cwp.at)),
@@ -482,7 +482,7 @@ pub fn renderBody(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id
else
ccol;
if (prow >= BOX_H and cx >= 0 and prow < body_bottom and cx < tw)
- s.cursor = .{ .x = tx + @as(u16, @intCast(cx)), .y = body_y + @as(u16, @intCast(prow - BOX_H)), .bar = pane.mode == .insert };
+ s.cursor = .{ .x = tx + @as(u16, @intCast(cx)), .y = body_y + @as(u16, @intCast(prow - BOX_H)), .bar = pane.body.mode == .insert };
} else if (panes.Terminal.visibleCursor(pane)) |cur| {
if (cur.y + BOX_H < body_bottom and cur.x < tw)
s.cursor = .{ .x = tx + cur.x, .y = body_y + cur.y };