summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 13:08:44 -0300
committerGabriel Schneider <[email protected]>2026-11-05 15:21:15 -0300
commit1b2ac091200e9192f3677abe161217ba82463606 (patch)
tree8fe35cf6edaa032e4650a631598dfab2fc4aabb5 /src
parent1870d06248f884439cb2ec4ef8f1b03952df2eb8 (diff)
downloadpardes-1b2ac091200e9192f3677abe161217ba82463606.tar.gz
pardes-1b2ac091200e9192f3677abe161217ba82463606.zip
effects out, the message animations: a message no longer falls into its row and dissolves out of it; it shows at once and goes when it has lingered, its lifetime the one deadline the core keeps for it (MessageLinger, a wait nextWake jumps in one step); MessageAnimation, MessageFall and MessageDissolve go with their settings, the entering and leaving phases (Pane.MessagePhase is shown or lingering), Messages.messageMotion and noticeLife, the notice band's colour blend toward the page, Layer.slide and fade, and the window's offset band, its clip to the body and its rule's fade; no frontend fades a message of its own (the window would have to see a notice come and go between frames for a 150 ms fade); the snapshot harness's, kitty harness's and casts' inits lose `MessageAnimation off`; the message tests keep their linger and stacking and lose the fall and dissolve, and `a notice leaves quicker than it arrives` goes; GUI goldens 10 and 12 to 17 change, the golden session having run with MessageAnimation on by default: a message dismissed while it fell stayed up (its dismissal undone by the next announcement), and FocusTint's stood on in every scene after; the tree before this change with MessageAnimation off draws exactly these frames, all sixteen byte for byte
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
-rw-r--r--src/Layer.zig8
-rw-r--r--src/Messages.zig251
-rw-r--r--src/builtins.zig2
-rw-r--r--src/config.zig48
-rw-r--r--src/draw.zig16
-rw-r--r--src/gui/gui.zig34
-rw-r--r--src/panes.zig9
7 files changed, 64 insertions, 304 deletions
diff --git a/src/Layer.zig b/src/Layer.zig
index c5125a81..3522fce8 100644
--- a/src/Layer.zig
+++ b/src/Layer.zig
@@ -70,14 +70,6 @@ cells: []pardes.Cell = &.{},
cursor: ?struct { x: u16, y: u16, bar: bool = false } = null,
/// A band's fill, where its cells run out.
bg: [3]u8 = .{ 0, 0, 0 },
-/// Vertical offset in rows (negative: above its viewport), for a band
-/// that is moving into place. A pixel shell draws it offset and clipped
-/// to the rows below the viewport's top; the grid has no such thing.
-slide: f32 = 0,
-/// How present a notice band is (1 = fully) while it fades up or
-/// dissolves. `bg` and the cells are already blended by it; a pixel
-/// shell uses it for what it draws around the band, like its rule.
-fade: f32 = 1,
/// Tag columns a viewport this wide holds at the tagline's pitch.
pub fn capacity(layer: *const Layer, metrics: Metrics) u16 {
diff --git a/src/Messages.zig b/src/Messages.zig
index 98e005be..0ab10dab 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -1,5 +1,5 @@
//! The message row: messages and statuses a pane shows between its body and
-//! its tagline, how each line falls in, lingers and dissolves, the notices
+//! its tagline, how each line lingers once dismissed, the notices
//! built from them every frame, and the log of everything said.
const pardes = @import("pardes.zig");
const memory = @import("memory.zig");
@@ -189,23 +189,14 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void {
pane.msg_announcement = false;
pane.msg_sent = false;
pane.msg_status = !stack;
- const arrives = pane.msg_len == 0 or pane.msg_life.phase == .leaving;
for (text[0..n], pane.msg[0..n]) |c, *cell| cell.* = if (c < 0x20 or c == 0x7f) ' ' else c;
pane.msg_len = @intCast(n);
// The clock when it was said (the session clock is the last pump's,
// and a 9P write after an idle hour would say it an hour ago).
pane.msg_said_ms = pardes.tape.value(.clock, nowMs, .{});
p.needs_frame = true;
- if (arrives) {
- pane.msg_life = .{ .phase = if (p.settings.message_animation and n > 0) .entering else .shown };
- } else if (pane.msg_life.phase == .lingering or
- (pane.msg_life.phase == .entering and !p.settings.message_animation))
- {
- // The same line again, or a status update: fresh, so it stays.
- pane.msg_life = .{};
- } else {
- pane.msg_life.dismissed = false;
- }
+ // New, the same line again or a status update: fresh, so it stays.
+ pane.msg_life = .{};
}
/// With no frontend attached no input dismisses a message, and a detached
@@ -239,8 +230,8 @@ pub fn expireUnattended(p: *Pardes) void {
}
/// The key or click that used to clear the message row now starts each
-/// line's exit: it stays `message_linger_ms`, then dissolves. A line
-/// already on its way out keeps its own timing.
+/// line's exit: it stays `message_linger_ms`, then goes. A line already
+/// on its way out keeps its own timing.
pub fn dismissMessage(p: *Pardes, pane: *Pane) void {
if (pane.msg_len > 0 and dismissLine(p, &pane.msg_life)) {
pane.msg_len = 0;
@@ -252,30 +243,16 @@ pub fn dismissMessage(p: *Pardes, pane: *Pane) void {
}
}
-/// Start one line's exit; true when it is gone at once (no linger, no
-/// animation).
+/// Start one line's exit; true when it is gone at once (no linger).
fn dismissLine(p: *const Pardes, life: *Pane.MessageLife) bool {
- switch (life.phase) {
- .lingering, .leaving => return false,
- // A falling line lands first, then lingers -- unless falling was
- // just turned off, and nothing will land it.
- .entering => if (p.settings.message_animation) {
- life.dismissed = true;
- return false;
- },
- .shown => {},
- }
- life.frame = 0;
- if (p.settings.message_linger_ms > 0) {
- life.phase = .lingering;
- } else if (p.settings.message_animation) {
- life.phase = .leaving;
- } else return true;
+ if (life.phase == .lingering) return false;
+ if (p.settings.message_linger_ms == 0) return true;
+ life.* = .{ .phase = .lingering };
return false;
}
-/// One animation frame of every message line. Each one that moves owes
-/// a frame, the one that finishes included: a tick asks for none itself.
+/// One frame of every lingering message line. The one that goes owes a
+/// frame: a tick asks for none itself.
pub fn advanceMessages(p: *Pardes) void {
for (p.panes) |slot| {
const pane = slot orelse continue;
@@ -294,22 +271,11 @@ pub fn advanceMessages(p: *Pardes) void {
}
}
-/// One frame of one line's life; true once it has left.
+/// One frame of one line's life; true once it has gone.
fn advanceLine(p: *const Pardes, life: *Pane.MessageLife) bool {
if (life.phase == .shown) return false;
life.frame +|= 1;
- switch (life.phase) {
- .shown => {},
- .entering => if (life.frame >= messageFrames(p.settings.message_fall_ms)) {
- life.* = .{ .phase = if (life.dismissed) .lingering else .shown };
- },
- .lingering => if (life.frame >= messageFrames(p.settings.message_linger_ms)) {
- if (!p.settings.message_animation) return true;
- life.* = .{ .phase = .leaving };
- },
- .leaving => if (life.frame >= messageFrames(p.settings.message_dissolve_ms)) return true,
- }
- return false;
+ return life.frame >= messageFrames(p.settings.message_linger_ms);
}
/// Move every lingering message line `frames` along its linger at once:
@@ -325,68 +291,25 @@ pub fn holdMessages(p: *Pardes, frames: u64) void {
}
}
-/// Frames until this pane's message lines next change: 1 while a line
-/// falls in or dissolves, the rest of its linger while one only waits, null
-/// when every line just shows.
+/// Frames until this pane's message lines next change: the rest of a
+/// linger, null when every line just shows.
pub fn messageWake(p: *const Pardes, pane: *const Pane) ?u64 {
var soonest: ?u64 = null;
const linger = messageFrames(p.settings.message_linger_ms);
for (0..@as(usize, pane.msg_older_len) + 1) |i| {
const life = if (i < pane.msg_older_len) pane.msg_older[i].life else if (pane.msg_len > 0) pane.msg_life else continue;
- const frames: u64 = switch (life.phase) {
- .shown => continue,
- .entering, .leaving => 1,
- .lingering => @max(1, linger -| life.frame),
- };
+ if (life.phase == .shown) continue;
+ const frames: u64 = @max(1, linger -| life.frame);
soonest = if (soonest) |n| @min(n, frames) else frames;
}
return soonest;
}
-/// How present a message is (1 = fully) and how far above its row it
-/// still is (rows): a fall that decelerates into place with its colour
-/// arriving ahead of it, and a dissolve.
-pub const MessageMotion = struct { alpha: f32 = 1, slide: f32 = 0 };
-
/// Animation frames a message timing lasts; at least one.
pub fn messageFrames(ms: u16) u16 {
return @intCast(@max(1, (@as(u32, ms) + animation.frame_ms - 1) / animation.frame_ms));
}
-pub fn messageMotion(p: *const Pardes, life: Pane.MessageLife) MessageMotion {
- const fall_frames = messageFrames(p.settings.message_fall_ms);
- const dissolve_frames = messageFrames(p.settings.message_dissolve_ms);
- return switch (life.phase) {
- .shown, .lingering => .{ .alpha = 1, .slide = 0 },
- .entering => blk: {
- const t = @as(f32, @floatFromInt(@min(life.frame, fall_frames))) / @as(f32, @floatFromInt(fall_frames));
- // Out of the gate fast and easing into its row (a cubic
- // ease-out), so it is there the moment it is said and the
- // last frames only settle it. No overshoot: at a row's height
- // and a dozen frames, a follow-through is a pixel or two that
- // reads as a jitter, not a bounce.
- // The drop follows the Motion flavour (its wind-up, overshoot
- // and all) over the fall's length.
- const left = 1 - animation.Motion.of(p.settings.motion).ease(t);
- // The colour leads the motion: solid by half way, so what
- // lands is already legible rather than still fading up.
- const faded = 1 - @min(1, 2 * t);
- // And never behind it, however fast the flavour leaves.
- break :blk .{ .alpha = @max(1 - faded * faded, std.math.clamp(1 - left, 0, 1)), .slide = -left };
- },
- .leaving => blk: {
- // Counted to its last frame rather than past it, so that frame
- // shows it gone and it never blinks out from part way.
- const last = @max(1, dissolve_frames - 1);
- const t = @as(f32, @floatFromInt(@min(life.frame, last))) / @as(f32, @floatFromInt(last));
- // An exit eases in: still readable for a beat, then away
- // faster and faster. It stays where it is -- the lines
- // stacked around it do not move either.
- break :blk .{ .alpha = 1 - t * t, .slide = 0 };
- },
- };
-}
-
/// What notice band `i` says. The grid pass and the band layers both
/// read it here, so a terminal and a pixel shell show the same line.
pub fn noticeText(p: *const Pardes, pane: *const Pane, i: usize, leader_buf: *[16]u8) []const u8 {
@@ -398,15 +321,6 @@ pub fn noticeText(p: *const Pardes, pane: *const Pane, i: usize, leader_buf: *[1
};
}
-/// The life of the message line notice `i` shows, if it shows one.
-pub fn noticeLife(pane: *const Pane, i: usize) ?Pane.MessageLife {
- return switch (pane.notices.kinds[i]) {
- .message => pane.msg_life,
- .older => pane.msg_older[pane.notices.index[i]].life,
- .leader, .prompt => null,
- };
-}
-
fn logMessage(p: *Pardes, id: usize, text: []const u8) void {
if (text.len == 0) return;
const serial: u32 = if (p.fs.session_write) 0 else if (id < MAX_PANES) if (p.panes[id]) |pane| pane.serial else 0 else 0;
@@ -707,13 +621,12 @@ test "Msg writes the transient row by hand, bare or with text, and input ends it
try std.testing.expect(p.executeBuiltinLine(2, "Msg"));
try std.testing.expectEqualStrings("Msg: no message", row(p, 2));
- // Input starts its exit: it lingers, dissolves, and is gone.
+ // Input starts its exit: it lingers, and is gone.
p.update(.{ .key = .{ .cp = Key.escape } });
try std.testing.expectEqualStrings("Msg: no message", row(p, 2));
for (0..200) |_| p.update(.tick);
try std.testing.expectEqualStrings("", row(p, 2));
- // ...and with neither linger nor animation it is as old as your last input.
- try std.testing.expect(p.executeBuiltinLine(2, "MessageAnimation off"));
+ // ...and with no linger it is as old as your last input.
try std.testing.expect(p.executeBuiltinLine(2, "MessageLinger 0"));
try std.testing.expect(p.executeBuiltinLine(2, "Msg gone"));
p.update(.{ .key = .{ .cp = 'h' } });
@@ -754,49 +667,16 @@ test "with no frontend attached a message goes once it has lingered, on the cloc
try std.testing.expect(pane.msg_len > 0);
}
-test "a message falls in, lingers past the input that dismisses it, and dissolves" {
+test "a message lingers past the input that dismisses it, and goes" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
while (p.nextEffect()) |_| {}
const pane = p.panes[p.active].?;
- try std.testing.expect(p.settings.message_animation);
- // Crisp: the flavour whose drop leaves at full speed and lands without
- // passing its row (the others are the Motion tests').
- p.settings.motion = .crisp;
try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 160"));
try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
- try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase);
- try std.testing.expect(p.animationActive());
- // An ease-out fall: starts a whole row up and unseen, covers most of the
- // way at once and settles into its row, landing exactly on it without
- // passing it. Its colour is whole by half way.
- const start = messageMotion(p, pane.msg_life);
- try std.testing.expectEqual(@as(f32, -1), start.slide);
- try std.testing.expectEqual(@as(f32, 0), start.alpha);
- const fall = messageFrames(p.settings.message_fall_ms);
- var last = start;
- var first_step: f32 = 0;
- var last_step: f32 = 0;
- for (0..fall) |frame| {
- p.needs_frame = false;
- p.update(.tick);
- // Every tick that moves it owes a frame, the landing one included.
- try std.testing.expect(p.needs_frame);
- const now = messageMotion(p, pane.msg_life);
- try std.testing.expect(now.slide >= last.slide and now.slide <= 0);
- try std.testing.expect(now.alpha >= last.alpha);
- if (frame == 0) first_step = now.slide - last.slide;
- // Never slower to colour up than to arrive, and solid by half way.
- try std.testing.expect(now.alpha >= 1 + now.slide);
- if (2 * (frame + 1) >= fall) try std.testing.expectEqual(@as(f32, 1), now.alpha);
- last_step = now.slide - last.slide;
- last = now;
- }
- try std.testing.expect(first_step > 4 * last_step);
+ // Shown at once, until input; the same line again stays shown.
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
- try std.testing.expectEqual(@as(f32, 0), messageMotion(p, pane.msg_life).slide);
try std.testing.expect(!p.animationActive());
- // Shown until input, like always; the same line again does not re-enter.
for (0..100) |_| p.update(.tick);
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
@@ -809,57 +689,24 @@ test "a message falls in, lingers past the input that dismisses it, and dissolve
p.update(.{ .key = .{ .cp = 'h' } });
}
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
+ // ...then it is gone, and the tick that clears it owes the frame that
+ // shows it gone.
+ p.needs_frame = false;
p.update(.tick);
- // ...then an ease-in dissolve: it lets go slowly and goes faster and
- // faster, in place, its last frame showing it gone.
- try std.testing.expectEqual(Pane.MessagePhase.leaving, pane.msg_life.phase);
- const dissolve = messageFrames(p.settings.message_dissolve_ms);
- var alpha: f32 = 1;
- var first_drop: f32 = 0;
- var last_drop: f32 = 0;
- for (0..dissolve) |frame| {
- const now = messageMotion(p, pane.msg_life);
- try std.testing.expect(now.alpha <= alpha);
- try std.testing.expectEqual(@as(f32, 0), now.slide);
- if (frame == 1) first_drop = alpha - now.alpha;
- last_drop = alpha - now.alpha;
- alpha = now.alpha;
- p.needs_frame = false;
- p.update(.tick);
- }
- try std.testing.expectEqual(@as(f32, 0), alpha);
- try std.testing.expect(first_drop > 0 and first_drop < last_drop);
try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
- try std.testing.expect(!p.animationActive());
- // The tick that clears it still owes the frame that shows it gone.
try std.testing.expect(p.needs_frame);
-
- // Dismissed mid-fall: it lands, then lingers.
+ try std.testing.expect(!p.animationActive());
+ // Shown again while lingering: fresh, so it stays; a status update to a
+ // line on screen swaps its text in place.
try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again"));
- try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase);
- p.update(.tick);
p.update(.{ .key = .{ .cp = 'h' } });
- try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase);
- for (0..messageFrames(p.settings.message_fall_ms)) |_| p.update(.tick);
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
- // Shown again while lingering: fresh, so it stays; a status update to a
- // line on screen swaps its text in place instead of falling again.
try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again"));
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
setStatus(p, p.active, "progress 50%");
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expectEqualStrings("progress 50%", pane.msg[0..pane.msg_len]);
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
- // The fall and the dissolve are timings of their own, in milliseconds.
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageFall 48"));
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageDissolve 0"));
- try std.testing.expectEqual(@as(u16, 3), messageFrames(p.settings.message_fall_ms));
- try std.testing.expectEqual(@as(u16, 1), messageFrames(p.settings.message_dissolve_ms));
- // The DumpConfig report reads back as configuration.
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageAnimation"));
- try std.testing.expect(!p.settings.message_animation);
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg plain"));
- try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
}
test "messages stack, oldest on top, each on its own timing" {
@@ -869,37 +716,35 @@ test "messages stack, oldest on top, each on its own timing" {
const pane = p.panes[p.active].?;
try std.testing.expect(p.executeBuiltinLine(p.active, "Verbose off"));
try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 160"));
- // A dissolve longer than a fall, so the second is caught mid-way.
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageDissolve 300"));
// `Verbose off` announced itself before it took effect.
pane.msg_len = 0;
pane.msg_life = .{};
- const fall = messageFrames(p.settings.message_fall_ms);
setMessage(p, p.active, "first");
- for (0..fall) |_| p.update(.tick);
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
// A second message stacks under the first instead of replacing it.
setMessage(p, p.active, "second");
try std.testing.expectEqual(@as(u8, 1), pane.msg_older_len);
try std.testing.expectEqualStrings("first", pane.msg_older[0].slice());
try std.testing.expectEqualStrings("second", pane.msg[0..pane.msg_len]);
- try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase);
collectNotices(p, pane, p.rects[p.active], p.active);
try std.testing.expectEqual(Pane.Notices.Kind.older, pane.notices.kinds[0]);
try std.testing.expectEqual(Pane.Notices.Kind.message, pane.notices.kinds[1]);
- // One key dismisses both, but each runs its own clock: the first starts
- // lingering now, the second only once it has landed.
+ // One key dismisses both, each on its own clock: a line already
+ // lingering keeps its timing.
p.update(.{ .key = .{ .cp = 'h' } });
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_older[0].life.phase);
- try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase);
+ try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
+ p.update(.tick);
+ setMessage(p, p.active, "third");
+ try std.testing.expectEqual(@as(u8, 2), pane.msg_older_len);
+ p.update(.{ .key = .{ .cp = 'h' } });
const linger = messageFrames(p.settings.message_linger_ms);
- const dissolve = messageFrames(p.settings.message_dissolve_ms);
- for (0..linger + dissolve) |_| p.update(.tick);
- // The first is gone; the second, a fall later, is still dissolving.
+ for (0..linger - 1) |_| p.update(.tick);
+ // The first two are gone; the third, a frame later, still lingers.
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
- try std.testing.expectEqualStrings("second", pane.msg[0..pane.msg_len]);
- try std.testing.expectEqual(Pane.MessagePhase.leaving, pane.msg_life.phase);
- for (0..fall) |_| p.update(.tick);
+ try std.testing.expectEqualStrings("third", pane.msg[0..pane.msg_len]);
+ try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
+ p.update(.tick);
try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
try std.testing.expect(!p.animationActive());
// A status ticking in place does not pile up.
@@ -1033,11 +878,8 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's
p.advance(1_000_000);
try std.testing.expectEqual(@as(?u64, null), p.nextWake());
const pane = p.panes[p.active].?;
+ // Shown, a message asks for no wake.
try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
- // Falling in: a frame from now.
- try std.testing.expectEqual(@as(?u64, p.stepped_ns + frame), p.nextWake());
- const fall = messageFrames(p.settings.message_fall_ms);
- p.advance(p.stepped_ns + fall * frame);
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expectEqual(@as(?u64, null), p.nextWake());
// A key starts the 800 ms linger: the core sleeps to its end, not a
@@ -1052,9 +894,6 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's
try std.testing.expectEqual(@as(?u64, due), p.nextWake());
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
p.advance(due);
- try std.testing.expectEqual(Pane.MessagePhase.leaving, pane.msg_life.phase);
- try std.testing.expectEqual(@as(?u64, due + frame), p.nextWake());
- p.advance(due + 10 * std.time.ns_per_s);
try std.testing.expectEqual(@as(usize, 0), pane.msg_len);
try std.testing.expectEqual(@as(?u64, null), p.nextWake());
@@ -1062,17 +901,9 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's
// the cap on catching up with moving frames.
try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 5000"));
try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again"));
- p.advance(p.stepped_ns + fall * frame);
p.update(.{ .key = .{ .cp = 'x' } });
const long_due = p.stepped_ns + messageFrames(5000) * frame;
try std.testing.expectEqual(@as(?u64, long_due), p.nextWake());
p.advance(long_due);
- try std.testing.expectEqual(Pane.MessagePhase.leaving, pane.msg_life.phase);
-}
-
-test "a notice leaves quicker than it arrives, each within its §8.1 band" {
- const settings: config.Runtime = .{};
- try std.testing.expect(settings.message_dissolve_ms < settings.message_fall_ms);
- try std.testing.expect(settings.message_fall_ms >= 150 and settings.message_fall_ms <= 220);
- try std.testing.expect(settings.message_dissolve_ms >= 100 and settings.message_dissolve_ms <= 160);
+ try std.testing.expectEqual(@as(usize, 0), pane.msg_len);
}
diff --git a/src/builtins.zig b/src/builtins.zig
index bb3a167b..cbde62da 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -244,7 +244,7 @@ pub const registry = struct {
// a switch flips bare, a choice steps, and DumpDir and Shell bare
// are the default
.toggle, .dump_dir, .choice, .motion, .shell => false,
- .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .inactive_dim, .grip_width => true,
+ .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_linger, .inactive_dim, .grip_width => true,
// bare, it says the current value (exec.applySettingBuiltin)
.tab, .callstack_depth, .search_rows => false,
};
diff --git a/src/config.zig b/src/config.zig
index dbe4e9b7..9a7e6848 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -158,10 +158,7 @@ pub const leader_path = paths: {
table.set(.Font, null);
table.set(.TaglineSize, null);
}
- table.set(.MessageAnimation, null);
table.set(.MessageLinger, null);
- table.set(.MessageFall, null);
- table.set(.MessageDissolve, null);
table.set(.DumpDir, null);
if (builtins.capabilities.window_opacity) table.set(.WindowOpacity, null);
if (builtins.capabilities.window_blur) table.set(.WindowBlur, null);
@@ -365,8 +362,7 @@ pub const wheel_cols: i32 = 4;
pub const look_preview_delay_frames: u16 = 2;
-/// The longest any message timing (MessageLinger, MessageFall,
-/// MessageDissolve) may be set to, in milliseconds.
+/// The longest MessageLinger may be set to, in milliseconds.
pub const message_ms_max: u16 = 60_000;
// Tag fonts keep body-cell geometry; valid sizes are 1...100 percent.
@@ -725,8 +721,6 @@ pub const Runtime = struct {
/// Builtins announce themselves on the message row.
verbose: bool = true,
- /// A message falls into its row and dissolves out of it.
- message_animation: bool = true,
/// The cursor blinks, a pixel shell's (docs/render-pipeline.md §5.4):
/// solid while typing and for half a second after, eased at each edge,
/// solid again after ten idle seconds.
@@ -739,12 +733,6 @@ pub const Runtime = struct {
program_esc: bool = false,
/// How long a message stays after the key or click that dismisses it.
message_linger_ms: u16 = 800,
- /// How long its fall into the row takes, easing out (§8.1: arriving,
- /// 150 to 220 ms).
- message_fall_ms: u16 = 180,
- /// How long its dissolve takes, easing in: leaving is quicker than
- /// arriving (§8.1: 100 to 160 ms).
- message_dissolve_ms: u16 = 150,
/// Where Dump writes and a relative Restore looks; empty is the default
/// ($XDG_DATA_HOME/pardes, else ~/.local/share/pardes).
dump_dir: Text(limits.host_path_cap) = .{},
@@ -879,10 +867,7 @@ pub const Runtime = struct {
pub const Capability = std.meta.FieldEnum(Capabilities);
- /// The message timings a setting word sets, each in milliseconds.
- pub const MessageTime = enum { linger, fall, dissolve };
-
- pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, jump_trail, program_esc };
+ pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, ligatures, cursor_blink, jump_trail, program_esc };
pub const Action = union(enum) {
toggle: Toggle,
@@ -892,7 +877,7 @@ pub const Runtime = struct {
tagline_size,
window_opacity,
window_blur,
- message_ms: MessageTime,
+ message_linger,
dump_dir,
/// A motion flavour.
motion,
@@ -948,7 +933,6 @@ pub const Runtime = struct {
.{ .word = "FocusTint", .action = .{ .toggle = .focus_tint }, .doc = "The focused pane's and column's tags are tinted, on or off." },
.{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold }, .doc = "Keywords and the like are drawn bold, on or off." },
.{ .word = "Verbose", .action = .{ .toggle = .verbose }, .doc = "A builtin says its own name on the message row as it runs, on or off." },
- .{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation }, .doc = "A message falls into its row and dissolves out of it, on or off." },
.{ .word = "Ligatures", .action = .{ .toggle = .ligatures }, .doc = "A font's programming ligatures draw across their cells, on or off." },
.{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .doc = "The cursor blinks, solid while typing, on or off." },
.{ .word = "JumpTrail", .action = .{ .toggle = .jump_trail }, .doc = "A jump of the cursor leaves a short trail that fades, on or off." },
@@ -957,9 +941,7 @@ pub const Runtime = struct {
.{ .word = "GripWidth", .action = .grip_width, .doc = "The grip and scrollbar width, as a percent of the theme's rail." },
.{ .word = "InactiveDim", .action = .inactive_dim, .doc = "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off." },
.{ .word = "Pet", .action = .{ .choice = .pet }, .doc = "The window's companion in the workspace tag's blank space: off, cat or frog." },
- .{ .word = "MessageLinger", .action = .{ .message_ms = .linger }, .doc = "How long, in milliseconds, a message stays after what dismisses it." },
- .{ .word = "MessageFall", .action = .{ .message_ms = .fall }, .doc = "How long, in milliseconds, a message takes to fall into its row." },
- .{ .word = "MessageDissolve", .action = .{ .message_ms = .dissolve }, .doc = "How long, in milliseconds, a message takes to dissolve." },
+ .{ .word = "MessageLinger", .action = .message_linger, .doc = "How long, in milliseconds, a message stays after what dismisses it." },
.{ .word = "DumpDir", .action = .dump_dir, .doc = "The directory Dump writes to and a relative Restore reads from; bare, the default." },
.{ .word = "Theme", .action = .theme, .doc = "Switch to the named theme." },
.{ .word = "Shell", .action = .shell, .doc = "The shell new terminals run; bare, $SHELL if it is executable, else /bin/sh." },
@@ -1045,12 +1027,7 @@ pub const Runtime = struct {
}
if (!state.dump_dir.set(text)) return false;
},
- .message_ms => |which| {
- const ms = number(u16, argument, " \t\r\n", 0, message_ms_max) orelse return false;
- switch (which) {
- inline else => |w| @field(state, "message_" ++ @tagName(w) ++ "_ms") = ms,
- }
- },
+ .message_linger => state.message_linger_ms = number(u16, argument, " \t\r\n", 0, message_ms_max) orelse return false,
// Bare, it steps to the next word, as a tag word should.
.choice => |which| switch (which) {
inline else => |field| {
@@ -1100,7 +1077,7 @@ pub const Runtime = struct {
.callstack_depth => "1-64 (levels)",
.search_rows => "1-100 (rows)",
.tagline_size => std.fmt.comptimePrint("{d}-{d} (a percentage)", .{ tagline_percent_min, tagline_percent_max }),
- .message_ms => std.fmt.comptimePrint("0-{d} (milliseconds)", .{message_ms_max}),
+ .message_linger => std.fmt.comptimePrint("0-{d} (milliseconds)", .{message_ms_max}),
.shell => "a path of at most 255 bytes; bare, $SHELL, else /bin/sh",
.dump_dir => std.fmt.comptimePrint("an absolute or ~ path of at most {d} bytes, to a directory that may be written; bare, the default", .{limits.host_path_cap}),
.font => "a name or path, :8 to :72 after it (Mono:14)",
@@ -1193,9 +1170,7 @@ pub const Runtime = struct {
const dir = if (state.dump_dir.len > 0) state.dump_dir.get() else context.default_dump_dir;
if (dir.len > 0) try out.print("{s} {s}\n", .{ setting.word, dir }) else try out.print("# {s} (none)\n", .{setting.word});
},
- .message_ms => |which| try out.print("{s} {d}\n", .{ setting.word, switch (which) {
- inline else => |w| @field(state, "message_" ++ @tagName(w) ++ "_ms"),
- } }),
+ .message_linger => try out.print("{s} {d}\n", .{ setting.word, state.message_linger_ms }),
.shell => {
const chosen = state.shell.requested.get();
try out.print("{s} {s}\n", .{ setting.word, if (chosen.len == 0) context.compiled_default_shell else chosen });
@@ -1393,11 +1368,10 @@ pub const Runtime = struct {
};
const values = [_][2][]const u8{
.{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
- .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
- .{ "DumpDir", "~/dumps" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
- .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Motion", "playful" },
- .{ "GripWidth", "200" }, .{ "InactiveDim", "35" }, .{ "CallstackDepth", "16" },
- .{ "Tab", "8" }, .{ "SearchRows", "12" },
+ .{ "MessageLinger", "1500" }, .{ "DumpDir", "~/dumps" }, .{ "TermImages", "petscii" },
+ .{ "JumpScope", "all" }, .{ "SearchPlace", "column" }, .{ "SearchPane", "new" },
+ .{ "Motion", "playful" }, .{ "GripWidth", "200" }, .{ "InactiveDim", "35" },
+ .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" },
};
for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1]));
try std.testing.expect(state.font.requested_name.set("Wanted Mono"));
diff --git a/src/draw.zig b/src/draw.zig
index d299b03f..55fab141 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -752,8 +752,6 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
layer.context_rows = 0;
layer.bg = bg;
layer.cursor = null;
- layer.slide = 0;
- layer.fade = 1;
// A notice band carries a PANE id, not a column index, so it must not
// answer to the column being edited -- that would scroll and select
// its text with the column tag's offsets and give it a second caret.
@@ -870,8 +868,6 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
layer.rows = rows;
layer.context_rows = 0;
layer.bg = if (p.window_pick == id) p.theme().sel_bg else if (active and p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg;
- layer.slide = 0;
- layer.fade = 1;
layer.cursor = if (p.header_focus) null else if (temporary.cursor) |cursor|
.{ .x = cursor.x - TAG_TEXT_INSET, .y = cursor.y, .bar = cursor.bar }
else
@@ -892,7 +888,6 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
/// grid's chip a copy of its right end, where its text is.
fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region) !void {
const chrome = p.chromeTheme();
- const th = p.theme();
const id: usize = region.owner;
const pane = p.panes[id].?;
const i: usize = region.notice;
@@ -901,15 +896,10 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
const chip = region.rect.w;
var leader_buf: [16]u8 = undefined;
const text = Messages.noticeText(p, pane, i, &leader_buf);
- // A message coming or going blends toward the page it sits on; a grid
- // cannot move it by less than a row, a pixel shell slides it too.
- const motion: Messages.MessageMotion = if (Messages.noticeLife(pane, i)) |life| Messages.messageMotion(p, life) else .{};
- const page = th.bg orelse chrome.tag_bg;
- const bg = colors.lerp(page, chrome.tag_bg, motion.alpha);
+ const bg = chrome.tag_bg;
// Where an exec was sent to a REPL reads in the tag's name tint, set
// apart from what the editor says.
- const ink = if (kind == .message and pane.msg_sent) chrome.tag_name_fg else chrome.tag_fg;
- const fg = colors.lerp(page, ink, motion.alpha);
+ const fg = if (kind == .message and pane.msg_sent) chrome.tag_name_fg else chrome.tag_fg;
// Nothing to say, or too narrow for a layer: a blank chip on the grid.
if (text.len == 0 or r.w <= TAG_TEXT_INSET) {
s.fill(region.rect.x, region.rect.y, chip, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
@@ -941,8 +931,6 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
@memcpy(line[pad..], kept);
const layer = &s.tag_layers[NOTICE_LAYER_BASE + id * Pane.Notices.max + i];
try renderHeaderLayer(p, layer, .notice, @intCast(id), region.rect, line, 0, bg, fg);
- layer.slide = motion.slide;
- layer.fade = motion.alpha;
// The caret rides the band, where the prompt's glyphs are.
if (kind == .prompt and id == p.active and pane.prompt != .del_side and pane.prompt != .repl_choice) caret: {
const typed = panes.File.displayWidth(text[0..@min(@as(usize, @intCast(@max(0, pane.input.cur_col))), text.len)]);
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 01a58eae..a81f029f 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -5548,13 +5548,7 @@ fn renderFrame(
if (layer.rows == 0) continue;
// A notice floats over the panes.
const group_index = if (layer.kind == .notice) groups.notices else 0;
- const start = cell_next[group_index];
emitTagLayer(g, instances, &cell_next[group_index], layer, win_w, win_h, page, cursors_shown);
- // A notice dropping past its row (a flavour's overshoot) stays
- // inside its pane's body.
- if (layer.kind == .notice and layer.slide > 0) if (bodyBottom(surface, layer.id, layout)) |bottom| {
- for (instances[start..cell_next[group_index]]) |*instance| clipInstance(instance, .{ -1e9, -1e9, 1e9, bottom }, win_w, win_h);
- };
}
for (groups.items[0..groups.len], 0..) |group, index|
std.debug.assert(cell_next[index] == group.cell_start + group.cell_count);
@@ -5809,14 +5803,6 @@ test "the layer cover is the per-cell layer scan, over a core's layouts and rand
}
}
-/// The bottom of pane `owner`'s body, in window pixels.
-fn bodyBottom(surface: *const pardes.Surface, owner: u16, layout: CellLayout) ?f32 {
- for (surface.regionList()) |region| {
- if (region.kind == .body and region.owner == owner) return @as(f32, @floatFromInt(region.rect.y + region.rect.h)) * layout.h;
- }
- return null;
-}
-
fn tagLayerCellCount(g: *const Gui, layer: *const pardes.Layer) u32 {
const pixels = @as(u32, layer.viewport.w) * g.cell_w;
return @min(layer.cols, (pixels + g.tagline_width - 1) / g.tagline_width);
@@ -5829,9 +5815,6 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
const left = @as(f32, @floatFromInt(layer.viewport.x)) * bw;
const right = left + @as(f32, @floatFromInt(layer.viewport.w)) * bw;
const background: pardes.Cell = .{ .default = false, .style = .{ .bg = .{ .rgb = layer.bg } } };
- // A band sliding into place is drawn offset and cut at its row's top, so
- // it comes out from under whatever is above it.
- const slide = layer.slide * bh;
// A window is rarely a whole number of cells wide: a band that ends at
// the last column runs on through the leftover pixels to the edge.
const band_right = if (win_w - right < bw) @max(right, win_w) else right;
@@ -5839,16 +5822,14 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
// A row to each line, each a grid row with the tagline's glyphs.
for (0..layer.rows) |index| {
const y = layer.viewport.y + @as(u16, @intCast(index));
- const top = @as(f32, @floatFromInt(y)) * bh;
- emitInstance(g, instances, next.*, 0, y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page);
- if (slide != 0) clipInstance(&instances[next.*], .{ -1e9, top, 1e9, 1e9 }, win_w, win_h);
+ emitInstance(g, instances, next.*, 0, y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = 0 }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page);
next.* += 1;
const cells = layer.cells[index * layer.cols ..][0..layer.cols];
const line_cursor: ?usize = if (layer.cursor) |cu| (if (cu.y == index) cu.x else null) else null;
for (0..tagLayerCellCount(g, layer)) |col| {
const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == index else false;
- emitInstance(g, instances, next.*, @intCast(col), y, .{ .w = tw, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, .tagline, cells, col, line_cursor, cursor, page);
- clipInstance(&instances[next.*], .{ -1e9, if (slide != 0) top else -1e9, right, 1e9 }, win_w, win_h);
+ emitInstance(g, instances, next.*, @intCast(col), y, .{ .w = tw, .h = bh, .x_off = left, .y_off = 0 }, win_w, win_h, .tagline, cells, col, line_cursor, cursor, page);
+ clipInstance(&instances[next.*], .{ -1e9, -1e9, right, 1e9 }, win_w, win_h);
if (faded and !cursor) dim.fade(&instances[next.*]);
next.* += 1;
}
@@ -7521,18 +7502,15 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
// A notice chip is tagline hung over the body's top rows, so it is
// ruled off from the text beneath it the way a tag is: the same
// colour and thickness along its bottom, running to the window's
- // edge when it does, fading up and dissolving with its band.
+ // edge when it does.
if (index == groups.notices) for (surface.tagLayers()) |*layer| {
if (layer.rows == 0 or layer.kind != .notice) continue;
const x0 = @as(f32, @floatFromInt(layer.viewport.x)) * layout.w;
const x1 = x0 + @as(f32, @floatFromInt(layer.viewport.w)) * layout.w;
const rule_x1 = if (win_w - x1 < layout.w) @max(x1, win_w) else x1;
const top = @as(f32, @floatFromInt(layer.viewport.y)) * layout.h;
- // A band still falling into place is cut at its row's top; its
- // rule comes with it, and shows only once it is below that cut.
- const rule_y = top + (1 + layer.slide) * layout.h;
- if (rule_y - dp(1) < top) continue;
- try addDecor(g, gpa, x0, rule_y - dp(1), rule_x1, rule_y, chrome.border, layer.fade, win_w, win_h);
+ const rule_y = top + layout.h;
+ try addDecor(g, gpa, x0, rule_y - dp(1), rule_x1, rule_y, chrome.border, 1, win_w, win_h);
};
if (index == groups.ink and cursors_shown) try cursorDecor(g, gpa, surface, layout, win_w, win_h);
}
diff --git a/src/panes.zig b/src/panes.zig
index 95917b42..73a0fc9e 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -309,15 +309,12 @@ pub const Pane = struct {
/// that view's focus leaving the pane drops it.
prompt_view: u8 = 0,
- pub const MessagePhase = enum { entering, shown, lingering, leaving };
- /// One message line's animation: falling in, shown, lingering after the
- /// key or click that dismissed it, dissolving. `frame` counts animation
- /// frames within the phase.
+ pub const MessagePhase = enum { shown, lingering };
+ /// One message line's life: shown, or lingering after the key or click
+ /// that dismissed it, `frame` frames of its linger gone.
pub const MessageLife = struct {
phase: MessagePhase = .shown,
frame: u16 = 0,
- /// Dismissed while still falling: it lingers once it has landed.
- dismissed: bool = false,
};
/// Older message lines kept on screen under a new one.
pub const message_stack = 3;