summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 19:53:53 -0300
committerGabriel Schneider <[email protected]>2026-11-05 22:03:21 -0300
commit12cb0a704075dea2512f77582635376fe967dee6 (patch)
tree0f498bf581e3f8ece31f8a5eaa06accba7aa7415 /src/mouse.zig
parent1a1ce29051ea6aa3be4754074f6a00b905d6b208 (diff)
downloadpardes-12cb0a704075dea2512f77582635376fe967dee6.tar.gz
pardes-12cb0a704075dea2512f77582635376fe967dee6.zip
split pardes.zig by noun, layout: the session's columns and the rows its chrome takes move into src/layout.zig: newColumn, setActiveColumn, activeColumn, noteTyped, newScratchIn, keyboardColumn, removeColumn, besideColumn, topBarHeight, columnBarHeight, wantedTagRows, bodyTop, tagTop, tagCapacity and reprojectTagHit; the session keeps four as declaration aliases (topBarHeight and bodyTop, called from everywhere; tagTop and setActiveColumn, which Store.zig and Handover.zig call, so the persistence agent's files are untouched), the rest are layout.x(p, ...) in their callers (draw.zig, mouse.zig, ninep/cols.zig, tagline.zig and seven more; gui.zig, whose locals are named layout, through pardes.layout); layout's own placement helper bodyTop, a pane's top past its tag as heights go, is bodyFrom now, the name going to the session's; tests moved with them, by name: a new column takes width only from the column that created it; Newcol refuses an unsplittable restored weight before spawning; repeated non-dyadic column splits preserve every unrelated boundary; dragging a column's only pane to another leaves that column in place, empty; tiny screens keep pane space before adding a column tag; a pure move, no field touched, a dump and the wire as they were; gates: tui core-test 960/960, behaviour-test 238/238, pane-test 171/172 (1 skipped), snap all 108 scripts ok, gui unit-test 1518/1519 (1 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 5c315b4e..365ed560 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -103,7 +103,7 @@ fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?s
const focused = p.header_focus and p.header_column == column;
const text = edit.flatSurface(p, t) catch return null;
const base = if (column != null) p.topBarHeight() else 0;
- const rows = if (column != null) p.columnBarHeight() else p.topBarHeight();
+ const rows = if (column != null) layout.columnBarHeight(p) else p.topBarHeight();
const row: u16 = if (clamp) @min(mrow -| base, rows -| 1) else mrow -| base;
const top: usize = if (focused) p.header_top else 0;
const lines = modal.lineCount(text);
@@ -230,7 +230,7 @@ pub const ChromeTarget = struct { col: u16, row: u16 };
/// on the cell, a pane's grip, a column's handle or a seam; then a cell
/// away, any of a pane's tag, a handle or a seam.
pub fn chromeTarget(p: *const Pardes, col: u16, row: u16) ?ChromeTarget {
- if (row < p.topBarHeight() + p.columnBarHeight()) return .{ .col = col, .row = row };
+ if (row < p.topBarHeight() + layout.columnBarHeight(p)) return .{ .col = col, .row = row };
for ([_]u16{ 0, 1 }) |slack| {
for (p.panes, 0..) |slot, id| {
const pane = slot orelse continue;
@@ -510,7 +510,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
const previous_hit = p.pointer_body_hit;
p.pointer_body_hit = m.body_hit;
const previous_tag_hit = p.pointer_tag_hit;
- p.pointer_tag_hit = if (m.tag_hit) |point| p.reprojectTagHit(point) else null;
+ p.pointer_tag_hit = if (m.tag_hit) |point| layout.reprojectTagHit(p, point) else null;
if (m.tag_hit != null and p.pointer_tag_hit == null and m.kind == .press) return;
if (m.tag_hit == null and (m.kind == .drag or m.kind == .release) and (p.drag == .select or p.header_drag or p.header_sweep != null)) {
if (previous_tag_hit) |previous| {
@@ -592,7 +592,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
return;
}
}
- if (mrow >= p.topBarHeight() and mrow < p.topBarHeight() + p.columnBarHeight() and m.kind == .press) {
+ if (mrow >= p.topBarHeight() and mrow < p.topBarHeight() + layout.columnBarHeight(p) and m.kind == .press) {
for (0..p.ncol) |column| {
if (mcol < p.col_x[column] or mcol >= p.col_x[column] + @min(config.GUTTER, p.col_w[column])) continue;
if (m.button == config.select_button) {
@@ -617,7 +617,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
if (m.kind == .release) p.header_drag = false;
return;
}
- if (mrow < p.topBarHeight() + p.columnBarHeight() and m.kind == .press and
+ if (mrow < p.topBarHeight() + layout.columnBarHeight(p) and m.kind == .press and
(m.button == config.select_button or m.button == config.exec_button or m.button == config.look_button))
{
if (m.button == config.select_button) if (p.panes[p.active]) |pane| {
@@ -777,7 +777,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
const on_tag = mrow >= tag_y and mrow < tag_y + pane.tag_rows;
if (on_tag and mcol < r.x + TAG_TEXT_INSET) return;
p.active = id;
- p.noteTyped(); // acme's button 1 sets activecol (acme.c:659)
+ layout.noteTyped(p); // acme's button 1 sets activecol (acme.c:659)
pane.closePrompt();
const pointed = edit.pointerTextSelection(p, id, mcol, mrow, m.body_hit, p.pointer_tag_hit) orelse return;
pane.clearPointerSelection(sel_slot);