summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig72
1 files changed, 2 insertions, 70 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index c7ae6704..2bee1f98 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -538,53 +538,8 @@ fn drainForSavePath(p: *Pardes, buf: []u8) ?[]const u8 {
return if (len) |n| buf[0..n] else null;
}
-fn drainForAttach(p: *Pardes) ?AttachRequest {
- while (p.nextEffect()) |effect| p.perform(effect);
- return p.takeAttach();
-}
-
-test "Attach asks for a session and tears nothing down" {
- if (comptime !can_attach) return;
- const gpa = std.testing.allocator;
- const p = try Pardes.init(gpa, .{ .tty_only = true });
- defer p.deinit();
- while (p.nextEffect()) |_| {}
-
- // Bare means whichever session is there, and that is an EMPTY name rather
- // than an absent request: the frontend still has to go and look.
- try std.testing.expect(p.executeBuiltinLine(0, "Attach"));
- const bare = drainForAttach(p) orelse return error.NoAttachAsked;
- try std.testing.expectEqualStrings("", bare.name);
- try std.testing.expectEqual(@as(u8, 0), bare.pane);
-
- // ...and the named form carries its tail, the way `Theme <name>` does.
- try std.testing.expect(p.executeBuiltinLine(0, "Attach work"));
- const named = drainForAttach(p) orelse return error.NoAttachAsked;
- try std.testing.expectEqualStrings("work", named.name);
- try std.testing.expect(p.takeAttach() == null); // taken once, then gone
-
- // The word only ASKS. A core that tore itself down here could not be handed
- // back intact when the connect fails, and that is the entire guarantee.
- try std.testing.expect(!p.quit);
- try std.testing.expect(p.panes[0] != null);
-}
-
-test "Attach in a detached session: bare is wrong #args, a name no session has says so, and nothing is asked" {
- if (comptime !can_attach) return;
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .detached_session = true });
- defer p.deinit();
- while (p.nextEffect()) |_| {}
- const pane = p.panes[0].?;
- try std.testing.expect(p.executeBuiltinLine(0, "Attach"));
- try std.testing.expect(drainForAttach(p) == null);
- try std.testing.expectStringStartsWith(pane.msg[0..pane.msg_len], "wrong #args");
- try std.testing.expect(p.executeBuiltinLine(0, "Attach zz-no-such-session-qq"));
- try std.testing.expect(drainForAttach(p) == null);
- try std.testing.expectEqualStrings("Attach: zz-no-such-session-qq: no such session", pane.msg[0..pane.msg_len]);
-}
-
-test "Detach asks the frontend to leave, and says so when there is nothing to leave" {
- if (comptime !can_attach) return; // compiled out where nothing polls `takeAttach` — see `can_attach`
+test "Detach asks the host to let its terminal go, and says so when there is nothing to leave" {
+ if (comptime !can_attach) return; // the word is compiled out elsewhere: see `can_attach`
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true });
defer p.deinit();
@@ -3753,10 +3708,6 @@ pub const Event = union(enum) {
tick,
};
-pub const attach_name_max = 256;
-
-pub const AttachRequest = struct { pane: u8, name: []const u8 };
-
pub const PendingWrite = struct { bytes: []u8, off: usize = 0 };
/// `command` is Kill's: SIGTERM to the terminal's foreground job, and never
@@ -3807,7 +3758,6 @@ pub const Effect = union(enum) {
/// Write the build-time theme ring below the per-user config directory.
/// The pane receives the completion/error message from the native host.
dump_themes: struct { pane: u8 },
- attach: struct { pane: u8, name: Buf(attach_name_max) },
detach: struct { pane: u8 },
quit,
@@ -4387,9 +4337,6 @@ pub const Options = struct {
/// window opens one as big as that, Handover.zig).
geometry: ?[]const u8 = null,
nested: bool = false,
- /// The core of a `--detach` session (detached/server.zig): it has no
- /// terminal of its own, so Attach there is refused with why.
- detached_session: bool = false,
startup_config: ?[]const u8 = null,
ninep_name: []const u8 = "",
ninep_tcp: ?[]const u8 = null,
@@ -4738,8 +4685,6 @@ pub const Pardes = struct {
/// shell consumes it via takeRestore each frame (restore contents stay host-fed)
restore_req: ?[]const u8 = null,
restore_buf: [1024]u8 = undefined,
- attach_req: ?AttachRequest = null,
- attach_buf: [attach_name_max]u8 = undefined,
surface: Surface = .{},
/// per-update scratch (paneCursorLines, selection text); reset each update
@@ -5088,14 +5033,6 @@ pub const Pardes = struct {
return r;
}
- /// the shell polls this each frame beside takeRestore: a pending Attach's
- /// session and reporting pane, or null
- pub fn takeAttach(p: *Pardes) ?AttachRequest {
- const a = p.attach_req;
- p.attach_req = null;
- return a;
- }
-
/// The workspace tag's height: one row while the setting keeps it, as
/// acme's row tag is, zero once a native shell takes its commands over.
/// Layout and hit testing read this rather than the constant, the way
@@ -5981,11 +5918,6 @@ pub const Pardes = struct {
},
.theme_file => |t| if (v.watch_theme) |f| f(p.host.ctx, t.generation, t.on),
.dump_themes => |d| if (v.dump_themes) |f| f(p.host.ctx, d.pane),
- .attach => |a| {
- const name = a.name.slice();
- @memcpy(p.attach_buf[0..name.len], name);
- p.attach_req = .{ .pane = a.pane, .name = p.attach_buf[0..name.len] };
- },
.detach => |d| if (v.detach) |f|
f(p.host.ctx)
else