diff options
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/core/Core.zig b/core/Core.zig index 835eb86c..a4c1d086 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -350,8 +350,8 @@ chrome: colors.ChromeTheme = colors.initial_chrome, frames: *FrameStats = undefined, own_frames: FrameStats = .{}, quit: bool = false, -/// A detached session with no frontend attached: nothing renders, so -/// no input ever dismisses a message (Messages.expireUnattended). +/// A detached session with no frontend attached: nothing renders, and a +/// 9P write may size its view (ninep/ctl.zig `size`). unattended: bool = false, haptic: HapticSlot = if (platform == .macos) .none else {}, /// The look just run found nothing (look.zig missed). @@ -1576,11 +1576,6 @@ pub fn pump(p: *Pardes, host: Host) !void { } else 0; _ = p.tape.host(p, .wait_input, .{timeout}); } - // Detached, nobody's key dismisses a message: they go on the clock, - // here in the step, where the clock read is taped (the host's wait - // did it, untaped, and a replay kept a message its session had let - // go). - Messages.expireUnattended(p); p.frames.mark_start = FrameStats.nowNs(); if (p.tape.host(p, .now, .{})) |now| p.advance(now); p.settle(); @@ -1708,11 +1703,6 @@ fn updateInner(p: *Pardes, ev: Event) void { // the screen. p.needs_frame = p.needs_frame or ev != .tick; p.shell_rows.sweep(p.gpa); - Messages.expireUnattended(p); - // An announcement stands in only until its own step says more. - for (p.panes) |slot| if (slot) |pane| { - pane.msg_announcement = false; - }; // A Look's hover outlives a tick, a batch of rows coming in (no // gesture), a move with no button, and a change to another pane. const hover_stays = switch (ev) { @@ -1727,15 +1717,9 @@ fn updateInner(p: *Pardes, ev: Event) void { look.cancelLookHover(p); } switch (ev) { - .key, .mouse => { - for (p.panes) |slot| { - if (slot) |pane| Messages.dismissMessage(p, pane); - } - v.clip_pending = null; - }, + .key, .mouse => v.clip_pending = null, .tick => { Stream.step(p); - Messages.advanceMessages(p); for (0..p.panes.len) |id| exec.flushReplEnter(p, id, false); }, else => {}, @@ -1902,10 +1886,10 @@ pub const SavePath = Effect.Buf(effect_path_cap); pub const noteLateFailure = pardes.tape.taped(noteLateFailureInner); fn noteLateFailureInner(p: *Pardes, id: Pane.Id) void { // Said by reportFailure just now: its words fitted whole, the - // reason kept; else what the message row has. + // reason kept; else what was said of the pane last. const said = if (p.fs.said_at == p.fs.failures and p.fs.said_len > 0) p.fs.said[0..p.fs.said_len] - else if (p.panes[id.index()]) |pane| pane.msg[0..pane.msg_len] else return; + else if (p.panes[id.index()]) |pane| p.messages.saidBy(pane) else return; const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len); @memcpy(p.fs.late_failure[0..kept.len], kept); p.fs.late_failure_len = @intCast(kept.len); @@ -2164,10 +2148,11 @@ pub fn nextWake(p: *const Pardes) ?u64 { const delay = config.look_preview_delay_frames; frames = @max(1, delay -| waiting.frames); } - for (p.panes) |slot| if (slot) |pane| { - const wait = Messages.messageWake(p, pane) orelse continue; + // A message dims at the end of its bright time. + if (Messages.dimDue(p)) |due| { + const wait = @max(1, (due - p.clock.stepped_ns + frame_ns - 1) / frame_ns); frames = if (frames) |soonest| @min(soonest, wait) else wait; - }; + } // Del's question goes up at the end of its delay: a frame then, and // none after (stepped time has reached it). for (p.panes) |slot| if (slot) |pane| if (pane.prompt == .del_side and pane.question_due_ns > p.clock.stepped_ns and pane.question_due_ns != Pane.question_asked) { @@ -2225,7 +2210,6 @@ fn advanceInner(p: *Pardes, now_ns: u64) void { // Only waiting until `due`: its counters move there at once. const held = (due - p.clock.stepped_ns) / frame; if (held > 1) { - Messages.holdMessages(p, held - 1); if (p.look_hover_wait) |*waiting| waiting.frames +|= @intCast(@min(held - 1, std.math.maxInt(u16))); p.clock.stepped_ns += (held - 1) * frame; } @@ -2621,14 +2605,13 @@ test "TreeContext rows in the tag style keep the message rows" { p.update(.{ .resize = .{ .cols = 60, .rows = 16, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } }); pane.file.?.tree_context = true; pane.file.?.scroll = 8; - pane.msg_len = 0; + p.messages.live_len = 0; p.sync(); _ = try p.render(p.scratch.allocator()); const full_height = p.surface.body_layers[0].viewport.h; try std.testing.expect(p.surface.body_layers[0].rows > full_height); try std.testing.expectEqual(FontRole.tagline, p.surface.body_layers[0].cells[0].style.font_role); - pane.msg[0] = '!'; - pane.msg_len = 1; + _ = Messages.keep(p, .notice, pane.serial, "", "!"); p.sync(); _ = try p.render(p.scratch.allocator()); // An overlay takes nothing: the message is a chip OVER the body's first @@ -2645,7 +2628,7 @@ test "TreeContext rows in the tag style keep the message rows" { try std.testing.expectEqual(r.x + r.w, band.viewport.x + band.viewport.w); try std.testing.expect(band.viewport.w < r.w - config.GUTTER); try std.testing.expectEqualStrings("!", band.cells[layout.tagCapacity(p, band.viewport.w) - 2].grapheme()); - pane.msg_len = 0; + p.messages.live_len = 0; p.view().prefix = .leader; p.sync(); _ = try p.render(p.scratch.allocator()); @@ -3032,7 +3015,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe try std.testing.expect(file.repl == null); try std.testing.expect(p.executeBuiltinLine(1, "Repl pithon")); try std.testing.expect(p.panes[1].?.repl == null); - try std.testing.expect(std.mem.indexOf(u8, p.panes[1].?.msg[0..p.panes[1].?.msg_len], "python") != null); + try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(p.panes[1].?), "python") != null); try std.testing.expect(p.executeBuiltinLine(1, "Repl python")); // again, as a code fence may name it: no change try std.testing.expect(p.executeBuiltinLine(1, "Repl PY")); @@ -3046,8 +3029,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe Sent.drain(p); try std.testing.expectEqualStrings("ls\r", Sent.said(1)); try std.testing.expect(!Sent.spawned); - try std.testing.expect(file.msg_sent); - try std.testing.expectEqualStrings("\u{2192} python-a", file.msg[0..file.msg_len]); + try std.testing.expectEqualStrings("\u{2192} python-a", p.messages.saidBy(file)); // A body's click written back to event is done as the click: sent. A // line written to exec came back as F and runs as the command it was. { @@ -3170,7 +3152,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe p.update(.{ .key = .{ .cp = 'b' } }); Sent.drain(p); try std.testing.expect(Sent.len[1] == 0 and Sent.len[2] == 0); - try std.testing.expectEqualStrings("Repl: the REPL chosen is gone; nothing sent", file.msg[0..file.msg_len]); + try std.testing.expectEqualStrings("Repl: the REPL chosen is gone; nothing sent", p.messages.saidBy(file)); try std.testing.expect(p.executeBuiltinLine(2, "Repl python")); try std.testing.expectEqualStrings("python-b", exec.replId(&idbuf, p.panes[2].?)); @@ -3187,7 +3169,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe try std.testing.expectEqual(Pane.Prompt.none, file.prompt); Sent.drain(p); try std.testing.expect(Sent.len[1] == 0 and Sent.len[2] == 0 and !Sent.spawned); - try std.testing.expect(std.mem.indexOf(u8, file.msg[0..file.msg_len], "no program running") != null); + try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(file), "no program running") != null); host.taken[1] = true; host.taken[2] = true; @@ -3197,7 +3179,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe try std.testing.expect(p.executeBuiltinLine(1, "Repl python")); try std.testing.expectEqualStrings("python-a", exec.replId(&idbuf, p.panes[1].?)); try std.testing.expect(p.executeBuiltinLine(2, "Repl")); - try std.testing.expectEqualStrings("Repl: python-b", p.panes[2].?.msg[0..p.panes[2].?.msg_len]); + try std.testing.expectEqualStrings("Repl: python-b", p.messages.saidBy(p.panes[2].?)); // A command pane is a REPL while its command runs: done, it is none, // and a done one cannot be bound. A document pane is no terminal. @@ -3276,13 +3258,13 @@ test "Term+fish, one word a tag can hold, opens a terminal on that shell" { const caller = p.panes[0].?; try std.testing.expect(p.executeBuiltinLine(0, "Term /nonexistent")); try std.testing.expect(p.view().active == before and caller.shell == null); - try std.testing.expect(std.mem.indexOf(u8, caller.msg[0..caller.msg_len], "shell \"/nonexistent\" not found") != null); + try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(caller), "shell \"/nonexistent\" not found") != null); try std.testing.expect(p.executeBuiltinLine(0, "Term fsh-not-a-shell")); try std.testing.expect(caller.shell == null); // A directory passes access(X_OK); it is no shell either. try std.testing.expect(p.executeBuiltinLine(0, "Term /etc")); try std.testing.expect(p.view().active == before); - try std.testing.expect(std.mem.indexOf(u8, caller.msg[0..caller.msg_len], "Term: not a shell: /etc is a directory") != null); + try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(caller), "Term: not a shell: /etc is a directory") != null); // Only a word that says so splits at `+`: `Dump+x.zon` is no Dump. try std.testing.expect(!p.executeBuiltinLine(0, "Dump+x.zon")); try std.testing.expect(!p.executeBuiltinLine(0, "Msg+hello")); @@ -3642,7 +3624,7 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T try std.testing.expectEqual(@as(i32, 1), pane.body.cur_col); // Bare, it says the width. try std.testing.expect(p.executeBuiltinLine(0, "Tab")); - try std.testing.expectEqualStrings("Tab 8", pane.msg[0..pane.msg_len]); + try std.testing.expectEqualStrings("Tab 8", p.messages.saidBy(pane)); // Out of range: refused, the width kept. try std.testing.expect(p.executeBuiltinLine(0, "Tab 0")); try std.testing.expectEqual(@as(u16, 8), p.settings.tab); @@ -4072,7 +4054,7 @@ test "bytes for a terminal past what may wait for it are dropped and said, never p.emitWrite(0, big); try std.testing.expectEqual(@as(usize, 0), p.pending_write_bytes); const pane = p.panes[0].?; - try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "dropped") != null); + try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(pane), "dropped") != null); } test "a bracketed paste larger than the ring still closes its bracket" { |
