summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Core.zig4
-rw-r--r--src/Dir.zig4
-rw-r--r--src/Output.zig10
-rw-r--r--src/Query.zig2
-rw-r--r--src/Store.zig3
-rw-r--r--src/addon_test.zig4
-rw-r--r--src/builtins.zig6
-rw-r--r--src/exec.zig130
-rw-r--r--src/keys.zig2
-rw-r--r--src/layout.zig118
-rw-r--r--src/look.zig4
-rw-r--r--src/mini.zig4
-rw-r--r--src/ninep/ctl.zig2
-rw-r--r--src/ninep/pane.zig3
-rw-r--r--src/panes.zig8
-rw-r--r--test/panes.zig2
16 files changed, 153 insertions, 153 deletions
diff --git a/src/Core.zig b/src/Core.zig
index 86916f9e..643ba4ae 100644
--- a/src/Core.zig
+++ b/src/Core.zig
@@ -112,7 +112,7 @@ pub const View = struct {
/// column last typed in (acme.c:487), clicked in with the select button
/// (acme.c:659), dropped into by a grip (acme.c:640), or given a new
/// pane (util.c:467). Where the acme placement puts new panes
- /// (exec.placeNew). A Look click moves the keyboard but not this.
+ /// (layout.placeNew). A Look click moves the keyboard but not this.
active_column: u32 = 0,
/// The live view's frontend (Event.frontend): a window, what it draws and
/// the words it takes (builtins.zig `here`); it starts as
@@ -228,7 +228,7 @@ next_serial: u32 = 0,
/// the column acme's commands take from their Text's col.
exec_column: ?usize = null,
/// Panes made this step that found no room in their column
-/// (exec.placeNew): closed at the step's end, once whatever made them
+/// (layout.placeNew): closed at the step's end, once whatever made them
/// is done with them.
unplaced: std.StaticBitSet(MAX_PANES) = .empty,
/// A look's word search is running (look.lookUnresolved): from a
diff --git a/src/Dir.zig b/src/Dir.zig
index 65e18c1a..337a09be 100644
--- a/src/Dir.zig
+++ b/src/Dir.zig
@@ -9,7 +9,7 @@ const std = @import("std");
const pardes = @import("pardes.zig");
const panes = @import("panes.zig");
const config = @import("config.zig");
-const exec = @import("exec.zig");
+const layout = @import("layout.zig");
const filesystem = @import("fs.zig");
const limits = @import("memory.zig").limits;
const Pardes = pardes.Pardes;
@@ -206,7 +206,7 @@ pub fn look(p: *Pardes, from: usize, dir: []const u8) void {
};
const pane = open(p, free, name, names) catch |err| return p.reportError(from, "look", err);
const failures = p.fs.failures;
- exec.placeNew(p, from, from, free, .doc);
+ layout.placeNew(p, from, from, free, .doc);
// Refused a place: that is the look's one failure.
if (p.fs.failures != failures) return;
fit(p, pane, @max(1, p.view().rects[free].w -| config.GUTTER));
diff --git a/src/Output.zig b/src/Output.zig
index a38245c7..c76e31b1 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -469,7 +469,7 @@ pub fn fillRows(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []con
const free = p.freeSlot() orelse return error.NoPaneSlots;
const np = try open(p, free, dir, from, arg, result_content);
np.file.?.location_rows = result_rows;
- exec.placeNew(p, id, id, free, .doc);
+ layout.placeNew(p, id, id, free, .doc);
p.view().active = id;
if (traits(from).steps) {
pane.search_pane = free;
@@ -640,7 +640,7 @@ pub fn openUnsaved(p: *Pardes, id: usize, content: []u8) void {
const dir = if (pardes.filesystem.localPath(own)) |local| (if (exec.kindOf(local) == .directory) own else p.sessionDir()) else own;
const free = p.freeSlot() orelse return p.gpa.free(content);
_ = open(p, free, dir, .unsaved, "", content) catch |err| return p.reportError(id, "+Unsaved", err);
- exec.placeNew(p, id, id, free, .doc);
+ layout.placeNew(p, id, id, free, .doc);
p.view().active = id;
}
@@ -671,7 +671,7 @@ pub fn openPager(p: *Pardes, from: usize, dir_arg: []const u8) !usize {
pane.file.?.pager = true;
pane.tty_filter = true;
const keyboard = p.view().active;
- exec.placeNew(p, from, null, free, .fs);
+ layout.placeNew(p, from, null, free, .fs);
if (p.unplaced.isSet(free)) return error.NoPaneRoom;
// Shown, not asked for: the keyboard stays where it was, as a command
// pane's does.
@@ -777,7 +777,7 @@ fn openStepped(p: *Pardes, id: usize, from: Origin, content: []u8) !void {
const dir = if (own.len == 0) p.sessionDir() else own;
const free = p.freeSlot() orelse return error.NoPaneSlots;
_ = try open(p, free, dir, from, "", content);
- exec.placeNew(p, id, id, free, .doc);
+ layout.placeNew(p, id, id, free, .doc);
p.view().active = id;
pane.search_pane = free;
pane.search_row = null;
@@ -1004,7 +1004,7 @@ fn openRead(p: *Pardes, id: usize, from: Origin, arg: []const u8, content: []u8)
const dir = p.execDir(id);
const free = p.freeSlot() orelse return error.NoPaneSlots;
_ = try open(p, free, dir, from, arg, content);
- exec.placeNew(p, id, id, free, if (from == .errors) .errors else .doc);
+ layout.placeNew(p, id, id, free, if (from == .errors) .errors else .doc);
p.view().active = free;
}
diff --git a/src/Query.zig b/src/Query.zig
index 301d3334..5a66a0a3 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -322,7 +322,7 @@ fn create(p: *Pardes, owner_id: usize, line: []const u8, source: Source) ?usize
if (!layout.attachFrom(p, owner_id, free, want, owner_id)) {
// An owner too short to give a query pane its rows: placed as any
// new pane is, the one place a search moves another pane.
- exec.placeNew(p, owner_id, owner_id, free, .doc);
+ layout.placeNew(p, owner_id, owner_id, free, .doc);
}
if (with_preview) _ = makePreview(p, free, preview_rows, owner_id);
return free;
diff --git a/src/Store.zig b/src/Store.zig
index 8b8db030..f6e4919f 100644
--- a/src/Store.zig
+++ b/src/Store.zig
@@ -9,7 +9,6 @@ const std = @import("std");
const pardes = @import("pardes.zig");
const dump = @import("dump.zig");
const layout = @import("layout.zig");
-const exec = @import("exec.zig");
const Pardes = pardes.Pardes;
/// This session keeps this many closed panes, the newest.
@@ -210,7 +209,7 @@ pub fn reopen(s: *Store, p: *Pardes, serial: u32, from: usize) bool {
layout.giveBack(p, free, g, place.below, place.rows)
else
false;
- if (!placed) exec.placeNew(p, from, from, free, .doc);
+ if (!placed) layout.placeNew(p, from, from, free, .doc);
if (layout.findPane(p, free) == null) {
p.removePane(free, null) catch |err| p.reportError(from, "reopen", err);
return false;
diff --git a/src/addon_test.zig b/src/addon_test.zig
index 2e673145..025d2e86 100644
--- a/src/addon_test.zig
+++ b/src/addon_test.zig
@@ -155,7 +155,7 @@ fn run(io: std.Io, gpa: std.mem.Allocator, lib: []const u8, script_path: ?[]cons
fn open(p: *Pardes, k: u8, path: ?[]const u8) !usize {
const free = p.freeSlot() orelse return error.NoPaneSlots;
_ = if (path) |at| try Kind.openFile(p, free, k, at) else try Kind.open(p, free, k, null, null);
- pardes.exec.placeNew(p, p.view().active, null, free, .doc);
+ pardes.layout.placeNew(p, p.view().active, null, free, .doc);
p.view().active = free;
drain(p);
return free;
@@ -178,7 +178,7 @@ fn reloaded(p: *Pardes, gpa: std.mem.Allocator, at: usize, out: *std.Io.Writer)
const pane = try p.newDocPane(free);
pane.addon = fresh;
pardes.dump.reviveSlot(p, free, fresh);
- pardes.exec.placeNew(p, p.view().active, null, free, .doc);
+ pardes.layout.placeNew(p, p.view().active, null, free, .doc);
p.view().active = free;
drain(p);
return free;
diff --git a/src/builtins.zig b/src/builtins.zig
index 1356874a..b715bae1 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -987,7 +987,7 @@ pub const Zerox = struct {
if (f.output != null or f.listing != null or f.mini != null) return c.p.reportFailure(c.id, "Zerox: only a file pane takes it");
const free = c.p.freeSlot() orelse return c.p.reportError(c.id, "Zerox", error.NoPaneSlots);
_ = panes.File.zerox(c.p, c.id, free) catch |err| return c.p.reportError(c.id, "Zerox", err);
- exec.placeNew(c.p, c.id, c.id, free, .doc);
+ layout.placeNew(c.p, c.id, c.id, free, .doc);
}
};
@@ -1320,7 +1320,7 @@ pub const Tutor = struct {
pub fn run(c: Ctx) void {
const free = c.p.freeSlot() orelse return c.p.reportError(c.id, "Tutor", error.NoPaneSlots);
_ = panes.openTutorView(c.p, free) catch |err| return c.p.reportError(c.id, "Tutor", err);
- exec.placeNew(c.p, c.id, c.id, free, .doc); // a doc like any other
+ layout.placeNew(c.p, c.id, c.id, free, .doc); // a doc like any other
}
};
@@ -1601,7 +1601,7 @@ pub const Follow = struct {
if (col + 1 < v.ncol) {
c.p.exec_column = col + 1;
defer c.p.exec_column = null;
- exec.placeNew(c.p, c.id, null, free, .scratch);
+ layout.placeNew(c.p, c.id, null, free, .scratch);
if (c.p.unplaced.isSet(free)) return;
} else if (!layout.splitColumn(c.p, last, free, false)) {
c.p.unplaced.set(free);
diff --git a/src/exec.zig b/src/exec.zig
index 93f524cf..d0bee0e9 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -403,7 +403,7 @@ pub fn spawnTty(p: *Pardes, from: usize) ?*Pane {
};
nt.greet = true;
nt.body.mode = .tty;
- placeNew(p, from, from, free, .shell);
+ layout.placeNew(p, from, from, free, .shell);
if (refusedPlacement(p, free)) {
p.reportError(from, "Term", error.NoPaneRoom);
return null;
@@ -411,13 +411,13 @@ pub fn spawnTty(p: *Pardes, from: usize) ?*Pane {
return nt;
}
-/// A pane placeNew found no room for: taken back now, before anything is
+/// A pane layout.placeNew found no room for: taken back now, before anything is
/// logged of it or answered with its serial (it was never announced), so
/// no `new`/`del` pair and no serial a script was told of is left behind.
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
+ // It held no weight (layout.placeNew put every pane's rows back as they
// were): nothing else moves, a pane dragged short included.
p.removePane(id, null) catch |err| p.reportError(id, "open", err);
return true;
@@ -717,7 +717,7 @@ pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usi
/// Runs `line` in a command pane for `from`'s directory: `from` itself if
/// it is one whose command is done, else the directory's command pane that
-/// is done, else a new one, placed as placeNew places a command pane.
+/// is done, else a new one, placed as layout.placeNew places a command pane.
/// A pane reused keeps what it showed: the new command runs below a line
/// naming it, as acme appends to +Errors and never clears it (util.c:213).
fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
@@ -739,7 +739,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
// Not one whose pty a job it left behind still prints to: reusing it
// would hang that job up.
// From a column's tag, only a finished pane in that column is reused,
- // as the new one goes in that column (placeNew).
+ // as the new one goes in that column (layout.placeNew).
// Nor one leased: an open that was answered its serial and is still
// open reads that pane's output, which another client's command must
// not replace; a new pane runs it instead.
@@ -784,7 +784,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
};
pane.command_from = winid(p, src);
echoCommand(p, pane, line);
- placeNew(p, from, from, free, .command);
+ layout.placeNew(p, from, from, free, .command);
if (refusedPlacement(p, free)) {
p.reportError(from, "exec", error.NoPaneRoom);
return null;
@@ -1092,122 +1092,6 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]
look.cancelLookHover(p);
}
-/// What a new pane is, and who asked: each rule places them differently.
-/// `scratch` is New's, `fs` 9P's pane/new, `errors` a +Errors pane.
-pub const NewPane = enum { scratch, fs, shell, doc, command, errors };
-
-/// Put new pane `id` in the layout: every new pane comes through here, as
-/// acme's makenewwindow places it, and every one but a command pane takes
-/// the keyboard. `from` is the pane that asked, `origin` the text it asked
-/// from: null when a column tag, the workspace tag or 9P asked (acme's
-/// t->w == nil).
-pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPane) void {
- const v = p.view();
- // No column left (the last one Delcol'd): a pane made from the workspace
- // tag opens one to go in.
- _ = layout.firstColumn(p);
- const asked = if (p.exec_column != null) null else origin;
- layout.compute(p);
- const before = v.rects;
- const before_min = layout.minima(p);
- switch (kind) {
- // New: the bottom half of the last pane in its own column
- // (look.c:921-923, et->col).
- .scratch => layout.acmePlace(p, p.exec_column orelse columnOf(p, from), null, id),
- // +Errors, a command's output: the last column (util.c:94-98); a
- // command run from a column's tag, that column.
- .command => layout.acmePlace(p, p.exec_column orelse v.ncol - 1, null, id),
- .errors => layout.acmePlace(p, v.ncol - 1, null, id),
- // makenewwindow(nil) for 9P's new (acme.c:877), else (t).
- .fs => layout.acmePlace(p, acmeColumn(p, from), null, id),
- .shell, .doc => layout.acmePlace(p, acmeColumn(p, from), asked, id),
- }
- // No pane is made shorter than its tag and two rows: where the place
- // chosen has not the room, the column's tallest pane gives it, and
- // where none can, the pane is refused, and closed at the step's end
- // (Pardes.unplaced) once whatever made it is done with it.
- if (!layout.placedRoomy(p, id, &before)) if (layout.findPane(p, id)) |f| {
- layout.removePane(p, id);
- for (v.cols[f.col].panes[0..p.view().cols[f.col].n]) |k| v.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.removePane(p, id);
- for (v.cols[f.col].panes[0..p.view().cols[f.col].n]) |k| v.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.takeRoom(p, f.col, id)) {} else if (kind == .errors or kind == .fs) {
- var c = v.ncol;
- while (c > 0) {
- c -= 1;
- if (c == f.col) continue;
- for (v.cols[c].panes[0..p.view().cols[c].n]) |k| v.rects[k] = before[k];
- layout.snapColWeights(p, c);
- if (v.cols[c].n == 0) {
- layout.insert(p, c, 0, id);
- break;
- }
- if (layout.splitTallest(p, c, id) and layout.placedRoomy(p, id, &before)) break;
- if (layout.findPane(p, id) != null) layout.removePane(p, id);
- } else {
- layout.insert(p, f.col, v.cols[f.col].n, 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.reportError(from, "placement", error.NoPaneRoom);
- return;
- }
- } else {
- layout.insert(p, f.col, v.cols[f.col].n, 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;
- p.unplaced.set(id);
- p.reportError(from, "placement", error.NoPaneRoom);
- return;
- }
- }
- };
- // 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);
- v.active = id;
- if (layout.findPane(p, id)) |f| p.setActiveColumn(f.col);
-}
-
-/// acme's makenewwindow column (util.c:456-467): the column a command came
-/// from (its tag's), else the active column, else the keyboard's pane's,
-/// else the asking pane's.
-fn acmeColumn(p: *Pardes, from: usize) usize {
- if (p.exec_column) |c| return c;
- if (layout.activeColumn(p)) |c| return c;
- if (layout.findPane(p, p.view().active)) |f| return f.col;
- return columnOf(p, from);
-}
-
-fn columnOf(p: *Pardes, id: usize) usize {
- return if (layout.findPane(p, id)) |f| f.col else p.view().ncol - 1;
-}
-
// ---- the words addons bring (Kind.Registry's) ----
/// A line whose first word is an addon's: run, and true; false for one
@@ -1237,7 +1121,7 @@ pub fn runWord(p: *Pardes, id: usize, w: *const pardes.Kind.Word, line: []const
p.unplaced.set(free);
return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: {s}", .{ name, made.addon.?.refused.slice() }) catch name);
}
- return placeNew(p, id, id, free, .doc);
+ return layout.placeNew(p, id, id, free, .doc);
}
const kind = p.kinds.kinds[w.kind].nameOf();
const here = if (p.panes[id]) |pane| if (pane.addon) |s| s.live and s.is(kind) else false else false;
diff --git a/src/keys.zig b/src/keys.zig
index c197940e..49ed00c0 100644
--- a/src/keys.zig
+++ b/src/keys.zig
@@ -261,7 +261,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
const nt = p.newShell(free, "") catch |err| return p.reportError(p.view().active, "Term", err);
nt.greet = true;
// From a tag, as a 9P new is: acme's t->w == nil.
- exec.placeNew(p, p.view().active, if (p.view().header != null) null else p.view().active, free, .shell);
+ layout.placeNew(p, p.view().active, if (p.view().header != null) null else p.view().active, free, .shell);
return;
}
for (config.jump_keys) |jk| {
diff --git a/src/layout.zig b/src/layout.zig
index 1d93c993..fca4c846 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -855,6 +855,122 @@ fn blankRows(p: *const Pardes, id: usize) u16 {
return rows -| @as(u16, @intCast(@min(used, rows)));
}
+/// What a new pane is, and who asked: each rule places them differently.
+/// `scratch` is New's, `fs` 9P's pane/new, `errors` a +Errors pane.
+pub const NewPane = enum { scratch, fs, shell, doc, command, errors };
+
+/// Put new pane `id` in the layout: every new pane comes through here, as
+/// acme's makenewwindow places it, and every one but a command pane takes
+/// the keyboard. `from` is the pane that asked, `origin` the text it asked
+/// from: null when a column tag, the workspace tag or 9P asked (acme's
+/// t->w == nil).
+pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPane) void {
+ const v = p.view();
+ // No column left (the last one Delcol'd): a pane made from the workspace
+ // tag opens one to go in.
+ _ = firstColumn(p);
+ const asked = if (p.exec_column != null) null else origin;
+ compute(p);
+ const before = v.rects;
+ const before_min = minima(p);
+ switch (kind) {
+ // New: the bottom half of the last pane in its own column
+ // (look.c:921-923, et->col).
+ .scratch => acmePlace(p, p.exec_column orelse columnOf(p, from), null, id),
+ // +Errors, a command's output: the last column (util.c:94-98); a
+ // command run from a column's tag, that column.
+ .command => acmePlace(p, p.exec_column orelse v.ncol - 1, null, id),
+ .errors => acmePlace(p, v.ncol - 1, null, id),
+ // makenewwindow(nil) for 9P's new (acme.c:877), else (t).
+ .fs => acmePlace(p, acmeColumn(p, from), null, id),
+ .shell, .doc => acmePlace(p, acmeColumn(p, from), asked, id),
+ }
+ // No pane is made shorter than its tag and two rows: where the place
+ // chosen has not the room, the column's tallest pane gives it, and
+ // where none can, the pane is refused, and closed at the step's end
+ // (Pardes.unplaced) once whatever made it is done with it.
+ if (!placedRoomy(p, id, &before)) if (findPane(p, id)) |f| {
+ removePane(p, id);
+ for (v.cols[f.col].panes[0..p.view().cols[f.col].n]) |k| v.rects[k] = before[k];
+ snapColWeights(p, f.col);
+ if (!splitTallest(p, f.col, id) or !placedRoomy(p, id, &before)) {
+ if (findPane(p, id) != null) {
+ removePane(p, id);
+ for (v.cols[f.col].panes[0..p.view().cols[f.col].n]) |k| v.rects[k] = before[k];
+ 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 (takeRoom(p, f.col, id)) {} else if (kind == .errors or kind == .fs) {
+ var c = v.ncol;
+ while (c > 0) {
+ c -= 1;
+ if (c == f.col) continue;
+ for (v.cols[c].panes[0..p.view().cols[c].n]) |k| v.rects[k] = before[k];
+ snapColWeights(p, c);
+ if (v.cols[c].n == 0) {
+ insert(p, c, 0, id);
+ break;
+ }
+ if (splitTallest(p, c, id) and placedRoomy(p, id, &before)) break;
+ if (findPane(p, id) != null) removePane(p, id);
+ } else {
+ insert(p, f.col, v.cols[f.col].n, 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.reportError(from, "placement", error.NoPaneRoom);
+ return;
+ }
+ } else {
+ insert(p, f.col, v.cols[f.col].n, 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;
+ p.unplaced.set(id);
+ p.reportError(from, "placement", error.NoPaneRoom);
+ return;
+ }
+ }
+ };
+ // 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);
+ restoreMinimaFrom(p, &settled, &before_min);
+ if (kind == .command) return;
+ tagline.exitHeader(p);
+ v.active = id;
+ if (findPane(p, id)) |f| p.setActiveColumn(f.col);
+}
+
+/// acme's makenewwindow column (util.c:456-467): the column a command came
+/// from (its tag's), else the active column, else the keyboard's pane's,
+/// else the asking pane's.
+fn acmeColumn(p: *Pardes, from: usize) usize {
+ if (p.exec_column) |c| return c;
+ if (activeColumn(p)) |c| return c;
+ if (findPane(p, p.view().active)) |f| return f.col;
+ return columnOf(p, from);
+}
+
+fn columnOf(p: *Pardes, id: usize) usize {
+ return if (findPane(p, id)) |f| f.col else p.view().ncol - 1;
+}
+
/// Whether column `col` has the width and the weight to halve for a new
/// column beside it.
pub fn canSplitCol(p: *Pardes, col: usize) bool {
@@ -977,7 +1093,7 @@ pub fn splitBelow(p: *Pardes, src_id: usize, nw: *Pane) void {
const cur: u16 = if (!src.isTerminal()) body / 2 else panes.terminal.gridCursor(src).y + 1;
// cap keep so a content-full source still leaves the new pane a tag +
// a few body rows (an Alt-n from a full shell was born 0 rows tall)
- // ...and the source min_body_rows of its own (exec.placeNew), when it
+ // ...and the source min_body_rows of its own (placeNew), when it
// has them: a boot layout splits before any row is laid out.
const least = @min(min_body_rows, body);
const keep = std.math.clamp(cur, least, @max(least, body -| (BOX_H + 3)));
diff --git a/src/look.zig b/src/look.zig
index be102339..d9a850d7 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1634,7 +1634,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
return lookOpenFailed(p, id, target.path, err);
if (target.at.col > 0) nt.body.cur_col = @intCast(target.at.col - 1);
const failures = p.fs.failures;
- exec.placeNew(p, id, id, free, .doc);
+ layout.placeNew(p, id, id, free, .doc);
// Refused a place: that is the look's one failure, not a
// miss of its line too.
if (p.fs.failures != failures) return;
@@ -1679,7 +1679,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
var cut: [miss_path_cap + "…".len]u8 = undefined;
return p.reportFailure(id, said.print("look: {s}: {s}", .{ missText(target.path, &cut), made.addon.?.refused.slice() }));
}
- exec.placeNew(p, id, id, free, .doc);
+ layout.placeNew(p, id, id, free, .doc);
if (target.at.line > 0) lookKind(p, id, free, spotText(target.at, &place), true);
},
}
diff --git a/src/mini.zig b/src/mini.zig
index 14b7d973..a068a812 100644
--- a/src/mini.zig
+++ b/src/mini.zig
@@ -2,7 +2,7 @@
const panes = @import("panes.zig");
const std = @import("std");
const pardes = @import("pardes.zig");
-const exec = @import("exec.zig");
+const layout = @import("layout.zig");
const config = @import("config.zig");
const Pardes = pardes.Pardes;
const modal = @import("modal.zig");
@@ -186,7 +186,7 @@ pub fn open(p: *Pardes, id: usize, argument: []const u8) !void {
.syntax_dirty = false,
};
pane.body.cur_pinned = true;
- exec.placeNew(p, id, id, free, .doc);
+ layout.placeNew(p, id, id, free, .doc);
p.view().active = free;
}
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index dc66663e..699b7833 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1569,7 +1569,7 @@ test "a builtin for one kind of pane is refused on another, and still acts on it
// A picture shown: the core's art words follow the kind's prefix.
const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03");
while (p.nextEffect()) |e| p.perform(e);
- pardes.exec.placeNew(p, 0, 0, id, .doc);
+ pardes.layout.placeNew(p, 0, 0, id, .doc);
_ = try p.render(p.scratch.allocator());
const r = wr(p, Node.of(doc.serial, .ctl), "Mode\n");
try testing.expectEqualStrings("Mode: only a text or terminal pane has modes", r.reply.ename);
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index b77d72d7..bb15b016 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -5,6 +5,7 @@ const std = @import("std");
const pardes = @import("../pardes.zig");
const tagline = @import("../tagline.zig");
const exec = @import("../exec.zig");
+const layout = @import("../layout.zig");
const look = @import("../look.zig");
const panes = @import("../panes.zig");
const modal = @import("../modal.zig");
@@ -927,7 +928,7 @@ pub fn appendErrors(p: *Pardes, id: usize, text: []const u8) ?usize {
p.gpa.free(content);
return null;
};
- exec.placeNew(p, id, id, free, .errors);
+ layout.placeNew(p, id, id, free, .errors);
// No column had room for it (it closes at the step's end): the text is
// logged instead, a msg a line, so it is not lost and nothing fails.
if (p.unplaced.isSet(free)) {
diff --git a/src/panes.zig b/src/panes.zig
index 37db35f6..3bac74ab 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -863,7 +863,7 @@ pub fn newDocPane(p: *Pardes, id: usize) !*Pane {
return pane;
}
-pub fn newScratch(p: *Pardes, from_id: usize, free: usize, kind: exec.NewPane) !*Pane {
+pub fn newScratch(p: *Pardes, from_id: usize, free: usize, kind: layout.NewPane) !*Pane {
// None asking (an empty window): the session's, as pane/new's is.
const src_or = p.panes[from_id];
const content = try p.gpa.dupe(u8, "");
@@ -881,17 +881,17 @@ pub fn newScratch(p: *Pardes, from_id: usize, free: usize, kind: exec.NewPane) !
return np;
}
-/// New: an empty scratch in `from_id`'s directory, placed as exec.placeNew
+/// New: an empty scratch in `from_id`'s directory, placed as layout.placeNew
/// places it.
pub fn newScratchBelow(p: *Pardes, from_id: usize) void {
newScratchFor(p, from_id, .scratch);
}
/// A scratch for New (`.scratch`) or 9P's pane/new (`.fs`).
-pub fn newScratchFor(p: *Pardes, from_id: usize, kind: exec.NewPane) void {
+pub fn newScratchFor(p: *Pardes, from_id: usize, kind: layout.NewPane) void {
const free = p.freeSlot() orelse return p.reportError(from_id, "New", error.NoPaneSlots);
_ = newScratch(p, from_id, free, kind) catch |err| return p.reportError(from_id, "New", err);
- exec.placeNew(p, from_id, from_id, free, kind);
+ layout.placeNew(p, from_id, from_id, free, kind);
}
pub fn freeSlot(p: *Pardes) ?usize {
diff --git a/test/panes.zig b/test/panes.zig
index 740f4897..732a2534 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -2260,7 +2260,7 @@ const ImageTests = struct {
const id = p.freeSlot().?;
const pane = try pardes.Kind.open(p, id, load(p), "/tmp/picture.ppm", "P6\n1 1\n255\n\x01\x02\x03");
while (p.nextEffect()) |e| p.perform(e);
- pardes.exec.placeNew(p, 0, 0, id, .doc);
+ pardes.layout.placeNew(p, 0, 0, id, .doc);
_ = try p.render(p.scratch.allocator());
pane.addon.?.art = .{ .glyph = true, .palette = .terminal, .ascii = false };
try std.testing.expectEqualStrings("img petscii:on palette:terminal ascii:off /tmp/picture.ppm", try pardes.tagline.tagPrefix(p, pane));