diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 11:50:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 15:17:05 -0300 |
| commit | ecdb0996147f319a4427273bf276e1fc5bf89156 (patch) | |
| tree | 0b1be457ce4b8ce99db4acd713ff2620cde2d015 /src/pardes.zig | |
| parent | 2bd4066a932ec8fc401e4b85e9f8441b17df3cfb (diff) | |
| download | pardes-ecdb0996147f319a4427273bf276e1fc5bf89156.tar.gz pardes-ecdb0996147f319a4427273bf276e1fc5bf89156.zip | |
effects out, the panel transitions: the eleven Panel words in both tracks go, with the core's Presentation (tracks, the frozen previous grid, cell diffs, the acknowledged-geometry pending guard, and the pointer's mapping through a moving pane, so a pointer's cell is the cell it is over), draw.zig's core-composed character effects, animation.zig's transition half, the Surface's tracks and previous grid, the tty's compositor (src/tui/panel_compositor.zig: the glide's rows move into tui.zig) and the window's track groups, frozen old layers, last-frame image snapshot, transition instance fields and shader paths (ui.vert, ui.frag's crossfade, image.vert and image.frag, the transition-<n>.ppm capture); acknowledgePanelPresentation becomes `presented`, which a frontend calls after drawing a frame (a drag's moving end and a look-hover follow what is under the pointer now), and its tape site with it; the pointer tape site goes; GUI golden 18-mid-transition goes, ttyhelp's golden loses the `SPC a` rows (its wait is on `SPC Y` now), the window monkey loses PanelSlide, and the settings behaviour test's floor of on/off words is ten
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 569 |
1 files changed, 23 insertions, 546 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 79e288a3..63f8b61a 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3,7 +3,6 @@ pub const layout = @import("layout.zig"); pub const animation = @import("animation.zig"); pub const glide = @import("glide.zig"); pub const FrameStats = @import("FrameStats.zig"); -pub const Presentation = @import("Presentation.zig"); pub const modal = @import("modal.zig"); pub const look = @import("look.zig"); pub const filesystem = @import("fs.zig"); @@ -37,7 +36,6 @@ pub const Color = @import("surface.zig").Color; pub const FontRole = @import("surface.zig").FontRole; pub const CellStyle = @import("surface.zig").CellStyle; pub const Cell = @import("surface.zig").Cell; -pub const PanelCellDiff = @import("surface.zig").PanelCellDiff; pub const ImageCacheKey = @import("surface.zig").ImageCacheKey; pub const NativePlacement = @import("surface.zig").NativePlacement; pub const ImagePatch = @import("surface.zig").ImagePatch; @@ -293,20 +291,12 @@ pub fn topbarPaneBorderPixels(cell_h: u32, tagline_h: u32) u32 { return @min(@as(u32, config.gui_topbar_pane_border_px), spare * 2); } -pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16, track: ?animation.Track) f32 { +pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16) f32 { if (row < p.topBarHeight()) return 0; if (row < p.topBarHeight() + p.columnBarHeight()) { for (p.col_x[0..p.ncol], p.col_w[0..p.ncol]) |x, w| if (col >= x and col - x < w) return @floatFromInt(x); } - if (track) |active| { - const box = active.contentBox(); - const rows: f32 = @floatFromInt(if (active.pane < MAX_PANES) if (p.panes[active.pane]) |pane| pane.tag_rows else BOX_H else BOX_H); - const tag_y = if (p.settings.tag_bottom) box.y + box.h - rows else box.y; - if (@as(f32, @floatFromInt(row)) >= tag_y and - @as(f32, @floatFromInt(row)) < tag_y + rows) - return box.x; - } for (p.panes, 0..) |slot, id| { const pane = slot orelse continue; const r = p.rects[id]; @@ -316,42 +306,6 @@ pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16, track: ?animation. return @floatFromInt(col); } -pub fn taglineOriginColForFrame(p: *const Pardes, col: u16, row: u16) f32 { - for (p.surface.panelTracks()) |track| - if (track.contentBox().contains(col, row)) - return taglineOriginCol(p, col, row, track); - return taglineOriginCol(p, col, row, null); -} - -test "paint order is moving, then opening, then closing tombstones on top" { - const Track = animation.Track; - // Deliberately interleaved on the way in: the phases are what order the - // output, not the slot they happened to occupy. - const live = [_]?Track{ - .{ .serial = 11, .pane = 3, .phase = .opening, .effect = .slide }, - .{ .serial = 12, .pane = 1, .phase = .moving, .effect = .zoom }, - null, - .{ .serial = 14, .pane = 5, .phase = .opening, .effect = .ascii }, - .{ .serial = 15, .pane = 2, .phase = .moving, .effect = .dissolve }, - }; - const closing = [_]Track{ - .{ .serial = 16, .pane = 2, .phase = .closing, .effect = .vertical }, - }; - var out: [8]Track = undefined; - const len = animation.paintOrder(&live, &closing, &out); - - var serials: [8]u32 = undefined; - for (out[0..len], 0..) |track, i| serials[i] = track.serial; - try std.testing.expectEqualSlices(u32, &.{ 12, 15, 11, 14, 16 }, serials[0..len]); - - // A host's array is fixed-size and the core's is not its business: writing - // past it would be a buffer overrun in whichever shell had the smaller one. - var tight: [2]Track = undefined; - try std.testing.expectEqual(@as(usize, 2), animation.paintOrder(&live, &closing, &tight)); - try std.testing.expectEqual(@as(u32, 12), tight[0].serial); - try std.testing.expectEqual(@as(u32, 15), tight[1].serial); -} - pub fn gridColAt(p: ?*const Pardes, x: f32, row: u16, body_w: f32, tagline_w: f32) u16 { const body = @max(body_w, 1); const tag = @max(tagline_w, 1); @@ -401,27 +355,27 @@ test "a compact tagline anchors at its own pane, and both shells step from the s const left = p.rects[0]; const right = p.rects[1]; try std.testing.expect(right.x > left.x); - try std.testing.expectEqual(@as(f32, @floatFromInt(left.x)), taglineOriginCol(p, left.x + 3, left.y, null)); - try std.testing.expectEqual(@as(f32, @floatFromInt(right.x)), taglineOriginCol(p, right.x + 3, right.y, null)); + try std.testing.expectEqual(@as(f32, @floatFromInt(left.x)), taglineOriginCol(p, left.x + 3, left.y)); + try std.testing.expectEqual(@as(f32, @floatFromInt(right.x)), taglineOriginCol(p, right.x + 3, right.y)); // The topbar's origin is column zero always — it is not a pane rect, which // is why row zero is right even in a window with no core to ask. - try std.testing.expectEqual(@as(f32, 0), taglineOriginCol(p, 40, 0, null)); + try std.testing.expectEqual(@as(f32, 0), taglineOriginCol(p, 40, 0)); const body_row = left.y + 2; - try std.testing.expectEqual(@as(f32, 7), taglineOriginCol(p, 7, body_row, null)); + try std.testing.expectEqual(@as(f32, 7), taglineOriginCol(p, 7, body_row)); const body_w: f32 = 10; const tag_w: f32 = 8; for (p.col_x[0..p.ncol], p.col_w[0..p.ncol]) |origin, width| { if (width == 0) continue; const col = origin; - try std.testing.expectEqual(@as(f32, @floatFromInt(origin)), taglineOriginCol(p, col, TOPBAR_H, null)); + try std.testing.expectEqual(@as(f32, @floatFromInt(origin)), taglineOriginCol(p, col, TOPBAR_H)); const glyph_x = @as(f32, @floatFromInt(origin)) * body_w; try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, TOPBAR_H, body_w, tag_w)); } for ([_]u16{ 0, 1, 5, 40, 119 }) |col| { - const origin = taglineOriginCol(p, col, left.y, null); + const origin = taglineOriginCol(p, col, left.y); const sdl = origin * (body_w - tag_w) + @as(f32, @floatFromInt(col)) * tag_w; const appkit = origin * body_w + (@as(f32, @floatFromInt(col)) - origin) * tag_w; try std.testing.expectEqual(sdl, appkit); @@ -430,7 +384,7 @@ test "a compact tagline anchors at its own pane, and both shells step from the s for ([_]u16{ 0, 1, 4, 9 }) |offset| { const col = left.x + offset; if (offset >= left.w) break; - const origin = taglineOriginCol(p, col, left.y, null); + const origin = taglineOriginCol(p, col, left.y); const glyph_x = origin * body_w + (@as(f32, @floatFromInt(col)) - origin) * tag_w; try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, left.y, body_w, tag_w)); } @@ -492,7 +446,6 @@ test { _ = @import("upgrade.zig"); _ = @import("recent.zig"); _ = @import("Store.zig"); - _ = @import("Presentation.zig"); _ = @import("animation.zig"); _ = @import("pager.zig"); _ = @import("Places.zig"); @@ -1860,7 +1813,6 @@ test "owned cwd close copies are transactional across inherited chains" { var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true }); defer p.deinit(); - p.presentation.enabled = false; const parent = try p.setTestFile("body\n"); p.gpa.free(parent.file.?.path); parent.file.?.path = try p.gpa.dupe(u8, "/work/project/source.zig"); @@ -1911,7 +1863,6 @@ test "owned cwd column close allocates every copy before removing any pane" { var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .shells = 3, .cols = 100, .rows = 30 }); defer p.deinit(); - p.presentation.enabled = false; p.setCwd(0, "/first"); p.setCwd(1, "/second"); const first_child = try p.newDocPane(3); @@ -1942,7 +1893,6 @@ test "owned cwd EOF failure retains the pane and Del retries its close" { var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true }); defer p.deinit(); - p.presentation.enabled = false; p.setCwd(0, "/exited"); const parent = p.panes[0].?; p.newScratchBelow(0); @@ -2405,32 +2355,16 @@ test "Font keeps requested and acknowledged faces as separate plain state" { try std.testing.expectEqualStrings(installed[0].path, request); try std.testing.expect(p.settings.font.pending); try std.testing.expect(p.takeFontRequest() == null); - const fake_track: animation.Track = .{ - .serial = p.panes[p.active].?.serial, - .pane = @intCast(p.active), - .effect = .slide, - .from = .{ .w = 20, .h = 10 }, - .to = .{ .x = 10, .w = 20, .h = 10 }, - }; - p.presentation.tracks[p.active] = fake_track; - p.presentation.shown_tracks[p.active] = fake_track; - p.presentation.acknowledged = true; try std.testing.expect(p.acknowledgeFont(installed[0].name, 1375, .pixels)); try std.testing.expect(!p.settings.font.pending); try std.testing.expectEqualStrings(installed[0].name, p.settings.font.effective_name.get()); try std.testing.expectEqual(@as(u16, 1375), p.settings.font.effective_size_hundredths); try std.testing.expectEqual(config.Runtime.FontSizeUnit.pixels, p.settings.font.effective_size_unit); - try std.testing.expect(p.presentation.tracks[p.active] == null); - try std.testing.expect(p.presentation.pending); try std.testing.expect(!p.acknowledgeFont("Duplicate Ack", 1400, .pixels)); - p.acknowledgePanelPresentation(&.{}); try std.testing.expect(p.executeBuiltinLine(p.active, cmd)); _ = p.takeFontRequest() orelse return error.MissingRepeatedFontRequest; - p.presentation.tracks[p.active] = fake_track; try std.testing.expect(p.acknowledgeFont(installed[0].name, 1375, .pixels)); - try std.testing.expect(p.presentation.tracks[p.active] != null); - try std.testing.expect(!p.presentation.pending); // A name nothing answers to changes neither request nor effective state. try std.testing.expect(p.executeBuiltinLine(p.active, "Font zzz-no-such-face")); @@ -2481,33 +2415,6 @@ test "startup config overrides restored styling before initFromDump returns" { try std.testing.expectEqual(ChromeTheme.fromTheme(restored.theme()), restored.chromeTheme().*); } -test "restored sessions animate layout changes after bootstrap" { - const source = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 16 }); - defer source.deinit(); - try dump.dumpState(source); - - const restored = try dump.initFromDump( - std.testing.allocator, - .{ .tty_only = true, .cols = 80, .rows = 16, .startup_config = "PanelSlide\n" }, - source.dump_out.?, - ); - defer restored.deinit(); - try std.testing.expectEqual(animation.Transition.slide, restored.settings.panel_transition); - try std.testing.expect(!restored.animationActive()); - - var frame: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer frame.deinit(); - const initial = try restored.render(frame.allocator()); - restored.acknowledgePanelPresentation(initial.panelTracks()); - _ = try restored.newShell(1, ""); - try std.testing.expect(layout.splitColumn(restored, 0, 1, false)); - restored.sync(); - - try std.testing.expect(restored.presentation.tracks[0] != null); - try std.testing.expect(restored.presentation.tracks[1] != null); - try std.testing.expect(restored.animationActive()); -} - test "restored terminals keep monotonic nonzero pane identities" { const gpa = std.testing.allocator; const source = try Pardes.init(gpa, .{ .shells = 3 }); @@ -2767,7 +2674,7 @@ test "editable workspace and column tags are typed into and persist" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 20, .tty_only = true }); defer p.deinit(); _ = try p.setTestFile("untouched\n"); - p.acknowledgePanelPresentation(&.{}); + p.presented(); try std.testing.expectEqual(TOPBAR_H + COLBAR_H, p.rects[0].y); // a sweep over a header is its selection, the caret where it ended p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = TAG_TEXT_INSET, .row = 0 } }); @@ -2812,7 +2719,7 @@ test "column tag first-cell execution keeps New local to the clicked column" { p.sync(); for (0..2) |column| { p.active = p.col_panes[1 - column][0]; - p.acknowledgePanelPresentation(&.{}); + p.presented(); const before = p.col_n; p.update(.{ .mouse = .{ .button = .middle, .kind = .press, .col = p.col_x[column] + TAG_TEXT_INSET, .row = TOPBAR_H } }); p.update(.{ .mouse = .{ .button = .middle, .kind = .release, .col = p.col_x[column] + TAG_TEXT_INSET, .row = TOPBAR_H } }); @@ -2836,7 +2743,7 @@ test "a screen too short for the column row releases a column tag's focus withou defer p.deinit(); const pane = try p.setTestFile("unchanged body\n"); p.col_tags[0].own = try p.gpa.dupe(u8, "New Help"); - p.acknowledgePanelPresentation(&.{}); + p.presented(); const shown = p.rects[0]; try std.testing.expectEqual(TOPBAR_H + COLBAR_H, shown.y); p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = TAG_TEXT_INSET, .row = TOPBAR_H } }); @@ -3196,48 +3103,6 @@ test "Newcol refuses an unsplittable restored weight before spawning" { try std.testing.expect(p.nextEffect() == null); } -test "layout commits publish finite tracks only for changed panes" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 }); - defer p.deinit(); - // The mechanism, at a fixed flavour, not the default\'s tuning. - p.settings.motion = .crisp; - - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - const untouched = p.rects[1]; - - p.settings.panel_transition = .slide; - _ = try p.newShell(2, ""); - try std.testing.expect(layout.splitColumn(p, 0, 2, true)); - p.sync(); - - // Pane 1 belongs to the unrelated right column. Its exact layout stayed - // fixed, so it does not receive a presentation record either. - try std.testing.expect(p.presentation.tracks[1] == null); - try std.testing.expect(p.presentation.tracks[0] != null); - try std.testing.expect(p.presentation.tracks[2] != null); - try std.testing.expectEqual(animation.Phase.moving, p.presentation.tracks[0].?.phase); - try std.testing.expectEqual(animation.Phase.opening, p.presentation.tracks[2].?.phase); - try std.testing.expectEqual(untouched, p.rects[1]); - try std.testing.expect(p.animationActive()); - - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - const surface = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 2), surface.panelTracks().len); - - for (0..animation.Transition.slide.frames()) |_| p.update(.tick); - try std.testing.expect(!p.animationActive()); - _ = frame.reset(.retain_capacity); - try std.testing.expectEqual(@as(usize, 0), (try p.render(frame.allocator())).panelTracks().len); - - p.settings.panel_transition = .zoom; - p.update(.{ .resize = .{ .cols = 101, .rows = 17 } }); - try std.testing.expect(!p.animationActive()); - for (p.presentation.tracks) |track| try std.testing.expect(track == null); -} - test "screen resize keeps its previous storage until allocation succeeds" { var failing: std.testing.FailingAllocator = .init(std.testing.allocator, .{}); const p = try Pardes.init(failing.allocator(), .{ .cols = 80, .rows = 24, .tty_only = true }); @@ -3260,307 +3125,6 @@ test "screen resize keeps its previous storage until allocation succeeds" { try std.testing.expectEqual(@as(usize, 81 * 25), resized.cells.len); } -test "vertical close samples only a canonical baseline containing that pane" { - { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 16, .tty_only = true }); - defer p.deinit(); - // The mechanism, at a fixed flavour, not the default\'s tuning. - p.settings.motion = .crisp; - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - p.settings.panel_transition = .vertical; - const boot = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(boot.panelTracks()); - - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - _ = frame.reset(.retain_capacity); - const opening = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(opening.panelTracks()); - try p.removePane(1, null); - p.sync(); - - try std.testing.expectEqual(@as(usize, 0), p.presentation.closing_len); - } - - // Once the pane itself has reached a canonical acknowledged frame, that - // exact box is safe frozen source data for its ordinary closing slide. - { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 16, .tty_only = true }); - defer p.deinit(); - // The mechanism, at a fixed flavour, not the default\'s tuning. - p.settings.motion = .crisp; - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - p.settings.panel_transition = .vertical; - const boot = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(boot.panelTracks()); - - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - for (0..animation.Transition.vertical.frames()) |_| p.update(.tick); - _ = frame.reset(.retain_capacity); - const canonical = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 0), canonical.panelTracks().len); - p.acknowledgePanelPresentation(canonical.panelTracks()); - const serial = p.panes[1].?.serial; - try p.removePane(1, null); - p.sync(); - - try std.testing.expectEqual(@as(usize, 1), p.presentation.closing_len); - try std.testing.expectEqual(serial, p.presentation.closing[0].serial); - } -} - -test "previous-grid animation refreshes its mask and snaps overlapping layout churn" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true }); - defer p.deinit(); - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - p.settings.panel_transition = .vertical; - const boot = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(boot.panelTracks()); - - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - _ = frame.reset(.retain_capacity); - const opening = try p.render(frame.allocator()); - const changed_index = for (opening.cell_diffs, 0..) |diff, index| { - if (diff.changed()) break index; - } else return error.MissingPanelDiff; - p.acknowledgePanelPresentation(opening.panelTracks()); - - // Corrupt one cached classification to prove a later live frame derives it again - // from the frozen old cells and freshly rendered new cells. - p.presentation.diffs[changed_index] = .unchanged; - _ = frame.reset(.retain_capacity); - const refreshed = try p.render(frame.allocator()); - try std.testing.expect(refreshed.cell_diffs[changed_index].changed()); - p.acknowledgePanelPresentation(refreshed.panelTracks()); - - _ = try p.newShell(2, ""); - try std.testing.expect(layout.splitColumn(p, 1, 2, false)); - p.sync(); - try std.testing.expect(p.presentation.diff_state == .none); - try std.testing.expectEqual(@as(usize, 0), p.presentation.closing_len); - for (p.presentation.tracks) |track| try std.testing.expect(track == null); - try std.testing.expect(p.presentation.pending); - - _ = frame.reset(.retain_capacity); - const snapped = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 0), snapped.panelTracks().len); -} - -test "canonical fallback and transition toggle retire unpresented tracks" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 16, .tty_only = true }); - defer p.deinit(); - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - const boot = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(boot.panelTracks()); - p.settings.panel_transition = .slide; - - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - _ = frame.reset(.retain_capacity); - const animated = try p.render(frame.allocator()); - try std.testing.expect(animated.panelTracks().len > 0); - - // A host which rendered the canonical fallback acknowledges exactly that - // empty record set; producers cannot resume on its next frame. - p.acknowledgePanelPresentation(&.{}); - try std.testing.expect(!p.animationActive()); - try std.testing.expect(p.presentation.diff_state == .none); - _ = frame.reset(.retain_capacity); - try std.testing.expectEqual(@as(usize, 0), (try p.render(frame.allocator())).panelTracks().len); - - // Recreate a visible sample, then change the selected effect. Actual old - // pixels remain on screen until the next submit, so pointer input waits. - p.settings.panel_transition = .slide; - p.col_weight[0] = column_weight_unit * 2; - p.col_weight[1] = column_weight_unit; - p.sync(); - _ = frame.reset(.retain_capacity); - const moving = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(moving.panelTracks()); - try std.testing.expect(moving.panelTracks().len > 0); - exec.applySettingBuiltin(p, config.Runtime.find("PanelZoom").?, null); - try std.testing.expectEqual(animation.Transition.zoom, p.settings.panel_transition); - try std.testing.expect(p.presentation.pending); - try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, 10, 4) == null); - for (p.presentation.tracks) |track| try std.testing.expect(track == null); - - p.acknowledgePanelPresentation(&.{}); - p.col_weight[0] = column_weight_unit; - p.col_weight[1] = column_weight_unit * 2; - p.sync(); - _ = frame.reset(.retain_capacity); - const before_resize = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(before_resize.panelTracks()); - try std.testing.expect(before_resize.panelTracks().len > 0); - const old_tagline_percent = p.settings.font.tagline_percent; - var percent_buf: [3]u8 = undefined; - const same_percent = try std.fmt.bufPrint(&percent_buf, "{d}", .{old_tagline_percent}); - exec.applySettingBuiltin(p, config.Runtime.find("TaglineSize").?, same_percent); - try std.testing.expect(p.animationActive()); - const changed_percent: u8 = if (old_tagline_percent == 73) 74 else 73; - const changed_text = try std.fmt.bufPrint(&percent_buf, "{d}", .{changed_percent}); - exec.applySettingBuiltin(p, config.Runtime.find("TaglineSize").?, changed_text); - try std.testing.expectEqual(changed_percent, p.settings.font.tagline_percent); - try std.testing.expect(p.presentation.pending); - for (p.presentation.tracks) |track| try std.testing.expect(track == null); -} - -test "back-to-back layout commits retarget from the last presented boxes" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true }); - defer p.deinit(); - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - const initial = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(initial.panelTracks()); - const shown_a = layout.panelBox(p.rects[0]); - p.settings.panel_transition = .slide; - - p.col_weight[0] = column_weight_unit; - p.col_weight[1] = column_weight_unit * 2; - p.sync(); - const target_b = p.presentation.tracks[0] orelse return error.MissingFirstRetarget; - try std.testing.expect(target_b.from.eql(shown_a)); - - // No render or acknowledgement of B: the pixels are still A. C must not - // jump to the logical-but-unseen B before beginning its own transition. - p.col_weight[0] = column_weight_unit * 2; - p.col_weight[1] = column_weight_unit; - p.sync(); - const target_c = p.presentation.tracks[0] orelse return error.MissingSecondRetarget; - try std.testing.expect(target_c.from.eql(shown_a)); - try std.testing.expect(target_c.to.eql(layout.panelBox(p.rects[0]))); - try std.testing.expectEqual(animation.Phase.moving, target_c.phase); - - _ = frame.reset(.retain_capacity); - const latest = try p.render(frame.allocator()); - var submitted: ?animation.Track = null; - for (latest.panelTracks()) |track| if (track.pane == 0) { - submitted = track; - break; - }; - const track = submitted orelse return error.MissingSubmittedRetarget; - p.acknowledgePanelPresentation(latest.panelTracks()); - try std.testing.expect(p.presentation.shown[0].?.box.eql(track.visualBox())); -} - -test "an unpresented opening pane remains in the opening paint phase" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true }); - defer p.deinit(); - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - const initial = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(initial.panelTracks()); - p.settings.panel_transition = .slide; - - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - const first = p.presentation.tracks[1] orelse return error.MissingOpeningTrack; - try std.testing.expectEqual(animation.Phase.opening, first.phase); - - _ = try p.newShell(2, ""); - try std.testing.expect(layout.splitColumn(p, 1, 2, true)); - p.sync(); - const retargeted = p.presentation.tracks[1] orelse return error.MissingOpeningRetarget; - try std.testing.expectEqual(animation.Phase.opening, retargeted.phase); - try std.testing.expect(retargeted.from.eql(first.from)); -} - -test "core composes ASCII bytes while visual-only cells pass through" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 8, .rows = 4, .tty_only = true }); - defer p.deinit(); - var current: [4]Cell = @splat(.{ .default = false }); - var previous = current; - for (¤t, "Dwxq") |*cell, byte| cell.text[0] = byte; - for (&previous, "Azxq") |*cell, byte| cell.text[0] = byte; - current[2].style.bold = true; // visual-only: same glyph, new style - current[3].text[0..2].* = .{ 0xc3, 0xa9 }; - current[3].len = 2; // non-ASCII: canonical immediately - const diffs = [_]PanelCellDiff{ - .{ .ascii = .{ .from = 'A', .to = 'D' } }, - .{ .ascii = .{ .from = 'z', .to = 'w' } }, - .visual, - .visual, - }; - var surface: Surface = .{ - .cols = 4, - .rows = 1, - .cells = ¤t, - .previous_cells = &previous, - .cell_diffs = &diffs, - }; - surface.panel_tracks[0] = .{ - .effect = .ascii, - .frame = 2, - .frame_count = 4, - .from = .{ .w = 4, .h = 1 }, - .to = .{ .w = 4, .h = 1 }, - }; - surface.npanel_tracks = 1; - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); - defer arena.deinit(); - - const presented = try draw.composeAsciiTransitions(p, arena.allocator(), &surface); - try std.testing.expect(presented != &surface); - try std.testing.expectEqualStrings("C", presented.at(0, 0).grapheme()); - try std.testing.expectEqualStrings("x", presented.at(1, 0).grapheme()); - try std.testing.expectEqual(current[2], presented.at(2, 0).*); - try std.testing.expectEqual(current[3], presented.at(3, 0).*); - try std.testing.expectEqualStrings("D", surface.at(0, 0).grapheme()); -} - -test "core composes character motion out of the new grid, not a fade" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 8, .rows = 4, .tty_only = true }); - defer p.deinit(); - var current: [8]Cell = @splat(.{ .default = false }); - var previous = current; - for (¤t, "abcdefgh") |*cell, byte| cell.text[0] = byte; - for (&previous, "........") |*cell, byte| cell.text[0] = byte; - // Motion effects carry every glyph in the pane, so a cell's semantic - // classification is irrelevant to them; only the frozen grid matters. - const diffs: [8]PanelCellDiff = @splat(.visual); - var surface: Surface = .{ - .cols = 8, - .rows = 1, - .cells = ¤t, - .previous_cells = &previous, - .cell_diffs = &diffs, - }; - surface.panel_tracks[0] = .{ - .effect = .edges, - .frame = 4, - .to = .{ .w = 8, .h = 1 }, - }; - surface.npanel_tracks = 1; - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); - defer arena.deinit(); - - const presented = try draw.composeAsciiTransitions(p, arena.allocator(), &surface); - try std.testing.expect(presented != &surface); - var seen: [8]u8 = undefined; - for (&seen, 0..) |*byte, col| byte.* = presented.at(@intCast(col), 0).text[0]; - try std.testing.expectEqualStrings("cdefgh..", &seen); - try std.testing.expectEqualStrings("a", surface.at(0, 0).grapheme()); - - // The last active sample is the untouched canonical grid, with no copy. - surface.panel_tracks[0].frame = animation.Transition.edges.frames() - 1; - try std.testing.expect(try draw.composeAsciiTransitions(p, arena.allocator(), &surface) == &surface); -} - test "repeated non-dyadic column splits preserve every unrelated boundary" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 979, .rows = 20 }); defer p.deinit(); @@ -3733,7 +3297,6 @@ pub const Pardes = struct { rects: [MAX_PANES]Rect = @splat(.{}), col_x: [MAX_COLS]u16 = undefined, col_w: [MAX_COLS]u16 = undefined, - presentation: Presentation = .{}, active: usize = 0, /// The files opened lately, closed ones too (recent.zig): `Recent`, @@ -4039,7 +3602,7 @@ pub const Pardes = struct { pub const replica = .{ .local = .{ // A frame, and the animations and timings that make it. - "surface", "presentation", "frames", "chrome_animation", + "surface", "frames", "chrome_animation", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "frame_arena", "scratch", "needs_frame", "present_skipped", "shell_continuous", "native_image_patches", "echo", @@ -4222,7 +3785,6 @@ pub const Pardes = struct { exec.applyStartupConfig(p); colors.finishThemeInitialization(p); p.sync(); - p.presentation.enabled = true; // A config init that opens a file with `Look …` armed the pulse before // anyone touched anything. Nobody asked for that, so boot is silent. _ = p.takeHaptic(); @@ -4396,7 +3958,6 @@ pub const Pardes = struct { gpa.free(p.surface.cells); for (&p.surface.body_layers) |*layer| gpa.free(layer.cells); for (&p.surface.tag_layers) |*layer| gpa.free(layer.cells); - p.presentation.deinit(gpa); p.surface.images.deinit(gpa); gpa.destroy(p); } @@ -4921,7 +4482,7 @@ pub const Pardes = struct { if (!p.observeFont(effective_name, effective_size_hundredths, unit)) return false; p.settings.font.pending = false; p.font_request_taken = false; - if (changed) p.abandonPanelAnimations(); + if (changed) look.cancelLookHover(p); return true; } @@ -5642,7 +5203,6 @@ pub const Pardes = struct { }; switch (ev) { .resize => |sz| { - p.presentation.snap_once = true; if (sz.row_metrics) |metrics| p.row_metrics = metrics; if (comptime pdf_enabled) { var before: [MAX_PANES]?panes.Pdf.Viewport = @splat(null); @@ -5702,13 +5262,7 @@ pub const Pardes = struct { p.typedInto(); p.handleKey(key); }, - .mouse => |m| { - if (m.kind == .release) switch (p.drag) { - .border_v, .border_h, .move, .column_move => p.presentation.snap_once = true, - else => {}, - }; - mouse.handleMouse(p, m); - }, + .mouse => |m| mouse.handleMouse(p, m), .pdf_scroll => |scroll| { if (comptime pdf_enabled) { if (scroll.pane < MAX_PANES) { @@ -5742,7 +5296,6 @@ pub const Pardes = struct { .tick => { mouse.edgeScroll(p); p.chrome_animation.advance(); - p.presentation.advance(); look.advanceLookHover(p); }, } @@ -6721,33 +6274,19 @@ pub const Pardes = struct { /// The rows n/N's walk over look-able text reads before it stops (look.zig). pub const max_look_rows = 8192; - pub fn acknowledgePanelPresentation(p: *Pardes, tracks: []const animation.Track) void { - const taped = tape.enter(p, .{ .acknowledge_panel_presentation = tracks }); + /// The frontend drew a frame: a pointer resting on it follows what is + /// under it now, a drag's moving end and a look-hover's word. + pub fn presented(p: *Pardes) void { + const taped = tape.enter(p, .presented); defer tape.leave(p, taped); - p.presentation.acknowledge(p, tracks); if (p.pointer_inside and p.drag != .none) { - if (p.pointerCell(p.pointer_raw_col, p.pointer_raw_row)) |mapped| { - p.hover_col = mapped.col; - p.hover_row = mapped.row; - mouse.dragUpdate(p, mapped.col, mapped.row, p.pointer_body_hit); - } + p.hover_col = p.pointer_raw_col; + p.hover_row = p.pointer_raw_row; + mouse.dragUpdate(p, p.pointer_raw_col, p.pointer_raw_row, p.pointer_body_hit); } look.refreshLookHoverFromRaw(p); } - /// The cell of the session's grid a pointer at this cell of the frame - /// is over, seen through the frame (a pane sliding in): the recording - /// session's answer, whose frames these were (src/tape.zig). Null over - /// a pane on its way out. - pub fn pointerCell(p: *const Pardes, col: u16, row: u16) ?Presentation.CellPosition { - return tape.value(.pointer, Presentation.pointer, .{ &p.presentation, p.screen_w, p.screen_h, col, row }); - } - - pub fn abandonPanelAnimations(p: *Pardes) void { - p.presentation.cancel(); - look.cancelLookHover(p); - } - /// 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 { @@ -7117,7 +6656,6 @@ pub const Pardes = struct { p.reapPanes(); if (views.several(p)) views.show(p); layout.compute(p); - p.presentation.sync(p); p.trackJump(); for (&p.panes, 0..) |*slot, id| { const pane = slot.* orelse continue; @@ -7292,7 +6830,7 @@ pub const Pardes = struct { // the next frame (writes served before the shell's clock was first // seen are stamped 0, which `advance` would count back from). if (p.fs.batch.bytes.items.len > 0) return @max(next, p.fs.batch.last_ns + ctlfs.pane.batch_pause_ns); - if (p.chrome_animation.isActive() or p.presentation.animating()) return next; + if (p.chrome_animation.isActive()) return next; // Places still to find resume on the next frame; a picture being // decoded is looked for. for (p.panes) |slot| if (slot) |pane| if (pane.places.busy(pane)) return next; @@ -8059,7 +7597,7 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const surface = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(&.{}); + p.presented(); const r = p.rects[p.active]; const row = r.y + report.tag_rows; const col = r.x + config.GUTTER + panes.File.gutterWidth(report) + 7; @@ -8369,35 +7907,6 @@ fn bootAndTearDown(gpa: std.mem.Allocator) !void { p.deinit(); } -test "transition grids: the surface borrows its snapshots" { - const per_cell = 2 * @sizeOf(Cell) + @sizeOf(PanelCellDiff); - - const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 16, .tty_only = true }); - defer p.deinit(); - var frame: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer frame.deinit(); - p.settings.panel_transition = .vertical; - const boot = try p.render(frame.allocator()); - p.acknowledgePanelPresentation(boot.panelTracks()); - _ = try p.newShell(1, ""); - try std.testing.expect(layout.splitColumn(p, 0, 1, false)); - p.sync(); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - - const cells = @as(usize, p.screen_w) * p.screen_h; - try std.testing.expectEqual(cells, p.surface.cells.len); - try std.testing.expectEqual(cells, p.presentation.previous_cells.len); - try std.testing.expectEqual(cells, p.presentation.diffs.len); - try std.testing.expect(p.surface.previous_cells.ptr == p.presentation.previous_cells.ptr); - try std.testing.expect(p.surface.cell_diffs.ptr == p.presentation.diffs.ptr); - try std.testing.expect(p.surface.cells.ptr != p.surface.previous_cells.ptr); - const owned = p.surface.cells.len * @sizeOf(Cell) + - p.presentation.previous_cells.len * @sizeOf(Cell) + - p.presentation.diffs.len * @sizeOf(PanelCellDiff); - try std.testing.expectEqual(cells * per_cell, owned); -} - test "LSP failure clears only its matching wait without completion indentation" { if (!lsp.supports.contains(.completion)) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); @@ -8620,38 +8129,6 @@ test "a Save the host could not do logs no save record" { try std.testing.expect(th.logHas(p, "\nsave ")); } -test "a new panel's frame zero is presented before it advances" { - const core = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); - defer core.deinit(); - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - const frame = animation.frame_ns; - - core.advance(100); - const idle = try core.render(arena.allocator()); - core.acknowledgePanelPresentation(idle.panelTracks()); - try std.testing.expectEqual(@as(?u64, null), core.nextWake()); - - core.settings.panel_transition = .slide; - core.update(.{ .command = "Newcol" }); - _ = arena.reset(.retain_capacity); - const first = try core.render(arena.allocator()); - const track_count = first.panelTracks().len; - try std.testing.expect(track_count > 0); - for (first.panelTracks()) |track| try std.testing.expectEqual(@as(u16, 0), track.frame); - - core.acknowledgePanelPresentation(first.panelTracks()); - // Just short of a frame is no frame at all. - core.advance(100 + frame - 1); - _ = arena.reset(.retain_capacity); - for ((try core.render(arena.allocator())).panelTracks()) |track| try std.testing.expectEqual(@as(u16, 0), track.frame); - core.advance(100 + frame); - _ = arena.reset(.retain_capacity); - const second = try core.render(arena.allocator()); - try std.testing.expectEqual(track_count, second.panelTracks().len); - for (second.panelTracks()) |track| try std.testing.expectEqual(@as(u16, 1), track.frame); -} - test "tagline bands center in their cells and Tagbottom faces the window edge" { const cell_h: u32 = 20; const tagline_h: u32 = 16; |
