summaryrefslogtreecommitdiff
path: root/src/tty
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-24 23:16:11 -0300
committerGabriel Schneider <[email protected]>2026-10-25 01:30:09 -0300
commit706b9d98fdce29a58ffe5a8a5417d6b2810e6d2c (patch)
tree1367ad33c41891dc89a7507b156660e0694e5a29 /src/tty
parent6e8a6a63d45b2caef7b649d358f836e6cc4134d6 (diff)
downloadpardes-706b9d98fdce29a58ffe5a8a5417d6b2810e6d2c.tar.gz
pardes-706b9d98fdce29a58ffe5a8a5417d6b2810e6d2c.zip
anim 12: the tty runs the GUI's motion system: the view's glide moves to src/glide.zig (Glide, its step: find the view that moved, snapshot, measure, kick), the GUI keeps only its wheel notches and its pixel draw; the tty steps it each loop and draws it at whole rows (glide.shifted: the position rounded, never the step, the rows that left in the gap, a caret whose line rode the scroll carried with it, one that kept its row left still); rows that only disagree glide the core's lines instead of snapping; the snapshot harness's virtual clock runs a frame a wake while it moves
Diffstat (limited to 'src/tty')
-rw-r--r--src/tty/tty.zig27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig
index b7bb2d54..c97ba4bf 100644
--- a/src/tty/tty.zig
+++ b/src/tty/tty.zig
@@ -1339,6 +1339,7 @@ fn localSession(
};
pardes.lsp.setStatusSink(&sh, lspStatusSink);
host_io.setExitWake(loop, wakeForExit);
+ defer sh.glide.deinit(gpa);
defer {
host_io.setExitWake(null, null);
pardes.lsp.setStatusSink(null, null);
@@ -1516,6 +1517,8 @@ const Shell = struct {
tracks: []const pardes.animation.Track = &.{},
/// T2: the cursor's jump trail (JumpTrail).
trail: JumpTrail = .{},
+ /// The view's glide, the GUI's motion drawn at whole rows (anim 12).
+ glide: pardes.glide.Glide = .{},
/// T7: when each pane's view last moved (ThumbFlash).
flash: ThumbFlash = .{},
/// PARDES_TEST_CLOCK's virtual time (host_io.testClock), and where the
@@ -1540,6 +1543,7 @@ const Shell = struct {
.now = clockNow,
.present = present,
.post_present = postPresent,
+ .poll_frame = stepGlide,
};
const vtable: host_io.Host.VTable = .{
@@ -1611,7 +1615,9 @@ const Shell = struct {
fn waitOnce(s: *Shell, wait: u32) void {
var batch: usize = 0;
if (wait != 0) {
- s.wake_to = s.core.nextWake() orelse 0;
+ // A virtual clock moves a frame a wake while anything moves
+ // continuously (the glide), as the real one would.
+ s.wake_to = s.core.nextWake() orelse if (s.core.continuous()) s.core.now_ns + pardes.animation.frame_ns else 0;
requestWake(s.io, wait);
}
pardes.turn.rest();
@@ -1789,8 +1795,17 @@ const Shell = struct {
s.loop.postEvent(.files_changed) catch {};
}
+ /// ponytail: a terminal's scrollback under the wheel lands here (the
+ /// wheel reaches the core as a mouse event, not counted as the GUI's
+ /// notches are); `wheeled` from the mouse event if it should glide.
+ fn stepGlide(ctx: ?*anyopaque) void {
+ const s = of(ctx);
+ s.glide.step(s.core, s.gpa, null, null);
+ }
+
fn pollFrame(ctx: ?*anyopaque) void {
const s = of(ctx);
+ stepGlide(ctx);
s.core.native_image_patches = kitty_shm.load(.acquire);
if (s.fs) |f| if (f.tick().pending) {
_ = s.loop.tryPostEvent(.fs_ready) catch {};
@@ -1831,8 +1846,12 @@ const Shell = struct {
const win = vx.window();
const truecolor = vx.caps.rgb or colortermTruecolor();
// Each of the shell's own motions below asks for frames while it runs.
- s.core.shell_continuous = false;
- const shadowed = chipShadows(s.frame.allocator(), surface, s.core, truecolor) catch surface;
+ if (s.glide.pending) s.glide.measure(s.gpa, canonical);
+ if (s.glide.moving()) s.glide.advance(s.core.now_ns, s.glide.motion);
+ s.core.shell_continuous = s.glide.moving();
+ s.core.frames.scroll = @round(s.glide.follow.offset);
+ const glided = pardes.glide.shifted(&s.glide, s.frame.allocator(), surface) catch surface;
+ const shadowed = chipShadows(s.frame.allocator(), glided, s.core, truecolor) catch glided;
const flashed = s.flash.apply(s.frame.allocator(), shadowed, s.core, truecolor) catch shadowed;
const trailed = s.trail.apply(s.frame.allocator(), flashed, s.core, truecolor) catch flashed;
paintCells(win, trailed.cells, trailed.cols, trailed.rows);
@@ -1922,7 +1941,7 @@ const Shell = struct {
vx.freeImage(s.tty.writer(), removed.value.id);
if (stale_len < stale.len) break;
}
- if (surface.cursor) |cur| paintCursor(win, cur.x, cur.y, cur.bar);
+ if (glided.cursor) |cur| paintCursor(win, cur.x, cur.y, cur.bar);
const tz_render = tracy.zone(@src(), "vx.render");
const before = s.tty.tty_writer.pos + s.tty.writer().end;
vx.render(s.tty.writer()) catch {};