diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-28 17:56:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-28 21:05:25 -0300 |
| commit | 96f840a055651b88eb1191772bc4b10fcbbb60ce (patch) | |
| tree | 55ccd6e05fc1f7419f1fef3fb2c7116b556c85d2 /src/exec.zig | |
| parent | f8c27dbfa9afca327189181a668f2191b499bea5 (diff) | |
| download | pardes-96f840a055651b88eb1191772bc4b10fcbbb60ce.tar.gz pardes-96f840a055651b88eb1191772bc4b10fcbbb60ce.zip | |
layout: a new pane takes rows only from the pane it splits, as acme's coladd does: no column shared out evenly after a placement (only a pane the rounding squeezed, and the new one, lifted to their minimum, restoreMinimaFrom), none when there is no pane to halve (takeRoom: its minimum from the panes with the most to spare), none after a refused pane (it held no weight; absorbVWeight gives back and snaps nothing for it), none after Newcol or the finder column (only a pane whose tag now wraps past its rows is lifted, squeezed); a pane dragged short keeps its rows through all of them; test: a pane made from the middle between two short ones, then Newcol
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/exec.zig b/src/exec.zig index 5b0eb204..c14a648c 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -457,12 +457,9 @@ fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) ?*Pane { fn refusedPlacement(p: *Pardes, id: usize) bool { if (!p.unplaced.isSet(id)) return false; p.unplaced.unset(id); + // It held no weight (placeNew put every pane's rows back as they + // were): nothing else moves, a pane dragged short included. p.removePane(id, null) catch {}; - // As sync does for a refused pane: none it squeezed stays under its - // minimum. - for (0..p.ncol) |c| if (!layout.columnAtMinimums(p, c)) { - _ = layout.shareColumn(p, c); - }; return true; } @@ -1208,6 +1205,7 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan const asked = if (p.exec_column != null) null else origin; layout.compute(p); const before = p.rects; + const before_min = layout.minima(p); switch (p.settings.placement) { .acme => switch (kind) { // New: the bottom half of the last pane in its own column @@ -1233,17 +1231,22 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan for (p.col_panes[f.col][0..p.col_n[f.col]]) |k| p.rects[k] = before[k]; layout.snapColWeights(p, f.col); if (!layout.splitTallest(p, f.col, id) or !layout.placedRoomy(p, id, &before)) { - if (layout.findPane(p, id) == null) layout.insert(p, f.col, p.col_n[f.col], id); - // No pane to halve, but the column holds every pane's minimum - // with the new one's: the rows are shared out again, so what is - // refused is only what the documented arithmetic cannot hold. + if (layout.findPane(p, id) != null) { + layout.removePane(p, id); + for (p.col_panes[f.col][0..p.col_n[f.col]]) |k| p.rects[k] = before[k]; + layout.snapColWeights(p, f.col); + } + // No pane to halve, but the column has the rows for the new + // one's minimum above the others': it takes them from those with + // the most to spare (a pane dragged short keeps its own), so + // what is refused is only what the documented arithmetic cannot + // hold. // +Errors and 9P's pane/new go wherever there is room, last // column first, as acme takes rows from a window that has them // before saying there are none; with none, +Errors's maker says // the text some other way (appendErrors), and pane/new is // refused. - if (layout.shareColumn(p, f.col)) {} else if (kind == .errors or kind == .fs) { - layout.removePane(p, id); + if (layout.takeRoom(p, f.col, id)) {} else if (kind == .errors or kind == .fs) { var c = p.ncol; while (c > 0) { c -= 1; @@ -1259,14 +1262,15 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan } else { layout.insert(p, f.col, p.col_n[f.col], id); p.unplaced.set(id); + // Refused holding no weight: its column's rows come + // back as they were. + p.panes[id].?.vweight = 0; // No pane anywhere can give it rows: pane/new is refused. - if (kind == .fs) { - p.panes[id].?.vweight = 0; - p.reportError(from, "placement", error.NoPaneRoom); - } + if (kind == .fs) p.reportError(from, "placement", error.NoPaneRoom); return; } } else { + layout.insert(p, f.col, p.col_n[f.col], id); // Refused, it closes at the step's end holding no weight, so // its column's rows come back as they were, none rounded off. p.panes[id].?.vweight = 0; @@ -1276,11 +1280,14 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan } } }; - // Placed: no pane of its column left under its minimum by the rows - // rounding or an earlier placement gave it; shared out again if so. - if (layout.findPane(p, id)) |f| if (!layout.columnAtMinimums(p, f.col)) { - _ = layout.shareColumn(p, f.col); - }; + // Placed: no pane the rows' rounding took under its minimum stays + // there. Only those: a pane dragged short before keeps its rows, and + // the others keep theirs, as acme's coladd moves only the window it + // splits (cols.c:41-108). The new pane had nothing to keep: it is + // lifted to its minimum too. + var settled = before; + settled[id].h = std.math.maxInt(u16); + layout.restoreMinimaFrom(p, &settled, &before_min); if (kind == .command) return; tagline.exitHeader(p); p.active = id; |
