summaryrefslogtreecommitdiff
path: root/src/surface.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 11:50:43 -0300
committerGabriel Schneider <[email protected]>2026-11-05 15:17:05 -0300
commitecdb0996147f319a4427273bf276e1fc5bf89156 (patch)
tree0b1be457ce4b8ce99db4acd713ff2620cde2d015 /src/surface.zig
parent2bd4066a932ec8fc401e4b85e9f8441b17df3cfb (diff)
downloadpardes-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/surface.zig')
-rw-r--r--src/surface.zig153
1 files changed, 0 insertions, 153 deletions
diff --git a/src/surface.zig b/src/surface.zig
index 367839d0..6e383841 100644
--- a/src/surface.zig
+++ b/src/surface.zig
@@ -3,7 +3,6 @@
const pardes = @import("pardes.zig");
const std = @import("std");
const layout = @import("layout.zig");
-const animation = @import("animation.zig");
const uucode = @import("uucode");
const vaxis = @import("vaxis");
const panes = @import("panes.zig");
@@ -58,70 +57,6 @@ pub const Cell = struct {
}
};
-pub const AsciiDiff = struct {
- from: u8,
- to: u8,
-
- /// Long printable-byte walks complete in about the same time as the other
- /// panel effects. Extra distance is crossed by eased character skips.
- pub const max_movement_frames = animation.ascii_max_movement_frames;
-
- pub fn between(old: *const Cell, new: *const Cell) ?AsciiDiff {
- const from = old.printableAscii() orelse return null;
- const to = new.printableAscii() orelse return null;
- if (from == to) return null;
- return .{ .from = from, .to = to };
- }
-
- pub fn distance(diff: AsciiDiff) u8 {
- return if (diff.from < diff.to) diff.to - diff.from else diff.from - diff.to;
- }
-
- pub fn movementFrames(diff: AsciiDiff) u16 {
- return @min(@as(u16, diff.distance()), max_movement_frames);
- }
-
- pub fn frameCount(diff: AsciiDiff) u16 {
- return diff.movementFrames() + 1;
- }
-
- pub fn byteAt(diff: AsciiDiff, frame: u16) u8 {
- const movements: u32 = diff.movementFrames();
- const at: u32 = @min(@as(u32, frame), movements);
- const delta: u8 = @intCast(easedDistance(diff.distance(), movements, at));
- return if (diff.from < diff.to) diff.from + delta else diff.from - delta;
- }
-
- fn easedDistance(span: u8, movements: u32, at: u32) u32 {
- if (movements == 0 or at >= movements) return span;
- const n: u64 = at;
- const d: u64 = movements;
- const shape = n * n * n * (10 * d * d + 6 * n * n - 15 * d * n);
- const denominator = d * d * d * d * d;
- return @intCast((@as(u64, span) * shape + denominator / 2) / denominator);
- }
-
- pub fn complete(diff: AsciiDiff, frame: u16) bool {
- return diff.byteAt(frame) == diff.to;
- }
-};
-
-pub const PanelCellDiff = union(enum) {
- unchanged,
- visual,
- ascii: AsciiDiff,
-
- pub fn between(old: *const Cell, new: *const Cell) PanelCellDiff {
- if (old.visuallyEqual(new)) return .unchanged;
- if (AsciiDiff.between(old, new)) |diff| return .{ .ascii = diff };
- return .visual;
- }
-
- pub fn changed(diff: PanelCellDiff) bool {
- return diff != .unchanged;
- }
-};
-
test "cell visual equality ignores dead grapheme tail bytes" {
var a: Cell = .{ .default = false };
var b = a;
@@ -137,73 +72,6 @@ test "cell visual equality ignores dead grapheme tail bytes" {
try std.testing.expect(a.visuallyEqual(&b));
}
-test "ASCII cell diffs ease long byte walks in both directions" {
- var low: Cell = .{ .default = false };
- low.text[0] = 'A';
- var high: Cell = .{ .default = false };
- high.text[0] = 'F';
-
- const rising = AsciiDiff.between(&low, &high).?;
- try std.testing.expectEqual(@as(u16, 6), rising.frameCount());
- try std.testing.expectEqual(@as(u8, 'A'), rising.byteAt(0));
- try std.testing.expectEqual(@as(u8, 'A'), rising.byteAt(1));
- try std.testing.expectEqual(@as(u8, 'C'), rising.byteAt(2));
- try std.testing.expectEqual(@as(u8, 'F'), rising.byteAt(4));
- try std.testing.expectEqual(@as(u8, 'F'), rising.byteAt(500));
-
- const falling = AsciiDiff.between(&high, &low).?;
- try std.testing.expectEqual(@as(u8, 'D'), falling.byteAt(2));
- try std.testing.expectEqual(@as(u8, 'A'), falling.byteAt(4));
-
- low.text[0] = ' ';
- high.text[0] = '~';
- const long_rising = AsciiDiff.between(&low, &high).?;
- try std.testing.expectEqual(@as(u16, 13), long_rising.frameCount());
- try std.testing.expectEqual(@as(u8, ' '), long_rising.byteAt(0));
- try std.testing.expectEqual(@as(u8, '#'), long_rising.byteAt(2));
- try std.testing.expectEqual(@as(u8, 'O'), long_rising.byteAt(6));
- try std.testing.expectEqual(@as(u8, '{'), long_rising.byteAt(10));
- try std.testing.expectEqual(@as(u8, '~'), long_rising.byteAt(12));
-
- const long_falling = AsciiDiff.between(&high, &low).?;
- try std.testing.expectEqual(@as(u8, 'O'), long_falling.byteAt(6));
- try std.testing.expectEqual(@as(u8, ' '), long_falling.byteAt(12));
-
- // The shape itself is the contract: never backwards, and the widest step
- // is in the middle of the walk rather than at either end.
- var previous = long_rising.byteAt(0);
- var first_step: u8 = 0;
- var middle_step: u8 = 0;
- var frame: u16 = 1;
- while (frame <= long_rising.movementFrames()) : (frame += 1) {
- const byte = long_rising.byteAt(frame);
- try std.testing.expect(byte >= previous);
- const step = byte - previous;
- if (frame == 1) first_step = step;
- if (frame == 6) middle_step = step;
- previous = byte;
- }
- try std.testing.expect(middle_step > first_step);
- try std.testing.expect(middle_step > long_rising.byteAt(12) - long_rising.byteAt(11));
-}
-
-test "ASCII diff classification skips stable and non-ASCII glyphs" {
- var old: Cell = .{ .default = false };
- old.text[0] = 'x';
- var style_only = old;
- style_only.style.bold = true;
- try std.testing.expectEqual(PanelCellDiff.visual, PanelCellDiff.between(&old, &style_only));
-
- var changed = old;
- changed.text[0] = 'z';
- try std.testing.expectEqual(AsciiDiff{ .from = 'x', .to = 'z' }, PanelCellDiff.between(&old, &changed).ascii);
-
- var unicode = old;
- unicode.text[0..2].* = .{ 0xc3, 0xa9 };
- unicode.len = 2;
- try std.testing.expectEqual(PanelCellDiff.visual, PanelCellDiff.between(&old, &unicode));
-}
-
pub const ImageCacheKey = if (pdf_enabled) struct {
serial: u32,
page: u32,
@@ -487,13 +355,6 @@ pub const Surface = struct {
/// bar: draw an insert-style thin cursor instead of the block
cursor: ?struct { x: u16, y: u16, bar: bool = false } = null,
images: std.ArrayList(ImagePlace) = .empty,
- panel_tracks: [MAX_PANES * 2]animation.Track = undefined,
- npanel_tracks: usize = 0,
- previous_cells: []const Cell = &.{},
- previous_body_layers: []const Layer = &.{},
- previous_tag_layers: []const Layer = &.{},
- previous_regions: []const Region = &.{},
- cell_diffs: []const PanelCellDiff = &.{},
pub fn tagLayers(s: *const Surface) []const Layer {
return &s.tag_layers;
@@ -519,20 +380,6 @@ pub const Surface = struct {
return null;
}
- pub fn panelTracks(s: *const Surface) []const animation.Track {
- return s.panel_tracks[0..s.npanel_tracks];
- }
-
- pub fn hasPanelDiff(s: *const Surface) bool {
- return s.previous_cells.len == s.cells.len and
- s.cell_diffs.len == s.cells.len;
- }
-
- pub fn panelCellChanged(s: *const Surface, x: u16, y: u16) bool {
- if (!s.hasPanelDiff() or x >= s.cols or y >= s.rows) return false;
- return s.cell_diffs[@as(usize, y) * s.cols + x].changed();
- }
-
pub fn at(s: *Surface, x: u16, y: u16) *Cell {
std.debug.assert(x < s.cols and y < s.rows);
return &s.cells[@as(usize, y) * s.cols + x];