summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/exec.zig b/src/exec.zig
index c14a648c..af312c45 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -409,13 +409,24 @@ pub fn spawnTty(p: *Pardes, from: usize) ?*Pane {
}
pub fn spawnV9fsTty(p: *Pardes, from: usize) void {
- if (comptime !hosted or @import("builtin").os.tag != .linux)
+ if (comptime !hosted) return p.reportError(from, "Tty9p", error.LinuxRequired);
+ // The session's host's and its 9P server's: a replica, of another
+ // build too (a Linux client of a FreeBSD session), has their answers.
+ if (!pardes.tape.authority(onLinux, .{}))
return p.reportError(from, "Tty9p", error.LinuxRequired);
- if (p.fs.socket_path.len == 0)
+ if (!pardes.tape.authority(servesSocket, .{p}))
return p.reportError(from, "Tty9p", error.SessionSocketRequired);
_ = spawnTtyWithMount(p, from, true);
}
+fn onLinux() bool {
+ return @import("builtin").os.tag == .linux;
+}
+
+fn servesSocket(p: *Pardes) bool {
+ return p.fs.socket_path.len != 0;
+}
+
fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) ?*Pane {
// No pane asking (an empty window's tag): the session's directory, as
// New's scratch is.
@@ -483,10 +494,14 @@ pub fn isFile(path: []const u8) bool {
/// What `path` is on this host, null when it is not there; the turn out
/// while it asks (it may be inside a mount this editor serves).
pub fn kindOf(path: []const u8) ?std.Io.File.Kind {
+ // A freestanding build has no host to ask.
+ if (comptime !pardes.hosted) return null;
var buf: [4096]u8 = undefined;
const z = std.fmt.bufPrintSentinel(&buf, "{s}", .{path}, 0) catch return null;
- pardes.turn.yield();
- defer pardes.turn.back();
+ return pardes.tape.site(.kind, null, kindHost, .{z});
+}
+
+fn kindHost(z: [:0]const u8) ?std.Io.File.Kind {
const stat = @import("fs.zig").statPath(std.Io.Threaded.global_single_threaded.io(), z, .{}) catch return null;
return stat.kind;
}
@@ -1005,7 +1020,7 @@ pub fn applyStartupConfig(p: *Pardes) void {
/// setting lines: a command in it (`Newcol`) is the session's start, and
/// would not be right twice.
pub fn reapplyInitFile(p: *Pardes, path: []const u8, text: []const u8) void {
- const init_path = p.opts.startup_config_path orelse return;
+ const init_path = p.startupPath() orelse return;
if (!std.mem.eql(u8, init_path, path)) return;
applyInitText(p, text, true);
}
@@ -1029,7 +1044,7 @@ fn applyInitText(p: *Pardes, text: []const u8, settings_only: bool) void {
if (settings_only and setting == null and std.meta.stringToEnum(Builtin, word[0 .. std.mem.indexOfAny(u8, word, " \t+") orelse word.len]) != null) continue;
// One init file serves the window and the terminal: a setting only
// the other has (Font, GripWidth in a terminal) is no failure here.
- if (setting) |s| if (!s.enabled(builtins.capabilities)) continue;
+ if (setting) |s| if (!s.enabled(builtins.viewCapabilities(p))) continue;
const failures = p.fs.failures;
const known = executeBuiltinLine(p, p.active, line);
if (known and p.fs.failures == failures) continue;
@@ -1053,6 +1068,12 @@ pub fn runBuiltin(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ?[]co
/// `runBuiltin` saying whether a gesture on the pane's body made it.
pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ?[]const u8, from_body: bool) void {
if (!normal.multiOnce(p)) return; // a builtin is per-keystroke, never per-cursor
+ // A window's own word in a terminal's view (Fonts, Lift): said, as a
+ // word a build lacks is, and never run.
+ if (!builtins.registry.here(p, b)) {
+ var said: [96]u8 = undefined;
+ return p.reportFailure(id, std.fmt.bufPrint(&said, "{s} is GUI-only, invalid here", .{@tagName(b)}) catch "GUI-only, invalid here");
+ }
// No pane at all (the window Delcol emptied): a word runs all the same,
// with a stand-in that is no pane (New, Newcol, Exit are what make sense).
const pane = p.panes[id] orelse (if (builtins.registry.scope(b) == .session or p.anyPane() == null) p.standIn() orelse return else return);
@@ -1116,7 +1137,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]
}
if (comptime pardes.hosted) {
var why: [320]u8 = undefined;
- if (@import("host_io.zig").Shell.refusal(want[0..@min(want.len, 200)], &why)) |refused| {
+ if (pardes.tape.value(.shell, @import("host_io.zig").Shell.refusal, .{ want[0..@min(want.len, 200)], &why })) |refused| {
var text: [340]u8 = undefined;
return p.reportFailure(p.active, std.fmt.bufPrint(&text, "Shell: {s}", .{refused}) catch "Shell: no such shell");
}
@@ -1161,10 +1182,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]
for (p.panes, 0..) |slot, id| {
p.surface.body_layers[id].rows = 0;
const pane = slot orelse continue;
- pane.body_rows = 0;
- pane.body_visible_rows = 0;
- pane.context_row_limit = null;
- pane.wrap_n = 0;
+ pane.geometry_key = 0;
}
p.abandonPanelAnimations();
}