summaryrefslogtreecommitdiff
path: root/src/detached/server.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/detached/server.zig')
-rw-r--r--src/detached/server.zig22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/detached/server.zig b/src/detached/server.zig
index 8f45135a..13cf4488 100644
--- a/src/detached/server.zig
+++ b/src/detached/server.zig
@@ -373,6 +373,7 @@ pub const Session = struct {
.pty_signal = ptySignal,
.close_pty = closePaneShell,
.tty_taken = ttyTaken,
+ .fg_name = fgName,
.kill_job = killJob,
.write_file = writeFile,
.write_dump = writeDump,
@@ -544,6 +545,14 @@ pub const Session = struct {
return host_io.ttyTaken(pt.pid, pt.fd);
}
+ fn fgName(ctx: ?*anyopaque, pane: u8, buf: []u8) ?[]const u8 {
+ const s = of(ctx);
+ if (pane >= s.ptys.len) return null;
+ const pt = s.ptys[pane];
+ if (pt.fd < 0) return null;
+ return host_io.foregroundName(pt.pid, pt.fd, buf);
+ }
+
fn killJob(ctx: ?*anyopaque, pane: u8) bool {
const s = of(ctx);
if (pane >= s.ptys.len) return false;
@@ -1076,7 +1085,9 @@ pub const Session = struct {
rows = if (rows == 0) c.rows else @min(rows, c.rows);
}
var regridded = false;
- if (cols != 0 and (cols != s.cols or rows != s.rows)) {
+ // Against the core's size too: a root ctl `size` may have set it
+ // while nobody was attached.
+ if (cols != 0 and (cols != s.cols or rows != s.rows or cols != s.core.screen_w or rows != s.core.screen_h)) {
s.cols = cols;
s.rows = rows;
for (&s.clients) |*c| c.need_full = true;
@@ -1190,11 +1201,20 @@ fn onQuitSignal(_: std.posix.SIG) callconv(.c) void {
if (quit_wake >= 0) _ = libc.send(quit_wake, "q", 1, nosignal);
}
+/// The screen of a detached session no frontend has sized.
+pub const detached_cols = 160;
+pub const detached_rows = 50;
+
pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void {
const gpa = init.gpa;
const allocs = pardes.memory.init(gpa);
defer pardes.memory.deinit();
var options = opts;
+ // No frontend yet, so no size to take: one roomy enough for a script's
+ // panes (80x24 left pane/new refused after a few); `size` sets another,
+ // and an attaching frontend its own.
+ options.cols = detached_cols;
+ options.rows = detached_rows;
options.image_allocator = allocs.image;
options.pdf_allocator = allocs.pdf;
options.tree_sitter_allocator = allocs.tree_sitter;