summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 2b1fae61..d7f35ed9 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -2868,7 +2868,9 @@ test "Pet command is SDL-only optional and validates its argument" {
defer p.deinit();
try std.testing.expectEqual(.off, p.settings.pet);
if (comptime platform != .gui) {
- try std.testing.expect(std.meta.stringToEnum(builtins.registry.Builtin(), "Pet") == null);
+ // A terminal's view has the word and takes it not.
+ try std.testing.expect(p.executeBuiltinLine(p.active, "Pet cat"));
+ try std.testing.expectEqual(.off, p.settings.pet);
return;
}
try std.testing.expect(p.executeBuiltinLine(p.active, "Pet cat"));
@@ -3717,9 +3719,16 @@ pub const Event = union(enum) {
/// How the host's handover `seq` went (Handover.finish): taken by `to`,
/// or `failure` says why not. Borrowed for the step.
handed: struct { seq: u32, to: []const u8 = "", failure: ?[]const u8 = null },
+ /// The live view's frontend, which its replica client says first
+ /// (docs/next-daemon.md, "Phase 6: GUI replica notes"): a window, which
+ /// draws pictures itself and takes the GUI's own words, or a terminal.
+ frontend: Frontend,
tick,
};
+/// A view's frontend: what a client of a session elsewhere says it is.
+pub const Frontend = struct { windowed: bool, native_images: bool = false, native_image_patches: bool = false };
+
pub const PendingWrite = struct { bytes: []u8, off: usize = 0 };
/// `command` is Kill's: SIGTERM to the terminal's foreground job, and never
@@ -4550,7 +4559,10 @@ pub const Pardes = struct {
/// A pixel shell's window, which hears the pointer leave it: only then
/// does /status say whether the pointer is over it (a terminal's mouse
/// reports never say it left, so a tty would claim it for ever).
- windowed: bool = false,
+ /// The live view's frontend is a window (Event.frontend): what it draws,
+ /// and the words it takes (builtins.zig `here`). A window's build
+ /// starts so, a terminal's not.
+ windowed: bool = platform == .gui,
/// The last plain B1 click, for acme's double-click (text.c:881,
/// textselect: a second click at the same point within 500 ms).
last_click: ?struct { id: usize, on_tag: bool, row: i32, col: i32, ms: i64 } = null,
@@ -5526,6 +5538,8 @@ pub const Pardes = struct {
pub fn takeFontRequest(p: *Pardes) ?[]const u8 {
if (comptime !font_picker) return null;
+ const taped = tape.enter(p, .take_font_request);
+ defer tape.leave(p, taped);
if (!p.settings.font.pending or p.font_request_taken) return null;
const path = p.settings.font.requested_path.get();
if (path.len == 0) return null;
@@ -5540,6 +5554,8 @@ pub const Pardes = struct {
unit: config.Runtime.FontSizeUnit,
) bool {
if (comptime !font_picker) return false;
+ const taped = tape.enter(p, .{ .observe_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } });
+ defer tape.leave(p, taped);
if (!p.settings.font.effective_name.set(effective_name)) return false;
p.settings.font.effective_size_hundredths = effective_size_hundredths;
p.settings.font.effective_size_unit = unit;
@@ -5555,6 +5571,8 @@ pub const Pardes = struct {
unit: config.Runtime.FontSizeUnit,
) bool {
if (comptime !font_picker) return false;
+ const taped = tape.enter(p, .{ .acknowledge_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } });
+ defer tape.leave(p, taped);
if (!p.settings.font.pending or !p.font_request_taken) return false;
const changed = !std.mem.eql(
u8,
@@ -5571,6 +5589,8 @@ pub const Pardes = struct {
pub fn rejectFont(p: *Pardes) void {
if (comptime !font_picker) return;
+ const taped = tape.enter(p, .reject_font);
+ defer tape.leave(p, taped);
if (!p.settings.font.pending or !p.font_request_taken) return;
p.settings.font.pending = false;
p.font_request_taken = false;
@@ -6346,6 +6366,11 @@ pub const Pardes = struct {
if (focused) if (p.host.vtable.newer_build) |f| if (f(p.host.ctx)) p.setMessage(p.active, newer_build_words);
},
.handed => |h| p.handover.finish(p, h.seq, h.to, h.failure),
+ .frontend => |f| {
+ p.windowed = f.windowed;
+ p.native_images = f.native_images;
+ p.native_image_patches = f.native_image_patches;
+ },
.pointer_leave => {
p.pointer_inside = false;
p.pointer_body_hit = null;
@@ -6818,11 +6843,14 @@ pub const Pardes = struct {
p.leader_on = true;
};
// a path-less builtin is a row here too (it is the same index Help
- // reads), and SPC cannot reach one — so both scans skip it
+ // reads), and SPC cannot reach one — so both scans skip it; and a
+ // window's own word is no path in a terminal's view
for (builtin_rows) |row| {
+ if (!builtins.registry.here(p, row.cmd)) continue;
if (std.mem.eql(u8, row.path orelse continue, pfx)) return exec.runBuiltin(p, row.cmd, p.active, "", null);
}
for (builtin_rows) |row| {
+ if (!builtins.registry.here(p, row.cmd)) continue;
if (std.mem.startsWith(u8, row.path orelse continue, pfx)) {
p.leader_on = true;
return;
@@ -7398,9 +7426,25 @@ pub const Pardes = struct {
/// A native post pass proved unavailable: the chain is emptied, which
/// DumpConfig then reports.
pub fn disableSceneEffects(p: *Pardes) void {
+ const taped = tape.enter(p, .disable_scene_effects);
+ defer tape.leave(p, taped);
p.settings.post.clear();
}
+ /// The window's answer to a WindowOpacity: done, or `failure` says why
+ /// not, `applied` the opacity it keeps.
+ pub fn windowOpacityDone(p: *Pardes, applied: u8, failure: ?[]const u8) void {
+ const taped = tape.enter(p, .{ .window_opacity_done = .{ .applied = applied, .failure = failure } });
+ defer tape.leave(p, taped);
+ p.settings.window_opacity_pending = false;
+ const reason = failure orelse return;
+ // Do not claim a value the compositor refused; an explicit retry of
+ // the same command will arm a new request.
+ p.settings.window_opacity = applied;
+ var buf: [256]u8 = undefined;
+ p.setMessage(p.active, std.fmt.bufPrint(&buf, "WindowOpacity: {s}", .{reason[0..@min(reason.len, 240)]}) catch "WindowOpacity: compositor rejected the request");
+ }
+
// ---- doc panes ----
pub fn openTutorView(p: *Pardes, id: usize) !*Pane {