summaryrefslogtreecommitdiff
path: root/src/Core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:41:40 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit65612a1cc13dd2a7e866f88176dbf6db5dd83467 (patch)
treed2b6173b9650532ff8fa8b489ca7506b75d93cbd /src/Core.zig
parent797e1b05324a8de7217b7e483496f44c1e7bcdbd (diff)
downloadpardes-65612a1cc13dd2a7e866f88176dbf6db5dd83467.tar.gz
pardes-65612a1cc13dd2a7e866f88176dbf6db5dd83467.zip
plumber: Plan 9's plumber in the core, its language and its files (docs/next-plumber.md, phase 1): src/Plumb.zig owns the rules, kept as their text (Core.plumber, digested and dumped; `include basic`'s, the embedded src/plumbing, until any are written, so a session and a dump from before it start with the defaults) and parsed again for each message, and a matcher over them read from rules.c and match.c: the message's pack and unpack (plumbunpackpartial's whole, short of its data, malformed), packed attributes read and quoted rc's way, rule sets of `object verb arg` lines, variables, include (basic, the configuration directory's, an absolute path, through the taped read site), rc's quoting and `$` expansion at parse and at match, every parse refusal in rules.c's words with its file and line, `$1`-`$9` refused in words (the regular expressions have no capture groups), `matches` over regexp.zig whole (`^(...)$`) or around a click counted in runes with Pike's two patterns, `is`, `set` rewriting for good, `add`, `delete` failing on an attribute not there as match.c's code does, `isfile` and `isdir` finding a name as Look does (past its place, the message's directory, a look's jump list's, Incl's) at the taped resolve sites, once a send; dispose to a port pardes reads (edit: opened as a look opens it, at addr=; web: the host's link opener; a loaded kind by its name), to a rule set's start or client run as exec runs a line (a builtin in place, else a command pane in the message's wdir: Core.exec_dir, exec.runCommand's reuse skipping the sender), or Plan 9's words for what went nowhere; rules print back in the order they were written, a variable where it was set, so a printed text reads back the same; plumb/rules (a write adds rule sets as each is whole, the rest at the close, `>` replaces them, one writer at a time) and plumb/send (a message put together across writes) in the tree, with fs-help's line, the reference's section and tree, and the fstree test's paths; nothing calls the plumber from Look yet; test: Plumb.zig's eleven (every parse error, print and read back, plan9port's basic less its submatch rule sets, its ¡-￿ classes UTF-8's bytes, whole and click matches with horse.gift, quoting, a set's rewrite kept, delete of an absent attribute, dst filtering, isfile and isdir, dispose, a dump keeping the rules), test/behaviour/plumber.zig's two through the tree (Session records the link a host would open); the root's listings in tree.zig's and the process tests gain plumb, and the README folds a blank line to stay 45 lines; the changelog says so
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/Core.zig')
-rw-r--r--src/Core.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Core.zig b/src/Core.zig
index c5187616..9a6e80d4 100644
--- a/src/Core.zig
+++ b/src/Core.zig
@@ -39,6 +39,7 @@ const Rect = pardes.Rect;
const Registers = pardes.Registers;
const RowMetrics = pardes.RowMetrics;
const Store = @import("Store.zig");
+const Plumb = @import("Plumb.zig");
const Db = pardes.Db;
const Stream = pardes.Stream;
const Surface = pardes.Surface;
@@ -211,6 +212,9 @@ incl: std.ArrayList([]u8) = .empty,
/// Plumb's rules, the user's, tried in order before the built-in ones
/// (look.resolve), the first to match taking the look. Kept in a dump.
plumb: std.ArrayList([]u8) = .empty,
+/// The plumber's rules (Plumb.zig): plumb/rules and plumb/send's, the
+/// defaults (`include basic`) until something writes others. Kept in a dump.
+plumber: Plumb = .{},
/// Zerox's groups of panes on one buffer (File.syncTwins), and the id
/// the next takes.
twin_groups: std.ArrayList(pardes.panes.File.TwinGroup) = .empty,
@@ -227,6 +231,9 @@ next_serial: u32 = 0,
/// The column whose tag the running command came from, while it runs:
/// the column acme's commands take from their Text's col.
exec_column: ?usize = null,
+/// The directory a `plumb start`'s command runs in, while it runs
+/// (Plumb.run): the message's wdir, which no pane need have.
+exec_dir: ?[]const u8 = null,
/// Panes made this step that found no room in their column
/// (layout.placeNew): closed at the step's end, once whatever made them
/// is done with them.
@@ -759,6 +766,7 @@ pub fn deinit(p: *Pardes) void {
p.incl.deinit(p.gpa);
for (p.plumb.items) |rule| p.gpa.free(rule);
p.plumb.deinit(p.gpa);
+ p.plumber.deinit(p.gpa);
for (p.twin_groups.items) |group| p.gpa.free(group.path);
p.twin_groups.deinit(p.gpa);
p.fs.batch.bytes.deinit(p.gpa);
@@ -1703,6 +1711,7 @@ fn processDir(buf: *[limits.host_path_cap]u8) ?[]const u8 {
/// The directory a word run from pane `id`'s text or tag runs in, or,
/// from a header, the session's.
pub fn execDir(p: *Pardes, id: usize) []const u8 {
+ if (p.exec_dir) |dir| return dir;
if (p.exec_header) return p.sessionDir();
return paneDir(p.panes[id] orelse return p.sessionDir());
}