diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 19:16:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 3189900c13b98298776d0da8dcbcb4e0d88858cf (patch) | |
| tree | a4bc0687586a108efe655c9dc9d255ef15260fa6 /src/layout.zig | |
| parent | 9a256d34ebca317e3007adf71c2b94016059d4a3 (diff) | |
| download | pardes-3189900c13b98298776d0da8dcbcb4e0d88858cf.tar.gz pardes-3189900c13b98298776d0da8dcbcb4e0d88858cf.zip | |
Joincol is refused, as Newcol is, when the joined column cannot give each pane its tag and 2 rows
Joincol moved every pane of the keyboard's column into the next one
whether they fit or not. Two columns of two panes in a 12-row window
became one column of four, wanting 12 rows where 10 were free, a layout
that `size` then refused as it stood. Joincol now tries the join in place
first (layout.joinFits: the panes and width moved, minimaFit asked,
everything put back, nothing dropped or logged). A join that does not
fit is refused, "Joincol: no space: the joined column cannot give each
pane its tag and 2 rows".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/layout.zig')
| -rw-r--r-- | src/layout.zig | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/layout.zig b/src/layout.zig index 4aebcf28..a2211dfd 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -360,13 +360,38 @@ pub fn noteColumn(p: *Pardes, what: []const u8, serial: u32) void { pub fn joinCol(p: *Pardes, c: usize) void { if (c + 1 >= p.ncol) return; const dst = c + 1; + joinPanes(p, c, dst); + dropColumn(p, c); +} + +/// Whether column `c` joined into the one on its right leaves every pane +/// its tag and 2 rows (minimaFit), tried in place and undone: nothing is +/// dropped or logged for a join that does not fit. +pub fn joinFits(p: *Pardes, c: usize) bool { + if (c + 1 >= p.ncol) return true; + const dst = c + 1; + const n = p.col_n[c]; + const had = p.col_n[dst]; + const weights = .{ p.col_weight[c], p.col_weight[dst] }; + const panes_c = p.col_panes[c]; + joinPanes(p, c, dst); + const fits = minimaFit(p); + p.col_n[dst] = had; + p.col_n[c] = n; + p.col_panes[c] = panes_c; + p.col_weight[c] = weights[0]; + p.col_weight[dst] = weights[1]; + compute(p); + return fits; +} + +fn joinPanes(p: *Pardes, c: usize, dst: usize) void { for (0..p.col_n[c]) |k| p.col_panes[dst][p.col_n[dst] + k] = p.col_panes[c][k]; p.col_n[dst] += p.col_n[c]; p.col_n[c] = 0; // The width goes right, where the panes went. p.col_weight[dst] +|= p.col_weight[c]; p.col_weight[c] = 0; - dropColumn(p, c); } /// Put new pane `id` in column `c` as acme's makenewwindow does |
