summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/typ/builtins-gui.json11
-rw-r--r--docs/typ/builtins-tui.json11
-rw-r--r--docs/typ/reference.typ8
-rw-r--r--shaders/decor.frag.glsl8
-rw-r--r--shaders/image.frag.glsl28
-rw-r--r--shaders/image.vert.glsl16
-rw-r--r--shaders/prebuilt/decor.frag.spvbin7852 -> 3772 bytes
-rw-r--r--shaders/prebuilt/image.frag.spvbin4200 -> 1344 bytes
-rw-r--r--shaders/prebuilt/image.vert.spvbin5032 -> 3152 bytes
-rw-r--r--shaders/prebuilt/ui.frag.spvbin6968 -> 6188 bytes
-rw-r--r--shaders/prebuilt/ui.vert.spvbin5612 -> 4072 bytes
-rw-r--r--shaders/ui.frag.glsl26
-rw-r--r--shaders/ui.vert.glsl35
-rw-r--r--src/Presentation.zig796
-rw-r--r--src/Query.zig4
-rw-r--r--src/animation.zig691
-rw-r--r--src/builtins.zig7
-rw-r--r--src/config.zig70
-rw-r--r--src/draw.zig195
-rw-r--r--src/dump.zig1
-rw-r--r--src/exec.zig20
-rw-r--r--src/gui/gui.zig994
-rw-r--r--src/look.zig69
-rw-r--r--src/main.zig1
-rw-r--r--src/mouse.zig265
-rw-r--r--src/ninep/screen.zig128
-rw-r--r--src/pardes.zig569
-rw-r--r--src/surface.zig153
-rw-r--r--src/tape.zig13
-rw-r--r--src/tui/panel_compositor.zig785
-rw-r--r--src/tui/tui.zig132
-rw-r--r--src/views.zig6
-rw-r--r--test/behaviour/settings.zig4
-rw-r--r--test/column_drag.zig5
-rw-r--r--test/gui-goldens.txt1
-rw-r--r--test/mode.zig2
-rw-r--r--test/output.zig16
-rw-r--r--test/panes.zig44
-rw-r--r--test/pdf.zig4
-rw-r--r--test/process/window.zig10
-rw-r--r--test/snapshots/ttyhelp.golden14
-rw-r--r--test/snapshots/ttyhelp.snap6
42 files changed, 461 insertions, 4687 deletions
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json
index f2eb46d3..0c3396c5 100644
--- a/docs/typ/builtins-gui.json
+++ b/docs/typ/builtins-gui.json
@@ -77,17 +77,6 @@
{"name": "Pager", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "pardes, off", "doc": "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it."},
{"name": "PagerColor", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A +Pager keeps its program's colours, on or off; for the next text paged."},
{"name": "Palette", "leader": "SPC t l", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "the C64 palette or the terminal's own 16"},
- {"name": "PanelAscii", "leader": "SPC a a", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close through a scatter of ASCII, on or off."},
- {"name": "PanelCurtain", "leader": "SPC a c", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close like a curtain, on or off."},
- {"name": "PanelDissolve", "leader": "SPC a d", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes dissolve in and out as they open and close, on or off."},
- {"name": "PanelEdges", "leader": "SPC a e", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close from their edges, on or off."},
- {"name": "PanelFall", "leader": "SPC a f", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes fall into place as they open, on or off."},
- {"name": "PanelScramble", "leader": "SPC a r", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close through scrambled text, on or off."},
- {"name": "PanelSlide", "leader": "SPC a s", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes slide in and out as they open and close, on or off."},
- {"name": "PanelType", "leader": "SPC a t", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes type themselves in as they open, on or off."},
- {"name": "PanelVertical", "leader": "SPC a v", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close with a vertical wipe, on or off."},
- {"name": "PanelWave", "leader": "SPC a w", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close in a wave, on or off."},
- {"name": "PanelZoom", "leader": "SPC a z", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes zoom in and out as they open and close, on or off."},
{"name": "Panes", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pick an open pane by its name in a query pane under this one (SPC b b)."},
{"name": "Parallax", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A theme's page pattern moves with the text at a quarter of its speed, on or off."},
{"name": "PdfFit", "leader": "SPC t z", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Fit the PDF page to the pane by width or by height, flipping between them (or to the one named, `width|height`)."},
diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json
index 2947aa98..6c979754 100644
--- a/docs/typ/builtins-tui.json
+++ b/docs/typ/builtins-tui.json
@@ -72,17 +72,6 @@
{"name": "Pager", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "pardes, off", "doc": "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it."},
{"name": "PagerColor", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A +Pager keeps its program's colours, on or off; for the next text paged."},
{"name": "Palette", "leader": "SPC t l", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "the C64 palette or the terminal's own 16"},
- {"name": "PanelAscii", "leader": "SPC a a", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close through a scatter of ASCII, on or off."},
- {"name": "PanelCurtain", "leader": "SPC a c", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close like a curtain, on or off."},
- {"name": "PanelDissolve", "leader": "SPC a d", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes dissolve in and out as they open and close, on or off."},
- {"name": "PanelEdges", "leader": "SPC a e", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close from their edges, on or off."},
- {"name": "PanelFall", "leader": "SPC a f", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes fall into place as they open, on or off."},
- {"name": "PanelScramble", "leader": "SPC a r", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close through scrambled text, on or off."},
- {"name": "PanelSlide", "leader": "SPC a s", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes slide in and out as they open and close, on or off."},
- {"name": "PanelType", "leader": "SPC a t", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes type themselves in as they open, on or off."},
- {"name": "PanelVertical", "leader": "SPC a v", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close with a vertical wipe, on or off."},
- {"name": "PanelWave", "leader": "SPC a w", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes open and close in a wave, on or off."},
- {"name": "PanelZoom", "leader": "SPC a z", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Panes zoom in and out as they open and close, on or off."},
{"name": "Panes", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pick an open pane by its name in a query pane under this one (SPC b b)."},
{"name": "PdfFit", "leader": "SPC t z", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Fit the PDF page to the pane by width or by height, flipping between them (or to the one named, `width|height`)."},
{"name": "PdfSections", "leader": "SPC t s", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the PDF's sections in a pane, each a place to go."},
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ
index 1544ddb6..d9622e9c 100644
--- a/docs/typ/reference.typ
+++ b/docs/typ/reference.typ
@@ -460,13 +460,7 @@ padded in groups of eight matches. An invalid field rejects the whole line;
a repeated field's last value wins. The settings survive #word("Dump") and #word("Restore").
Source analysis is cached for 64 files and 64 MiB.
-*Effects.* Panel transitions, one at a time, running the active one again
-turning it off: #word("PanelSlide"), #word("PanelZoom"),
-#word("PanelDissolve"), #word("PanelAscii"), #word("PanelVertical"),
-#word("PanelEdges"), #word("PanelFall"), #word("PanelWave"),
-#word("PanelCurtain"), #word("PanelScramble"), #word("PanelType"); all
-start off, and the web shell has none. #word("Motion")
-`off|crisp|smooth|bouncy|playful` (default `smooth`), #word("Parallax"),
+*Effects.* #word("Motion") `off|crisp|smooth|bouncy|playful` (default `smooth`), #word("Parallax"),
#word("CursorBlink"), #word("GripWidth") `<50-300>`, the GUI's. No effect
may lower the contrast of text, the selection or a focus indicator.
diff --git a/shaders/decor.frag.glsl b/shaders/decor.frag.glsl
index 72083ffe..5a6ac458 100644
--- a/shaders/decor.frag.glsl
+++ b/shaders/decor.frag.glsl
@@ -1,8 +1,8 @@
#version 450
-// Decor, drawn by ui.vert.glsl like a cell, its track's transition included,
-// and blended as the overlay pipeline blends (backgroundLayerBlend). Ink (a
-// cursor) is drawn with the opacity uniform at 1.
+// Decor, drawn by ui.vert.glsl like a cell, and blended as the overlay
+// pipeline blends (backgroundLayerBlend). Ink (a cursor) is drawn with the
+// opacity uniform at 1.
//
// Flat: a hard-edged fill (a rule, a rail, a grip mark, a bar cursor). Its
// colour rides in the cell's ground (a_bg), its coverage in a_fg.r, so the
@@ -18,7 +18,7 @@ layout(location = 0) in vec2 v_uv;
layout(location = 1) in vec3 v_fg;
layout(location = 2) in vec3 v_bg;
layout(location = 3) in vec2 v_cell_uv;
-layout(location = 4) flat in uvec4 v_effect;
+layout(location = 4) flat in uvec2 v_effect;
layout(location = 5) flat in vec4 v_clip;
layout(location = 0) out vec4 o_col;
diff --git a/shaders/image.frag.glsl b/shaders/image.frag.glsl
index 0cc1b2ee..38a95da6 100644
--- a/shaders/image.frag.glsl
+++ b/shaders/image.frag.glsl
@@ -6,40 +6,12 @@ layout(std140, set = 3, binding = 0) uniform UiUniforms {
} u_ui;
layout(location = 0) in vec2 v_uv;
-layout(location = 1) in vec2 v_panel_uv;
-layout(location = 2) flat in uvec4 v_effect;
layout(location = 0) out vec4 o_col;
-float cellNoise(uint serial, uint col, uint row) {
- uint x = serial ^ (col * 0x9e3779b9u) ^ (row * 0x85ebca6bu);
- x ^= x >> 16;
- x *= 0x7feb352du;
- x ^= x >> 15;
- x *= 0x846ca68bu;
- x ^= x >> 16;
- return float(x & 0xffffu) / 65535.0;
-}
-
void main() {
vec4 source = texture(u_image, v_uv);
// Keep source coverage for destination subtraction; the pipeline scales
// source alpha by the same opacity through its alpha blend constant.
source.rgb *= clamp(u_ui.background_opacity, 0.0, 1.0);
- uint effect = v_effect.x & 0x7fffffffu;
- bool oldLayer = (v_effect.x & 0x80000000u) != 0u;
- float progress = clamp(uintBitsToFloat(v_effect.y), 0.0, 1.0);
- uvec2 dimensions = max(
- uvec2(v_effect.w & 0xffffu, v_effect.w >> 16),
- uvec2(1u));
- uvec2 cellCoord = min(
- uvec2(floor(max(v_panel_uv, vec2(0.0)) * vec2(dimensions))),
- dimensions - 1u);
- float noise = cellNoise(v_effect.z, cellCoord.x, cellCoord.y);
- if (effect == 3u) {
- bool reveal = progress >= 1.0 || (progress > 0.0 && noise < progress);
- if (oldLayer == reveal) discard;
- o_col = source;
- return;
- }
o_col = source;
}
diff --git a/shaders/image.vert.glsl b/shaders/image.vert.glsl
index 04196ce4..ace55a53 100644
--- a/shaders/image.vert.glsl
+++ b/shaders/image.vert.glsl
@@ -4,13 +4,8 @@
// the pane's cell rectangle and the aspect-preserving contain fit to NDC.
layout(location = 0) in vec4 a_rect; // x0, y0, x1, y1
layout(location = 1) in vec4 a_uv_rect; // u0, v0, u1, v1
-layout(location = 2) in vec4 a_panel_rect;
-layout(location = 3) in vec4 a_present_rect;
-layout(location = 4) in uvec4 a_effect;
layout(location = 0) out vec2 v_uv;
-layout(location = 1) out vec2 v_panel_uv;
-layout(location = 2) flat out uvec4 v_effect;
void main() {
vec2 pos;
@@ -34,16 +29,5 @@ void main() {
pos = vec2(a_rect.x, a_rect.w);
v_uv = vec2(a_uv_rect.x, a_uv_rect.w);
}
- v_panel_uv = v_uv;
- uint effect = a_effect.x & 0x7fffffffu;
- if (effect != 0u) {
- vec2 panel_size = a_panel_rect.zw - a_panel_rect.xy;
- panel_size.x = abs(panel_size.x) < 0.000001 ? 0.000001 : panel_size.x;
- panel_size.y = abs(panel_size.y) < 0.000001 ? -0.000001 : panel_size.y;
- v_panel_uv = (pos - a_panel_rect.xy) / panel_size;
- if (effect == 1u || effect == 2u || effect == 5u)
- pos = mix(a_present_rect.xy, a_present_rect.zw, v_panel_uv);
- }
- v_effect = a_effect;
gl_Position = vec4(pos, 0.0, 1.0);
}
diff --git a/shaders/prebuilt/decor.frag.spv b/shaders/prebuilt/decor.frag.spv
index bd565d03..6ec3fe61 100644
--- a/shaders/prebuilt/decor.frag.spv
+++ b/shaders/prebuilt/decor.frag.spv
Binary files differ
diff --git a/shaders/prebuilt/image.frag.spv b/shaders/prebuilt/image.frag.spv
index c9511ad7..d663ed80 100644
--- a/shaders/prebuilt/image.frag.spv
+++ b/shaders/prebuilt/image.frag.spv
Binary files differ
diff --git a/shaders/prebuilt/image.vert.spv b/shaders/prebuilt/image.vert.spv
index 35165d69..1105bae2 100644
--- a/shaders/prebuilt/image.vert.spv
+++ b/shaders/prebuilt/image.vert.spv
Binary files differ
diff --git a/shaders/prebuilt/ui.frag.spv b/shaders/prebuilt/ui.frag.spv
index 02e3edc4..aa788c0b 100644
--- a/shaders/prebuilt/ui.frag.spv
+++ b/shaders/prebuilt/ui.frag.spv
Binary files differ
diff --git a/shaders/prebuilt/ui.vert.spv b/shaders/prebuilt/ui.vert.spv
index af5b0738..4e90e521 100644
--- a/shaders/prebuilt/ui.vert.spv
+++ b/shaders/prebuilt/ui.vert.spv
Binary files differ
diff --git a/shaders/ui.frag.glsl b/shaders/ui.frag.glsl
index 51ec5b8c..68bfe70b 100644
--- a/shaders/ui.frag.glsl
+++ b/shaders/ui.frag.glsl
@@ -22,7 +22,7 @@ layout(location = 0) in vec2 v_uv;
layout(location = 1) in vec3 v_fg;
layout(location = 2) in vec3 v_bg;
layout(location = 3) in vec2 v_cell_uv;
-layout(location = 4) flat in uvec4 v_effect;
+layout(location = 4) flat in uvec2 v_effect;
layout(location = 5) flat in vec4 v_clip;
layout(location = 0) out vec4 o_col;
@@ -31,16 +31,13 @@ void main() {
if (v_clip.z >= v_clip.x && (gl_FragCoord.x < v_clip.x || gl_FragCoord.x >= v_clip.z ||
gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard;
float a = texture(u_atlas, v_uv).r;
- bool oldLayer = (v_effect.x & 0x80000000u) != 0u;
// A block cursor is foreground chrome even though its fill occupies the
// cell background: keep it visible at WindowOpacity 0. Otherwise a clear
// theme ground has no coverage and ordinary backgrounds use the setting.
- // The three high flags are shared with ui.vert.glsl and src/gui/gui.zig.
+ // The high flags are shared with ui.vert.glsl and src/gui/gui.zig.
float bgA = (v_effect.x & 0x20000000u) != 0u ? 1.0
: (v_effect.x & 0x40000000u) != 0u ? 0.0
: clamp(u_ui.background_opacity, 0.0, 1.0);
- uint effect = v_effect.x & 0x07ffffffu;
- float progress = clamp(uintBitsToFloat(v_effect.y), 0.0, 1.0);
// Ink over ground, both premultiplied: v_fg*a + (v_bg*bgA)*(1-a), which is
// mix() with the ground already premultiplied. At bgA = 1 that is exactly
@@ -50,9 +47,9 @@ void main() {
// dot every period pixels, fixed to the window, under the text.
if ((v_effect.x & 0x10000000u) != 0u) {
float period = u_ui.decor_dot_geom.x;
- // v_effect.z: how far its pane's text has moved the dots (G13's
+ // v_effect.y: how far its pane's text has moved the dots (G13's
// parallax), in pixels, as a float's bits (0 without).
- vec2 at = gl_FragCoord.xy - vec2(0.0, uintBitsToFloat(v_effect.z));
+ vec2 at = gl_FragCoord.xy - vec2(0.0, uintBitsToFloat(v_effect.y));
vec2 d = mod(at, period) - 0.5 * period;
float dot_a = 1.0 - smoothstep(u_ui.decor_dot_geom.y, u_ui.decor_dot_geom.z, length(d));
ground = mix(ground, u_ui.decor_dots.rgb, u_ui.decor_dots.a * dot_a);
@@ -72,21 +69,6 @@ void main() {
}
vec4 cell = vec4(mix(under.rgb, v_fg, a), mix(under.a, 1.0, a));
- // 3 = dissolve, a crossfade (G7): a changed cell's new form is drawn
- // first, whole, and its frozen old one over it at 1 - progress,
- // premultiplied (the frame's cells blend over, pipeline_over), so the
- // old fades out as the new comes in; at the ends, exactly one of them.
- // The tty keeps its per-cell swap (panel_animation.dissolveRevealed).
- if (effect == 3u) {
- if (!oldLayer) {
- o_col = cell;
- return;
- }
- if (progress >= 1.0) discard;
- o_col = cell * (1.0 - progress);
- return;
- }
-
// FreeType's hinted grayscale bitmap is already the intended coverage.
// Preserve it exactly; weight-changing gamma hacks blur small stems.
o_col = cell;
diff --git a/shaders/ui.vert.glsl b/shaders/ui.vert.glsl
index de22adee..313070c6 100644
--- a/shaders/ui.vert.glsl
+++ b/shaders/ui.vert.glsl
@@ -9,28 +9,20 @@ layout(location = 0) in vec4 a_rect; // x0, y0, x1, y1
layout(location = 1) in vec4 a_uv_rect; // u0, v0, u1, v1
layout(location = 2) in vec3 a_fg;
layout(location = 3) in vec3 a_bg;
-// Final and presented panel rectangles in NDC. The CPU still uploads logical
-// final cells; this shader is the only place transition geometry is applied.
-layout(location = 4) in vec4 a_panel_rect;
-layout(location = 5) in vec4 a_present_rect;
-// effect id, eased-progress float bits, pane serial, local row/column packed
-// into one uint. The FIVE high effect bits are flags — the frozen-old cell
-// layer, a see-through cell background, an opaque block-cursor fill, a soft
-// shadow (decor.frag.glsl) or dotted page ground (ui.frag.glsl), and a
-// checker (decor) or a file name's shadow (ui) — so the id is what is left
-// below them; integer transport preserves the exact
-// cross-backend hash.
-layout(location = 6) in uvec4 a_effect;
+// Flags, and the theme's dots' offset (G13's parallax) as a float's bits.
+// The flags are the high bits of x: a see-through cell background, an
+// opaque block-cursor fill, a dotted page ground (ui.frag.glsl) and a
+// checker (decor) or a file name's shadow (ui).
+layout(location = 4) in uvec2 a_effect;
// A clip rectangle in target pixels (x0, y0, x1, y1): the fragment shader
-// drops what lies outside it. x1 < x0 is none. A vertical transition clips
-// its pane's instances to the box the pane is growing into.
-layout(location = 7) in vec4 a_clip;
+// drops what lies outside it. x1 < x0 is none.
+layout(location = 5) in vec4 a_clip;
layout(location = 0) out vec2 v_uv;
layout(location = 1) out vec3 v_fg;
layout(location = 2) out vec3 v_bg;
layout(location = 3) out vec2 v_cell_uv;
-layout(location = 4) flat out uvec4 v_effect;
+layout(location = 4) flat out uvec2 v_effect;
layout(location = 5) flat out vec4 v_clip;
void main() {
@@ -62,17 +54,6 @@ void main() {
uv = vec2(a_uv_rect.x, a_uv_rect.w);
v_cell_uv = vec2(0.0, 1.0);
}
-
- uint effect = a_effect.x & 0x07ffffffu;
- if (effect == 1u || effect == 2u || effect == 5u) {
- // NDC y points up, so a top-left/bottom-right box has a NEGATIVE y
- // delta. Preserve that sign or every local y is mirrored/outside.
- vec2 panel_size = a_panel_rect.zw - a_panel_rect.xy;
- panel_size.x = abs(panel_size.x) < 0.000001 ? 0.000001 : panel_size.x;
- panel_size.y = abs(panel_size.y) < 0.000001 ? -0.000001 : panel_size.y;
- vec2 within = (pos - a_panel_rect.xy) / panel_size;
- pos = mix(a_present_rect.xy, a_present_rect.zw, within);
- }
v_uv = uv;
v_fg = a_fg;
v_bg = a_bg;
diff --git a/src/Presentation.zig b/src/Presentation.zig
deleted file mode 100644
index fc6de5b6..00000000
--- a/src/Presentation.zig
+++ /dev/null
@@ -1,796 +0,0 @@
-//! Panel presentation: which pane geometry the shells have been shown, the
-//! transition tracks that move it there, and the frozen previous grid the
-//! character and dissolve effects read. Only acknowledged draws advance the
-//! shown geometry; committed and submitted may be ahead of it.
-const std = @import("std");
-const pardes = @import("pardes.zig");
-const layout = @import("layout.zig");
-const animation = @import("animation.zig");
-const Pardes = pardes.Pardes;
-const MAX_PANES = pardes.MAX_PANES;
-const Box = animation.Box;
-const Track = animation.Track;
-const Phase = animation.Phase;
-const Transition = animation.Transition;
-const openingBox = animation.openingBox;
-const closingBox = animation.closingBox;
-const panelBox = layout.panelBox;
-
-const Presentation = @This();
-
-pub const Snapshot = struct { serial: u32, box: Box };
-
-// Only acknowledged draws advance shown geometry; committed and submitted may be ahead.
-committed: [MAX_PANES]?Snapshot = @splat(null),
-initialized: bool = false,
-enabled: bool = false,
-snap_once: bool = false,
-tracks: [MAX_PANES]?Track = @splat(null),
-closing: [MAX_PANES]Track = undefined,
-closing_len: usize = 0,
-submitted: [MAX_PANES]?Snapshot = @splat(null),
-submitted_ready: bool = false,
-shown: [MAX_PANES]?Snapshot = @splat(null),
-shown_tracks: [MAX_PANES]?Track = @splat(null),
-shown_closing: [MAX_PANES]Track = undefined,
-shown_closing_len: usize = 0,
-acknowledged: bool = false,
-pending: bool = false,
-previous_cells: []pardes.Cell = &.{},
-previous_body_layers: [MAX_PANES]pardes.Layer = @splat(.{}),
-previous_tag_layers: [pardes.MAX_TAG_LAYERS]pardes.Layer = @splat(.{}),
-previous_regions: [pardes.MAX_REGIONS]pardes.Region = undefined,
-previous_nregions: u16 = 0,
-previous_cols: u16 = 0,
-previous_rows: u16 = 0,
-previous_valid: bool = false,
-previous_layout: [MAX_PANES]?Snapshot = @splat(null),
-diffs: []pardes.PanelCellDiff = &.{},
-diff_state: enum { none, requested, ready } = .none,
-
-pub const CellPosition = struct { col: u16, row: u16 };
-
-pub fn deinit(self: *Presentation, gpa: std.mem.Allocator) void {
- if (self.previous_cells.len > 0) gpa.free(self.previous_cells);
- for (&self.previous_body_layers) |*layer| gpa.free(layer.cells);
- for (&self.previous_tag_layers) |*layer| gpa.free(layer.cells);
- if (self.diffs.len > 0) gpa.free(self.diffs);
-}
-
-pub fn sync(self: *Presentation, p: *Pardes) void {
- const initializing = !self.initialized or !self.enabled;
- if (initializing or self.snap_once) {
- const had_layout = self.initialized;
- self.committed = @splat(null);
- self.tracks = @splat(null);
- self.closing_len = 0;
- self.diff_state = .none;
- if (initializing) {
- self.shown_tracks = @splat(null);
- self.shown_closing_len = 0;
- }
- for (p.panes, 0..) |slot, id| {
- const pane = slot orelse continue;
- self.committed[id] = .{ .serial = pane.serial, .box = panelBox(p.rects[id]) };
- }
- self.initialized = true;
- self.snap_once = false;
- if (had_layout and self.acknowledged)
- self.pending = true;
- return;
- }
-
- const effect = p.settings.panel_transition;
- if (effect.needsPreviousGrid() and self.diff_state != .none) {
- var second_change = false;
- for (p.panes, self.committed, 0..) |slot, snapshot, id| {
- const pane = slot orelse {
- second_change = second_change or snapshot != null;
- continue;
- };
- const target = panelBox(p.rects[id]);
- second_change = second_change or snapshot == null or
- snapshot.?.serial != pane.serial or !snapshot.?.box.eql(target);
- }
- if (second_change) {
- p.abandonPanelAnimations();
- self.committed = @splat(null);
- for (p.panes, 0..) |slot, id| {
- const pane = slot orelse continue;
- self.committed[id] = .{ .serial = pane.serial, .box = panelBox(p.rects[id]) };
- }
- return;
- }
- }
- var changed = false;
- var animated_change = false;
- for (p.panes, 0..) |slot, id| {
- const pane = slot orelse {
- if (self.committed[id]) |old| {
- changed = true;
- if (effect.lifecycleOnly()) {
- if (self.appendClosing(.{
- .serial = old.serial,
- .pane = @intCast(id),
- .phase = .closing,
- .effect = effect,
- .from = old.box,
- .to = closingBox(effect, old.box),
- })) animated_change = true;
- }
- }
- self.committed[id] = null;
- self.tracks[id] = null;
- // Never let pixels from a dead pane address a reused slot.
- self.shown_tracks[id] = null;
- continue;
- };
- const target = panelBox(p.rects[id]);
- const previous = self.committed[id];
- self.committed[id] = .{ .serial = pane.serial, .box = target };
-
- if (effect == .off) {
- changed = changed or previous == null or previous.?.serial != pane.serial or
- !previous.?.box.eql(target);
- self.tracks[id] = null;
- continue;
- }
- if (previous) |old| {
- if (old.serial == pane.serial and old.box.eql(target)) continue;
- const same_lifetime = old.serial == pane.serial;
- const prior = if (self.tracks[id]) |track|
- if (track.serial == pane.serial and track.active()) track else null
- else
- null;
- if (effect.lifecycleOnly() and same_lifetime) {
- if (prior) |active| if (active.phase == .opening) {
- var next = active;
- next.from = openingBox(effect, target, p.screen_w);
- next.to = target;
- self.tracks[id] = next;
- changed = true;
- animated_change = true;
- continue;
- };
- self.tracks[id] = null;
- changed = true;
- continue;
- }
- if (effect.lifecycleOnly() and !same_lifetime) {
- _ = self.appendClosing(.{
- .serial = old.serial,
- .pane = @intCast(id),
- .phase = .closing,
- .effect = effect,
- .from = old.box,
- .to = closingBox(effect, old.box),
- });
- }
- const shown = if (self.shown[id]) |snapshot|
- if (snapshot.serial == pane.serial) snapshot.box else null
- else
- null;
- const from = if (!same_lifetime)
- openingBox(effect, target, p.screen_w)
- else if (shown) |box|
- box
- else if (self.acknowledged and prior != null)
- prior.?.from
- else
- old.box;
- var next = stamp(p, .{
- .serial = pane.serial,
- .pane = @intCast(id),
- .phase = if (!same_lifetime or
- (prior != null and prior.?.phase == .opening)) .opening else .moving,
- .effect = effect,
- .from = from,
- .to = target,
- });
- // Retargeted mid-way from where it shows: it keeps its speed.
- if (same_lifetime and shown != null) if (prior) |old_move| {
- next.launch = carriedLaunch(old_move, next);
- };
- self.tracks[id] = next;
- changed = true;
- animated_change = true;
- } else {
- const next = stamp(p, .{
- .serial = pane.serial,
- .pane = @intCast(id),
- .phase = .opening,
- .effect = effect,
- .from = openingBox(effect, target, p.screen_w),
- .to = target,
- });
- self.tracks[id] = next;
- changed = true;
- animated_change = true;
- }
- }
- if (animated_change and effect.needsPreviousGrid()) {
- self.diff_state = .requested;
- }
- if (changed and self.acknowledged) self.pending = true;
-}
-
-/// A pane that moves (slides, zooms or rises) follows the Motion flavour:
-/// its curve, and a length in proportion (animation.Motion.span).
-fn stamp(p: *const Pardes, track: Track) Track {
- var stamped = track;
- switch (track.effect) {
- .slide, .zoom, .vertical => {
- const motion = animation.Motion.of(p.settings.motion);
- stamped.motion = @backingInt(p.settings.motion) + 1;
- stamped.frame_count = @intFromFloat(@max(2, @round(@as(f32, @floatFromInt(track.effect.frames())) * motion.span)));
- },
- else => {},
- }
- return stamped;
-}
-
-/// A retargeted move's starting speed, in its own lengths per unit of
-/// progress, from the old move's speed now (cells per frame), along the
-/// new move's longest side; within four lengths per unit either way.
-fn carriedLaunch(old_move: Track, next: Track) f32 {
- const v = old_move.velocity();
- if (next.frames() <= 1) return 0;
- const steps: f32 = @floatFromInt(next.frames() - 1);
- const d: [4]f32 = .{ next.to.x - next.from.x, next.to.y - next.from.y, next.to.w - next.from.w, next.to.h - next.from.h };
- const vs: [4]f32 = .{ v.x, v.y, v.w, v.h };
- var axis: usize = 0;
- for (d, 0..) |value, i| if (@abs(value) > @abs(d[axis])) {
- axis = i;
- };
- if (@abs(d[axis]) < 1e-3) return 0;
- return std.math.clamp(vs[axis] * steps / d[axis], -4, 4);
-}
-
-fn appendClosing(self: *Presentation, track: Track) bool {
- std.debug.assert(track.phase == .closing);
- const baseline = self.previous_layout[track.pane] orelse return false;
- if (!self.previous_valid or baseline.serial != track.serial or
- !baseline.box.eql(track.from)) return false;
- if (self.closing_len == self.closing.len) {
- std.mem.copyForwards(
- Track,
- self.closing[0 .. self.closing.len - 1],
- self.closing[1..],
- );
- self.closing_len -= 1;
- }
- self.closing[self.closing_len] = track;
- self.closing_len += 1;
- return true;
-}
-
-pub fn advance(self: *Presentation) void {
- for (&self.tracks) |*slot| {
- const track = if (slot.*) |*track| track else continue;
- track.frame +|= 1;
- if (!track.active()) slot.* = null;
- }
- var out: usize = 0;
- for (self.closing[0..self.closing_len]) |value| {
- var track = value;
- track.frame +|= 1;
- if (!track.active()) continue;
- self.closing[out] = track;
- out += 1;
- }
- self.closing_len = out;
-}
-
-pub fn acknowledge(self: *Presentation, p: *Pardes, tracks: []const Track) void {
- var presented: [MAX_PANES]?Track = @splat(null);
- var presented_closing: [MAX_PANES]Track = undefined;
- var nclosing: usize = 0;
- var presented_layout: [MAX_PANES]?Snapshot = if (self.submitted_ready)
- self.submitted
- else
- @splat(null);
- if (!self.submitted_ready) for (p.panes, 0..) |slot, id| {
- const pane = slot orelse continue;
- presented_layout[id] = .{ .serial = pane.serial, .box = panelBox(p.rects[id]) };
- };
- for (&presented_layout, 0..) |*snapshot, id| if (snapshot.*) |saved| {
- const pane = p.panes[id] orelse {
- snapshot.* = null;
- continue;
- };
- if (pane.serial != saved.serial) snapshot.* = null;
- };
- for (tracks) |track| {
- if (track.phase == .closing) {
- const current = for (self.closing[0..self.closing_len]) |candidate| {
- if (candidate.serial == track.serial and candidate.pane == track.pane and
- candidate.effect == track.effect) break true;
- } else false;
- if (!current or !track.active() or nclosing == presented_closing.len) continue;
- presented_closing[nclosing] = track;
- nclosing += 1;
- continue;
- }
- const id: usize = track.pane;
- if (id >= p.panes.len or !track.active()) continue;
- const pane = p.panes[id] orelse continue;
- if (pane.serial != track.serial) continue;
- presented[id] = track;
- presented_layout[id] = .{ .serial = track.serial, .box = track.visualBox() };
- }
- self.shown_tracks = presented;
- self.shown_closing = presented_closing;
- self.shown_closing_len = nclosing;
- self.shown = presented_layout;
- self.acknowledged = true;
- self.pending = false;
- if (tracks.len == 0) {
- self.tracks = @splat(null);
- self.closing_len = 0;
- self.diff_state = .none;
- // The frozen grid exists for transitions alone: with them off, an
- // idle frame copies nothing.
- if (p.settings.panel_transition != .off) {
- self.capturePrevious(p.gpa, &p.surface);
- } else {
- self.previous_valid = false;
- self.previous_layout = @splat(null);
- }
- }
-}
-
-pub fn capturePrevious(self: *Presentation, gpa: std.mem.Allocator, surface: *const pardes.Surface) void {
- self.diff_state = .none;
- const cells = surface.cells;
- copy: {
- if (cells.len == 0) break :copy;
- if (self.previous_cells.len != cells.len) {
- const next = gpa.alloc(pardes.Cell, cells.len) catch break :copy;
- if (self.previous_cells.len > 0) gpa.free(self.previous_cells);
- self.previous_cells = next;
- }
- const olds = [_][]pardes.Layer{ &self.previous_body_layers, &self.previous_tag_layers };
- const currents = [_][]const pardes.Layer{ surface.bodyLayers(), surface.tagLayers() };
- for (olds, currents) |old_layers, current_layers| for (old_layers, current_layers) |*old, *current| {
- const count = if (current.rows > 0) current.cells.len else 0;
- const storage = if (old.cells.len == count) old.cells else gpa.realloc(old.cells, count) catch break :copy;
- if (count > 0) @memcpy(storage, current.cells);
- old.* = current.*;
- old.cells = storage;
- };
- @memcpy(self.previous_cells, cells);
- @memcpy(self.previous_regions[0..surface.nregions], surface.regionList());
- self.previous_nregions = surface.nregions;
- self.previous_cols = surface.cols;
- self.previous_rows = surface.rows;
- self.previous_valid = true;
- self.previous_layout = if (self.submitted_ready)
- self.submitted
- else
- @splat(null);
- return;
- }
- self.previous_valid = false;
- self.previous_layout = @splat(null);
-}
-
-pub fn cellDiff(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u16) pardes.PanelCellDiff {
- if (self.diff_state != .ready or col >= cols or row >= rows or
- self.diffs.len != @as(usize, cols) * rows) return .unchanged;
- return self.diffs[@as(usize, row) * cols + col];
-}
-
-pub const Point = struct { x: f32, y: f32 };
-
-/// Coordinates stay fractional until the host resolves its body font grid.
-pub fn pointerFractional(self: *const Presentation, cols: u16, rows: u16, x: f32, y: f32) ?Point {
- if (self.pending or !std.math.isFinite(x) or !std.math.isFinite(y) or
- x < 0 or y < 0 or x >= @as(f32, @floatFromInt(cols)) or y >= @as(f32, @floatFromInt(rows))) return null;
- var closing = self.shown_closing_len;
- while (closing > 0) {
- closing -= 1;
- const track = self.shown_closing[closing];
- if (track.active() and boxContainsPoint(track.contentBox(), x, y) and
- boxContainsPoint(track.presented(), x, y)) return null;
- }
- for ([_]Phase{ .opening, .moving }) |phase| {
- var index = self.shown_tracks.len;
- while (index > 0) {
- index -= 1;
- const track = self.shown_tracks[index] orelse continue;
- if (!track.active() or track.phase != phase) continue;
- switch (track.effect) {
- .slide, .zoom, .vertical => {
- const target = track.contentBox();
- if (track.effect == .vertical and !boxContainsPoint(target, x, y)) continue;
- // Past its mark (a flavour's overshoot or wind-up) a pane
- // is drawn over a neighbour; a point there is the
- // neighbour's, never the moving pane's.
- if (pastMark(track) and !boxContainsPoint(target, x, y)) continue;
- const shown = track.presented();
- if (!boxContainsPoint(shown, x, y)) {
- if (track.effect == .vertical) return null;
- continue;
- }
- return .{
- .x = target.x + (x - shown.x) / shown.w * target.w,
- .y = target.y + (y - shown.y) / shown.h * target.h,
- };
- },
- else => {
- if (!boxContainsPoint(track.to, x, y)) continue;
- _ = self.pointer(cols, rows, @intFromFloat(@floor(x)), @intFromFloat(@floor(y))) orelse return null;
- return .{ .x = x, .y = y };
- },
- }
- }
- }
- _ = self.pointer(cols, rows, @intFromFloat(@floor(x)), @intFromFloat(@floor(y))) orelse return null;
- return .{ .x = x, .y = y };
-}
-
-/// A flavour's overshoot or wind-up: the pane is drawn beyond the path from
-/// where it was to where it goes.
-fn pastMark(track: Track) bool {
- const t = track.amount();
- return t < 0 or t > 1;
-}
-
-fn boxContainsPoint(box: Box, x: f32, y: f32) bool {
- return box.w > 0 and box.h > 0 and x >= box.x and y >= box.y and x < box.x + box.w and y < box.y + box.h;
-}
-
-pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u16) ?CellPosition {
- if (self.pending) return null;
- var closing = self.shown_closing_len;
- while (closing > 0) {
- closing -= 1;
- const track = self.shown_closing[closing];
- if (!track.active()) continue;
- if (track.contentBox().contains(col, row) and
- track.presented().contains(col, row)) return null;
- }
- const phases = [_]Phase{ .opening, .moving };
- for (phases) |phase| {
- // Backends paint pane slots forward within a phase. Probe them in
- // reverse so overlapping transition quads address the top pixel.
- var index = self.shown_tracks.len;
- while (index > 0) {
- index -= 1;
- const track = self.shown_tracks[index] orelse continue;
- if (!track.active() or track.phase != phase) continue;
- switch (track.effect) {
- .slide, .zoom => {
- const shown = track.presented();
- // Past its mark, the neighbour's cells stay the neighbour's.
- if (pastMark(track) and !track.to.contains(col, row)) continue;
- if (shown.w <= 0 or shown.h <= 0 or !shown.contains(col, row)) continue;
- const x = @as(f32, @floatFromInt(col)) + 0.5;
- const y = @as(f32, @floatFromInt(row)) + 0.5;
- const u = std.math.clamp((x - shown.x) / shown.w, 0, 0.999_999);
- const v = std.math.clamp((y - shown.y) / shown.h, 0, 0.999_999);
- const logical_x: i32 = @intFromFloat(@floor(track.to.x + u * track.to.w));
- const logical_y: i32 = @intFromFloat(@floor(track.to.y + v * track.to.h));
- return .{
- .col = @intCast(std.math.clamp(logical_x, 0, @as(i32, cols -| 1))),
- .row = @intCast(std.math.clamp(logical_y, 0, @as(i32, rows -| 1))),
- };
- },
- .vertical => {
- const clip = track.contentBox();
- if (!clip.contains(col, row)) continue;
- const shown = track.presented();
- if (shown.w <= 0 or shown.h <= 0 or !shown.contains(col, row))
- return null;
- const x = @as(f32, @floatFromInt(col)) + 0.5;
- const y = @as(f32, @floatFromInt(row)) + 0.5;
- const u = std.math.clamp((x - shown.x) / shown.w, 0, 0.999_999);
- const v = std.math.clamp((y - shown.y) / shown.h, 0, 0.999_999);
- return .{
- .col = @intFromFloat(@floor(clip.x + u * clip.w)),
- .row = @intFromFloat(@floor(clip.y + v * clip.h)),
- };
- },
- .dissolve, .ascii => {
- if (!track.to.contains(col, row)) continue;
- const cell_diff = self.cellDiff(cols, rows, col, row);
- if (!cell_diff.changed())
- return .{ .col = col, .row = row };
- const relative_col: u16 = @intFromFloat(@floor(
- @as(f32, @floatFromInt(col)) + 0.5 - track.to.x,
- ));
- const relative_row: u16 = @intFromFloat(@floor(
- @as(f32, @floatFromInt(row)) + 0.5 - track.to.y,
- ));
- const visible = switch (track.effect) {
- .dissolve => animation.dissolveRevealed(
- track.serial,
- relative_col,
- relative_row,
- track.amount(),
- ),
- .ascii => switch (cell_diff) {
- .ascii => |diff| diff.complete(track.frame),
- .unchanged, .visual => true,
- },
- else => unreachable,
- };
- return if (visible) .{ .col = col, .row = row } else null;
- },
- .edges, .fall, .wave, .curtain, .scramble, .typewriter => {
- if (!track.to.contains(col, row)) continue;
- const area = animation.CellArea.of(track.to);
- const settled = std.meta.eql(
- animation.charSource(
- track,
- col -| area.x0,
- row -| area.y0,
- area,
- ),
- animation.CharSource.settled,
- );
- return if (settled) .{ .col = col, .row = row } else null;
- },
- .off => {},
- }
- }
- }
- for (self.shown_tracks) |maybe| {
- const track = maybe orelse continue;
- if (!track.active() or (track.effect != .slide and track.effect != .zoom and
- track.effect != .vertical)) continue;
- if (track.to.contains(col, row)) return null;
- }
- return .{ .col = col, .row = row };
-}
-
-pub fn cancel(self: *Presentation) void {
- self.tracks = @splat(null);
- self.closing_len = 0;
- self.shown_tracks = @splat(null);
- self.shown_closing_len = 0;
- self.diff_state = .none;
- self.pending = self.acknowledged;
-}
-
-fn prepareDiff(self: *Presentation, gpa: std.mem.Allocator, surface: *const pardes.Surface) !bool {
- const count = surface.cells.len;
- if (!self.previous_valid or
- self.previous_cols != surface.cols or
- self.previous_rows != surface.rows or
- self.previous_cells.len != count) return false;
- if (self.diffs.len != count) {
- const next = try gpa.alloc(pardes.PanelCellDiff, count);
- if (self.diffs.len > 0) gpa.free(self.diffs);
- self.diffs = next;
- }
- for (self.diffs, self.previous_cells, surface.cells) |*diff, *old, *new|
- diff.* = pardes.PanelCellDiff.between(old, new);
- for (&self.tracks) |*slot| {
- const track = if (slot.*) |*track| track else continue;
- if (track.effect != .ascii) continue;
- var longest: u16 = 1;
- var row: u16 = 0;
- while (row < surface.rows) : (row += 1) {
- var col: u16 = 0;
- while (col < surface.cols) : (col += 1) {
- if (!track.to.contains(col, row)) continue;
- const index = @as(usize, row) * surface.cols + col;
- switch (self.diffs[index]) {
- .ascii => |diff| longest = @max(longest, diff.frameCount()),
- .unchanged, .visual => {},
- }
- }
- }
- track.frame_count = @max(track.frame_count, longest);
- }
- self.diff_state = .ready;
- return true;
-}
-
-pub fn submit(self: *Presentation, p: *Pardes, s: *pardes.Surface) !void {
- self.submitted = @splat(null);
- for (p.panes, 0..) |slot, id| {
- const pane = slot orelse continue;
- self.submitted[id] = .{
- .serial = pane.serial,
- .box = panelBox(p.rects[id]),
- };
- }
- self.submitted_ready = true;
- if (self.diff_state != .none and !try self.prepareDiff(p.gpa, s)) {
- for (&self.tracks) |*slot| {
- const track = slot.* orelse continue;
- if (track.effect.needsPreviousGrid()) slot.* = null;
- }
- self.closing_len = 0;
- self.diff_state = .none;
- }
- if (self.diff_state == .ready) {
- s.previous_cells = self.previous_cells;
- s.previous_body_layers = &self.previous_body_layers;
- s.previous_tag_layers = &self.previous_tag_layers;
- s.previous_regions = self.previous_regions[0..self.previous_nregions];
- s.cell_diffs = self.diffs;
- }
- s.npanel_tracks = animation.paintOrder(
- &self.tracks,
- self.closing[0..self.closing_len],
- &s.panel_tracks,
- );
-}
-
-pub fn animating(self: *const Presentation) bool {
- for (self.tracks) |track| if (track != null and track.?.active()) return true;
- for (self.closing[0..self.closing_len]) |track|
- if (track.active()) return true;
- return false;
-}
-
-test "presentation cache allocation failures retain ownership and allow retry" {
- var allocator: std.testing.FailingAllocator = .init(std.testing.allocator, .{});
- const gpa = allocator.allocator();
- var state: Presentation = .{};
- defer state.deinit(gpa);
- var cells: [3]pardes.Cell = @splat(.{});
- cells[0].default = false;
- cells[0].text[0] = 'a';
- var surface: pardes.Surface = .{ .cols = 2, .rows = 1, .cells = cells[0..2] };
- state.submitted[0] = .{ .serial = 7, .box = .{ .x = 0, .y = 0, .w = 2, .h = 1 } };
- state.submitted_ready = true;
- state.capturePrevious(gpa, &surface);
- try std.testing.expect(state.previous_valid);
- try std.testing.expectEqual(@as(u32, 7), state.previous_layout[0].?.serial);
- const previous = state.previous_cells.ptr;
- const allocated = allocator.allocations;
- allocator.fail_index = allocator.alloc_index;
- state.capturePrevious(gpa, &surface);
- try std.testing.expect(state.previous_valid);
- try std.testing.expectEqual(allocated, allocator.allocations);
- try std.testing.expect(!allocator.has_induced_failure);
-
- surface.cols = 3;
- surface.cells = &cells;
- state.submitted[0].?.box.w = 3;
- state.diff_state = .ready;
- state.capturePrevious(gpa, &surface);
- try std.testing.expect(allocator.has_induced_failure);
- try std.testing.expect(!state.previous_valid);
- try std.testing.expectEqual(previous, state.previous_cells.ptr);
- try std.testing.expectEqual(@as(usize, 2), state.previous_cells.len);
- try std.testing.expectEqual(@as(u8, 'a'), state.previous_cells[0].text[0]);
- try std.testing.expect(state.previous_layout[0] == null);
- try std.testing.expectEqual(.none, state.diff_state);
-
- allocator.fail_index = std.math.maxInt(usize);
- state.capturePrevious(gpa, &surface);
- try std.testing.expect(state.previous_valid);
- try std.testing.expectEqual(@as(usize, 3), state.previous_cells.len);
- try std.testing.expectEqual(@as(f32, 3), state.previous_layout[0].?.box.w);
- state.diff_state = .requested;
- allocator.fail_index = allocator.alloc_index;
- try std.testing.expectError(error.OutOfMemory, state.prepareDiff(gpa, &surface));
- try std.testing.expectEqual(.requested, state.diff_state);
- try std.testing.expectEqual(@as(usize, 0), state.diffs.len);
- allocator.fail_index = std.math.maxInt(usize);
- try std.testing.expect(try state.prepareDiff(gpa, &surface));
- try std.testing.expectEqual(.ready, state.diff_state);
- try std.testing.expectEqual(@as(usize, 3), state.diffs.len);
- for (state.diffs) |diff| try std.testing.expectEqual(.unchanged, diff);
-}
-
-test "presentation submission failure preserves shown geometry until retry is acknowledged" {
- var allocator: std.testing.FailingAllocator = .init(std.testing.allocator, .{});
- const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true, .cols = 40, .rows = 12 });
- defer p.deinit();
- var frame: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer frame.deinit();
- // The frozen grid is kept only while a transition is chosen.
- p.settings.panel_transition = .slide;
- _ = try p.render(frame.allocator());
- p.acknowledgePanelPresentation(&.{});
- const shown = p.presentation.shown;
- const previous = p.presentation.previous_cells.ptr;
- p.presentation.diff_state = .requested;
- p.presentation.pending = true;
- allocator.fail_index = allocator.alloc_index;
- try std.testing.expectError(error.OutOfMemory, p.presentation.submit(p, &p.surface));
- try std.testing.expectEqualDeep(shown, p.presentation.shown);
- try std.testing.expectEqual(previous, p.presentation.previous_cells.ptr);
- try std.testing.expectEqual(.requested, p.presentation.diff_state);
- try std.testing.expect(p.presentation.pending);
- try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, 5, 3) == null);
-
- allocator.fail_index = std.math.maxInt(usize);
- try p.presentation.submit(p, &p.surface);
- try std.testing.expectEqualDeep(shown, p.presentation.shown);
- try std.testing.expect(p.presentation.pending);
- p.acknowledgePanelPresentation(&.{});
- try std.testing.expect(!p.presentation.pending);
- try std.testing.expectEqual(CellPosition{ .col = 5, .row = 3 }, p.presentation.pointer(p.screen_w, p.screen_h, 5, 3).?);
-}
-
-test "a pane past its mark never takes a neighbour's click" {
- // Bouncy, at its peak: pane 0 slides right to 0..40 and swings past it,
- // over the neighbour at 40..80.
- var presentation: Presentation = .{};
- var track: Track = .{ .serial = 7, .effect = .slide, .motion = @backingInt(animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = -40, .y = 0, .w = 40, .h = 20 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 20 } };
- var peak: u16 = 0;
- var furthest: f32 = -1e9;
- while (track.frame < track.frames()) : (track.frame += 1) {
- if (track.presented().x > furthest) {
- furthest = track.presented().x;
- peak = track.frame;
- }
- }
- track.frame = peak;
- try std.testing.expect(track.presented().x > 2);
- presentation.shown_tracks[0] = track;
- // A cell of the neighbour under the overshoot is the neighbour's own.
- const col: u16 = 41;
- try std.testing.expectEqual(CellPosition{ .col = col, .row = 5 }, presentation.pointer(80, 20, col, 5).?);
- const point = presentation.pointerFractional(80, 20, 41.5, 5.5).?;
- try std.testing.expectApproxEqAbs(@as(f32, 41.5), point.x, 1e-4);
-}
-
-test "fractional panel inverse preserves compact header rows through slide and zoom" {
- const layer: pardes.Layer = .{ .serial = 7, .viewport = .{ .x = 4, .y = 3, .w = 30, .h = 10 }, .cols = 30, .rows = 15, .context_rows = 4 };
- for ([_]Transition{ .slide, .zoom, .vertical }) |effect| {
- var presentation: Presentation = .{};
- const track: Track = .{ .serial = 7, .effect = effect, .frame = 4, .frame_count = 10, .from = .{ .x = 2, .y = 2, .w = 20, .h = 8 }, .to = .{ .x = 3, .y = 2, .w = 32, .h = 12 } };
- presentation.shown_tracks[0] = track;
- const shown = track.presented();
- for (0..4) |index| {
- const row: u16 = @intCast(index);
- const source_x: f32 = 5.3;
- const source_y = (layer.rowTop(row, 20, 10) + 5) / 20;
- const x = shown.x + (source_x - track.to.x) / track.to.w * shown.w;
- const y = shown.y + (source_y - track.to.y) / track.to.h * shown.h;
- const point = presentation.pointerFractional(80, 30, x, y).?;
- try std.testing.expectApproxEqAbs(source_x, point.x, 0.0001);
- try std.testing.expectApproxEqAbs(source_y, point.y, 0.0001);
- const body_hit = layer.bodyHit(point.x * 10, point.y * 20, 10, 20, 8, 10).?;
- try std.testing.expectEqual(row, body_hit.row);
- }
- }
-}
-
-test "presentation snapshots own compact body and tag rows across later edits" {
- var state: Presentation = .{};
- defer state.deinit(std.testing.allocator);
- var cells: [1]pardes.Cell = .{.{}};
- var body: [2]pardes.Cell = .{ .{}, .{} };
- body[0].text[0] = 'A';
- var surface: pardes.Surface = .{ .cols = 1, .rows = 1, .cells = &cells };
- surface.body_layers[0] = .{ .serial = 9, .cols = 1, .rows = 2, .context_rows = 1, .cells = &body };
- var tag: [1]pardes.Cell = .{.{}};
- tag[0].text[0] = 'T';
- surface.tag_layers[0] = .{ .kind = .pane, .serial = 9, .cols = 1, .rows = 1, .cells = &tag };
- state.capturePrevious(std.testing.allocator, &surface);
- try std.testing.expect(state.previous_valid);
- tag[0].text[0] = 'U';
- try std.testing.expectEqual(@as(u8, 'T'), state.previous_tag_layers[0].cells[0].text[0]);
- body[0].text[0] = 'B';
- surface.body_layers[0].context_rows = 0;
- try std.testing.expectEqual(@as(u8, 'A'), state.previous_body_layers[0].cells[0].text[0]);
- try std.testing.expectEqual(@as(u16, 1), state.previous_body_layers[0].context_rows);
- state.capturePrevious(std.testing.allocator, &surface);
- try std.testing.expectEqual(@as(u8, 'B'), state.previous_body_layers[0].cells[0].text[0]);
- try std.testing.expectEqual(@as(u8, 'U'), state.previous_tag_layers[0].cells[0].text[0]);
-}
-
-test "a move retargeted mid-way carries its speed into the new one" {
- const smooth = @backingInt(animation.Motion.Flavour.smooth) + 1;
- const first: Track = .{ .serial = 1, .phase = .moving, .effect = .slide, .motion = smooth, .frame = 4, .frame_count = 14, .from = .{ .x = 0, .y = 1, .w = 40, .h = 20 }, .to = .{ .x = 40, .y = 1, .w = 40, .h = 20 } };
- const was = first.velocity();
- try std.testing.expect(was.x > 0.5);
- var next: Track = .{ .serial = 1, .phase = .moving, .effect = .slide, .motion = smooth, .frame_count = 14, .from = first.presented(), .to = .{ .x = 60, .y = 1, .w = 40, .h = 20 } };
- next.launch = carriedLaunch(first, next);
- try std.testing.expect(next.launch > 0);
- // It sets off at the speed the old one had, not from a stop.
- const now = next.velocity();
- try std.testing.expectApproxEqRel(was.x, now.x, 0.15);
- // And still lands exactly.
- next.frame = 13;
- try std.testing.expectEqual(next.to.x, next.presented().x);
-}
diff --git a/src/Query.zig b/src/Query.zig
index b6c564b1..88091bf7 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -2537,7 +2537,7 @@ test "B1 on a query pane's rows places the caret and selects, nothing else, the
const qid = queryPane(p).?;
const qp = p.panes[qid].?;
const q = qp.query.?;
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
const owner_sel = pane.body.primaryRange(pane.file.?.content, 0);
const owner_scroll = pane.file.?.scroll;
try std.testing.expectEqual(@as(?usize, 0), q.current);
@@ -2643,7 +2643,7 @@ test "a query row's place is its text: the match tinted after it, B3 on it opens
try std.testing.expect(row4 > 0);
// B3 on the address: the place, in the pane that shows it
a.body.cur_row = 0;
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
const r = p.rects[qid];
const y = r.y + qp.tag_rows + @as(u16, @intCast(row4)) - @as(u16, @intCast(qp.scroll()));
const x = r.x + config.GUTTER + File.gutterWidth(qp) + 3;
diff --git a/src/animation.zig b/src/animation.zig
index 51164495..25abf421 100644
--- a/src/animation.zig
+++ b/src/animation.zig
@@ -1,664 +1,26 @@
-//! Animation curves and the panel transition records every shell reads:
-//! easing presets, transition kinds and their tracks, the fractional boxes
-//! they move through, and the character effects' per-cell sources; the
-//! springs that settle a view, a lift and the cursor (colors.zig fades the
-//! chrome).
+//! The springs that settle a view and the cursor, and the Motion flavours
+//! they move by (colors.zig fades the chrome).
const std = @import("std");
-pub const ascii_max_movement_frames: u16 = 12;
-
-pub const Easing = enum(u8) {
- linear,
- smooth,
- /// Quintic ease-in-out. It creeps at both ends and crosses the middle of
- /// the distance fast, inside the same frame count a linear walk would use.
- smoother,
- in_cubic,
- out_cubic,
- out_back,
-};
-
-pub const Transition = enum(u8) {
- // Numeric values are shared with the GUI shader ABI.
- off = 0,
- slide = 1,
- zoom = 2,
- dissolve = 3,
- ascii = 4,
- vertical = 5,
- edges = 6,
- fall = 7,
- wave = 8,
- curtain = 9,
- scramble = 10,
- typewriter = 11,
-
- pub fn easing(effect: Transition) Easing {
- return switch (effect) {
- .off, .dissolve, .wave => .smooth,
- .slide, .vertical, .edges => .out_cubic,
- .zoom => .out_back,
- // Character walks and per-cell locks read best with a slow start,
- // a fast middle, and a slow settle over their fixed frame count.
- .ascii, .fall, .scramble => .smoother,
- // A sweep and a typewriter are constant-rate by definition: easing
- // their head would make the pass visibly hesitate mid-pane.
- .curtain, .typewriter => .linear,
- };
- }
-
- pub fn frames(effect: Transition) u16 {
- return switch (effect) {
- .off => 0,
- .slide => 12,
- .zoom => 14,
- .dissolve => 10,
- .ascii => ascii_max_movement_frames + 1,
- .vertical => 12,
- .edges, .curtain, .scramble => 12,
- // Travelling motion needs a couple more samples than a lock or a
- // rigid slide before it stops reading as a jump.
- .fall, .wave, .typewriter => 14,
- };
- }
-
- pub fn composedByCore(effect: Transition) bool {
- return switch (effect) {
- .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => true,
- .off, .slide, .zoom, .dissolve, .vertical => false,
- };
- }
-
- pub fn needsPreviousGrid(effect: Transition) bool {
- return effect == .dissolve or effect == .vertical or effect.composedByCore();
- }
-
- pub fn lifecycleOnly(effect: Transition) bool {
- return effect == .vertical;
- }
-};
-
-pub const Phase = enum(u8) {
- opening = 0,
- moving = 1,
- /// Presentation-only content whose pane lifetime has already ended.
- /// It is never a valid input target.
- closing = 2,
-};
-
-pub const Box = extern struct {
- x: f32 = 0,
- y: f32 = 0,
- w: f32 = 0,
- h: f32 = 0,
-
- pub fn eql(a: Box, b: Box) bool {
- return a.x == b.x and a.y == b.y and a.w == b.w and a.h == b.h;
- }
-
- /// A cell belongs to a fractional box when its centre lies inside:
- /// drawing and hit testing both ask this.
- pub fn contains(box: Box, col: u16, row: u16) bool {
- const x = @as(f32, @floatFromInt(col)) + 0.5;
- const y = @as(f32, @floatFromInt(row)) + 0.5;
- return x >= box.x and x < box.x + box.w and y >= box.y and y < box.y + box.h;
- }
-};
-
-// Drawing and hit testing share this moving/opening/closing order.
-pub fn paintOrder(live: []const ?Track, closing: []const Track, out: []Track) usize {
- var len: usize = 0;
- for ([_]Phase{ .moving, .opening }) |phase| for (live) |maybe| {
- const track = maybe orelse continue;
- if (!track.active() or track.phase != phase) continue;
- if (len == out.len) return len;
- out[len] = track;
- len += 1;
- };
- for (closing) |track| {
- if (!track.active()) continue;
- if (len == out.len) return len;
- out[len] = track;
- len += 1;
- }
- return len;
-}
-
-/// One POD record is enough for every backend. `from` and `to` are logical
-/// cell boxes; frontends convert them to pixels only at their render edge.
-pub const Track = extern struct {
- serial: u32 = 0,
- pane: u8 = 0,
- phase: Phase = .moving,
- effect: Transition = .off,
- /// The Motion flavour a pane's move follows, plus one; 0 is the
- /// effect's own easing (Presentation.stamp).
- motion: u8 = 0,
- frame: u16 = 0,
- frame_count: u16 = 0,
- from: Box = .{},
- to: Box = .{},
- /// The move's speed as it starts, in its lengths per unit of progress:
- /// 0 sets off as the flavour does; a move retargeted mid-way carries
- /// the old one's speed on (Presentation.sync), so it never stops dead.
- launch: f32 = 0,
-
- pub fn active(track: Track) bool {
- return track.effect != .off and track.frame < track.frames();
- }
-
- pub fn frames(track: Track) u16 {
- return if (track.frame_count != 0) track.frame_count else track.effect.frames();
- }
-
- pub fn amount(track: Track) f32 {
- // Opening rises quickly and settles; closing reverses that motion and
- // accelerates down out of the fixed clip.
- if (track.phase == .closing and track.effect == .vertical)
- return progressEased(.in_cubic, track.frames(), track.frame);
- if (track.flavour()) |motion|
- return motion.easeFrom(track.progress(), track.launch);
- return progressEased(track.effect.easing(), track.frames(), track.frame);
- }
-
- /// The flavour an opening or moving pane follows; a closing one keeps
- /// its effect's own exit.
- fn flavour(track: Track) ?Motion {
- if (track.motion == 0 or track.phase == .closing) return null;
- const which = std.enums.fromInt(Motion.Flavour, track.motion - 1) orelse return null;
- return Motion.of(which);
- }
-
- /// How fast its presented box moves now, in cells per frame of its
- /// own (x, y, w, h); zero when it follows no flavour or has landed.
- pub fn velocity(track: Track) Box {
- const motion = track.flavour() orelse return .{};
- const u = track.progress();
- if (u >= 1 or track.frames() <= 1) return .{};
- const rate = motion.speedFrom(u, track.launch) / @as(f32, @floatFromInt(track.frames() - 1));
- return .{ .x = (track.to.x - track.from.x) * rate, .y = (track.to.y - track.from.y) * rate, .w = (track.to.w - track.from.w) * rate, .h = (track.to.h - track.from.h) * rate };
- }
-
- fn progress(track: Track) f32 {
- if (track.frames() <= 1 or track.frame >= track.frames() - 1) return 1;
- return @as(f32, @floatFromInt(track.frame)) / @as(f32, @floatFromInt(track.frames() - 1));
- }
-
- pub fn presented(track: Track) Box {
- // A flavour's wind-up goes back past where the move began.
- const t = track.amount();
- // Landed, it is exactly where it goes: no stretch or float residue.
- if (track.flavour() != null and track.progress() >= 1) return track.to;
- var box = if (t < 0) lerpBox(track.to, track.from, 1 - t) else lerpBox(track.from, track.to, t);
- // Squash and stretch: along its path a moving pane lengthens with
- // its speed and, landing past its mark and coming back, squashes
- // (the user's choice: its text with it; a pointer inverts the same
- // box, so a click lands on the glyph it is drawn as).
- const motion = track.flavour() orelse return box;
- if (motion.stretch == 0) return box;
- const factor = 1 + motion.stretch * std.math.clamp(motion.speedFrom(track.progress(), track.launch) / 4, -1, 1);
- if (@abs(track.to.x - track.from.x) >= @abs(track.to.y - track.from.y)) {
- const w = box.w * factor;
- box.x -= (w - box.w) / 2;
- box.w = w;
- } else {
- const h = box.h * factor;
- box.y -= (h - box.h) / 2;
- box.h = h;
- }
- return box;
- }
-
- pub fn visualBox(track: Track) Box {
- return switch (track.effect) {
- .slide, .zoom, .vertical => track.presented(),
- // A fade, a dissolve and every character effect stay inside the
- // pane's final rectangle.
- .off, .dissolve, .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => track.to,
- };
- }
-
- pub fn contentBox(track: Track) Box {
- return if (track.phase == .closing) track.from else track.to;
- }
-};
-
-pub fn openingBox(effect: Transition, target: Box, screen_width: u16) Box {
- return switch (effect) {
- .slide => blk: {
- var from = target;
- const middle = target.x + target.w * 0.5;
- from.x = if (middle < @as(f32, @floatFromInt(screen_width)) * 0.5)
- -target.w
- else
- @floatFromInt(screen_width);
- break :blk from;
- },
- .zoom => .{
- .x = target.x + target.w * 0.5,
- .y = target.y + target.h * 0.5,
- .w = 0,
- .h = 0,
- },
- .vertical => blk: {
- var from = target;
- from.y += target.h;
- break :blk from;
- },
- // A dissolve and the character effects own the glyphs inside a fixed
- // rectangle, so their panel opens at exactly its final geometry.
- .off, .dissolve, .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => target,
- };
-}
-
-pub fn closingBox(effect: Transition, source: Box) Box {
- return switch (effect) {
- .vertical => blk: {
- var to = source;
- to.y += source.h;
- break :blk to;
- },
- else => source,
- };
-}
+/// The curves a theme change's chrome fades on (colors.ChromeAnimation).
+pub const Easing = enum(u8) { smooth, out_cubic };
pub fn sample(easing: Easing, raw: f32) f32 {
const t = std.math.clamp(raw, 0.0, 1.0);
return switch (easing) {
- .linear => t,
.smooth => t * t * (3.0 - 2.0 * t),
- .smoother => t * t * t * (t * (6.0 * t - 15.0) + 10.0),
- .in_cubic => t * t * t,
.out_cubic => 1.0 - (1.0 - t) * (1.0 - t) * (1.0 - t),
- // Robert Penner's ease-out-back polynomial. It intentionally travels
- // a little past one before settling exactly on the endpoint.
- .out_back => blk: {
- const c1: f32 = 1.70158;
- const c3 = c1 + 1.0;
- const u = t - 1.0;
- break :blk 1.0 + c3 * u * u * u + c1 * u * u;
- },
};
}
-fn progressEased(easing: Easing, frames: u16, frame: u16) f32 {
- if (frames <= 1 or frame >= frames - 1) return 1.0;
- return sample(easing, @as(f32, @floatFromInt(frame)) / @as(f32, @floatFromInt(frames - 1)));
-}
-
-pub fn lerpBox(from: Box, to: Box, t: f32) Box {
- const u = @max(0.0, t);
- return .{
- .x = from.x + (to.x - from.x) * u,
- .y = from.y + (to.y - from.y) * u,
- .w = @max(0.0, from.w + (to.w - from.w) * u),
- .h = @max(0.0, from.h + (to.h - from.h) * u),
- };
-}
-
-/// Stable cell noise shared by the TTY reveal and shader ports. Integer-only
-/// hashing means resizing or repainting a frame does not make cells flicker.
-pub fn cellNoise(serial: u32, col: u16, row: u16) f32 {
- var x = serial ^ (@as(u32, col) *% 0x9e37_79b9) ^ (@as(u32, row) *% 0x85eb_ca6b);
- x ^= x >> 16;
- x *%= 0x7feb_352d;
- x ^= x >> 15;
- x *%= 0x846c_a68b;
- x ^= x >> 16;
- return @as(f32, @floatFromInt(x & 0xffff)) / 65535.0;
-}
-
-/// Whether a changed dissolve cell has crossed from the frozen old grid to
-/// the new one. Exact endpoints are part of the presentation contract.
-/// T4 (§9.2): an ordered swap, each cell at its place in a 4x4 Bayer
-/// matrix (shifted by the pane's serial so two panes differ), so the new
-/// content comes in as an even, patterned screen rather than noise, and
-/// each cell swaps once.
-pub fn dissolveRevealed(serial: u32, col: u16, row: u16, raw_progress: f32) bool {
- const t = std.math.clamp(raw_progress, 0.0, 1.0);
- if (t <= 0) return false;
- if (t >= 1) return true;
- const bayer = [4][4]u8{ .{ 0, 8, 2, 10 }, .{ 12, 4, 14, 6 }, .{ 3, 11, 1, 9 }, .{ 15, 7, 13, 5 } };
- const x = (@as(u32, col) +% serial) % 4;
- const y = (@as(u32, row) +% serial / 4) % 4;
- return (@as(f32, @floatFromInt(bayer[y][x])) + 0.5) / 16 < t;
-}
-
-pub const CellArea = struct {
- x0: u16 = 0,
- y0: u16 = 0,
- cols: u16 = 1,
- rows: u16 = 1,
-
- pub fn of(box: Box) CellArea {
- return .{
- .x0 = floorCell(box.x),
- .y0 = floorCell(box.y),
- .cols = ceilCell(box.w),
- .rows = ceilCell(box.h),
- };
- }
-};
-
-fn floorCell(value: f32) u16 {
- return @intFromFloat(std.math.clamp(@floor(value), 0.0, @as(f32, std.math.maxInt(u16))));
-}
-
-fn ceilCell(value: f32) u16 {
- return @intFromFloat(std.math.clamp(@ceil(value), 1.0, @as(f32, std.math.maxInt(u16))));
-}
-
-pub const CharSource = union(enum) {
- /// Nothing has arrived here yet: keep the frozen old cell.
- old,
- at: Offset,
- /// Paint this printable byte in the destination cell's own style, whatever
- /// that cell holds — a caret marching over empty space is still a caret.
- byte: u8,
- churn: u8,
- /// The destination cell with its colours still this far (0..1) toward
- /// the frozen old cell's ground: a soft edge between the two grids.
- edge: f32,
-
- pub const Offset = struct { cols: i32 = 0, rows: i32 = 0 };
-
- pub const settled: CharSource = .{ .at = .{} };
+/// A fractional box in grid cells: the cursor's quad aims at one.
+pub const Box = extern struct {
+ x: f32 = 0,
+ y: f32 = 0,
+ w: f32 = 0,
+ h: f32 = 0,
};
-pub fn charSource(track: Track, col: u16, row: u16, area: CellArea) CharSource {
- const t = track.amount();
- if (t >= 1.0) return .settled;
- const w: f32 = @floatFromInt(area.cols);
- const h: f32 = @floatFromInt(area.rows);
- const c: f32 = @floatFromInt(col);
- const r: f32 = @floatFromInt(row);
- const remaining = 1.0 - t;
- return switch (track.effect) {
- .edges => blk: {
- const travel = cellsOf(remaining * (w + 1.0));
- break :blk .{ .at = .{ .cols = if (row % 2 == 0) travel else -travel } };
- },
- // Columns rain down, each with its own stable head start, so the pane
- // fills from the top and the last glyphs land at the bottom.
- .fall => blk: {
- const local = staggered(t, cellNoise(track.serial, col, 0) * 0.4);
- if (local <= 0.0) break :blk .old;
- break :blk .{ .at = .{ .rows = cellsOf((1.0 - local) * (h + 1.0)) } };
- },
- // A vertical ripple travels left to right and its amplitude decays, so
- // the pane settles out of a wave instead of a fade.
- .wave => .{ .at = .{
- .rows = cellsOf(remaining * @min(4.0, h) * @sin(c * 0.55 - t * 9.0)),
- } },
- // A wipe, left to right: the new grid behind the head, the old one
- // ahead of it, and between them a soft edge two cells wide whose
- // colours step from the old ground to the new. Only the head's
- // columns change from one frame to the next.
- .curtain => blk: {
- const lead = t * (w + 2.0) - c;
- if (lead <= 0.0) break :blk .old;
- if (lead <= 1.0) break :blk .{ .edge = 2.0 / 3.0 };
- if (lead <= 2.0) break :blk .{ .edge = 1.0 / 3.0 };
- break :blk .settled;
- },
- // Every cell churns through printable ASCII and locks onto its final
- // glyph at its own stable threshold: the pane resolves out of noise.
- .scramble => blk: {
- if (t >= cellNoise(track.serial, col, row) * 0.8) break :blk .settled;
- const churn = cellNoise(
- track.serial ^ (@as(u32, track.frame) *% 0x27d4_eb2f),
- col,
- row,
- );
- break :blk .{ .churn = @intCast(33 + @min(93, @as(u32, @intFromFloat(churn * 94.0)))) };
- },
- // Reading-order reveal with a caret sitting on the write head.
- .typewriter => blk: {
- const head = t * w * h;
- const index = r * w + c;
- if (index + 1.0 <= head) break :blk .settled;
- if (index <= head) break :blk .{ .byte = '_' };
- break :blk .old;
- },
- // PanelAscii walks its own byte distance per cell, and the geometry
- // effects never reach this path at all.
- .off, .slide, .zoom, .dissolve, .vertical, .ascii => .settled,
- };
-}
-
-fn cellsOf(distance: f32) i32 {
- return @intFromFloat(@round(std.math.clamp(distance, -65535.0, 65535.0)));
-}
-
-/// Remap track progress into one cell's own window. A stagger delays a glyph
-/// without making the effect as a whole end after its last frame.
-fn staggered(t: f32, delay: f32) f32 {
- if (delay >= 1.0) return t;
- return (t - delay) / (1.0 - delay);
-}
-
-test "easing presets have exact endpoints and intended shapes" {
- inline for (std.enums.values(Easing)) |easing| {
- try std.testing.expectEqual(@as(f32, 0), sample(easing, 0));
- try std.testing.expectEqual(@as(f32, 1), sample(easing, 1));
- }
- try std.testing.expectEqual(@as(f32, 0.5), sample(.linear, 0.5));
- try std.testing.expect(sample(.in_cubic, 0.5) < sample(.linear, 0.5));
- try std.testing.expect(sample(.out_cubic, 0.5) > sample(.linear, 0.5));
- try std.testing.expect(sample(.out_back, 0.8) > 1.0);
- // Slow at both ends, fast through the middle, and symmetric about the
- // halfway point: the same curve the integer byte walk reproduces.
- try std.testing.expectEqual(@as(f32, 0.5), sample(.smoother, 0.5));
- try std.testing.expect(sample(.smoother, 0.15) < sample(.smooth, 0.15));
- try std.testing.expect(sample(.smoother, 0.85) > sample(.smooth, 0.85));
- try std.testing.expect(sample(.smoother, 0.6) - sample(.smoother, 0.4) >
- sample(.linear, 0.6) - sample(.linear, 0.4));
-}
-
-test "transition progress completes exactly" {
- inline for (std.enums.values(Transition)) |effect| {
- try std.testing.expectEqual(@as(f32, 1), progressEased(effect.easing(), effect.frames(), effect.frames()));
- if (effect.frames() > 0)
- try std.testing.expectEqual(@as(f32, 1), progressEased(effect.easing(), effect.frames(), effect.frames() - 1));
- try std.testing.expectEqual(@as(f32, 1), progressEased(effect.easing(), effect.frames(), std.math.maxInt(u16)));
- }
- try std.testing.expectEqual(@as(f32, 1), progressEased(Transition.off.easing(), Transition.off.frames(), 0));
-
- const shrinking = lerpBox(.{ .w = 100, .h = 40 }, .{}, sample(.out_back, 0.8));
- try std.testing.expectEqual(@as(f32, 0), shrinking.w);
- try std.testing.expectEqual(@as(f32, 0), shrinking.h);
- const opening = lerpBox(.{}, .{ .w = 100, .h = 40 }, sample(.out_back, 0.8));
- try std.testing.expect(opening.w > 100);
- try std.testing.expect(opening.h > 40);
-}
-
-test "character effects are core-composed and settle on the canonical glyph" {
- const box: Box = .{ .x = 4, .y = 2, .w = 20, .h = 6 };
- const area: CellArea = .of(box);
- try std.testing.expectEqual(@as(u16, 4), area.x0);
- try std.testing.expectEqual(@as(u16, 2), area.y0);
- try std.testing.expectEqual(@as(u16, 20), area.cols);
- try std.testing.expectEqual(@as(u16, 6), area.rows);
-
- inline for (std.enums.values(Transition)) |effect| {
- if (comptime !effect.composedByCore()) continue;
- // Core composition needs the frozen old grid for every glyph which has
- // not arrived, so no character effect may animate without it.
- try std.testing.expect(effect.needsPreviousGrid());
- if (comptime effect == .ascii) continue; // owns its own per-cell byte walk
-
- const last: Track = .{ .effect = effect, .frame = effect.frames() - 1, .to = box };
- const first: Track = .{ .effect = effect, .frame = 0, .to = box };
- var moving = false;
- var row: u16 = 0;
- while (row < area.rows) : (row += 1) {
- var col: u16 = 0;
- while (col < area.cols) : (col += 1) {
- // The last active sample is the exact canonical grid: no cell
- // is displaced, churning, or still frozen.
- try std.testing.expectEqual(CharSource.settled, charSource(last, col, row, area));
- if (!std.meta.eql(CharSource.settled, charSource(first, col, row, area)))
- moving = true;
- }
- }
- try std.testing.expect(moving);
- }
-}
-
-test "each character effect moves glyphs along its own axis" {
- const box: Box = .{ .w = 30, .h = 8 };
- const area: CellArea = .of(box);
-
- // Rows alternate which screen edge they come from, and every glyph in a row
- // travels as one rigid slide: one offset, no vertical component.
- var edges: Track = .{ .effect = .edges, .frame = 2, .to = box };
- const even = charSource(edges, 5, 0, area).at;
- const odd = charSource(edges, 5, 1, area).at;
- try std.testing.expect(even.cols > 0);
- try std.testing.expectEqual(-even.cols, odd.cols);
- try std.testing.expectEqual(@as(i32, 0), even.rows);
- try std.testing.expectEqual(even, charSource(edges, 17, 0, area).at);
- edges.frame = 5;
- try std.testing.expect(charSource(edges, 5, 0, area).at.cols < even.cols);
-
- // Falling columns are vertical only, staggered, and sample from below the
- // destination because the new text is still above the pane.
- const fall: Track = .{ .effect = .fall, .frame = 4, .to = box };
- var falling = false;
- var col: u16 = 0;
- while (col < area.cols) : (col += 1) switch (charSource(fall, col, 0, area)) {
- .old => {},
- .byte, .churn, .edge => return error.FallShouldNotChurn,
- .at => |offset| {
- try std.testing.expectEqual(@as(i32, 0), offset.cols);
- try std.testing.expect(offset.rows >= 0);
- if (offset.rows > 0) falling = true;
- },
- };
- try std.testing.expect(falling);
-
- // The wave displaces rows both ways as it travels, and only rows.
- const wave: Track = .{ .effect = .wave, .frame = 1, .to = box };
- var above = false;
- var below = false;
- col = 0;
- while (col < area.cols) : (col += 1) {
- const offset = charSource(wave, col, 3, area).at;
- try std.testing.expectEqual(@as(i32, 0), offset.cols);
- if (offset.rows < 0) above = true;
- if (offset.rows > 0) below = true;
- }
- try std.testing.expect(above and below);
-
- // The curtain wipes: columns ahead of its head hold the old grid,
- // columns it has passed are settled, and between them a soft edge of
- // exactly two columns steps from the old ground to the new.
- const curtain: Track = .{ .effect = .curtain, .frame = 5, .to = box };
- try std.testing.expectEqual(CharSource.settled, charSource(curtain, 0, 0, area));
- try std.testing.expectEqual(CharSource{ .old = {} }, charSource(curtain, 29, 0, area));
- var wiped: [2]f32 = undefined;
- var at_edge: usize = 0;
- col = 0;
- while (col < area.cols) : (col += 1) switch (charSource(curtain, col, 0, area)) {
- .edge => |weight| {
- wiped[at_edge] = weight;
- at_edge += 1;
- },
- .old, .at, .byte, .churn => {},
- };
- try std.testing.expectEqual(@as(usize, 2), at_edge);
- try std.testing.expect(wiped[0] < wiped[1]);
-
- var scramble: Track = .{ .effect = .scramble, .frame = 3, .to = box };
- var churning: usize = 0;
- var locked: usize = 0;
- var changed = false;
- col = 0;
- while (col < area.cols) : (col += 1) switch (charSource(scramble, col, 0, area)) {
- .churn => |byte| {
- try std.testing.expect(byte >= ' ' and byte <= '~');
- churning += 1;
- scramble.frame = 4;
- switch (charSource(scramble, col, 0, area)) {
- .churn => |next| changed = changed or next != byte,
- .old, .at, .byte, .edge => {},
- }
- scramble.frame = 3;
- },
- .at => locked += 1,
- .old, .byte, .edge => return error.ScrambleShouldNotFreeze,
- };
- try std.testing.expect(churning > 0 and locked > 0 and changed);
-
- // The typewriter writes in reading order with a caret on its head.
- const typewriter: Track = .{ .effect = .typewriter, .frame = 7, .to = box };
- try std.testing.expectEqual(CharSource.settled, charSource(typewriter, 0, 0, area));
- try std.testing.expectEqual(
- CharSource{ .old = {} },
- charSource(typewriter, area.cols - 1, area.rows - 1, area),
- );
- var carets: usize = 0;
- var row: u16 = 0;
- while (row < area.rows) : (row += 1) {
- col = 0;
- while (col < area.cols) : (col += 1) switch (charSource(typewriter, col, row, area)) {
- .byte => |byte| {
- try std.testing.expectEqual(@as(u8, '_'), byte);
- carets += 1;
- },
- .old, .at, .churn, .edge => {},
- };
- }
- try std.testing.expectEqual(@as(usize, 1), carets);
-}
-
-test "opening presets separate geometry and content transitions" {
- const target: Box = .{ .x = 30, .y = 2, .w = 20, .h = 8 };
- try std.testing.expectEqual(target, openingBox(.ascii, target, 80));
- try std.testing.expectEqual(@as(f32, 0), openingBox(.zoom, target, 80).w);
- try std.testing.expectEqual(@as(f32, 80), openingBox(.slide, target, 80).x);
- try std.testing.expectEqual(@as(f32, target.y + target.h), openingBox(.vertical, target, 80).y);
- try std.testing.expectEqual(@as(f32, target.y + target.h), closingBox(.vertical, target).y);
-
- var track: Track = .{ .effect = .slide, .from = target, .to = target };
- try std.testing.expect(track.active());
- track.frame = track.effect.frames();
- try std.testing.expect(!track.active());
-
- track = .{ .effect = .dissolve, .frame = 3, .from = .{}, .to = target };
- try std.testing.expectEqual(target, track.visualBox());
-
- var closing: Track = .{
- .phase = .closing,
- .effect = .vertical,
- .from = target,
- .to = closingBox(.vertical, target),
- };
- try std.testing.expectEqual(target, closing.contentBox());
- closing.frame = 2;
- try std.testing.expect(closing.amount() < progressEased(Transition.vertical.easing(), Transition.vertical.frames(), closing.frame));
-}
-
-test "the ordered dissolve reveals a 4x4 block evenly, each cell once" {
- for ([_]f32{ 0.25, 0.5, 0.75 }) |t| {
- var revealed: usize = 0;
- for (0..4) |y| for (0..4) |x| {
- if (dissolveRevealed(7, @intCast(x), @intCast(y), t)) revealed += 1;
- };
- try std.testing.expectEqual(@as(usize, @intFromFloat(t * 16)), revealed);
- }
-}
-
-test "dissolve has exact stable endpoints" {
- for (0..64) |col| {
- const x: u16 = @intCast(col);
- try std.testing.expect(!dissolveRevealed(42, x, 7, 0));
- try std.testing.expect(dissolveRevealed(42, x, 7, 1));
- if (dissolveRevealed(42, x, 7, 0.25))
- try std.testing.expect(dissolveRevealed(42, x, 7, 0.75));
- }
-}
-
pub const frame_ms: u32 = 16;
pub const frame_ns: u64 = frame_ms * std.time.ns_per_ms;
pub const transition_steps: u16 = 10;
@@ -910,39 +272,6 @@ test "each flavour is its own motion: off lands at once, bouncy overshoots, play
for (std.enums.values(Motion.Flavour)) |flavour| try std.testing.expectEqual(@as(f32, 1), Motion.of(flavour).ease(1));
}
-test "a flavour's stretched pane lands exactly on its box, and a click finds the glyph drawn there" {
- const from: Box = .{ .x = 0, .y = 2, .w = 30, .h = 10 };
- const to: Box = .{ .x = 37.3, .y = 2, .w = 30, .h = 10 };
- for (std.enums.values(Motion.Flavour)) |flavour| {
- var track: Track = .{ .effect = .slide, .motion = @backingInt(flavour) + 1, .frame_count = 20, .from = from, .to = to };
- track.frame = track.frames() - 1;
- const landed = track.presented();
- // Bit for bit: no stretch or float residue once it lands.
- try std.testing.expectEqual(to, landed);
- }
- // Playful at its most stretched: the pane is drawn wider than its box,
- // and the drawn place of a cell maps back to that cell (the pointer
- // inverts the same box: target + (x - shown.x) / shown.w * target.w).
- var track: Track = .{ .effect = .slide, .motion = @backingInt(Motion.Flavour.playful) + 1, .frame_count = 20, .from = from, .to = to };
- var most: u16 = 0;
- var widest: f32 = 0;
- while (track.frame < track.frames()) : (track.frame += 1) {
- if (track.presented().w > widest) {
- widest = track.presented().w;
- most = track.frame;
- }
- }
- track.frame = most;
- const shown = track.presented();
- try std.testing.expect(shown.w > to.w * 1.05);
- for (0..30) |k| {
- const cell = to.x + @as(f32, @floatFromInt(k)) + 0.5;
- const drawn = shown.x + (cell - to.x) / to.w * shown.w;
- const back = to.x + (drawn - shown.x) / shown.w * to.w;
- try std.testing.expectApproxEqAbs(cell, back, 1e-3);
- }
-}
-
/// A view that follows its input (anim 9, 11): the picture's offset from
/// the core's position now (in the view's own unit: rows of text, pixels of
/// a PDF strip; negative, the picture still shows what is above), its speed
diff --git a/src/builtins.zig b/src/builtins.zig
index 6b31aba7..c6c4327b 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -17,7 +17,6 @@ const limits = @import("memory.zig").limits;
/// What this build's own frontend draws and its host does: the render's.
pub const frontend: config.Runtime.Capabilities = .{
.font_picker = pardes.font_picker,
- .panel_transitions = true,
// The tty's font belongs to its emulator.
.tagline_font_size = pardes.platform != .tui,
.window_opacity = pardes.platform == .gui or pardes.platform == .macos,
@@ -34,8 +33,8 @@ pub const frontend: config.Runtime.Capabilities = .{
/// its own frontend does (`viewCapabilities`), so a terminal's replica of a
/// window's session steps as the window's own does, and back.
pub const desktop = pardes.platform == .tui or pardes.platform == .gui;
-const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .panel_transitions = true, .tagline_font_size = true, .window_opacity = true, .window_blur = false, .ligatures = true, .lift = true };
-const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .panel_transitions = true, .tagline_font_size = false, .window_opacity = false, .window_blur = false, .ligatures = false, .lift = false };
+const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .tagline_font_size = true, .window_opacity = true, .window_blur = false, .ligatures = true, .lift = true };
+const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .tagline_font_size = false, .window_opacity = false, .window_blur = false, .ligatures = false, .lift = false };
/// The words this build has: a desktop build's are the window's.
pub const capabilities: config.Runtime.Capabilities = if (desktop) window_capabilities else frontend;
@@ -244,7 +243,7 @@ pub const registry = struct {
if (@backingInt(b) == i) return switch (setting.action) {
// a switch flips bare, a choice steps, and DumpDir and Shell bare
// are the default
- .toggle, .transition, .dump_dir, .choice, .motion, .shell => false,
+ .toggle, .dump_dir, .choice, .motion, .shell => false,
.theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .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 647f3112..aea87230 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -171,19 +171,6 @@ pub const leader_path = paths: {
table.set(.ProgramEsc, null);
table.set(.Motion, null);
if (builtins.capabilities.lift) table.set(.GripWidth, null);
- if (builtins.capabilities.panel_transitions) {
- table.set(.PanelSlide, "as");
- table.set(.PanelZoom, "az");
- table.set(.PanelDissolve, "ad");
- table.set(.PanelAscii, "aa");
- table.set(.PanelVertical, "av");
- table.set(.PanelEdges, "ae");
- table.set(.PanelFall, "af");
- table.set(.PanelWave, "aw");
- table.set(.PanelCurtain, "ac");
- table.set(.PanelScramble, "ar");
- table.set(.PanelType, "at");
- }
if (builtins.TreeContext.enabled) table.set(.TreeContext, null);
table.set(.ThemeFile, null);
table.set(.DumpThemes, null);
@@ -776,7 +763,6 @@ pub const Runtime = struct {
tagline_percent: u8 = 100,
} = .{},
- panel_transition: animation.Transition = .off,
/// What a terminal's shell pages through (host_io.ChildEnv): `pardes`,
/// PAGER and GIT_PAGER set to `pardes -`, a +Pager pane, where the
/// user's environment set neither; `off`, the environment as it is.
@@ -871,7 +857,6 @@ pub const Runtime = struct {
pub const Capabilities = struct {
font_picker: bool,
- panel_transitions: bool,
tagline_font_size: bool,
window_opacity: bool = false,
window_blur: bool = false,
@@ -904,7 +889,6 @@ pub const Runtime = struct {
tab,
callstack_depth,
search_rows,
- transition: animation.Transition,
choice: Choice,
};
@@ -930,7 +914,6 @@ pub const Runtime = struct {
.font, .tagline_size => .font_picker,
.window_opacity => .window_opacity,
.window_blur => .window_blur,
- .transition => .panel_transitions,
.grip_width => .lift,
.toggle => |field| switch (field) {
.ligatures => .ligatures,
@@ -968,17 +951,6 @@ pub const Runtime = struct {
.{ .word = "TaglineSize", .action = .tagline_size, .doc = "Scale the tag font, a percentage." },
.{ .word = "WindowOpacity", .action = .window_opacity, .doc = "The window's opacity, a percentage." },
.{ .word = "WindowBlur", .action = .window_blur, .doc = "The blur behind a translucent window, a radius." },
- .{ .word = "PanelSlide", .action = .{ .transition = .slide }, .doc = "Panes slide in and out as they open and close, on or off." },
- .{ .word = "PanelZoom", .action = .{ .transition = .zoom }, .doc = "Panes zoom in and out as they open and close, on or off." },
- .{ .word = "PanelDissolve", .action = .{ .transition = .dissolve }, .doc = "Panes dissolve in and out as they open and close, on or off." },
- .{ .word = "PanelAscii", .action = .{ .transition = .ascii }, .doc = "Panes open and close through a scatter of ASCII, on or off." },
- .{ .word = "PanelVertical", .action = .{ .transition = .vertical }, .doc = "Panes open and close with a vertical wipe, on or off." },
- .{ .word = "PanelEdges", .action = .{ .transition = .edges }, .doc = "Panes open and close from their edges, on or off." },
- .{ .word = "PanelFall", .action = .{ .transition = .fall }, .doc = "Panes fall into place as they open, on or off." },
- .{ .word = "PanelWave", .action = .{ .transition = .wave }, .doc = "Panes open and close in a wave, on or off." },
- .{ .word = "PanelCurtain", .action = .{ .transition = .curtain }, .doc = "Panes open and close like a curtain, on or off." },
- .{ .word = "PanelScramble", .action = .{ .transition = .scramble }, .doc = "Panes open and close through scrambled text, on or off." },
- .{ .word = "PanelType", .action = .{ .transition = .typewriter }, .doc = "Panes type themselves in as they open, on or off." },
.{ .word = "Pager", .action = .{ .choice = .pager }, .doc = "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it." },
.{ .word = "PagerColor", .action = .{ .toggle = .pager_color }, .doc = "A +Pager keeps its program's colours, on or off; for the next text paged." },
.{ .word = "TermImages", .action = .{ .choice = .term_images }, .doc = "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art." },
@@ -1018,11 +990,6 @@ pub const Runtime = struct {
if (actionCount(.shell) != 1 or actionCount(.theme) != 1 or actionCount(.font) != 1 or
actionCount(.tagline_size) != 1 or actionCount(.window_opacity) != 1 or actionCount(.window_blur) != 1)
@compileError("Shell, Theme, Font, TaglineSize, WindowOpacity, and WindowBlur actions must each occur exactly once");
- for (std.enums.values(animation.Transition)) |effect| {
- const expected: comptime_int = @intFromBool(effect != .off);
- if (actionCount(.{ .transition = effect }) != expected)
- @compileError("non-off panel transition must occur exactly once: " ++ @tagName(effect));
- }
}
pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool {
@@ -1068,18 +1035,6 @@ pub const Runtime = struct {
inline else => |w| @field(state, "message_" ++ @tagName(w) ++ "_ms") = ms,
}
},
- // Panel effects are one choice, so `on` picks this one and `off`
- // turns it off only if it is the one on.
- .transition => |effect| {
- const want = switchedTo(argument) catch return false;
- if (want == null) {
- state.panel_transition = if (state.panel_transition == effect) .off else effect;
- } else if (want.?) {
- state.panel_transition = effect;
- } else if (state.panel_transition == effect) {
- state.panel_transition = .off;
- }
- },
// Bare, it steps to the next word, as a tag word should.
.choice => |which| switch (which) {
inline else => |field| {
@@ -1109,7 +1064,7 @@ pub const Runtime = struct {
}
};
return switch (action) {
- .toggle, .transition => "on, off",
+ .toggle => "on, off",
.choice => |which| switch (which) {
inline else => |field| comptime words.of(@FieldType(Runtime, @tagName(field))),
},
@@ -1244,8 +1199,6 @@ pub const Runtime = struct {
try out.writeByte('\n');
},
.tagline_size => try out.print("{s} {d}\n", .{ setting.word, state.font.tagline_percent }),
- // Each a switch of its own, the one in use on.
- .transition => |transition| try out.print("{s} {s}\n", .{ setting.word, onOff(state.panel_transition == transition) }),
.choice => |which| switch (which) {
inline else => |field| try out.print("{s} {s}\n", .{ setting.word, @tagName(@field(state, @tagName(field))) }),
},
@@ -1284,21 +1237,6 @@ pub const Runtime = struct {
try out.print("# Native images: {s}\n", .{onOff(context.native_images)});
}
- test "panel effects flip bare and are set by on and off" {
- var state: Runtime = .{};
- const slide = findAction(.{ .transition = .slide }).?;
- const zoom = findAction(.{ .transition = .zoom }).?;
- try std.testing.expect(apply(&state, slide, "on"));
- try std.testing.expectEqual(animation.Transition.slide, state.panel_transition);
- try std.testing.expect(apply(&state, zoom, "off"));
- try std.testing.expectEqual(animation.Transition.slide, state.panel_transition);
- try std.testing.expect(apply(&state, slide, "on"));
- try std.testing.expectEqual(animation.Transition.slide, state.panel_transition);
- try std.testing.expect(apply(&state, slide, null));
- try std.testing.expectEqual(animation.Transition.off, state.panel_transition);
- try std.testing.expect(!apply(&state, slide, "yes"));
- }
-
test "a toggle flips when bare and sets when told on or off" {
var state: Runtime = .{};
const verbose = find("Verbose").?;
@@ -1328,10 +1266,6 @@ pub const Runtime = struct {
try std.testing.expect(apply(&state, find("Shell").?, " fish\n"));
try std.testing.expectEqualStrings("fish", state.shell.requested.get());
try std.testing.expect(state.shell.pending);
- try std.testing.expect(apply(&state, find("PanelAscii").?, null));
- try std.testing.expectEqual(animation.Transition.ascii, state.panel_transition);
- try std.testing.expect(apply(&state, find("PanelAscii").?, null));
- try std.testing.expectEqual(animation.Transition.off, state.panel_transition);
}
test "tagline size validates before mutating live state" {
@@ -1432,7 +1366,6 @@ pub const Runtime = struct {
.native_images = true,
.capabilities = .{
.font_picker = true,
- .panel_transitions = true,
.tagline_font_size = true,
.window_opacity = true,
.window_blur = true,
@@ -1483,7 +1416,6 @@ pub const Runtime = struct {
defaults_context.native_images = false;
defaults_context.capabilities = .{
.font_picker = false,
- .panel_transitions = true,
.tagline_font_size = false,
};
defaults_context.state = &defaults;
diff --git a/src/draw.zig b/src/draw.zig
index 2ddb8faf..015d2def 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -2,7 +2,7 @@
//! `render` is the whole order, top to bottom: the page, each pane (its
//! grip, tag and body, and the body layer of its compact rows), the notice
//! chips, the workspace and column tags, the tag layers, drag overlays, the
-//! debug box, then the presentation's tracks and the character effects.
+//! debug box, then the cursor.
const std = @import("std");
const vaxis = @import("vaxis");
const pardes = @import("pardes.zig");
@@ -314,11 +314,9 @@ const PaneFrame = struct {
};
fn paneFrame(s: *const Surface, serial: u32, rect: Rect) PaneFrame {
+ _ = s;
+ _ = serial;
const still = layout.panelBox(rect);
- for (s.panelTracks()) |track| {
- if (track.serial != serial or track.phase == .closing or !track.active()) continue;
- return .{ .to = track.to, .at = track.visualBox() };
- }
return .{ .to = still, .at = still };
}
@@ -356,12 +354,6 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
for (&s.body_layers) |*layer| layer.rows = 0;
for (&s.tag_layers) |*layer| layer.rows = 0;
s.images.clearRetainingCapacity();
- s.npanel_tracks = 0;
- s.previous_cells = &.{};
- s.previous_body_layers = &.{};
- s.previous_tag_layers = &.{};
- s.previous_regions = &.{};
- s.cell_diffs = &.{};
const chrome = p.chromeTheme();
s.chrome = .{
.page = p.theme().bg,
@@ -552,122 +544,8 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
}
}
};
- // After the tracks are submitted: the cursor is drawn through its
- // pane's.
- try p.presentation.submit(p, s);
glideCursor(p, s);
- return composeAsciiTransitions(p, arena, s);
-}
-
-pub fn composeAsciiTransitions(p: *Pardes, arena: std.mem.Allocator, canonical: *Surface) !*Surface {
- _ = p;
- if (!canonical.hasPanelDiff()) return canonical;
- var presented: ?*Surface = null;
- for (canonical.panelTracks()) |track| {
- if (!track.effect.composedByCore() or track.phase == .closing) continue;
- const area = animation.CellArea.of(track.to);
- const col_end = @min(canonical.cols, area.x0 +| area.cols);
- const row_end = @min(canonical.rows, area.y0 +| area.rows);
- var row: u16 = area.y0;
- while (row < row_end) : (row += 1) {
- var col: u16 = area.x0;
- while (col < col_end) : (col += 1) {
- const index = @as(usize, row) * canonical.cols + col;
- const composed = composedCell(canonical, track, area, col, row, index) orelse
- continue;
- if (composed.visuallyEqual(&canonical.cells[index])) continue;
- if (presented == null) {
- const next = try arena.create(Surface);
- next.* = canonical.*;
- next.cells = try arena.dupe(Cell, canonical.cells);
- presented = next;
- }
- presented.?.cells[index] = composed;
- }
- }
- }
- return presented orelse canonical;
-}
-
-fn composedCell(
- canonical: *const Surface,
- track: animation.Track,
- area: animation.CellArea,
- col: u16,
- row: u16,
- index: usize,
-) ?Cell {
- if (track.effect == .ascii) {
- const diff = switch (canonical.cell_diffs[index]) {
- .ascii => |diff| diff,
- .unchanged, .visual => return null,
- };
- const byte = diff.byteAt(track.frame);
- if (byte == diff.to) return null;
- if (track.frame == 0) return canonical.previous_cells[index];
- return withByte(canonical.cells[index], byte);
- }
- return switch (animation.charSource(track, col - area.x0, row - area.y0, area)) {
- .old => canonical.previous_cells[index],
- .byte => |byte| withByte(canonical.cells[index], byte),
- .edge => |weight| towardGround(canonical.cells[index], canonical.previous_cells[index].style.bg, weight),
- // Churn belongs on the glyph, not on the pane's empty space, and it
- // borrows whichever side of the diff actually has one.
- .churn => |byte| blk: {
- const new_cell = &canonical.cells[index];
- if (hasGlyph(new_cell)) break :blk withByte(new_cell.*, byte);
- const old_cell = &canonical.previous_cells[index];
- if (hasGlyph(old_cell)) break :blk withByte(old_cell.*, byte);
- break :blk old_cell.*;
- },
- .at => |offset| blk: {
- const source_col = @as(i32, col) + offset.cols;
- const source_row = @as(i32, row) + offset.rows;
- // A glyph whose source lies outside the pane has not arrived
- // yet: the frozen old cell is the only truthful thing under it.
- if (source_col < area.x0 or source_row < area.y0 or
- source_col >= @as(i32, area.x0) + area.cols or
- source_row >= @as(i32, area.y0) + area.rows or
- source_col >= canonical.cols or source_row >= canonical.rows)
- break :blk canonical.previous_cells[index];
- const source = @as(usize, @intCast(source_row)) * canonical.cols +
- @as(usize, @intCast(source_col));
- break :blk canonical.cells[source];
- },
- };
-}
-
-/// A cell with its ink and ground drawn `weight` of the way toward another
-/// ground, in OKLab. A palette or default colour cannot be mixed, so the
-/// ground steps over at the halfway point instead.
-fn towardGround(cell: Cell, ground: Color, weight: f32) Cell {
- var out = cell;
- const to = switch (ground) {
- .rgb => |rgb| rgb,
- .default, .index => return if (weight >= 0.5) blk: {
- out.style.bg = ground;
- break :blk out;
- } else out,
- };
- inline for (.{ &out.style.fg, &out.style.bg }) |color| switch (color.*) {
- .rgb => |rgb| color.* = .{ .rgb = colors.mixOklab(rgb, to, weight) },
- .default, .index => {},
- };
- return out;
-}
-
-fn withByte(cell: Cell, byte: u8) Cell {
- var out = cell;
- out.text[0] = byte;
- out.len = 1;
- out.default = false;
- return out;
-}
-
-/// Whether a cell shows a glyph a character effect can work on. An unpainted
-/// cell and a space are both blank space, whatever style they carry.
-fn hasGlyph(cell: *const Cell) bool {
- return !cell.default and !(cell.len == 1 and cell.text[0] == ' ');
+ return s;
}
fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
@@ -1750,8 +1628,8 @@ test "a monkey over notices, prompts, tags and tiny panes at a gui's metrics nev
}
p.sync();
_ = arena.reset(.retain_capacity);
- const s = try p.render(arena.allocator());
- p.acknowledgePanelPresentation(s.panelTracks());
+ _ = try p.render(arena.allocator());
+ p.presented();
}
}
@@ -1842,65 +1720,12 @@ fn twoColumns(p: *Pardes, arena: *std.heap.ArenaAllocator) !void {
try std.testing.expect(layout.splitColumn(p, 0, 1, false));
p.sync();
p.advance(std.time.ns_per_s);
- const boot = try p.render(arena.allocator());
- p.acknowledgePanelPresentation(boot.panelTracks());
+ _ = try p.render(arena.allocator());
+ p.presented();
p.advance(2 * std.time.ns_per_s);
_ = arena.reset(.retain_capacity);
- const settled = try p.render(arena.allocator());
- p.acknowledgePanelPresentation(settled.panelTracks());
- try std.testing.expect(!p.cursor_glide.moving());
-}
-
-test "while its pane slides the cursor rides with it, at the same cell of the pane every frame" {
- if (!builtins.frontend.lift) return error.SkipZigTest;
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 });
- defer p.deinit();
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- p.settings.motion = .bouncy;
- try twoColumns(p, &arena);
- p.active = 1;
- p.advance(3 * std.time.ns_per_s);
- _ = arena.reset(.retain_capacity);
- p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks());
- p.advance(4 * std.time.ns_per_s);
- p.settings.panel_transition = .slide;
- // The right column's pane moves right.
- p.col_weight[0] = layout.column_weight_unit * 2;
- p.col_weight[1] = layout.column_weight_unit;
- p.sync();
- var now: u64 = 4 * std.time.ns_per_s;
- var riding: usize = 0;
- for (0..40) |_| {
- now += 16 * std.time.ns_per_ms;
- p.advance(now);
- _ = arena.reset(.retain_capacity);
- const s = try p.render(arena.allocator());
- p.acknowledgePanelPresentation(s.panelTracks());
- const frame = paneFrame(s, p.panes[1].?.serial, p.rects[1]);
- const box = focusedCursorBox(p, s).?;
- const want = frame.place(.{ box.x, box.y });
- try std.testing.expectApproxEqAbs(want[0], s.chrome.cursor_quad[0], 0.01);
- try std.testing.expectApproxEqAbs(want[1], s.chrome.cursor_quad[1], 0.01);
- if (frame.moving()) {
- riding += 1;
- // Drawn as the quad while the pane moves.
- try std.testing.expect(s.chrome.cursor_glide & 1 != 0);
- }
- }
- try std.testing.expect(riding >= 3);
-
- // With no transition, the cursor lands with the text at once.
- p.settings.panel_transition = .off;
- p.col_weight[0] = layout.column_weight_unit;
- p.col_weight[1] = layout.column_weight_unit * 2;
- p.sync();
- now += 16 * std.time.ns_per_ms;
- p.advance(now);
- _ = arena.reset(.retain_capacity);
- const landed = try p.render(arena.allocator());
- const box = focusedCursorBox(p, landed).?;
- try std.testing.expectApproxEqAbs(box.x, landed.chrome.cursor_quad[0], 0.01);
+ _ = try p.render(arena.allocator());
+ p.presented();
try std.testing.expect(!p.cursor_glide.moving());
}
diff --git a/src/dump.zig b/src/dump.zig
index a35a9fab..1b3bcb5c 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -445,7 +445,6 @@ fn reviveSession(p: *Pardes, previous: ?*const Pardes, resumed: bool) !void {
if (!resumed) exec.applyStartupConfig(p);
colors.finishThemeInitialization(p);
p.sync();
- p.presentation.enabled = true;
_ = p.takeHaptic(); // see init: a restored session is not a gesture
try p.fs.log.buf.ensureTotalCapacityPrecise(p.gpa, p.fs.log.cap);
ctlfs.events.announce(p);
diff --git a/src/exec.zig b/src/exec.zig
index b258549e..81826271 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -302,11 +302,11 @@ pub fn withArg(p: *Pardes, txt: []const u8, arg: ?[]const u8) []const u8 {
const a = std.mem.trim(u8, arg orelse return txt, " \t\r\n");
if (a.len == 0) return txt;
const t = std.mem.trim(u8, txt, " \t\r\n");
- // A switch (Verbose, PanelSlide) clicked with some other text
+ // A switch (Verbose, Wrap) clicked with some other text
// selected flips, as it does bare: only `on` or `off` is an argument
// for it. What a ctl write gives it is checked strictly instead.
if (config.Runtime.find(commandText(t))) |setting| switch (setting.action) {
- .toggle, .transition => if (!std.mem.eql(u8, a, "on") and !std.mem.eql(u8, a, "off")) return txt,
+ .toggle => if (!std.mem.eql(u8, a, "on") and !std.mem.eql(u8, a, "off")) return txt,
else => {},
};
return std.fmt.allocPrint(p.scratch.allocator(), "{s} {s}", .{ t, a }) catch txt;
@@ -1014,7 +1014,6 @@ pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ?
pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]const u8) void {
const previous_colors = p.settings.colors;
const previous_context_style = p.settings.tree_context_tag_style;
- const previous_transition = p.settings.panel_transition;
const previous_tagline_percent = p.settings.font.tagline_percent;
switch (setting.action) {
.theme => {
@@ -1085,19 +1084,10 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]
const pane = slot orelse continue;
pane.geometry_key = 0;
}
- p.abandonPanelAnimations();
- }
- const transition_changed = setting.action == .transition and
- p.settings.panel_transition != previous_transition;
- const tagline_metrics_changed = setting.action == .tagline_size and
- p.settings.font.tagline_percent != previous_tagline_percent;
- // Idle frames keep no frozen grid while transitions are off; the one
- // just drawn is the baseline the first transition starts from.
- if (transition_changed and previous_transition == .off)
- p.presentation.capturePrevious(p.gpa, &p.surface);
- if (transition_changed or tagline_metrics_changed) {
- p.abandonPanelAnimations();
+ look.cancelLookHover(p);
}
+ if (setting.action == .tagline_size and p.settings.font.tagline_percent != previous_tagline_percent)
+ look.cancelLookHover(p);
}
/// What a new pane is, and who asked: each rule places them differently.
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index e97e6e38..24b15b35 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -425,18 +425,10 @@ const CellInstance = extern struct {
br: f32,
bg: f32,
bb: f32,
- panel_x0: f32 = 0,
- panel_y0: f32 = 0,
- panel_x1: f32 = 0,
- panel_y1: f32 = 0,
- present_x0: f32 = 0,
- present_y0: f32 = 0,
- present_x1: f32 = 0,
- present_y1: f32 = 0,
+ /// The flags (the high bits, ui.vert.glsl), and the theme's dots'
+ /// offset (G13's parallax) as a float's bits.
effect: u32 = 0,
- progress_bits: u32 = @bitCast(@as(f32, 1)),
serial: u32 = 0,
- cell_coord: u32 = 0,
/// A clip rectangle in target pixels; x1 < x0 is none (ui.vert.glsl).
clip_x0: f32 = 0,
clip_y0: f32 = 0,
@@ -463,21 +455,8 @@ const ImageInstance = extern struct {
v0: f32,
u1: f32,
v1: f32,
- panel_x0: f32 = 0,
- panel_y0: f32 = 0,
- panel_x1: f32 = 0,
- panel_y1: f32 = 0,
- present_x0: f32 = 0,
- present_y0: f32 = 0,
- present_x1: f32 = 0,
- present_y1: f32 = 0,
- effect: u32 = 0,
- progress_bits: u32 = @bitCast(@as(f32, 1)),
- serial: u32 = 0,
- cell_coord: u32 = 0,
};
-const old_layer_bit: u32 = 0x8000_0000;
const clear_bg_bit: u32 = 0x4000_0000;
const opaque_bg_bit: u32 = 0x2000_0000;
/// Decor that is a checker (decor.frag.glsl).
@@ -487,123 +466,16 @@ const checker_bit: u32 = 0x0800_0000;
const dotted_bit: u32 = 0x1000_0000;
const title_bit: u32 = 0x0800_0000;
-const SavedImagePlace = struct {
- key: pardes.ImageCacheKey,
- pane: u8,
- serial: u32,
- native: pardes.NativePlacement,
- x: u16,
- y: u16,
- w: u16,
- h: u16,
- iw: usize,
- ih: usize,
-
- fn from(place: pardes.ImagePlace) SavedImagePlace {
- return .{
- .key = place.cacheKey(),
- .pane = place.pane,
- .serial = place.serial,
- .native = place.native,
- .x = place.x,
- .y = place.y,
- .w = place.w,
- .h = place.h,
- .iw = place.iw,
- .ih = place.ih,
- };
- }
-
- fn cacheKey(place: SavedImagePlace) pardes.ImageCacheKey {
- return place.key;
- }
-};
-
const PreparedImage = struct {
- place: SavedImagePlace,
+ place: pardes.ImagePlace,
texture: *c.SDL_GPUTexture,
- track: ?pardes.animation.Track = null,
- clip: ?pardes.animation.Box = null,
- old_layer: bool = false,
};
-test "saved native placement retains identity and geometry but no producer bytes" {
- try std.testing.expect(!@hasField(SavedImagePlace, "rgba"));
- const current: pardes.ImagePlace = .{
- .pane = 3,
- .serial = 91,
- .x = 4,
- .y = 5,
- .w = 6,
- .h = 7,
- .rgba = &.{ 1, 2, 3, 4 },
- .iw = 1,
- .ih = 1,
- };
- const saved = SavedImagePlace.from(current);
- try std.testing.expect(sameSavedPlacement(saved, current));
- try std.testing.expect(placeIntersectsBox(saved, .{ .x = 8, .y = 8, .w = 4, .h = 4 }));
- try std.testing.expect(!placeIntersectsBox(saved, .{ .x = 20, .y = 20, .w = 2, .h = 2 }));
-}
-
-test "shader instance ABI carries aligned transition vectors" {
- try std.testing.expectEqual(@as(usize, 120), @sizeOf(CellInstance));
- try std.testing.expectEqual(@as(usize, 104), @offsetOf(CellInstance, "clip_x0"));
- try std.testing.expectEqual(@as(usize, 56), @offsetOf(CellInstance, "panel_x0"));
- try std.testing.expectEqual(@as(usize, 72), @offsetOf(CellInstance, "present_x0"));
- try std.testing.expectEqual(@as(usize, 88), @offsetOf(CellInstance, "effect"));
- try std.testing.expectEqual(@as(usize, 80), @sizeOf(ImageInstance));
- try std.testing.expectEqual(@as(usize, 32), @offsetOf(ImageInstance, "panel_x0"));
- try std.testing.expectEqual(@as(usize, 48), @offsetOf(ImageInstance, "present_x0"));
- try std.testing.expectEqual(@as(usize, 64), @offsetOf(ImageInstance, "effect"));
- try std.testing.expectEqual(@as(usize, 32), @sizeOf([8]f32));
-
- const tracks = [_]pardes.animation.Track{
- .{ .pane = 0, .phase = .opening, .effect = .slide },
- .{ .pane = 1, .phase = .moving, .effect = .slide },
- .{ .pane = 2, .phase = .moving, .effect = .slide },
- };
- // Tier 0, the tracks as the core ordered them, then tiers 4 and 5.
- const groups = makeGroups(&tracks, true);
- try std.testing.expectEqual(@as(usize, 7), groups.len);
- try std.testing.expect(groups.items[0].track == null);
- try std.testing.expectEqual(@as(u8, 0), groups.items[1].track.?.pane);
- try std.testing.expectEqual(@as(u8, 1), groups.items[2].track.?.pane);
- try std.testing.expectEqual(@as(u8, 2), groups.items[3].track.?.pane);
- try std.testing.expectEqual(@as(usize, 4), groups.notices);
- try std.testing.expectEqual(@as(usize, 5), groups.guides);
- try std.testing.expectEqual(@as(usize, 6), groups.ink);
- for ([_]usize{ groups.notices, groups.guides, groups.ink }) |index| try std.testing.expect(groups.items[index].track == null);
-}
-
-test "GUI paint plan snaps history effects without a frozen grid" {
- const tracks = [_]pardes.animation.Track{
- .{ .pane = 0, .phase = .opening, .effect = .ascii },
- .{ .pane = 1, .phase = .closing, .effect = .vertical },
- };
- try std.testing.expectEqual(@as(usize, 0), makeGroups(&tracks, false).tracks);
- const ready = makeGroups(&tracks, true);
- try std.testing.expectEqual(@as(usize, 2), ready.tracks);
- try std.testing.expectEqual(pardes.animation.Phase.opening, ready.items[1].track.?.phase);
- try std.testing.expectEqual(pardes.animation.Phase.closing, ready.items[2].track.?.phase);
-}
-
-test "closing tombstone overlays but never owns canonical cells" {
- const closing: pardes.animation.Track = .{
- .pane = 0,
- .phase = .closing,
- .effect = .vertical,
- .from = .{ .x = 2, .y = 3, .w = 10, .h = 4 },
- .to = .{ .x = 2, .y = -1, .w = 10, .h = 4 },
- };
- const groups = makeGroups(&.{closing}, true);
- try std.testing.expectEqual(@as(usize, 0), groupAt(&groups, 4, 4));
- // A still pane's notice stays under the tombstone sliding over it.
- const notice: pardes.Layer = .{ .kind = .notice, .viewport = .{ .x = 4, .y = 4, .w = 3, .h = 1 }, .rows = 1 };
- try std.testing.expectEqual(@as(usize, 0), noticeGroup(&groups, &notice));
- try std.testing.expectEqual(makeGroups(&.{}, false).notices, noticeGroup(&makeGroups(&.{}, false), &notice));
- try std.testing.expectEqual(@as(usize, 1), groups.tracks);
- try std.testing.expectEqual(pardes.animation.Phase.closing, groups.items[1].track.?.phase);
+test "the shader instance ABI: the flags after the colours, the clip after them" {
+ try std.testing.expectEqual(@as(usize, 80), @sizeOf(CellInstance));
+ try std.testing.expectEqual(@as(usize, 56), @offsetOf(CellInstance, "effect"));
+ try std.testing.expectEqual(@as(usize, 64), @offsetOf(CellInstance, "clip_x0"));
+ try std.testing.expectEqual(@as(usize, 32), @sizeOf(ImageInstance));
}
fn updateCoreResize(core: *pardes.Pardes, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) bool {
@@ -1098,10 +970,8 @@ const Gui = struct {
image_vxfer: ?*c.SDL_GPUTransferBuffer = null,
image_capacity: u32 = 0,
native_images: std.AutoHashMapUnmanaged(pardes.ImageCacheKey, *c.SDL_GPUTexture) = .empty,
- presented_images: std.ArrayListUnmanaged(SavedImagePlace) = .empty,
prepared_images: std.ArrayListUnmanaged(PreparedImage) = .empty,
- /// renderFrame's cover of the grid (coverFrame): this frame's, then the
- /// frame a panel transition is leaving.
+ /// renderFrame's cover of the grid (coverFrame).
cover: std.ArrayListUnmanaged(Cover) = .empty,
/// renderFrame's decor instances, group by group (buildDecor).
decor: std.ArrayListUnmanaged(CellInstance) = .empty,
@@ -1221,7 +1091,7 @@ const Gui = struct {
/// The Gui's fields that are each window's own, one a view (views.zig):
/// the window and its presenting, its scroll and glide, its pointer, its
-/// blink, its images as presented, its capture. The
+/// blink, its images, its capture. The
/// device, the atlas, the font and the pipelines are every window's. The
/// Gui holds the live window's; the others wait in `Shell.windows`.
const window_fields = [_][:0]const u8{
@@ -1231,7 +1101,7 @@ const window_fields = [_][:0]const u8{
"scroll_lag", "scroll_edge", "scroll_edge_len", "scroll_notch", "program_wheel",
"glide", "pace_ns", "frame_arrival_ns",
"blink_due", "cursor_quad_alpha", "pointer_present", "pointer_shape",
- "pointer_cell", "presented_images", "prepared_images", "touch",
+ "pointer_cell", "prepared_images", "touch",
"live_ctrl", "live_alt", "applied_window_opacity", "capture_tex", "capture_tex_w",
"capture_tex_h", "capture_xfer", "capture_xfer_size", "captured", "capture_dir",
};
@@ -1274,7 +1144,6 @@ fn releaseWindowParts(g: *Gui, gpa: std.mem.Allocator) void {
if (g.capture_xfer) |transfer| c.SDL_ReleaseGPUTransferBuffer(g.device, transfer);
g.glide.deinit(gpa);
gpa.free(g.scroll_edge);
- g.presented_images.deinit(gpa);
g.prepared_images.deinit(gpa);
}
@@ -1405,12 +1274,9 @@ fn fixedCellLayout(g: *const Gui) CellLayout {
return .{ .w = @floatFromInt(g.cell_w), .h = @floatFromInt(g.cell_h), .x_off = 0, .y_off = 0 };
}
-const boxContains = pardes.animation.Box.contains;
-
-/// What one tier draws, or one track in tiers 2 and 3 (docs/render-pipeline.md
-/// §3.4), in this order: its cells, its images, then its decor.
+/// What one group draws, in this order: its cells, its images, then its
+/// decor.
const Group = struct {
- track: ?pardes.animation.Track = null,
cell_start: u32 = 0,
cell_count: u32 = 0,
image_start: u32 = 0,
@@ -1422,61 +1288,17 @@ const Group = struct {
under_count: u32 = 0,
};
-/// The frame's draw groups, bottom to top: tier 0 (the page and the panes
-/// standing still), a group for each track in paint order (tier 2 moving and
-/// opening, tier 3 closing), tier 4 (floating: the notices, then the guides
-/// and the debug box, which the core paints over them) and tier 5 (ink: the
-/// bar cursors; the cursor's glide draws after it). Tier 1 is the
-/// focus lift, which does not exist yet.
+/// The frame's draw groups, bottom to top: the page and the panes, the
+/// notices floating over them, the guides and the debug box the core paints
+/// over those, and ink (the bar cursors; the cursor's glide draws after it).
const Groups = struct {
- items: [pardes.MAX_PANES * 2 + 4]Group = @splat(.{}),
- /// Groups 1 through `tracks` are the tracks'.
- tracks: usize = 0,
+ items: [4]Group = @splat(.{}),
notices: usize = 1,
guides: usize = 2,
ink: usize = 3,
len: usize = 4,
};
-fn makeGroups(tracks: []const pardes.animation.Track, has_diff: bool) Groups {
- var groups: Groups = .{};
- for (tracks) |track| {
- if (!track.active()) continue;
- if (track.effect.needsPreviousGrid() and !has_diff) continue;
- std.debug.assert(groups.tracks < pardes.MAX_PANES * 2);
- groups.tracks += 1;
- groups.items[groups.tracks].track = track;
- }
- groups.notices = groups.tracks + 1;
- groups.guides = groups.tracks + 2;
- groups.ink = groups.tracks + 3;
- groups.len = groups.tracks + 4;
- return groups;
-}
-
-/// The group of the track whose pane covers this cell, else tier 0.
-fn groupAt(groups: *const Groups, col: u16, row: u16) usize {
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- if (group.track.?.phase == .closing) continue;
- if (boxContains(group.track.?.to, col, row)) return index;
- }
- return 0;
-}
-
-fn groupOf(groups: *const Groups, serial: u32) usize {
- for (groups.items[1..][0..groups.tracks], 1..) |group, index|
- if (group.track.?.serial == serial) return index;
- return 0;
-}
-
-/// A notice floats over the panes and its pane's picture (tier 4) while
-/// nothing moves; while anything does it stays in its own pane's group, under
-/// whatever pane slides, opens or closes over it.
-fn noticeGroup(groups: *const Groups, layer: *const pardes.Layer) usize {
- if (groups.tracks > 0) return groupAt(groups, layer.viewport.x, layer.viewport.y);
- return groups.notices;
-}
-
/// What draws a grid cell, marked once a frame from the layers and the
/// regions (coverFrame), so the cell loops read it rather than search.
const Cover = packed struct(u16) {
@@ -1548,69 +1370,6 @@ fn coverFrame(cover: []Cover, cols: u16, rows: u16, body_layers: []const pardes.
};
}
-fn panelCellCoord(track: pardes.animation.Track, col: u16, row: u16) u32 {
- const source = track.contentBox();
- const x0: u16 = @intFromFloat(@max(0.0, @floor(source.x)));
- const y0: u16 = @intFromFloat(@max(0.0, @floor(source.y)));
- return @as(u32, row -| y0) << 16 | @as(u32, col -| x0);
-}
-
-fn panelGridSize(track: pardes.animation.Track) u32 {
- const source = track.contentBox();
- const cols: u16 = @intFromFloat(@min(@as(f32, std.math.maxInt(u16)), @max(1.0, @ceil(source.w))));
- const rows: u16 = @intFromFloat(@min(@as(f32, std.math.maxInt(u16)), @max(1.0, @ceil(source.h))));
- return @as(u32, rows) << 16 | @as(u32, cols);
-}
-
-fn ndcBox(box: pardes.animation.Box, layout: CellLayout, win_w: f32, win_h: f32) [4]f32 {
- const px0 = layout.x_off + box.x * layout.w;
- const py0 = layout.y_off + box.y * layout.h;
- const px1 = px0 + box.w * layout.w;
- const py1 = py0 + box.h * layout.h;
- return .{
- px0 / win_w * 2.0 - 1.0,
- 1.0 - py0 / win_h * 2.0,
- px1 / win_w * 2.0 - 1.0,
- 1.0 - py1 / win_h * 2.0,
- };
-}
-
-/// A new instance's transition fields for `track`, which moves its pane;
-/// with none it keeps its defaults (still, all of it shown).
-fn setTransitionFields(
- instance: anytype,
- track: ?pardes.animation.Track,
- layout: CellLayout,
- win_w: f32,
- win_h: f32,
- cell_coord: u32,
-) void {
- const active = track orelse return;
- const final = ndcBox(active.contentBox(), layout, win_w, win_h);
- const presented = ndcBox(active.visualBox(), layout, win_w, win_h);
- instance.panel_x0 = final[0];
- instance.panel_y0 = final[1];
- instance.panel_x1 = final[2];
- instance.panel_y1 = final[3];
- instance.present_x0 = presented[0];
- instance.present_y0 = presented[1];
- instance.present_x1 = presented[2];
- instance.present_y1 = presented[3];
- instance.effect = @backingInt(active.effect);
- instance.progress_bits = @bitCast(active.amount());
- instance.serial = active.serial;
- instance.cell_coord = cell_coord;
- // A vertical transition shows its pane only inside the box it grows
- // into, in whole pixels.
- if (@hasField(@TypeOf(instance.*), "clip_x0") and active.effect == .vertical) {
- const box = active.contentBox();
- instance.clip_x0 = std.math.clamp(@floor(box.x * layout.w), 0, win_w);
- instance.clip_y0 = std.math.clamp(@floor(box.y * layout.h), 0, win_h);
- instance.clip_x1 = std.math.clamp(@ceil((box.x + box.w) * layout.w), instance.clip_x0, win_w);
- instance.clip_y1 = std.math.clamp(@ceil((box.y + box.h) * layout.h), instance.clip_y0, win_h);
- }
-}
-
pub fn run(init: std.process.Init, opts: pardes.Options, headless: bool) !void {
return runNative(init, opts, headless, null);
}
@@ -1895,7 +1654,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
defer {
clearNativeImages(&g);
g.native_images.deinit(gpa);
- g.presented_images.deinit(gpa);
g.prepared_images.deinit(gpa);
g.cover.deinit(gpa);
g.decor.deinit(gpa);
@@ -2133,7 +1891,6 @@ fn localSession(
shell.windowed = 1;
shell.stopPtys();
clearNativeImages(g);
- g.presented_images.clearRetainingCapacity();
g.prepared_images.clearRetainingCapacity();
nc.native_images = true;
nc.native_image_patches = true;
@@ -3114,21 +2871,25 @@ fn gridCellAtDimensions(
var point: MouseCell = .{ .col = @intFromFloat(@min(@floor(@max(x, 0) / @max(body_w, 1)), 10_000)), .row = row };
// On the rule over this row, which is where two panes meet if they do.
point.rule_above = row > 0 and @max(y, 0) - @as(f32, @floatFromInt(row)) * @max(body_h, 1) < dp(rule_grab_px);
- if (core.presentation.pointerFractional(core.screen_w, core.screen_h, x / @max(body_w, 1), y / @max(body_h, 1))) |mapped| {
- for (core.surface.tagLayers()) |*layer| {
- if (layer.tagHit(mapped.x * body_w, mapped.y * body_h, body_w, body_h, tagline_w, @floatFromInt(core.row_metrics.tagline_h))) |hit| {
- point.tag_hit = hit;
- break;
- }
+ if (onGrid(core, x / @max(body_w, 1), y / @max(body_h, 1))) for (core.surface.tagLayers()) |*layer| {
+ if (layer.tagHit(x, y, body_w, body_h, tagline_w, @floatFromInt(core.row_metrics.tagline_h))) |hit| {
+ point.tag_hit = hit;
+ break;
}
- }
+ };
return point;
}
+/// Whether a point, in cells, is on the grid.
+fn onGrid(core: *const pardes.Pardes, x: f32, y: f32) bool {
+ return std.math.isFinite(x) and std.math.isFinite(y) and x >= 0 and y >= 0 and
+ x < @as(f32, @floatFromInt(core.screen_w)) and y < @as(f32, @floatFromInt(core.screen_h));
+}
+
fn gridCellAtPixels(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32) MouseCell {
var point = gridCellAtDimensions(core, x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width));
- if (core.presentation.pointerFractional(core.screen_w, core.screen_h, x / @as(f32, @floatFromInt(g.cell_w)), y / @as(f32, @floatFromInt(g.cell_h)))) |mapped| for (core.surface.bodyLayers()) |*layer| {
- if (layer.bodyHit(mapped.x * @as(f32, @floatFromInt(g.cell_w)), mapped.y * @as(f32, @floatFromInt(g.cell_h)), @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width), @floatFromInt(g.tagline_height))) |hit| {
+ if (onGrid(core, x / @as(f32, @floatFromInt(g.cell_w)), y / @as(f32, @floatFromInt(g.cell_h)))) for (core.surface.bodyLayers()) |*layer| {
+ if (layer.bodyHit(x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width), @floatFromInt(g.tagline_height))) |hit| {
point.body_hit = hit;
break;
}
@@ -3141,7 +2902,6 @@ test "tagline pointer mapping retains physical grips and carries logical text co
defer core.deinit();
core.update(.{ .resize = .{ .cols = 60, .rows = 12 } });
core.update(.{ .command = "Newcol" });
- core.presentation.enabled = false;
core.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 12 };
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
@@ -4302,16 +4062,14 @@ fn postPresent(ctx: ?*anyopaque) void {
const s = shellOf(ctx);
s.follow();
const g = s.gui orelse return;
- // No image (a minimized window) shows no tracks; time still passes and
- // the pump advances it all the same.
+ // No image (a minimized window): nothing was drawn to point at.
if (!s.presented) return;
- const frame = s.surface orelse return;
- // A client's view live: the window's frame is acknowledged when its
- // own view is live and drawn.
+ // A client's view live: the window's frame counts when its own view is
+ // live and drawn.
if (s.core.view != s.gview) return;
var in: Input = .{ .core = s.core };
refreshPresentedPointer(g, &in);
- s.core.acknowledgePanelPresentation(frame.panelTracks());
+ s.core.presented();
}
fn guiNow(ctx: ?*anyopaque) u64 {
@@ -5226,8 +4984,6 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
const pane = if (gliding) glide.pane else g.scroll_pane orelse return 0;
const lag = if (gliding) glide.follow.offset else g.scroll_lag;
if (lag == 0) return 0;
- for (surface.panelTracks()) |track|
- if (track.active() and track.pane == pane) return 0;
const r = if (gliding) glide.rect else g.scroll_rect;
const bh = if (gliding) glide.body_h else g.scroll_body_h;
const y0 = if (gliding) glide.body_y else g.scroll_body_y;
@@ -5257,7 +5013,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
const row_cursor: ?usize = if (surface.cursor) |cu| if (cu.y == row) cu.x else null else null;
var col = x0;
while (col < x0 + bw) : (col += 1) {
- emitInstance(g, instances, base + n, col, row, shifted, win_w, win_h, null, cellFontRole(&line[col]), line, col, row_cursor, false, @as(u32, row) * surface.cols + col == caret, page);
+ emitInstance(g, instances, base + n, col, row, shifted, win_w, win_h, cellFontRole(&line[col]), line, col, row_cursor, @as(u32, row) * surface.cols + col == caret, page);
n += 1;
}
}
@@ -5267,7 +5023,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
const erow: u16 = if (lag > 0) y0 + bh else y0 - 1;
var i: u16 = 0;
while (i < bw) : (i += 1) {
- emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, null, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, false, page);
+ emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, page);
n += 1;
}
}
@@ -5286,7 +5042,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
// emitInstance takes an unsigned row: move the layout instead.
at.y_off += @as(f32, @floatFromInt(at_row - @as(i32, y0))) * layout.h;
for (0..bw) |c_i| {
- emitInstance(g, instances, base + n, x0 + @as(u16, @intCast(c_i)), y0, at, win_w, win_h, null, cellFontRole(&cells[c_i]), cells, c_i, null, false, false, page);
+ emitInstance(g, instances, base + n, x0 + @as(u16, @intCast(c_i)), y0, at, win_w, win_h, cellFontRole(&cells[c_i]), cells, c_i, null, false, page);
n += 1;
}
}
@@ -5363,51 +5119,6 @@ fn surfaceHasNativeKey(surface: *const pardes.Surface, key: pardes.ImageCacheKey
return false;
}
-fn snapshotHasNativeKey(g: *const Gui, key: pardes.ImageCacheKey) bool {
- for (g.presented_images.items) |place|
- if (place.key.eql(key)) return true;
- return false;
-}
-
-fn rememberPresentedImages(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface) void {
- var next: std.ArrayListUnmanaged(SavedImagePlace) = .empty;
- var adopted = false;
- defer if (!adopted) next.deinit(gpa);
- next.ensureTotalCapacity(gpa, surface.images.items.len) catch return;
- for (surface.images.items) |place| {
- if (validImageBytes(place) == null or !g.native_images.contains(place.cacheKey())) continue;
- next.appendAssumeCapacity(SavedImagePlace.from(place));
- }
- var old = g.presented_images;
- g.presented_images = next;
- adopted = true;
- old.deinit(gpa);
-}
-
-fn sameSavedPlacement(saved: SavedImagePlace, current: pardes.ImagePlace) bool {
- return saved.key.eql(current.cacheKey()) and
- saved.pane == current.pane and saved.serial == current.serial and
- saved.x == current.x and saved.y == current.y and
- saved.w == current.w and saved.h == current.h and
- saved.iw == current.iw and saved.ih == current.ih and
- std.meta.eql(saved.native, current.native);
-}
-
-fn snapshotContainsPlacement(g: *const Gui, current: pardes.ImagePlace) bool {
- for (g.presented_images.items) |saved|
- if (sameSavedPlacement(saved, current)) return true;
- return false;
-}
-
-fn placeIntersectsBox(place: SavedImagePlace, box: pardes.animation.Box) bool {
- const x0: f32 = @floatFromInt(place.x);
- const y0: f32 = @floatFromInt(place.y);
- const x1: f32 = @floatFromInt(@as(u32, place.x) + place.w);
- const y1: f32 = @floatFromInt(@as(u32, place.y) + place.h);
- return x0 < box.x + box.w and x1 > box.x and
- y0 < box.y + box.h and y1 > box.y;
-}
-
fn validImageBytes(place: pardes.ImagePlace) ?u32 {
if (place.iw == 0 or place.ih == 0 or
place.iw > std.math.maxInt(u32) or place.ih > std.math.maxInt(u32)) return null;
@@ -5419,13 +5130,13 @@ fn validImageBytes(place: pardes.ImagePlace) ?u32 {
const NativeBounds = struct { w: u32, h: u32 };
-fn nativeBounds(g: *const Gui, place: SavedImagePlace) ?NativeBounds {
+fn nativeBounds(g: *const Gui, place: pardes.ImagePlace) ?NativeBounds {
const bound_w = std.math.mul(u32, place.w, g.cell_w) catch return null;
const bound_h = std.math.mul(u32, place.h, g.cell_h) catch return null;
return .{ .w = bound_w, .h = bound_h };
}
-fn nativePlaceGeometry(g: *const Gui, place: SavedImagePlace) ?pardes.image.NativeGeometry {
+fn nativePlaceGeometry(g: *const Gui, place: pardes.ImagePlace) ?pardes.image.NativeGeometry {
if (comptime pardes.pdf_enabled) {
if (place.native.geometry) |geometry| return geometry;
const bounds = nativeBounds(g, place) orelse return null;
@@ -5442,7 +5153,7 @@ fn nativePlaceGeometry(g: *const Gui, place: SavedImagePlace) ?pardes.image.Nati
return null;
}
-fn nativePlaceDrawable(g: *const Gui, place: SavedImagePlace) bool {
+fn nativePlaceDrawable(g: *const Gui, place: pardes.ImagePlace) bool {
if (comptime pardes.pdf_enabled) return nativePlaceGeometry(g, place) != null;
const bounds = nativeBounds(g, place) orelse return false;
return pardes.image.containGeometry(place.iw, place.ih, bounds.w, bounds.h) != null;
@@ -5468,10 +5179,6 @@ fn uploadNativeTexture(
try uploadTextureRows(g, cmd, texture, place.rgba[patch.y * row ..][0 .. patch.h * row], place.iw, patch.y, patch.h);
try g.native_images.put(gpa, key, texture);
_ = g.native_images.remove(base);
- // A transition snapshot of the last frame follows its texture.
- for (g.presented_images.items) |*saved| if (saved.key.eql(base)) {
- saved.key = key;
- };
return;
};
@@ -5524,30 +5231,16 @@ fn uploadTextureRows(
c.SDL_EndGPUCopyPass(copy);
}
-fn appendPreparedImage(
- g: *Gui,
- gpa: std.mem.Allocator,
- place: SavedImagePlace,
- track: ?pardes.animation.Track,
- clip: ?pardes.animation.Box,
- old_layer: bool,
-) void {
- const texture = g.native_images.get(place.key) orelse return;
+fn appendPreparedImage(g: *Gui, gpa: std.mem.Allocator, place: pardes.ImagePlace) void {
+ const texture = g.native_images.get(place.cacheKey()) orelse return;
if (!nativePlaceDrawable(g, place)) return;
- g.prepared_images.append(gpa, .{
- .place = place,
- .texture = texture,
- .track = track,
- .clip = clip,
- .old_layer = old_layer,
- }) catch {};
+ g.prepared_images.append(gpa, .{ .place = place, .texture = texture }) catch {};
}
fn emitPreparedImage(
g: *Gui,
instance: *ImageInstance,
prepared: PreparedImage,
- layout: CellLayout,
win_w: f32,
win_h: f32,
) bool {
@@ -5586,15 +5279,6 @@ fn emitPreparedImage(
.v1 = 1,
};
}
- setTransitionFields(
- instance,
- prepared.track,
- layout,
- win_w,
- win_h,
- if (prepared.track) |active| panelGridSize(active) else 0,
- );
- if (prepared.old_layer) instance.effect |= old_layer_bit;
return true;
}
@@ -5617,8 +5301,7 @@ fn prepareNativeImages(
var stale_len: usize = 0;
var iterator = g.native_images.iterator();
while (iterator.next()) |entry| {
- if (surfaceHasNativeKey(surface, entry.key_ptr.*) or
- snapshotHasNativeKey(g, entry.key_ptr.*)) continue;
+ if (surfaceHasNativeKey(surface, entry.key_ptr.*)) continue;
stale[stale_len] = entry.key_ptr.*;
stale_len += 1;
if (stale_len == stale.len) break;
@@ -5628,47 +5311,11 @@ fn prepareNativeImages(
}
g.prepared_images.clearRetainingCapacity();
- for (groups.items[0..groups.len], 0..) |*group, group_index| {
- group.image_start = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
- const track = group.track;
-
- if (track) |active| {
- if (active.phase == .closing) {
- for (g.presented_images.items) |saved| {
- if (saved.serial != active.serial) continue;
- appendPreparedImage(g, gpa, saved, active, null, false);
- }
- } else if (active.effect == .dissolve) {
- for (g.presented_images.items) |saved| {
- if (!placeIntersectsBox(saved, active.contentBox())) continue;
- appendPreparedImage(g, gpa, saved, active, active.contentBox(), true);
- }
- }
- }
-
- if (track == null or track.?.phase != .closing) {
- for (surface.images.items) |current| {
- if (validImageBytes(current) == null or
- groupOf(groups, current.serial) != group_index) continue;
- const saved = SavedImagePlace.from(current);
- const current_track = if (track) |active| switch (active.effect) {
- .dissolve => if (snapshotContainsPlacement(g, current)) null else active,
- else => active,
- } else null;
- appendPreparedImage(g, gpa, saved, current_track, null, false);
- }
- }
- if (group_index == 0) for (groups.items[1..][0..groups.tracks]) |tracked| {
- const active = tracked.track.?;
- if (active.effect != .vertical or active.phase != .opening) continue;
- for (g.presented_images.items) |saved| {
- if (!placeIntersectsBox(saved, active.contentBox())) continue;
- appendPreparedImage(g, gpa, saved, null, active.contentBox(), false);
- }
- };
- const image_end = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
- group.image_count = image_end - group.image_start;
- }
+ // The pictures are the page's: the other groups float over them.
+ for (surface.images.items) |place|
+ if (validImageBytes(place) != null) appendPreparedImage(g, gpa, place);
+ groups.items[0].image_start = 0;
+ groups.items[0].image_count = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
const capacity = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
if (capacity == 0) return true;
@@ -5678,10 +5325,9 @@ fn prepareNativeImages(
const instances: [*]ImageInstance = @ptrCast(@alignCast(ptr));
const win_w: f32 = @floatFromInt(sw);
const win_h: f32 = @floatFromInt(sh);
- const layout = fixedCellLayout(g);
var idx: u32 = 0;
for (g.prepared_images.items) |prepared| {
- if (!emitPreparedImage(g, &instances[idx], prepared, layout, win_w, win_h)) continue;
+ if (!emitPreparedImage(g, &instances[idx], prepared, win_w, win_h)) continue;
idx += 1;
}
c.SDL_UnmapGPUTransferBuffer(g.device, g.image_vxfer.?);
@@ -5695,18 +5341,7 @@ fn prepareNativeImages(
return true;
}
-fn imageScissor(
- g: *const Gui,
- prepared: PreparedImage,
- max_w: u32,
- max_h: u32,
-) c.SDL_Rect {
- if (prepared.clip) |box| return panelBoxScissor(g, box, max_w, max_h);
- if (prepared.track) |active| {
- const box = if (active.effect == .vertical) active.contentBox() else active.visualBox();
- return panelBoxScissor(g, box, max_w, max_h);
- }
- const place = prepared.place;
+fn imageScissor(g: *const Gui, place: pardes.ImagePlace) c.SDL_Rect {
return .{
.x = @intCast(@as(u32, place.x) * g.cell_w),
.y = @intCast(@as(u32, place.y) * g.cell_h),
@@ -5715,38 +5350,18 @@ fn imageScissor(
};
}
-fn panelBoxScissor(g: *const Gui, box: pardes.animation.Box, max_w: u32, max_h: u32) c.SDL_Rect {
- const x0: i32 = @intFromFloat(@floor(box.x * @as(f32, @floatFromInt(g.cell_w))));
- const y0: i32 = @intFromFloat(@floor(box.y * @as(f32, @floatFromInt(g.cell_h))));
- const x1: i32 = @intFromFloat(@ceil((box.x + box.w) * @as(f32, @floatFromInt(g.cell_w))));
- const y1: i32 = @intFromFloat(@ceil((box.y + box.h) * @as(f32, @floatFromInt(g.cell_h))));
- const clipped_x0 = std.math.clamp(x0, 0, @as(i32, @intCast(max_w)));
- const clipped_y0 = std.math.clamp(y0, 0, @as(i32, @intCast(max_h)));
- const clipped_x1 = std.math.clamp(x1, clipped_x0, @as(i32, @intCast(max_w)));
- const clipped_y1 = std.math.clamp(y1, clipped_y0, @as(i32, @intCast(max_h)));
- return .{
- .x = clipped_x0,
- .y = clipped_y0,
- .w = clipped_x1 - clipped_x0,
- .h = clipped_y1 - clipped_y0,
- };
-}
-
fn drawNativeImagesGpu(
g: *Gui,
rp: ?*c.SDL_GPURenderPass,
- surface: *const pardes.Surface,
batch: Group,
whole: c.SDL_Rect,
) void {
const pass = rp orelse return;
c.SDL_BindGPUGraphicsPipeline(pass, g.image_pipeline);
- const max_w = @as(u32, surface.cols) * g.cell_w;
- const max_h = @as(u32, surface.rows) * g.cell_h;
var idx = batch.image_start;
const end = batch.image_start + batch.image_count;
for (g.prepared_images.items[batch.image_start..end]) |prepared| {
- const clip = imageScissor(g, prepared, max_w, max_h);
+ const clip = imageScissor(g, prepared.place);
if (clip.w > 0 and clip.h > 0) {
c.SDL_SetGPUScissor(pass, &clip);
const sampler = c.SDL_GPUTextureSamplerBinding{ .texture = prepared.texture, .sampler = g.linear_sampler };
@@ -5833,11 +5448,10 @@ fn renderFrame(
cell_decor.nplaques += 1;
}
}
- var groups = makeGroups(surface.panelTracks(), surface.hasPanelDiff());
- // While panes move the cells' cursors are not drawn; the focused one is
- // the overlay's quad, riding with its pane (draw.glideCursor), as it is
- // while it glides or blinks. One or the other every frame (none only at
- // a blink's off half).
+ var groups: Groups = .{};
+ // While the cursor glides or blinks the cells' cursors are not drawn;
+ // the focused one is the overlay's quad. One or the other every frame
+ // (none only at a blink's off half).
const blink_alpha: f32 = if (blinkNow(g, chrome)) |b| b.alpha else 1;
// While a glide moves the text, the caret is its quad, drawn from its
// own springs, not a cell of the moving rows.
@@ -5848,7 +5462,7 @@ fn renderFrame(
const pdf_focus = if (core.panes[core.active]) |pane| pane.hasPdf() else false;
if (!pdf_focus) core.frames.scroll = g.glide.follow.offset;
core.frames.caret = caretRow(g, surface) orelse 0;
- const cursors_shown = groups.tracks == 0 and !quad_mode;
+ const cursors_shown = !quad_mode;
var overlay_count = buildOverlay(g, surface, sw, sh);
if (overlay_count != 0 and !uploadOverlayGpu(g, cmd, overlay_count))
overlay_count = 0;
@@ -5861,13 +5475,9 @@ fn renderFrame(
}
const cells: u32 = @as(u32, surface.cols) * surface.rows;
- try g.cover.resize(gpa, @as(usize, cells) * 2);
+ try g.cover.resize(gpa, cells);
const covered = g.cover.items[0..cells];
coverFrame(covered, surface.cols, surface.rows, surface.bodyLayers(), surface.tagLayers(), surface.regionList());
- // Only a panel transition paints the grid under the layers it leaves.
- const previous_covered = g.cover.items[cells..];
- if (groups.tracks != 0)
- coverFrame(previous_covered, surface.cols, surface.rows, surface.previous_body_layers, surface.previous_tag_layers, surface.previous_regions);
try buildDecor(g, gpa, surface, &groups, layout, win_w, win_h, cursors_shown);
const page = chrome.page orelse bg_default;
@@ -5890,71 +5500,25 @@ fn renderFrame(
while (col < surface.cols) : (col += 1) {
const at = @as(usize, row) * surface.cols + col;
if (covered[at].layer and !covered[at].floating) continue;
- const group_index = if (covered[at].floating) groups.guides else groupAt(&groups, col, row);
- const track = groups.items[group_index].track;
- const data_effect = if (track) |active| active.effect == .dissolve else false;
- const data_diff = data_effect and gripCellChanged(surface, covered, previous_covered, col, row);
- const instance_count = if (data_diff)
- cellInstanceCount(&surface.previous_cells[at]) + cellInstanceCount(&surface.cells[at])
- else
- cellInstanceCount(&surface.cells[at]);
- groups.items[group_index].cell_count = std.math.add(u32, groups.items[group_index].cell_count, instance_count) catch return error.GpuCapacity;
- }
- }
- for (groups.items[1..][0..groups.tracks]) |*group| {
- const track = group.track.?;
- const duplicate_under = track.effect == .vertical and track.phase == .opening;
- if (!duplicate_under and track.phase != .closing) continue;
- row = 0;
- while (row < surface.rows) : (row += 1) {
- var col: u16 = 0;
- while (col < surface.cols) : (col += 1) {
- if (!boxContains(track.contentBox(), col, row)) continue;
- const at = @as(usize, row) * surface.cols + col;
- if (previous_covered[at].layer) continue;
- const destination = if (duplicate_under) &groups.items[0] else group;
- destination.cell_count = std.math.add(u32, destination.cell_count, cellInstanceCount(&surface.previous_cells[at])) catch return error.GpuCapacity;
- }
+ const group_index = if (covered[at].floating) groups.guides else 0;
+ groups.items[group_index].cell_count = std.math.add(u32, groups.items[group_index].cell_count, cellInstanceCount(&surface.cells[at])) catch return error.GpuCapacity;
}
}
for (surface.bodyLayers()) |*layer| {
if (layer.rows == 0) continue;
- const group = &groups.items[groupAt(&groups, layer.viewport.x, layer.viewport.y)];
+ const group = &groups.items[0];
const bottom = @as(f32, @floatFromInt(layer.viewport.y + layer.viewport.h)) * layout.h;
for (0..layer.rows) |lr| {
if (layer.rowTop(@intCast(lr), layout.h, @floatFromInt(g.tagline_height)) >= bottom) break;
group.cell_count += layer.cols + @as(u32, if (lr < layer.context_rows) 1 else 0) + @as(u32, @intFromBool(layer.hasContextBorderAfter(lr)));
}
}
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_body_layers) |*layer| {
- if (layer.rows == 0 or layer.serial != track.serial) continue;
- const destination = &groups.items[if (under) 0 else index];
- const bottom = @as(f32, @floatFromInt(layer.viewport.y + layer.viewport.h)) * layout.h;
- for (0..layer.rows) |lr| {
- if (layer.rowTop(@intCast(lr), layout.h, @floatFromInt(g.tagline_height)) >= bottom) break;
- destination.cell_count += layer.cols + @as(u32, if (lr < layer.context_rows) 1 else 0) + @as(u32, @intFromBool(layer.hasContextBorderAfter(lr)));
- }
- }
- }
for (surface.tagLayers()) |*layer| {
if (layer.rows == 0) continue;
- const group_index = if (layer.kind == .notice) noticeGroup(&groups, layer) else groupAt(&groups, layer.viewport.x, layer.viewport.y);
+ const group_index = if (layer.kind == .notice) groups.notices else 0;
groups.items[group_index].cell_count += (tagLayerCellCount(g, layer) + 1) * layer.rows;
}
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_tag_layers) |*layer| {
- if (layer.rows == 0 or layer.kind != .pane or layer.serial != track.serial) continue;
- groups.items[if (under) 0 else index].cell_count += (tagLayerCellCount(g, layer) + 1) * layer.rows;
- }
- }
- var cell_next: [pardes.MAX_PANES * 2 + 4]u32 = @splat(0);
+ var cell_next: [4]u32 = @splat(0);
var cell_total: u32 = 0;
for (groups.items[0..groups.len], 0..) |*group, index| {
group.cell_start = cell_total;
@@ -5984,12 +5548,7 @@ fn renderFrame(
while (col < surface.cols) : (col += 1) {
const at = @as(usize, row) * surface.cols + col;
if (covered[at].layer and !covered[at].floating) continue;
- const group_index = if (covered[at].floating) groups.guides else groupAt(&groups, col, row);
- const track = groups.items[group_index].track;
- const data_effect = if (track) |active| active.effect == .dissolve else false;
- const data_diff = data_effect and gripCellChanged(surface, covered, previous_covered, col, row);
- // The new cell, then (a dissolve) the old one fading out over
- // it, as the old layers come after the new ones.
+ const group_index = if (covered[at].floating) groups.guides else 0;
emitSurfaceCell(
g,
chrome,
@@ -6000,106 +5559,33 @@ fn renderFrame(
layout,
win_w,
win_h,
- if (data_effect and !data_diff) null else track,
line,
line_cover,
col,
line_cursor,
- false,
cursors_shown and at == cursor_idx and !cursor_bar and bodyLayerIn(surface.bodyLayers(), col, row) == null,
page,
);
- if (data_diff) emitSurfaceCell(
- g,
- chrome,
- instances,
- &cell_next[group_index],
- col,
- row,
- layout,
- win_w,
- win_h,
- track,
- surface.previous_cells[@as(usize, row) * surface.cols ..][0..surface.cols],
- previous_covered[@as(usize, row) * surface.cols ..][0..surface.cols],
- col,
- null,
- true,
- false,
- page,
- );
}
}
// Body layers first: a notice chip over a tree-sitter context band
// is a tag layer, and instances paint in emission order.
for (surface.bodyLayers()) |*layer| {
if (layer.rows == 0) continue;
- const group_index = groupAt(&groups, layer.viewport.x, layer.viewport.y);
- emitBodyLayer(g, instances, &cell_next[group_index], layer, win_w, win_h, groups.items[group_index].track, page, cursors_shown, false, chrome.topbar_rule);
+ emitBodyLayer(g, instances, &cell_next[0], layer, win_w, win_h, page, cursors_shown, chrome.topbar_rule);
}
for (surface.tagLayers()) |*layer| {
if (layer.rows == 0) continue;
- const track_index = groupAt(&groups, layer.viewport.x, layer.viewport.y);
- // A notice floats over the panes, moving with its own.
- const group_index = if (layer.kind == .notice) noticeGroup(&groups, layer) else track_index;
+ // 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, groups.items[track_index].track, page, cursors_shown, false);
+ 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[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_tag_layers) |*layer| {
- if (layer.rows == 0 or layer.kind != .pane or layer.serial != track.serial) continue;
- emitTagLayer(g, instances, &cell_next[if (under) 0 else index], layer, win_w, win_h, if (under) null else track, page, false, track.effect == .dissolve);
- }
- }
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_body_layers) |*layer| {
- if (layer.rows == 0 or layer.serial != track.serial) continue;
- emitBodyLayer(g, instances, &cell_next[if (under) 0 else index], layer, win_w, win_h, if (under) null else track, page, false, track.effect == .dissolve, chrome.topbar_rule);
- }
- }
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const duplicate_under = track.effect == .vertical and track.phase == .opening;
- if (!duplicate_under and track.phase != .closing) continue;
- row = 0;
- while (row < surface.rows) : (row += 1) {
- var col: u16 = 0;
- while (col < surface.cols) : (col += 1) {
- if (!boxContains(track.contentBox(), col, row)) continue;
- if (previous_covered[@as(usize, row) * surface.cols + col].layer) continue;
- emitSurfaceCell(
- g,
- chrome,
- instances,
- &cell_next[if (duplicate_under) 0 else index],
- col,
- row,
- layout,
- win_w,
- win_h,
- if (duplicate_under) null else track,
- surface.previous_cells[@as(usize, row) * surface.cols ..][0..surface.cols],
- previous_covered[@as(usize, row) * surface.cols ..][0..surface.cols],
- col,
- null,
- false,
- false,
- page,
- );
- }
- }
- }
for (groups.items[0..groups.len], 0..) |group, index|
std.debug.assert(cell_next[index] == group.cell_start + group.cell_count);
// The body's context rows, which its scroll leaves where they are.
@@ -6155,9 +5641,8 @@ fn renderFrame(
const has_shifted = index == 0 and shifted != 0;
if ((group.cell_count != 0 or has_shifted) and g.vbuf != null) {
// Blended over what is under: a theme's plaques show through
- // blank tag cells; a dissolve's old cells fade over its new.
- const dissolving = if (group.track) |active| active.effect == .dissolve else false;
- c.SDL_BindGPUGraphicsPipeline(rp, if (cell_decor.inked_clear or dissolving) g.pipeline_over else g.pipeline);
+ // blank tag cells.
+ c.SDL_BindGPUGraphicsPipeline(rp, if (cell_decor.inked_clear) g.pipeline_over else g.pipeline);
const samp_binding = c.SDL_GPUTextureSamplerBinding{ .texture = g.atlas_tex, .sampler = g.atlas_sampler };
c.SDL_BindGPUFragmentSamplers(rp, 0, &samp_binding, 1);
if (group.cell_count != 0) {
@@ -6174,7 +5659,7 @@ fn renderFrame(
c.SDL_SetGPUScissor(rp, &whole);
}
}
- if (group.image_count != 0) drawNativeImagesGpu(g, rp, surface, group, whole);
+ if (group.image_count != 0) drawNativeImagesGpu(g, rp, group, whole);
if (group.decor_count > group.under_count and g.vbuf != null) {
c.SDL_BindGPUGraphicsPipeline(rp, g.decor_pipeline);
// Ink keeps its colour at any WindowOpacity.
@@ -6188,9 +5673,7 @@ fn renderFrame(
c.SDL_EndGPURenderPass(rp);
command_consumed = true;
- const shown = try finishFrame(g, gpa, cmd, frame_target, if (groups.tracks != 0) groups.items[1].track.?.frame else null);
- if (shown and groups.tracks == 0) rememberPresentedImages(g, gpa, surface);
- return shown;
+ return finishFrame(g, gpa, cmd, frame_target);
}
const Target = struct { texture: *c.SDL_GPUTexture, w: u32, h: u32 };
@@ -6220,9 +5703,9 @@ fn acquireTarget(g: *Gui, cmd: *c.SDL_GPUCommandBuffer, capture_w: u32, capture_
}
/// Submits the frame: captured, handed to the soft presenter, or presented.
-fn finishFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: Target, transition: ?u16) !bool {
+fn finishFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: Target) !bool {
if (g.capture) {
- try captureFrame(g, gpa, cmd, target.texture, target.w, target.h, transition);
+ try captureFrame(g, gpa, cmd, target.texture, target.w, target.h);
return true;
}
if (g.soft_present) {
@@ -6397,7 +5880,7 @@ fn tagLayerCellCount(g: *const Gui, layer: *const pardes.Layer) u32 {
return @min(layer.cols, (pixels + g.tagline_width - 1) / g.tagline_width);
}
-fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, track: ?pardes.animation.Track, page: [3]u8, show_cursor: bool, old_layer: bool) void {
+fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, page: [3]u8, show_cursor: bool) void {
const bw: f32 = @floatFromInt(g.cell_w);
const bh: f32 = @floatFromInt(g.cell_h);
const tw: f32 = @floatFromInt(g.tagline_width);
@@ -6414,7 +5897,7 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
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, track, .body, (&background)[0..1], 0, null, old_layer, false, page);
+ 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);
// A theme's plaque is drawn under the band: the band's own ground
// lets it show (tagPlaques).
if (cell_decor.nplaques != 0 and cell_decor.inPlaque(left + 0.5, top + 0.5)) plaqueThrough(instances, next.*);
@@ -6424,7 +5907,7 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
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, track, .tagline, cells, col, line_cursor, old_layer, cursor, page);
+ 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);
next.* += 1;
}
@@ -6439,7 +5922,7 @@ fn bodyLayerIn(layers: []const pardes.Layer, col: u16, row: u16) ?*const pardes.
return null;
}
-fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, track: ?pardes.animation.Track, page: [3]u8, show_cursor: bool, old_layer: bool, border_rgb: [3]u8) void {
+fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, page: [3]u8, show_cursor: bool, border_rgb: [3]u8) void {
const bw: f32 = @floatFromInt(g.cell_w);
const bh: f32 = @floatFromInt(g.cell_h);
const tw: f32 = @floatFromInt(g.tagline_width);
@@ -6458,7 +5941,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const
if (header) {
var background: pardes.Cell = .{ .default = false, .style = layer.cells[index * layer.cols].style };
background.style.font_role = .body;
- emitInstance(g, instances, next.*, 0, 0, .{ .w = @as(f32, @floatFromInt(layer.viewport.w)) * bw, .h = height, .x_off = left, .y_off = top }, win_w, win_h, track, .body, (&background)[0..1], 0, null, old_layer, false, page);
+ emitInstance(g, instances, next.*, 0, 0, .{ .w = @as(f32, @floatFromInt(layer.viewport.w)) * bw, .h = height, .x_off = left, .y_off = top }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page);
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, bottom }, win_w, win_h);
next.* += 1;
}
@@ -6468,7 +5951,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const
if (left + @as(f32, @floatFromInt(col)) * width >= right) break;
const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == row else false;
const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height))) else 0);
- emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, track, role, line, col, line_cursor, old_layer, cursor, page);
+ emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, role, line, col, line_cursor, cursor, page);
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, bottom }, win_w, win_h);
next.* += 1;
}
@@ -6479,23 +5962,13 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const
.h = 1,
.x_off = left,
.y_off = top + height - 1,
- }, win_w, win_h, track, .body, (&border)[0..1], 0, null, old_layer, false, page);
+ }, win_w, win_h, .body, (&border)[0..1], 0, null, false, page);
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, bottom }, win_w, win_h);
next.* += 1;
}
}
}
-/// A dissolving cell changes with its grip's glyph, which is the cell its
-/// grip offset to the left, in this frame's grip or the last one's.
-fn gripCellChanged(surface: *const pardes.Surface, covered: []const Cover, previous_covered: []const Cover, col: u16, row: u16) bool {
- if (surface.panelCellChanged(col, row)) return true;
- const at = @as(usize, row) * surface.cols + col;
- for ([_]Cover{ covered[at], previous_covered[at] }) |cover|
- if (cover.grip and surface.panelCellChanged(col -| cover.grip_offset, row)) return true;
- return false;
-}
-
/// acme's Scrollwid column at a pane's or column's left edge, in window
/// pixels: where its button sits over its scrollbar, one width for both
/// (`rail_px` at acme's 17px font, scaled with the tagline, and always
@@ -6576,12 +6049,10 @@ fn emitSurfaceCell(
body_layout: CellLayout,
win_w: f32,
win_h: f32,
- track: ?pardes.animation.Track,
line: []const pardes.Cell,
line_cover: []const Cover,
at: usize,
cursor: ?usize,
- old_layer: bool,
is_cursor: bool,
page: [3]u8,
) void {
@@ -6595,7 +6066,7 @@ fn emitSurfaceCell(
// The smaller font changes the ink, not the chrome's coverage. Painting
// this underlay at tagline height leaves page-colored gutters between
// adjacent workspace, column and pane tags at TaglineSize < 100.
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .body, (&band_base)[0..1], 0, null, old_layer, false, page);
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .body, (&band_base)[0..1], 0, null, false, page);
// Over a theme's plaque the underlay lets it show (tagPlaques),
// in a grip's cell too where the plaque reaches into it past the
// button (which is drawn over the cells).
@@ -6611,9 +6082,9 @@ fn emitSurfaceCell(
blank.text[0] = ' ';
blank.len = 1;
if (here.pane_grip)
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, (&blank)[0..1], 0, null, old_layer, false, page)
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .tagline, (&blank)[0..1], 0, null, false, page)
else
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, line, at, cursor, old_layer, is_cursor, page);
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .tagline, line, at, cursor, is_cursor, page);
// A grip's glyph is the cell at its left edge, and a blank one is
// no glyph: its marks are decor.
const glyph = &line[at - @min(here.grip_offset, at)];
@@ -6687,7 +6158,7 @@ fn emitSurfaceCell(
next.* += 1;
return;
}
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, role, line, at, cursor, old_layer, is_cursor, page);
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, role, line, at, cursor, is_cursor, page);
next.* += 1;
}
@@ -6712,7 +6183,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits
const cover = try gpa.alloc(Cover, @as(usize, s.cols) * s.rows);
defer gpa.free(cover);
coverFrame(cover, s.cols, s.rows, s.bodyLayers(), s.tagLayers(), s.regionList());
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, layout, win_w, win_h, true);
const grip = s.region(.grip, 0).?;
// The grip column's pixels, band first, then its cells, then decor.
@@ -6742,7 +6213,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits
const row: u16 = grip.rect.y + @as(u16, @intCast(line));
const at = @as(usize, row) * s.cols;
var next: u32 = 0;
- emitSurfaceCell(&g, &s.chrome, &instances, &next, col, row, layout, win_w, win_h, null, s.cells[at..][0..s.cols], cover[at..][0..s.cols], col, null, false, false, bg_default);
+ emitSurfaceCell(&g, &s.chrome, &instances, &next, col, row, layout, win_w, win_h, s.cells[at..][0..s.cols], cover[at..][0..s.cols], col, null, false, bg_default);
for (instances[0..next]) |i| paint.quad(pixels, i.x0, i.y0, i.x1, i.y1, .{ i.br, i.bg, i.bb }, win_w, win_h, x_px, y_px, w_px, h_px);
};
for (g.decor.items) |i| if (i.fr >= 1 and i.clip_x1 < i.clip_x0) paint.quad(pixels, i.x0, i.y0, i.x1, i.y1, .{ i.br, i.bg, i.bb }, win_w, win_h, x_px, y_px, w_px, h_px);
@@ -6780,27 +6251,6 @@ test "every pixel of a grip column is band, button or ring, and the button sits
pane.file.?.revision = pane.file.?.saved_revision;
}
-test "a rising pane past its mark stays inside its box" {
- // Bouncy, a vertical rise at its highest overshoot: drawn past its box,
- // clipped to it.
- var g = testGui(10, 20, 6, 12);
- var track: pardes.animation.Track = .{ .serial = 3, .phase = .opening, .effect = .vertical, .motion = @backingInt(pardes.animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = 0, .y = 10, .w = 40, .h = 10 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 10 } };
- var peak: u16 = 0;
- var highest: f32 = 1e9;
- while (track.frame < track.frames()) : (track.frame += 1) {
- if (track.presented().y < highest) {
- highest = track.presented().y;
- peak = track.frame;
- }
- }
- track.frame = peak;
- try std.testing.expect(track.presented().y < 0);
- var instance: CellInstance = std.mem.zeroes(CellInstance);
- setTransitionFields(&instance, track, fixedCellLayout(&g), 800, 480, 0);
- try std.testing.expectEqual(@as(f32, 0), instance.clip_y0);
- try std.testing.expectEqual(@as(f32, 200), instance.clip_y1);
-}
-
test "small tagline fonts leave no background gutters between adjacent tags" {
const chrome: pardes.Chrome = .{};
var g = testGui(10, 20, 8, 16);
@@ -6809,7 +6259,7 @@ test "small tagline fonts leave no background gutters between adjacent tags" {
var next: u32 = 0;
for (0..3) |row| {
// Column 1: past the anchor's inset edge at the column's left.
- emitSurfaceCell(&g, &chrome, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], &.{.{}}, 0, null, false, false, bg_default);
+ emitSurfaceCell(&g, &chrome, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{}}, 0, null, false, bg_default);
const base = instances[row * 2];
const ink = instances[row * 2 + 1];
try std.testing.expectApproxEqAbs(@as(f32, 20.0 / 480.0 * 2), base.y0 - base.y1, 0.0001);
@@ -6822,14 +6272,10 @@ test "small tagline fonts leave no background gutters between adjacent tags" {
// Column 0 is an anchor's edge: its ink is inset by the band's margin
// (2 px here) and its underlay still covers the whole cell.
next = 0;
- emitSurfaceCell(&g, &chrome, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], &.{.{ .anchor = true }}, 0, null, false, false, bg_default);
+ emitSurfaceCell(&g, &chrome, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{ .anchor = true }}, 0, null, false, bg_default);
try std.testing.expectApproxEqAbs(@as(f32, 10.0 / 800.0 * 2), instances[0].x1 - instances[0].x0, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 8.0 / 800.0 * 2), instances[1].x1 - instances[1].x0, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 8) / atlas_w, instances[1].u1 - instances[1].u0, 0.0001);
- next = 0;
- emitSurfaceCell(&g, &chrome, &instances, &next, 0, 2, fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], &.{.{}}, 0, null, true, false, bg_default);
- try std.testing.expectEqual(@as(u32, 2), next);
- try std.testing.expectApproxEqAbs(@as(f32, 16.0 / 480.0 * 2), instances[1].y0 - instances[1].y1, 0.0001);
}
fn emitInstance(
@@ -6841,12 +6287,10 @@ fn emitInstance(
layout: CellLayout,
win_w: f32,
win_h: f32,
- track: ?pardes.animation.Track,
role: pardes.FontRole,
line: []const pardes.Cell,
at: usize,
cursor: ?usize,
- old_layer: bool,
is_cursor: bool,
page: [3]u8,
) void {
@@ -6887,15 +6331,6 @@ fn emitInstance(
.bg = @as(f32, @floatFromInt(resolved.bg[1])) / 255.0,
.bb = @as(f32, @floatFromInt(resolved.bg[2])) / 255.0,
};
- setTransitionFields(
- &instances[idx],
- track,
- fixedCellLayout(g),
- win_w,
- win_h,
- if (track) |active| panelCellCoord(active, col, row) else 0,
- );
- if (old_layer) instances[idx].effect |= old_layer_bit;
// A block cursor is foreground UI ink, even though its color is carried
// in the reversed cell background. Keep it visible at WindowOpacity 0.
if (is_cursor) instances[idx].effect |= opaque_bg_bit;
@@ -6927,7 +6362,7 @@ test "block cursor alone overrides transparent cell background" {
const cell: pardes.Cell = .{};
var instances: [2]CellInstance = undefined;
for ([_]bool{ false, true }, 0..) |cursor, i| {
- emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, null, .body, (&cell)[0..1], 0, null, false, cursor, bg_default);
+ emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, .body, (&cell)[0..1], 0, null, cursor, bg_default);
try std.testing.expectEqual(cursor, instances[i].effect & opaque_bg_bit != 0);
}
}
@@ -6953,14 +6388,14 @@ test "lapis dots only the page's own ground and shadows only a file name, never
.{ .cell = title, .role = .tagline, .cursor = true, .dotted = false, .shadowed = false },
.{ .cell = plain_tag, .role = .tagline, .cursor = false, .dotted = false, .shadowed = false },
}) |case| {
- emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, null, case.role, (&case.cell)[0..1], 0, null, false, case.cursor, page);
+ emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, case.role, (&case.cell)[0..1], 0, null, case.cursor, page);
try std.testing.expectEqual(case.dotted, instances[0].effect & dotted_bit != 0);
try std.testing.expectEqual(case.shadowed, instances[0].effect & title_bit != 0);
}
// A theme without decor marks nothing.
chrome = .{ .page = page };
cell_decor = CellDecor.of(&chrome);
- emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, null, .body, (&on_page)[0..1], 0, null, false, false, page);
+ emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, .body, (&on_page)[0..1], 0, null, false, page);
try std.testing.expectEqual(@as(u32, 0), instances[0].effect & (dotted_bit | title_bit));
}
@@ -6978,7 +6413,7 @@ test "lapis plaques stay in their tag's band, clear of every grip; only the focu
var g = testGui(16, 32, 12, 22);
defer g.decor.deinit(gpa);
display_scale = 1;
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true);
const layout = fixedCellLayout(&g);
const under = g.decor.items[groups.items[0].decor_start..][0..groups.items[0].under_count];
@@ -7632,24 +7067,14 @@ test "pane indicator cached ink centers bearings styles and sizes" {
try std.testing.expectEqual(@as(?Slot, null), cachedGlyph(&g, .{ .face = 0, .glyph = c.ui_font_glyph(font, '^'), .role = .tagline, .centered = true }));
}
-test "pane indicator halves share dissolve changes and safe exhausted atlas" {
+test "pane indicator halves are safe on an exhausted atlas" {
var cells: [12]pardes.Cell = @splat(.{ .default = false, .style = .{ .font_role = .tagline } });
cells[0].text[0] = '$';
- var previous = cells;
- previous[0].text[0] = '^';
- var diffs: [12]pardes.PanelCellDiff = @splat(.unchanged);
- diffs[0] = pardes.PanelCellDiff.between(&previous[0], &cells[0]);
- const surface: pardes.Surface = .{ .cols = 6, .rows = 2, .cells = &cells, .previous_cells = &previous, .cell_diffs = &diffs };
- // A grip two cells wide at the top left, in both frames.
+ // A grip two cells wide at the top left.
const grip = [_]pardes.Region{.{ .kind = .grip, .serial = 1, .rect = .{ .x = 0, .y = 0, .w = 2, .h = 1 } }};
var cover: [12]Cover = undefined;
- var previous_cover: [12]Cover = undefined;
coverFrame(&cover, 6, 2, &.{}, &.{}, &grip);
- coverFrame(&previous_cover, 6, 2, &.{}, &.{}, &grip);
- try std.testing.expect(gripCellChanged(&surface, &cover, &previous_cover, 0, 0));
- try std.testing.expect(gripCellChanged(&surface, &cover, &previous_cover, 1, 0));
- try std.testing.expect(!gripCellChanged(&surface, &cover, &previous_cover, 2, 0));
- try std.testing.expect(!cover[2].grip);
+ try std.testing.expect(cover[0].grip and cover[1].grip and !cover[2].grip);
// A column's grip is a button too, cut the same way (it has no glyph).
coverFrame(&cover, 6, 2, &.{}, &.{}, &.{.{ .kind = .column_grip, .rect = .{ .x = 0, .y = 0, .w = 2, .h = 1 } }});
try std.testing.expect(cover[0].grip);
@@ -7666,16 +7091,13 @@ test "pane indicator halves share dissolve changes and safe exhausted atlas" {
g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator);
defer g.glyphs.deinit();
defer g.words.deinit(std.testing.allocator);
- for ([_]bool{ false, true }) |old| {
- var instances: [4]CellInstance = undefined;
- var next: u32 = 0;
- for (0..2) |col| {
- emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, null, cells[0..6], cover[0..6], col, null, old, false, bg_default);
- try std.testing.expectEqual(@as(f32, 0), instances[col * 2 + 1].u0);
- try std.testing.expectEqual(old, instances[col * 2 + 1].effect & old_layer_bit != 0);
- }
- try std.testing.expectEqual(@as(u32, 4), next);
+ var instances: [4]CellInstance = undefined;
+ var next: u32 = 0;
+ for (0..2) |col| {
+ emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, bg_default);
+ try std.testing.expectEqual(@as(f32, 0), instances[col * 2 + 1].u0);
}
+ try std.testing.expectEqual(@as(u32, 4), next);
}
// Underline and strikethrough stay inside the existing atlas slot, so text
@@ -7854,10 +7276,8 @@ const cell_input: VertexInput = .{ .pitch = @sizeOf(CellInstance), .rate = c.SDL
.{ .location = 1, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "u0") },
.{ .location = 2, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "fr") },
.{ .location = 3, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "br") },
- .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "panel_x0") },
- .{ .location = 5, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "present_x0") },
- .{ .location = 6, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT4, .offset = @offsetOf(CellInstance, "effect") },
- .{ .location = 7, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "clip_x0") },
+ .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT2, .offset = @offsetOf(CellInstance, "effect") },
+ .{ .location = 5, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "clip_x0") },
} };
const overlay_input: VertexInput = .{ .pitch = @sizeOf(OverlayVertex), .rate = c.SDL_GPU_VERTEXINPUTRATE_VERTEX, .attrs = &.{
@@ -7868,9 +7288,6 @@ const overlay_input: VertexInput = .{ .pitch = @sizeOf(OverlayVertex), .rate = c
const image_input: VertexInput = .{ .pitch = @sizeOf(ImageInstance), .rate = c.SDL_GPU_VERTEXINPUTRATE_INSTANCE, .attrs = &.{
.{ .location = 0, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "x0") },
.{ .location = 1, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "u0") },
- .{ .location = 2, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "panel_x0") },
- .{ .location = 3, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "present_x0") },
- .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT4, .offset = @offsetOf(ImageInstance, "effect") },
} };
/// A pipeline drawing triangles into `color_format`: `vert`, and `frag`
@@ -8133,10 +7550,9 @@ fn latencyNote(comptime fmt: []const u8, args: anytype) void {
_ = libc.write(latency_fd, line.ptr, line.len);
}
-/// Writes the frame to latest.ppm in the capture directory, and a panel
-/// transition's frame `transition` to transition-<frame>.ppm too, so a test
-/// can hold one partway (test/process/window.zig).
-fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: *c.SDL_GPUTexture, sw: u32, sh: u32, transition: ?u16) !void {
+/// Writes the frame to latest.ppm in the capture directory, and in a
+/// series to frame-<n>.ppm too.
+fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: *c.SDL_GPUTexture, sw: u32, sh: u32) !void {
const size = c.SDL_CalculateGPUTextureFormatSize(g.swapchain_format, sw, sh, 1);
if (size == 0) {
_ = c.SDL_SubmitGPUCommandBuffer(cmd);
@@ -8156,8 +7572,7 @@ fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, t
const pixels: [*]const u8 = @ptrCast(mapped);
try writeCapturePpm(g, gpa, pixels[0..size], sw, sh, "latest");
var name: [24]u8 = undefined;
- // unreachable below: "transition-" or "frame-" and a u32 fit 24
- if (transition) |frame| try writeCapturePpm(g, gpa, pixels[0..size], sw, sh, std.fmt.bufPrint(&name, "transition-{d}", .{frame}) catch unreachable);
+ // unreachable below: "frame-" and a u32 fit 24
if (g.capture_series) try writeCapturePpm(g, gpa, pixels[0..size], sw, sh, std.fmt.bufPrint(&name, "frame-{d:0>5}", .{g.captured}) catch unreachable);
g.captured +%= 1;
}
@@ -8230,9 +7645,8 @@ fn writeCapturePpm(g: *Gui, gpa: std.mem.Allocator, pixels: []const u8, width: u
}
/// One flat, hard-edged rectangle of decor, in window pixels: clipped to the
-/// window and dropped when empty, as the triangle overlay drew it, and moved
-/// by `track` as its pane's cells are.
-fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32, y1_in: f32, rgb: [3]u8, alpha: f32, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void {
+/// window and dropped when empty, as the triangle overlay drew it.
+fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32, y1_in: f32, rgb: [3]u8, alpha: f32, win_w: f32, win_h: f32) !void {
const x0 = std.math.clamp(@min(x0_in, x1_in), 0.0, win_w);
const x1 = std.math.clamp(@max(x0_in, x1_in), 0.0, win_w);
const y0 = std.math.clamp(@min(y0_in, y1_in), 0.0, win_h);
@@ -8240,7 +7654,7 @@ fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32,
if (x1 <= x0 or y1 <= y0) return;
// decor.frag.glsl reads the colour from the ground and the coverage
// from the ink's red.
- var instance: CellInstance = .{
+ try g.decor.append(gpa, .{
.x0 = (x0 / win_w) * 2.0 - 1.0,
.y0 = 1.0 - (y0 / win_h) * 2.0,
.x1 = (x1 / win_w) * 2.0 - 1.0,
@@ -8255,17 +7669,15 @@ fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32,
.br = @as(f32, @floatFromInt(rgb[0])) / 255.0,
.bg = @as(f32, @floatFromInt(rgb[1])) / 255.0,
.bb = @as(f32, @floatFromInt(rgb[2])) / 255.0,
- };
- setTransitionFields(&instance, track, fixedCellLayout(g), win_w, win_h, 0);
- try g.decor.append(gpa, instance);
+ });
}
/// A checker (decor.frag.glsl): squares of `px` window pixels in `a` and
/// `b` from the quad's corner (lapis's scroll track); `stripes`, bands of
/// `px` across it instead (lapis's focused title bar), `a` first.
-fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f32, a: [3]u8, b: [3]u8, px: f32, stripes: bool, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void {
+fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f32, a: [3]u8, b: [3]u8, px: f32, stripes: bool, win_w: f32, win_h: f32) !void {
const first = g.decor.items.len;
- try addDecor(g, gpa, x0, y0, x1, y1, a, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y0, x1, y1, a, 1, win_w, win_h);
if (g.decor.items.len == first) return;
const instance = &g.decor.items[first];
instance.u0 = px;
@@ -8289,9 +7701,9 @@ fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 {
}
/// The frame's decor, group by group (docs/render-pipeline.md §3.4), all of it
-/// read from the regions and the palette: the page's rules and the still
-/// panes' rails, rules and grip marks in tier 0, a moving or closing pane's
-/// in its track's group, notice rules in tier 4, bar cursors in tier 5.
+/// read from the regions and the palette: the page's rules and the panes'
+/// rails, rules and grip marks with the page, notice rules with the
+/// notices, bar cursors with the ink.
fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, groups: *Groups, layout: CellLayout, win_w: f32, win_h: f32, cursors_shown: bool) !void {
g.decor.clearRetainingCapacity();
const chrome = &surface.chrome;
@@ -8299,20 +7711,13 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
for (groups.items[0..groups.len], 0..) |*group, index| {
group.decor_start = @intCast(g.decor.items.len);
defer group.decor_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start;
- // Under the cells: a theme's tag plaques, this group's panes' (and
- // the column and workspace tags with the still ones).
- if (index <= groups.tracks) {
- const closing = if (group.track) |active| active.phase == .closing else false;
- try tagPlaques(g, gpa, if (closing) surface.previous_regions else regions, groups, index, chrome, layout, win_w, win_h, group.track);
- }
+ // Under the cells: a theme's tag plaques.
+ if (index == 0) try tagPlaques(g, gpa, regions, chrome, layout, win_w, win_h);
group.under_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start;
- // The grips' buttons before any rule: the rules over their rows cut
- // them, and the band round them never covers a rule.
- if (index <= groups.tracks) {
- const closing = if (group.track) |active| active.phase == .closing else false;
- try gripDecor(g, gpa, if (closing) surface.previous_regions else regions, if (closing) surface.previous_cells else surface.cells, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, group.track);
- }
if (index == 0) {
+ // The grips' buttons before any rule: the rules over their rows
+ // cut them, and the band round them never covers a rule.
+ try gripDecor(g, gpa, regions, surface.cells, chrome, layout, surface.cols, surface.rows, win_w, win_h);
const top = for (regions) |region| {
if (region.kind == .workspace_tag) break region.rect.h;
} else 0;
@@ -8325,13 +7730,13 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
const height: u32 = @intFromFloat(@max(1, @min(rulePx(chrome), @as(f32, @floatFromInt((g.cell_h -| g.tagline_height) * 2)))));
if (top != 0 and top < surface.rows and tag_under and height != 0) {
const y0: f32 = @floatFromInt(top * g.cell_h - height / 2);
- try addDecor(g, gpa, 0, y0, win_w, y0 + @as(f32, @floatFromInt(height)), chrome.topbar_rule, 1, null, win_w, win_h);
+ try addDecor(g, gpa, 0, y0, win_w, y0 + @as(f32, @floatFromInt(height)), chrome.topbar_rule, 1, win_w, win_h);
}
// The column bar is ruled off from the panes under it.
for (regions) |bar| {
if (bar.kind != .column_grip) continue;
const y = @as(f32, @floatFromInt(bar.rect.y + bar.rect.h)) * layout.h;
- try addDecor(g, gpa, 0, y - rulePx(chrome), win_w, y, chrome.border, 1, null, win_w, win_h);
+ try addDecor(g, gpa, 0, y - rulePx(chrome), win_w, y, chrome.border, 1, win_w, win_h);
break;
}
// A tag on the last row runs on through the pixels under the grid.
@@ -8340,17 +7745,10 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
.grip, .tag, .column_grip, .column_tag, .workspace_tag => if (region.rect.h != 0 and region.rect.y + region.rect.h == surface.rows) break true,
else => {},
} else false;
- if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, null, win_w, win_h);
- }
- if (index <= groups.tracks) {
- const track = group.track;
- // A closing pane is gone: its chrome is the last frame's.
- const closing = if (track) |active| active.phase == .closing else false;
- const placed = if (closing) surface.previous_regions else regions;
- const ticks: []const pardes.RailTick = if (closing) &.{} else surface.rail_ticks[0..surface.nrail_ticks];
- try paneDecor(g, gpa, placed, ticks, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, track);
+ if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, win_w, win_h);
+ try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], chrome, layout, surface.cols, surface.rows, win_w, win_h);
// A single spine runs down each column, through every tag and body.
- if (index == 0) for (regions) |column| {
+ for (regions) |column| {
if (column.kind != .column) continue;
const x = @as(f32, @floatFromInt(column.rect.x)) * layout.w;
const y0 = @as(f32, @floatFromInt(column.rect.y)) * layout.h;
@@ -8358,15 +7756,15 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
const y1 = if (win_h - grid_y1 < layout.h) @max(grid_y1, win_h) else grid_y1;
// None at the window's edge: nothing to rule apart there.
if (column.rect.x == 0) continue;
- if (y1 > y0) try addDecor(g, gpa, x, y0, x + rulePx(chrome), y1, chrome.border, 1, null, win_w, win_h);
- };
+ if (y1 > y0) try addDecor(g, gpa, x, y0, x + rulePx(chrome), y1, chrome.border, 1, win_w, win_h);
+ }
}
// 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.
- for (surface.tagLayers()) |*layer| {
- if (layer.rows == 0 or layer.kind != .notice or noticeGroup(groups, layer) != index) continue;
+ 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;
@@ -8375,20 +7773,19 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
// 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;
- const track = groups.items[groupAt(groups, layer.viewport.x, layer.viewport.y)].track;
- try addDecor(g, gpa, x0, rule_y - dp(1), rule_x1, rule_y, chrome.border, layer.fade, track, win_w, win_h);
- }
+ try addDecor(g, gpa, x0, rule_y - dp(1), rule_x1, rule_y, chrome.border, layer.fade, win_w, win_h);
+ };
if (index == groups.ink and cursors_shown) try cursorDecor(g, gpa, surface, layout, win_w, win_h);
}
}
/// Each pane's rule between its tag and body, and its scroll rail: a page
/// coloured gutter with a thin track and its thumb, running down through the
-/// pixels past the last whole row. Only the panes of group `index`.
-fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, groups: *const Groups, index: usize, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void {
+/// pixels past the last whole row.
+fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
const page = chrome.page orelse bg_default;
for (regions) |rail| {
- if (rail.kind != .rail or rail.rect.h == 0 or groupOf(groups, rail.serial) != index) continue;
+ if (rail.kind != .rail or rail.rect.h == 0) continue;
const tag = for (regions) |region| {
if (region.kind == .tag and region.owner == rail.owner) break region;
} else continue;
@@ -8402,7 +7799,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const rule_x1 = if (win_w - x1 < layout.w) @max(x1, win_w) else x1;
const tag_bottom = tag.rect.y > rail.rect.y;
const rule_y = @as(f32, @floatFromInt(if (tag_bottom) tag.rect.y else tag.rect.y + tag.rect.h)) * layout.h;
- try addDecor(g, gpa, x0, if (tag_bottom) rule_y else rule_y - dp(1), rule_x1, if (tag_bottom) rule_y + dp(1) else rule_y, chrome.tag_rule orelse mixRgb(chrome.tag_bg, page), 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, if (tag_bottom) rule_y else rule_y - dp(1), rule_x1, if (tag_bottom) rule_y + dp(1) else rule_y, chrome.tag_rule orelse mixRgb(chrome.tag_bg, page), 1, win_w, win_h);
// Stacked panes are ruled apart as columns are, where one pane's
// body meets the next one's tag (acme's Border).
{
@@ -8418,10 +7815,10 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const spare = g.cell_h -| g.tagline_height;
if (stacked and !tag_bottom) {
const room = taglineBandOffset(pane_top, win_h, g.cell_h, g.tagline_height);
- try addDecor(g, gpa, x0, y, rule_x1, y + @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), chrome.border, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y, rule_x1, y + @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), chrome.border, 1, win_w, win_h);
} else if (stacked and pane_top > 0) {
const room = spare - taglineBandOffset(pane_top - 1, win_h, g.cell_h, g.tagline_height);
- try addDecor(g, gpa, x0, y - @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), rule_x1, y, chrome.border, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y - @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), rule_x1, y, chrome.border, 1, win_w, win_h);
}
}
@@ -8435,11 +7832,11 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
// grip's button; the thumb is a pixel short of its right edge, so
// the track edges it.
const column = scrollColumn(g, chrome, rail.rect.x, layout);
- try addDecor(g, gpa, x0, y0, x0 + layout.w, y1, page, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y0, x0 + layout.w, y1, page, 1, win_w, win_h);
if (chrome.decor_checker) |gold|
- try addPattern(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, gold, dp(@floatFromInt(@max(1, chrome.decor_checker_px))), false, track, win_w, win_h)
+ try addPattern(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, gold, dp(@floatFromInt(@max(1, chrome.decor_checker_px))), false, win_w, win_h)
else
- try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, win_w, win_h);
if (rail.thumb_h != 0 and rail.thumb_span > 0) {
// In pixels, not rows, and with the picture while it glides
// or lags behind the core's rows (both in rows of the body).
@@ -8451,11 +7848,11 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const at = rail.thumb_at + lag * rail.thumb_span / @as(f32, @floatFromInt(rail.rect.h));
const thumb_y0 = y0 + std.math.clamp(at * track_px, 0, track_px - size);
const thumb_y1 = if (thumb_y0 + size >= body_y1 - 0.5) y1 else thumb_y0 + size;
- try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, win_w, win_h);
} else if (rail.thumb_h != 0) {
const thumb_y0 = @as(f32, @floatFromInt(rail.rect.y + rail.thumb_y)) * layout.h;
const thumb_y1 = if (rail.thumb_y + rail.thumb_h == rail.rect.h) y1 else @as(f32, @floatFromInt(rail.rect.y + rail.thumb_y + rail.thumb_h)) * layout.h;
- try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, win_w, win_h);
}
// A query's places' ticks over the track and thumb, where its matches
// are in the file (Places.addTicks); the current one last, on top.
@@ -8465,7 +7862,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const at = @as(f32, @floatFromInt(tick.at)) / @as(f32, @floatFromInt(pardes.panes.Places.tick_scale));
const h = if (tick.current) dp(3) else dp(2);
const ty = y0 + std.math.clamp(at * track_px, 0, track_px - h);
- try addDecor(g, gpa, column[0], ty, column[1], ty + h, if (tick.current) chrome.match_current else chrome.match_tick, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], ty, column[1], ty + h, if (tick.current) chrome.match_current else chrome.match_tick, 1, win_w, win_h);
};
}
}
@@ -8585,7 +7982,7 @@ fn dp(logical: f32) f32 {
/// its words on plates of the tag's ground (their cells stay opaque; the
/// spaces between let the stripes through, emitInstance); a column or the
/// workspace takes a quieter box, a one-pixel frame and a two-pixel shadow.
-fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, groups: *const Groups, index: usize, chrome: *const pardes.Chrome, layout: CellLayout, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void {
+fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, chrome: *const pardes.Chrome, layout: CellLayout, win_w: f32, win_h: f32) !void {
const border_rgb = chrome.decor_box_border orelse return;
if (cell_decor.plaques_off) return;
const page = chrome.page orelse bg_default;
@@ -8596,8 +7993,6 @@ fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, g
if (pane != panes) continue;
if (!pane and tag.kind != .column_tag and tag.kind != .workspace_tag) continue;
if (tag.rect.w == 0 or tag.rect.h == 0) continue;
- if (pane and groupOf(groups, tag.serial) != index) continue;
- if (!pane and index != 0) continue;
const plaque = plaqueBox(g, chrome, regions, tag, layout, win_w, win_h) orelse continue;
const b = plaque.border;
const sh = plaque.shadow;
@@ -8607,34 +8002,34 @@ fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, g
// opaque, so that is the same picture drawn once, not four times.
const shadow: [4]f32 = .{ plaque.box[0] + sh[0], plaque.box[1] + sh[1], plaque.box[2] + sh[0], plaque.box[3] + sh[1] };
const inner: [4]f32 = .{ plaque.box[0] + b, plaque.box[1] + b, plaque.box[2] - b, plaque.box[3] - b };
- try addDecorExcept(g, gpa, plaque.band, &.{ plaque.box, shadow }, page, track, win_w, win_h);
+ try addDecorExcept(g, gpa, plaque.band, &.{ plaque.box, shadow }, page, win_w, win_h);
const shadow_rgb = chrome.decor_box_shadow orelse border_rgb;
- try addDecorExcept(g, gpa, shadow, &.{plaque.box}, if (pane) shadow_rgb else mixRgb(shadow_rgb, page), track, win_w, win_h);
- try addDecorExcept(g, gpa, plaque.box, &.{inner}, border_rgb, track, win_w, win_h);
+ try addDecorExcept(g, gpa, shadow, &.{plaque.box}, if (pane) shadow_rgb else mixRgb(shadow_rgb, page), win_w, win_h);
+ try addDecorExcept(g, gpa, plaque.box, &.{inner}, border_rgb, win_w, win_h);
if (pane and tag.active and chrome.decor_box_stripe != null)
- try addPattern(g, gpa, inner[0], inner[1], inner[2], inner[3], chrome.decor_box_stripe.?, fill, dp(@floatFromInt(@max(1, chrome.decor_box_stripe_px))), true, track, win_w, win_h)
+ try addPattern(g, gpa, inner[0], inner[1], inner[2], inner[3], chrome.decor_box_stripe.?, fill, dp(@floatFromInt(@max(1, chrome.decor_box_stripe_px))), true, win_w, win_h)
else
- try addDecor(g, gpa, inner[0], inner[1], inner[2], inner[3], fill, 1, track, win_w, win_h);
+ try addDecor(g, gpa, inner[0], inner[1], inner[2], inner[3], fill, 1, win_w, win_h);
};
}
/// Flat decor over `rect` (window pixels) less each of `holes`: up to four
/// strips round the first hole's part of it, each less the rest.
-fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const [4]f32, rgb: [3]u8, track: ?pardes.animation.Track, win_w: f32, win_h: f32) std.mem.Allocator.Error!void {
+fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const [4]f32, rgb: [3]u8, win_w: f32, win_h: f32) std.mem.Allocator.Error!void {
if (rect[0] >= rect[2] or rect[1] >= rect[3]) return;
- if (holes.len == 0) return addDecor(g, gpa, rect[0], rect[1], rect[2], rect[3], rgb, 1, track, win_w, win_h);
+ if (holes.len == 0) return addDecor(g, gpa, rect[0], rect[1], rect[2], rect[3], rgb, 1, win_w, win_h);
const hole = holes[0];
const x0 = @max(rect[0], hole[0]);
const y0 = @max(rect[1], hole[1]);
const x1 = @min(rect[2], hole[2]);
const y1 = @min(rect[3], hole[3]);
- if (x0 >= x1 or y0 >= y1) return addDecorExcept(g, gpa, rect, holes[1..], rgb, track, win_w, win_h);
+ if (x0 >= x1 or y0 >= y1) return addDecorExcept(g, gpa, rect, holes[1..], rgb, win_w, win_h);
for ([_][4]f32{
.{ rect[0], rect[1], rect[2], y0 },
.{ rect[0], y1, rect[2], rect[3] },
.{ rect[0], y0, x0, y1 },
.{ x1, y0, rect[2], y1 },
- }) |strip| try addDecorExcept(g, gpa, strip, holes[1..], rgb, track, win_w, win_h);
+ }) |strip| try addDecorExcept(g, gpa, strip, holes[1..], rgb, win_w, win_h);
}
test "decor less its holes covers each pixel of the rest once and none of the holes" {
@@ -8642,7 +8037,7 @@ test "decor less its holes covers each pixel of the rest once and none of the ho
var g = testGui(1, 1, 1, 1);
defer g.decor.deinit(gpa);
const holes = [_][4]f32{ .{ 3, 2, 9, 6 }, .{ 5, 4, 12, 8 }, .{ 30, 30, 40, 40 } };
- try addDecorExcept(&g, gpa, .{ 1, 1, 11, 10 }, &holes, .{ 1, 2, 3 }, null, 16, 12);
+ try addDecorExcept(&g, gpa, .{ 1, 1, 11, 10 }, &holes, .{ 1, 2, 3 }, 16, 12);
for (0..12) |y| for (0..16) |x| {
const px: f32 = @as(f32, @floatFromInt(x)) + 0.5;
const py: f32 = @as(f32, @floatFromInt(y)) + 0.5;
@@ -8734,11 +8129,11 @@ fn tagBandAt(regions: []const pardes.Region, tag: pardes.Region, side: enum { ab
}
/// The two short bars on each row of a grip with no mode glyph there,
-/// centered in its anchor. Only the panes of group `index`.
-fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, cells: []const pardes.Cell, groups: *const Groups, index: usize, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void {
+/// centered in its anchor.
+fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, cells: []const pardes.Cell, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
if (g.tagline_height < 6 or g.tagline_width < 3) return;
for (regions) |grip| {
- if ((grip.kind != .grip and grip.kind != .column_grip) or groupOf(groups, grip.serial) != index) continue;
+ if (grip.kind != .grip and grip.kind != .column_grip) continue;
if (grip.rect.h == 0 or grip.rect.y >= rows) continue;
const button = gripButton(g, chrome, grip.rect.x, grip.rect.y, layout);
// Round the button, its first row is the tag's band: nothing of the
@@ -8746,14 +8141,14 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
const band = if (grip.active) chrome.tag_focus_bg else chrome.tag_bg;
const left = @as(f32, @floatFromInt(grip.rect.x)) * layout.w;
const right = @as(f32, @floatFromInt(grip.rect.x + grip.rect.w)) * layout.w;
- try addDecor(g, gpa, left, button[1], button[0], button[3], band, 1, track, win_w, win_h);
+ try addDecor(g, gpa, left, button[1], button[0], button[3], band, 1, win_w, win_h);
// Right of it, a theme's plaque starts flush against it (plaqueBox).
const plaqued = chrome.decor_box_border != null and !cell_decor.plaques_off;
- if (!plaqued) try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, track, win_w, win_h);
+ if (!plaqued) try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, win_w, win_h);
// Its cells over the plaque's reach are let through (emitInstance):
// under the button's row, the band goes on as far as the plaque.
if (plaqued and grip.rect.h > 1)
- try addDecor(g, gpa, left, button[3], button[2], @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h, band, 1, track, win_w, win_h);
+ try addDecor(g, gpa, left, button[3], button[2], @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h, band, 1, win_w, win_h);
if (grip.kind != .grip) continue;
// acme's button ring, two pixels (ButtonBorder) inside the button:
// the focused one's in its own fill. An unfocused dirty one keeps a
@@ -8782,16 +8177,16 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
const ring = if (grip.active) chrome.grip_focus_ring else chrome.grip_border;
// acme's ButtonBorder: two logical pixels.
const b = dp(2);
- try addDecor(g, gpa, x0, y0, x1, y0 + b, ring, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0, y1 - b, x1, y1, ring, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0, y0 + b, x0 + b, y1 - b, ring, 1, track, win_w, win_h);
- try addDecor(g, gpa, x1 - b, y0 + b, x1, y1 - b, ring, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y0, x1, y0 + b, ring, 1, win_w, win_h);
+ try addDecor(g, gpa, x0, y1 - b, x1, y1, ring, 1, win_w, win_h);
+ try addDecor(g, gpa, x0, y0 + b, x0 + b, y1 - b, ring, 1, win_w, win_h);
+ try addDecor(g, gpa, x1 - b, y0 + b, x1, y1 - b, ring, 1, win_w, win_h);
if (grip.dirty and !grip.active) {
const gap = b + dp(1);
- try addDecor(g, gpa, x0 + b, y0 + b, x1 - b, y0 + gap, band, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0 + b, y1 - gap, x1 - b, y1 - b, band, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0 + b, y0 + gap, x0 + gap, y1 - gap, band, 1, track, win_w, win_h);
- try addDecor(g, gpa, x1 - gap, y0 + gap, x1 - b, y1 - gap, band, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0 + b, y0 + b, x1 - b, y0 + gap, band, 1, win_w, win_h);
+ try addDecor(g, gpa, x0 + b, y1 - gap, x1 - b, y1 - b, band, 1, win_w, win_h);
+ try addDecor(g, gpa, x0 + b, y0 + gap, x0 + gap, y1 - gap, band, 1, win_w, win_h);
+ try addDecor(g, gpa, x1 - gap, y0 + gap, x1 - b, y1 - gap, band, 1, win_w, win_h);
}
}
// The marks are the first row's alone, where its cell is blank (no
@@ -8809,8 +8204,8 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
// The mode's two bars: a logical pixel thick, a pixel either side of
// the middle.
const bar = dp(1);
- try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, track, win_w, win_h);
- try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, win_w, win_h);
+ try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, win_w, win_h);
}
}
@@ -8829,7 +8224,7 @@ test "a theme's own rules and scrollbar are drawn at its widths: acme's 2px blac
try std.testing.expectEqual(@as(u8, 18), s.chrome.rail_px);
var g = testGui(16, 20, 10, 12);
defer g.decor.deinit(gpa);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 480, true);
const px = struct {
fn w(item: CellInstance) f32 {
@@ -8865,7 +8260,7 @@ test "the scrollbar thumb moves by the pixel and follows a glide" {
gui.decor.clearRetainingCapacity();
p.sync();
const s = try p.render(p.scratch.allocator());
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(gui, std.testing.allocator, s, &groups, fixedCellLayout(gui), 800, 480, true);
const ink = s.chrome.scroll_thumb;
for (gui.decor.items) |item| if (@abs(item.br - @as(f32, @floatFromInt(ink[0])) / 255) < 1e-3 and
@@ -8905,7 +8300,7 @@ test "the rule between stacked panes stays in the tag band's slack, at any tagli
for ([_]u32{ 12, 20 }) |tagline_h| {
var g = testGui(10, 20, 6, tagline_h);
defer g.decor.deinit(gpa);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true);
const top = @as(f32, @floatFromInt(lower.rect.y)) * 20;
const slack: f32 = @floatFromInt(@max(1, pardes.taglineBandOffset(lower.rect.y, 480, 20, tagline_h)));
@@ -8936,7 +8331,7 @@ test "an empty column is ruled on both sides, as between two filled ones" {
var g = testGui(10, 20, 6, 12);
defer g.decor.deinit(gpa);
const layout = fixedCellLayout(&g);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, layout, 800, 480, true);
const border = [3]f32{ @as(f32, @floatFromInt(s.chrome.border[0])) / 255, @as(f32, @floatFromInt(s.chrome.border[1])) / 255, @as(f32, @floatFromInt(s.chrome.border[2])) / 255 };
// Its left edge and its right edge (the next column's left): each a
@@ -8966,7 +8361,7 @@ test "at a 2x display every logical pixel is two: rules, the tag rule, the grip'
defer display_scale = 1;
var g = testGui(16, 32, 12, 24);
defer g.decor.deinit(gpa);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true);
const w = struct {
fn of(item: CellInstance) f32 {
@@ -9015,7 +8410,7 @@ test "at a 2x display every logical pixel is two: rules, the tag rule, the grip'
}
}
-test "decor is read from the regions, each pane's in its own group" {
+test "decor is read from the regions" {
const gpa = std.testing.allocator;
const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 });
defer core.deinit();
@@ -9031,7 +8426,7 @@ test "decor is read from the regions, each pane's in its own group" {
return px / 800 * 2 - 1;
}
};
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, layout, 800, 480, true);
// A spine one pixel wide at each column's left edge, down from under the
// workspace tag; a rail two pixels wide at each pane's.
@@ -9056,21 +8451,6 @@ test "decor is read from the regions, each pane's in its own group" {
_ = rail;
}
try std.testing.expectEqual(@as(u32, 0), groups.items[groups.notices].decor_count);
- const still = groups.items[0].decor_count;
-
- // Pane 1 moving: its rule and rail leave tier 0 for its track's group,
- // which moves them with it.
- const serial = core.panes[1].?.serial;
- const moving: pardes.animation.Track = .{ .pane = 1, .serial = serial, .phase = .moving, .effect = .slide, .from = .{ .x = 0, .y = 1, .w = 40, .h = 23 }, .to = .{ .x = 40, .y = 1, .w = 40, .h = 23 } };
- groups = makeGroups(&.{moving}, true);
- try buildDecor(&g, gpa, s, &groups, layout, 800, 480, groups.tracks == 0);
- const tracked = groups.items[1];
- try std.testing.expect(tracked.decor_count >= 4);
- try std.testing.expectEqual(still, groups.items[0].decor_count + tracked.decor_count);
- for (g.decor.items[tracked.decor_start..][0..tracked.decor_count]) |item|
- try std.testing.expectEqual(@as(u32, @backingInt(pardes.animation.Transition.slide)), item.effect);
- // Cursors stand still while panes move.
- try std.testing.expectEqual(@as(u32, 0), groups.items[groups.ink].decor_count);
}
test "a body tells its first line, and lapis's dots under it move a quarter as far" {
@@ -9178,7 +8558,7 @@ fn cursorBoxes(g: *const Gui, surface: *const pardes.Surface, layout: CellLayout
fn cursorDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, layout: CellLayout, win_w: f32, win_h: f32) !void {
var boxes: [max_cursors]CursorBox = undefined;
for (boxes[0..cursorBoxes(g, surface, layout, win_h, &boxes)]) |box|
- if (box.bar) try addDecor(g, gpa, box.x0, box.y0, box.x1, box.y1, box.rgb, 1, null, win_w, win_h);
+ if (box.bar) try addDecor(g, gpa, box.x0, box.y0, box.x1, box.y1, box.rgb, 1, win_w, win_h);
}
/// The triangle overlay: the cursor's glide, over everything.
@@ -9320,7 +8700,7 @@ test "compact body layer rendering fills recovered rows and clips the final glyp
layer.setContextLines(&.{ 0, 4, 5, 6 });
var instances: [32]CellInstance = undefined;
var next: u32 = 0;
- emitBodyLayer(&g, &instances, &next, &layer, 200, 200, null, bg_default, false, false, .{ 80, 90, 100 });
+ emitBodyLayer(&g, &instances, &next, &layer, 200, 200, bg_default, false, .{ 80, 90, 100 });
// Four compact header rows (48px), then three body rows: two complete
// and a third clipped to the remaining12px of the100px viewport.
try std.testing.expectEqual(@as(u32, 20), next);
@@ -9334,11 +8714,9 @@ test "compact body layer rendering fills recovered rows and clips the final glyp
try std.testing.expectApproxEqAbs(instances[19].v0 + @as(f32, 12) / atlas_h, instances[19].v1, 0.0001);
// A drag preview reserves the last physical column without changing cells.
layer.viewport.w = 1;
- for ([_]bool{ false, true }) |old| {
- next = 0;
- emitBodyLayer(&g, &instances, &next, &layer, 200, 200, null, bg_default, false, old, .{ 80, 90, 100 });
- for (instances[0..next]) |instance| try std.testing.expect(instance.x1 <= -0.6 + 0.0001);
- }
+ next = 0;
+ emitBodyLayer(&g, &instances, &next, &layer, 200, 200, bg_default, false, .{ 80, 90, 100 });
+ for (instances[0..next]) |instance| try std.testing.expect(instance.x1 <= -0.6 + 0.0001);
}
test "compact tag layers fill available width and clip at their physical edge" {
@@ -9347,14 +8725,14 @@ test "compact tag layers fill available width and clip at their physical edge" {
const layer: pardes.Layer = .{ .kind = .pane, .id = 0, .serial = 7, .viewport = .{ .x = 2, .y = 3, .w = 3, .h = 1 }, .cols = 6, .rows = 1, .cells = &cells, .bg = .{ 20, 30, 40 } };
var instances: [8]CellInstance = undefined;
var next: u32 = 0;
- emitTagLayer(&g, &instances, &next, &layer, 100, 100, null, bg_default, false, false);
+ emitTagLayer(&g, &instances, &next, &layer, 100, 100, bg_default, false);
// Five six-pixel cells fit in the three body-column viewport.
try std.testing.expectEqual(@as(u32, 6), next);
try std.testing.expectApproxEqAbs(@as(f32, -0.6), instances[1].x0, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 0), instances[5].x1, 0.0001);
g.tagline_width = 8;
next = 0;
- emitTagLayer(&g, &instances, &next, &layer, 100, 100, null, bg_default, false, false);
+ emitTagLayer(&g, &instances, &next, &layer, 100, 100, bg_default, false);
try std.testing.expectEqual(@as(u32, 5), next);
try std.testing.expectApproxEqAbs(@as(f32, 0), instances[4].x1, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 6) / atlas_w, instances[4].u1 - instances[4].u0, 0.0001);
diff --git a/src/look.zig b/src/look.zig
index 634310f1..0574985b 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -8,7 +8,6 @@ const pdf_enabled = @import("pardes_config").mupdf;
const diff = @import("diff.zig");
const platform_has_fs = filesystem.platform_has_fs;
const layout = @import("layout.zig");
-const animation = @import("animation.zig");
const modal = @import("modal.zig");
const tagline = @import("tagline.zig");
const filesystem = @import("fs.zig");
@@ -937,8 +936,7 @@ fn noteLookHover(p: *Pardes, col: u16, row: u16, body_hit: ?Mouse.BodyHit, tag_h
pub fn refreshLookHoverFromRaw(p: *Pardes) void {
if (!p.pointer_inside or !p.raw_hover_intent) return;
- const mapped = p.pointerCell(p.pointer_raw_col, p.pointer_raw_row) orelse
- return cancelLookHover(p);
+ const mapped: struct { col: u16, row: u16 } = .{ .col = p.pointer_raw_col, .row = p.pointer_raw_row };
p.hover_col = mapped.col;
p.hover_row = mapped.row;
const body_hit: ?Mouse.BodyHit = if (p.pointer_body_hit) |mapped_hit|
@@ -2009,7 +2007,7 @@ test "Look hover waits without mutating the pane and input cancels it" {
try std.testing.expect(p.look_hover_preview == null);
// The following host repaint must not resurrect a hover after keyboard
// input cancelled its raw-pointer intent.
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
try std.testing.expect(p.look_hover_wait == null);
}
@@ -2037,67 +2035,6 @@ test "cwd changes cancel only the affected pane's Look hover" {
try std.testing.expect(p.look_hover_preview == null);
}
-test "stationary Look hover follows only acknowledged panel samples" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true });
- defer p.deinit();
- const pane = p.panes[0].?;
- const rect = p.rects[0];
- const target: animation.Box = .{
- .x = @floatFromInt(rect.x),
- .y = @floatFromInt(rect.y),
- .w = @floatFromInt(rect.w),
- .h = @floatFromInt(rect.h),
- };
- var track: animation.Track = .{
- .serial = pane.serial,
- .pane = 0,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .x = 20, .y = 5, .w = 40, .h = 10 },
- .to = target,
- };
- p.acknowledgePanelPresentation(&.{track});
- p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = 30, .row = 8 } });
- const first = p.look_hover_wait orelse return error.MissingInitialHoverWait;
-
- // Advancing the producer-side track alone cannot move the semantic cell
- // under a stationary pointer.
- track.frame = track.effect.frames() - 1;
- p.presentation.tracks[0] = track;
- refreshLookHoverFromRaw(p);
- try std.testing.expectEqual(first, p.look_hover_wait.?);
-
- // Once that exact sample is acknowledged, the same raw cell maps through
- // the new panel rectangle and the debounce starts over for the new target.
- p.acknowledgePanelPresentation(&.{track});
- const moved = p.look_hover_wait orelse return error.MissingRemappedHoverWait;
- try std.testing.expect(first.col != moved.col or first.row != moved.row);
- try std.testing.expectEqual(@as(u16, 0), moved.frames);
-
- // Re-acknowledging the same semantic target is host repaint noise, not a
- // new hover, so it preserves the accumulated delay.
- p.look_hover_wait.?.frames = 3;
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expectEqual(@as(u16, 3), p.look_hover_wait.?.frames);
-
- // A zero-sized opening sample covers its future target but exposes no
- // clickable content. Successful presentation therefore cancels the hover.
- track.phase = .opening;
- track.effect = .zoom;
- track.frame = 0;
- track.from = .{
- .x = target.x + target.w * 0.5,
- .y = target.y + target.h * 0.5,
- };
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expect(p.look_hover_wait == null);
- try std.testing.expect(p.look_hover_preview == null);
-
- track.frame = track.effect.frames() - 1;
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expect(p.look_hover_wait != null);
-}
-
test "Look copies its operand before releasing pointer selection storage" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 });
defer p.deinit();
@@ -2153,7 +2090,7 @@ test "a pointer resting where a look-hover found nothing does not wake the core
while (p.nextWake() != null and frames < 20) : (frames += 1) {
p.update(.tick);
// What a shell's present does after every frame.
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
}
try std.testing.expect(frames < 20);
try std.testing.expect(p.look_hover_wait == null and p.look_hover_preview == null);
diff --git a/src/main.zig b/src/main.zig
index 777673bf..20c29ed8 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1095,7 +1095,6 @@ test {
_ = @import("lsp/lsp.zig");
if (comptime pardes.platform == .tui) {
_ = @import("tui/tui.zig");
- _ = @import("tui/panel_compositor.zig");
}
if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig");
if (comptime pardes.font_picker) _ = @import("fonts.zig");
diff --git a/src/mouse.zig b/src/mouse.zig
index e38d5d5f..6cb602f7 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -7,14 +7,11 @@ const exec = @import("exec.zig");
const look = @import("look.zig");
const std = @import("std");
const layout = @import("layout.zig");
-const Presentation = @import("Presentation.zig");
-const animation = @import("animation.zig");
const modal = @import("modal.zig");
const ctlfs = @import("ninep/tree.zig");
const panes = @import("panes.zig");
const edit = @import("edit.zig");
const body_layer = @import("body_layer.zig");
-const PanelCellDiff = @import("surface.zig").PanelCellDiff;
const builtins = @import("builtins.zig");
const config = @import("config.zig");
const pdf_enabled = panes.Pdf.enabled;
@@ -393,7 +390,7 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
else => return false,
};
const bit: u3 = if (button) |b| @as(u3, 1) << @intCast(@backingInt(b)) else 0;
- const at = p.pointerCell(@min(m.col, p.screen_w -| 1), @min(m.row, p.screen_h -| 1));
+ const at: struct { col: u16, row: u16 } = .{ .col = @min(m.col, p.screen_w -| 1), .row = @min(m.row, p.screen_h -| 1) };
var mods: panes.terminal.MouseMods = .{ .shift = m.shift, .alt = m.alt, .ctrl = m.ctrl };
var buf: [64]u8 = undefined;
if (p.mouse_grab) |*grab| {
@@ -409,8 +406,8 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
// Off the grid the cell runs on past its edge, and the encoder
// clamps it there.
const r = p.rects[grab.id];
- const col: i32 = if (at) |a| @as(i32, a.col) - @as(i32, r.x + config.GUTTER) else 0;
- const row: i32 = if (at) |a| @as(i32, a.row) - @as(i32, p.bodyTop(pane, r)) else 0;
+ const col: i32 = @as(i32, at.col) - @as(i32, r.x + config.GUTTER);
+ const row: i32 = @as(i32, at.row) - @as(i32, p.bodyTop(pane, r));
const action: panes.terminal.MouseAction = switch (m.kind) {
.press => .press,
.release => .release,
@@ -427,7 +424,7 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
const shifted_to_program = m.button == .middle or m.button == .right;
if (m.shift != shifted_to_program) return false;
if (shifted_to_program) mods.shift = false;
- const mapped = at orelse return false;
+ const mapped = at;
const id = paneAt(p, mapped.col, mapped.row) orelse return false;
const pane = p.panes[id].?;
if (!tracksMouse(pane)) return false;
@@ -550,17 +547,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
return;
}
p.raw_hover_intent = false;
- const mapped = p.pointerCell(raw_col, raw_row) orelse {
- look.cancelLookHover(p);
- if (m.kind == .release) {
- if (p.header_sweep) |sweep| if (sweep.button == m.button) {
- p.header_sweep = null;
- return headerSweepRun(p, sweep);
- };
- dragRelease(p, m.button);
- }
- return;
- };
+ const mapped: struct { col: u16, row: u16 } = .{ .col = raw_col, .row = raw_row };
const mcol = mapped.col;
const mrow = mapped.row;
p.hover_col = mcol;
@@ -1527,18 +1514,16 @@ test "plain left click clears explicit modal selection" {
try std.testing.expectEqual(.none, pane.sel[@backingInt(config.select_button)].state);
}
-test "selection drag and queued release do not enter panel pending state" {
+test "a selection drag and its release leave the selection done" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 50, .rows = 10, .tty_only = true });
defer p.deinit();
const pane = try p.setTestFile("alpha beta\n");
- p.acknowledgePanelPresentation(&.{});
const rect = p.rects[0];
const x = rect.x + config.GUTTER + config.PREFIX_W + 1;
const y = rect.y + BOX_H;
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } });
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .drag, .col = x + 2, .row = y } });
- try std.testing.expect(!p.presentation.pending);
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = x + 2, .row = y } });
try std.testing.expect(p.drag == .none);
try std.testing.expectEqual(.done, pane.sel[sel_slot].state);
@@ -1686,242 +1671,6 @@ test "a RIGHT-column corner's two axes clamp independently" {
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = handle, .row = 999 } });
}
-test "pointer coordinates follow presented panel geometry" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true });
- defer p.deinit();
- const pane = p.panes[0].?;
-
- const moving: animation.Track = .{
- .serial = pane.serial,
- .pane = 0,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .x = 20, .y = 5, .w = 40, .h = 10 },
- .to = .{ .x = 0, .y = 1, .w = 80, .h = 18 },
- };
- p.acknowledgePanelPresentation(&.{moving});
- // One shared physical-to-logical map feeds all pointer gestures. The
- // selected sample is 26.25% across and 35% down the presented rectangle.
- try std.testing.expectEqual(Presentation.CellPosition{ .col = 21, .row = 7 }, p.presentation.pointer(p.screen_w, p.screen_h, 30, 8).?);
- // Canonical cells covered only by the not-yet-arrived target are inert.
- try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, 2, 2) == null);
- // Unrelated screen space remains in the ordinary grid coordinate system.
- try std.testing.expectEqual(Presentation.CellPosition{ .col = 100, .row = 10 }, p.presentation.pointer(p.screen_w, p.screen_h, 100, 10).?);
-
- p.acknowledgePanelPresentation(&.{animation.Track{
- .serial = pane.serial,
- .pane = 0,
- .phase = .opening,
- .effect = .zoom,
- .from = .{ .x = 40, .y = 10, .w = 0, .h = 0 },
- .to = .{ .x = 0, .y = 1, .w = 80, .h = 18 },
- }});
- try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, 40, 10) == null);
-
- // Tracks paint in pane-slot order inside a phase. The later slot is the
- // top quad and therefore owns an overlap, even though both are moving.
- const overlap = [_]animation.Track{ .{
- .serial = pane.serial,
- .pane = 0,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .x = 20, .y = 2, .w = 20, .h = 4 },
- .to = .{ .x = 0, .y = 2, .w = 20, .h = 4 },
- }, .{
- .serial = pane.serial + 1,
- .pane = 1,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .x = 20, .y = 2, .w = 20, .h = 4 },
- .to = .{ .x = 60, .y = 2, .w = 20, .h = 4 },
- } };
- p.presentation.shown_tracks = @splat(null);
- p.presentation.shown_tracks[0] = overlap[0];
- p.presentation.shown_tracks[1] = overlap[1];
- try std.testing.expectEqual(Presentation.CellPosition{ .col = 65, .row = 3 }, p.presentation.pointer(p.screen_w, p.screen_h, 25, 3).?);
-}
-
-test "queued pointer input is inert until a changed layout is presented" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 16, .tty_only = true });
- defer p.deinit();
- // Establish that a real host has presented the boot layout.
- p.acknowledgePanelPresentation(&.{});
- p.settings.panel_transition = .slide;
-
- _ = try p.newShell(1, "");
- try std.testing.expect(layout.splitColumn(p, 0, 1, false));
- p.sync();
- try std.testing.expect(p.presentation.pending);
- try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, 10, 4) == null);
-
- var tracks: [MAX_PANES]animation.Track = undefined;
- var len: usize = 0;
- for (p.presentation.tracks) |maybe| if (maybe) |track| {
- tracks[len] = track;
- len += 1;
- };
- p.acknowledgePanelPresentation(tracks[0..len]);
- try std.testing.expect(!p.presentation.pending);
- // Whether this particular opening sample exposes the chosen cell is the
- // transition's concern; it is no longer rejected merely as speculative.
- try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, 99, 4) != null);
-}
-
-test "pointer rejects panel content cells which have not materialized" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 12, .tty_only = true });
- defer p.deinit();
- const pane = p.panes[0].?;
- const target: animation.Box = .{ .x = 4, .y = 2, .w = 32, .h = 4 };
- p.presentation.diffs = try p.gpa.alloc(PanelCellDiff, @as(usize, p.screen_w) * p.screen_h);
- @memset(p.presentation.diffs, .unchanged);
- for (2..6) |row| {
- for (4..36) |col| {
- // Distances on both sides of frame five prove that finished ASCII
- // bytes are clickable while bytes still walking are not.
- p.presentation.diffs[row * p.screen_w + col] = .{ .ascii = .{
- .from = ' ',
- .to = @intCast(' ' + (col - 4) % 12 + 1),
- } };
- }
- }
- p.presentation.diff_state = .ready;
-
- for ([_]animation.Transition{ .dissolve, .ascii }) |effect| {
- const frame: u16 = if (effect == .dissolve) 3 else 5;
- const track: animation.Track = .{
- .serial = pane.serial,
- .pane = 0,
- .phase = .opening,
- .effect = effect,
- .frame = frame,
- .from = target,
- .to = target,
- };
- p.acknowledgePanelPresentation(&.{track});
-
- var saw_visible = false;
- var saw_hidden = false;
- for (0..4) |relative_row| for (0..32) |relative_col| {
- const rcol: u16 = @intCast(relative_col);
- const rrow: u16 = @intCast(relative_row);
- const col: u16 = @intCast(4 + relative_col);
- const row: u16 = @intCast(2 + relative_row);
- const visible = switch (effect) {
- .dissolve => animation.dissolveRevealed(
- pane.serial,
- rcol,
- rrow,
- track.amount(),
- ),
- .ascii => switch (p.presentation.cellDiff(p.screen_w, p.screen_h, col, row)) {
- .ascii => |diff| diff.complete(track.frame),
- .unchanged, .visual => true,
- },
- else => unreachable,
- };
- const mapped = p.presentation.pointer(p.screen_w, p.screen_h, col, row);
- try std.testing.expectEqual(visible, mapped != null);
- if (mapped) |point|
- try std.testing.expectEqual(Presentation.CellPosition{ .col = col, .row = row }, point);
- saw_visible = saw_visible or visible;
- saw_hidden = saw_hidden or !visible;
- };
- try std.testing.expect(saw_visible);
- try std.testing.expect(saw_hidden);
- }
-}
-
-test "unchanged content cells remain clickable through data effects" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 40, .rows = 10, .tty_only = true });
- defer p.deinit();
- const pane = p.panes[0].?;
- p.presentation.diffs = try p.gpa.alloc(PanelCellDiff, @as(usize, p.screen_w) * p.screen_h);
- @memset(p.presentation.diffs, .unchanged);
- p.presentation.diff_state = .ready;
- const box: animation.Box = .{ .x = 2, .y = 2, .w = 20, .h = 4 };
-
- for ([_]animation.Transition{ .dissolve, .ascii }) |effect| {
- p.acknowledgePanelPresentation(&.{.{
- .serial = pane.serial,
- .pane = 0,
- .phase = .opening,
- .effect = effect,
- .from = box,
- .to = box,
- }});
- try std.testing.expectEqual(Presentation.CellPosition{ .col = 8, .row = 3 }, p.presentation.pointer(p.screen_w, p.screen_h, 8, 3).?);
- }
-}
-
-test "held drag follows acknowledged panels and balances an invisible release" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true });
- defer p.deinit();
- const pane = p.panes[0].?;
- const target = layout.panelBox(p.rects[0]);
- var track: animation.Track = .{
- .serial = pane.serial,
- .pane = 0,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .x = 50, .y = 5, .w = 20, .h = 8 },
- .to = target,
- };
- const raw_col: u16 = 55;
- const raw_row: u16 = 7;
- p.acknowledgePanelPresentation(&.{track});
- p.update(.{ .mouse = .{
- .button = config.select_button,
- .kind = .press,
- .col = raw_col,
- .row = raw_row,
- } });
- try std.testing.expect(p.drag == .select);
- const first_col = pane.sel[sel_slot].c1;
- const first_row = pane.sel[sel_slot].r1;
-
- // Advancing producer state alone cannot move input. Only the sample the
- // host says it actually drew may remap the stationary held endpoint.
- track.frame = track.effect.frames() - 1;
- p.presentation.tracks[0] = track;
- try std.testing.expectEqual(first_col, pane.sel[sel_slot].c1);
- try std.testing.expectEqual(first_row, pane.sel[sel_slot].r1);
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expect(first_col != pane.sel[sel_slot].c1 or
- first_row != pane.sel[sel_slot].r1);
-
- const last_col = pane.sel[sel_slot].c1;
- const last_row = pane.sel[sel_slot].r1;
- track.phase = .opening;
- track.effect = .zoom;
- track.frame = 0;
- track.from = .{
- .x = target.x + target.w * 0.5,
- .y = target.y + target.h * 0.5,
- };
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expect(p.presentation.pointer(p.screen_w, p.screen_h, raw_col, raw_row) == null);
- try std.testing.expectEqual(last_col, pane.sel[sel_slot].c1);
- try std.testing.expectEqual(last_row, pane.sel[sel_slot].r1);
-
- // An unrelated release cannot consume the left drag. Its own release is
- // nevertheless balanced at the retained endpoint while the cell is dark.
- p.update(.{ .mouse = .{
- .button = config.exec_button,
- .kind = .release,
- .col = raw_col,
- .row = raw_row,
- } });
- try std.testing.expect(p.drag == .select);
- p.update(.{ .mouse = .{
- .button = config.select_button,
- .kind = .release,
- .col = raw_col,
- .row = raw_row,
- } });
- try std.testing.expect(p.drag == .none);
- try std.testing.expectEqual(.done, pane.sel[sel_slot].state);
-}
-
test "mouse thumb buttons navigate once and clear selection gestures" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 });
defer p.deinit();
@@ -2060,7 +1809,7 @@ test "Alt-click is B2 and Super-click B3, kept from the press through the releas
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
const file = try p.setTestFile("Newcol here\n");
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
const r = p.rects[0];
const col = r.x + config.GUTTER + panes.File.gutterWidth(file) + 1;
const row = p.bodyTop(file, r);
diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig
index 95fe50a7..71b656d2 100644
--- a/src/ninep/screen.zig
+++ b/src/ninep/screen.zig
@@ -223,89 +223,55 @@ test "screen snapshots preserve rendered cells and styles until their handle is
for (p.fs.opens) |o| try testing.expect(o.node == 0);
}
-test "screen inspection preserves acknowledged presentation and the next real frame" {
+test "screen inspection leaves the next real frame as it would have been" {
const gpa = testing.allocator;
- for (std.enums.values(pardes.animation.Transition)) |transition| {
- errdefer std.debug.print("screen inspection during {s}\n", .{@tagName(transition)});
- const control = try withFile(gpa, "const value = 1;\n");
- defer control.deinit();
- const inspected = try withFile(gpa, "const value = 1;\n");
- defer inspected.deinit();
- var arena: std.heap.ArenaAllocator = .init(gpa);
- defer arena.deinit();
- for ([_]*Pardes{ control, inspected }) |p| {
- // The mechanism, at a fixed flavour, not the default's tuning.
- p.settings.motion = .crisp;
- p.settings.panel_transition = .off;
- p.update(.tick);
- p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks());
- p.settings.panel_transition = transition;
- }
- for (0..4) |phase| {
- for ([_]*Pardes{ control, inspected }) |p| switch (phase) {
- 0 => {},
- 1 => p.update(.{ .command = "New" }),
- 2 => {
- p.update(.tick);
- try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .body), "changed cells\n").reply.status);
- },
- 3 => {
- for (0..transition.frames() + 1) |_| p.update(.tick);
- p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks());
- p.update(.{ .command = "Del" });
- },
- else => unreachable,
- };
- for (0..2) |_| {
- const opened = call(inspected, .{ .tag = 1, .op = .open, .node = screen_node });
- try testing.expectEqual(Status.ok, opened.reply.status);
- const captured = call(inspected, .{ .tag = 2, .op = .read, .node = screen_node, .handle = opened.reply.handle, .size = 32 });
- try testing.expectEqual(Status.ok, captured.reply.status);
- try testing.expect(captured.bytes.len > 0);
- try testing.expectEqual(Status.ok, call(inspected, .{
- .tag = 3,
- .op = .release,
- .node = screen_node,
- .handle = opened.reply.handle,
- }).reply.status);
- }
- const a = &control.presentation;
- const b = &inspected.presentation;
- try testing.expectEqualDeep(a.shown, b.shown);
- try testing.expectEqualDeep(a.shown_tracks, b.shown_tracks);
- try testing.expectEqualDeep(a.shown_closing[0..a.shown_closing_len], b.shown_closing[0..b.shown_closing_len]);
- try testing.expectEqual(a.pending, b.pending);
- try testing.expectEqual(a.acknowledged, b.acknowledged);
- try testing.expectEqual(a.previous_valid, b.previous_valid);
- try testing.expectEqual(a.previous_cols, b.previous_cols);
- try testing.expectEqual(a.previous_rows, b.previous_rows);
- try testing.expectEqualDeep(a.previous_layout, b.previous_layout);
- try testing.expectEqual(a.previous_cells.len, b.previous_cells.len);
- for (a.previous_cells, b.previous_cells) |*expected, *actual|
- try testing.expect(expected.visuallyEqual(actual));
-
- const expected = try control.render(arena.allocator());
- const actual = try inspected.render(arena.allocator());
- try testing.expectEqual(expected.cols, actual.cols);
- try testing.expectEqual(expected.rows, actual.rows);
- try testing.expectEqualDeep(expected.cursor, actual.cursor);
- try testing.expectEqualDeep(expected.panelTracks(), actual.panelTracks());
- try testing.expectEqualDeep(expected.cell_diffs, actual.cell_diffs);
- try testing.expectEqual(expected.previous_cells.len, actual.previous_cells.len);
- try testing.expectEqual(expected.cells.len, actual.cells.len);
- try testing.expectEqual(@as(usize, 0), expected.images.items.len);
- try testing.expectEqual(@as(usize, 0), actual.images.items.len);
- for (expected.cells, actual.cells) |*left, *right| try testing.expect(left.visuallyEqual(right));
- for (expected.previous_cells, actual.previous_cells) |*left, *right| try testing.expect(left.visuallyEqual(right));
- if (phase == 1 and transition != .off) try testing.expect(expected.panelTracks().len > 0);
- if (phase == 1 and transition.needsPreviousGrid()) try testing.expect(expected.hasPanelDiff());
- if (phase == 3 and transition == .vertical) try testing.expect(a.closing_len > 0);
- control.acknowledgePanelPresentation(expected.panelTracks());
- inspected.acknowledgePanelPresentation(actual.panelTracks());
- try testing.expectEqualDeep(a.shown, b.shown);
- try testing.expectEqualDeep(a.previous_layout, b.previous_layout);
- _ = arena.reset(.retain_capacity);
+ const control = try withFile(gpa, "const value = 1;\n");
+ defer control.deinit();
+ const inspected = try withFile(gpa, "const value = 1;\n");
+ defer inspected.deinit();
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ for ([_]*Pardes{ control, inspected }) |p| {
+ p.update(.tick);
+ _ = try p.render(arena.allocator());
+ p.presented();
+ }
+ for (0..4) |phase| {
+ for ([_]*Pardes{ control, inspected }) |p| switch (phase) {
+ 0 => {},
+ 1 => p.update(.{ .command = "New" }),
+ 2 => {
+ p.update(.tick);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .body), "changed cells\n").reply.status);
+ },
+ 3 => p.update(.{ .command = "Del" }),
+ else => unreachable,
+ };
+ for (0..2) |_| {
+ const opened = call(inspected, .{ .tag = 1, .op = .open, .node = screen_node });
+ try testing.expectEqual(Status.ok, opened.reply.status);
+ const captured = call(inspected, .{ .tag = 2, .op = .read, .node = screen_node, .handle = opened.reply.handle, .size = 32 });
+ try testing.expectEqual(Status.ok, captured.reply.status);
+ try testing.expect(captured.bytes.len > 0);
+ try testing.expectEqual(Status.ok, call(inspected, .{
+ .tag = 3,
+ .op = .release,
+ .node = screen_node,
+ .handle = opened.reply.handle,
+ }).reply.status);
}
+ const expected = try control.render(arena.allocator());
+ const actual = try inspected.render(arena.allocator());
+ try testing.expectEqual(expected.cols, actual.cols);
+ try testing.expectEqual(expected.rows, actual.rows);
+ try testing.expectEqualDeep(expected.cursor, actual.cursor);
+ try testing.expectEqual(expected.cells.len, actual.cells.len);
+ try testing.expectEqual(@as(usize, 0), expected.images.items.len);
+ try testing.expectEqual(@as(usize, 0), actual.images.items.len);
+ for (expected.cells, actual.cells) |*left, *right| try testing.expect(left.visuallyEqual(right));
+ control.presented();
+ inspected.presented();
+ _ = arena.reset(.retain_capacity);
}
}
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 (&current, "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 = &current,
- .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 (&current, "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 = &current,
- .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;
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];
diff --git a/src/tape.zig b/src/tape.zig
index 380cf14e..ad5a1c04 100644
--- a/src/tape.zig
+++ b/src/tape.zig
@@ -61,7 +61,7 @@ pub const Input = union(enum) {
reload_watched_file: struct { id: u8, bytes: []const u8 },
note_late_failure: usize,
invalidate,
- acknowledge_panel_presentation: []const pardes.animation.Track,
+ presented,
run_closed_lines,
file_deleted: u8,
open_view,
@@ -109,7 +109,6 @@ pub const Site = enum(u16) {
shell,
mtime,
cwd,
- pointer,
/// What a terminal's ingest told the positions pardes keeps over it.
positions,
/// Whether a terminal is at its prompt, as a step reads it after its
@@ -131,9 +130,9 @@ pub const results = .{
u32, i64,
[8]u8, ?u64,
[]const u8, ?[]const u8,
- ?std.Io.File.Kind, ?pardes.Presentation.CellPosition,
- ?pardes.filesystem.Resolved, pardes.filesystem.OsReadWrite,
- anyerror!pardes.filesystem.OsStat, anyerror![]const u8,
+ ?std.Io.File.Kind, ?pardes.filesystem.Resolved,
+ pardes.filesystem.OsReadWrite, anyerror!pardes.filesystem.OsStat,
+ anyerror![]const u8,
anyerror![]u8, anyerror!void,
terminal.Told, ?pardes.ctlfs.pty.Printed,
@typeInfo(@TypeOf(terminal.greeting)).@"fn".return_type.?,
@@ -391,7 +390,7 @@ pub const Tape = struct {
/// A host call the headless replica does not make (it draws no frame,
/// so presents none): what the host told the core inside it (what it
- /// presented, `acknowledge_panel_presentation`) is applied all the
+ /// presented, `presented`) is applied all the
/// same, the host's own calls below it stepped over.
fn skipHost(t: *Tape) void {
while (t.diverged == null) {
@@ -618,7 +617,7 @@ pub const Tape = struct {
.reload_watched_file => |a| _ = p.reloadWatchedFile(a.id, a.bytes),
.note_late_failure => |id| p.noteLateFailure(id),
.invalidate => p.invalidate(),
- .acknowledge_panel_presentation => |tracks| p.acknowledgePanelPresentation(tracks),
+ .presented => p.presented(),
.run_closed_lines => pardes.ctlfs.runClosedLines(p),
.file_deleted => |id| pardes.panes.File.deleted(p, id),
.open_view => _ = p.openView(),
diff --git a/src/tui/panel_compositor.zig b/src/tui/panel_compositor.zig
deleted file mode 100644
index 142a6fae..00000000
--- a/src/tui/panel_compositor.zig
+++ /dev/null
@@ -1,785 +0,0 @@
-//! TTY implementation of panel transitions.
-//!
-//! The core publishes presentation cells plus POD tracks. It has already
-//! composed PanelAscii because byte stepping is semantic, while this backend
-//! copies the grid for geometry and dissolve operations. No terminal escape
-//! trick or pixel assumption leaks into the core.
-
-const std = @import("std");
-const pardes = @import("../pardes.zig");
-const layout = @import("../layout.zig");
-const animation = @import("../animation.zig");
-
-const Box = animation.Box;
-const Track = animation.Track;
-const Glide = pardes.glide.Glide;
-
-/// What the tty draws this frame: the canonical surface until a pass
-/// changes a cell or the cursor, then the one copy of it the first such
-/// pass makes (`own`), which every later pass changes in place.
-pub const Frame = struct {
- arena: std.mem.Allocator,
- canonical: *const pardes.Surface,
- copy: ?*pardes.Surface = null,
-
- pub fn shown(f: *const Frame) *const pardes.Surface {
- return f.copy orelse f.canonical;
- }
-
- /// The copy, made at the first call.
- pub fn own(f: *Frame) !*pardes.Surface {
- if (f.copy) |c| return c;
- const c = try f.arena.create(pardes.Surface);
- c.* = f.canonical.*;
- c.cells = try f.arena.dupe(pardes.Cell, f.canonical.cells);
- f.copy = c;
- return c;
- }
-};
-
-/// Kitty placements cannot be resampled through the character-grid transform.
-/// Keep their transmitted pixels cached, but omit the placement while its pane
-/// geometry moves. Data effects animate changed grid cells in place and have
-/// no honest old Kitty bitmap, so leaving an unchanged attachment canonical is
-/// better than making it disappear for the whole reveal and pop back.
-pub fn hidesAttachment(tracks: []const Track, serial: u32) bool {
- for (tracks) |track| {
- if (track.serial != serial or !track.active()) continue;
- if (track.effect != .slide and track.effect != .zoom and track.effect != .vertical) continue;
- // The last active sample is already the exact canonical frame. Place
- // the image there too, rather than making it pop in one tick later.
- if (track.frame + 1 < track.frames()) return true;
- }
- return false;
-}
-
-/// This frame's TTY presentation of the panel tracks, drawn on the frame's
-/// copy (the canonical surface is left as it is when idle). Geometry exposed
-/// by a moving panel uses the theme's page background when it has one; null
-/// deliberately leaves the host terminal's default background showing.
-pub fn compose(frame: *Frame, tracks: []const Track, theme_bg: ?[3]u8) !void {
- const source = frame.canonical;
- var active = false;
- var noncanonical = false;
- for (tracks) |track| {
- if (!drawable(source, track)) continue;
- active = true;
- noncanonical = noncanonical or track.amount() < 1.0;
- }
- if (!active) return;
- // Every effect's last active sample is its exact canonical endpoint. Keep
- // the real cursor and attachments in that sample instead of suppressing
- // them for one extra frame that is otherwise pixel-identical.
- if (!noncanonical) return;
-
- const out = try frame.own();
- // A cursor has no pane/phase record of its own. All native backends hide
- // it for the short transition rather than disagreeing about whether it
- // should move, stay static, or cover an overlapping opening pane.
- out.cursor = null;
-
- // Clear every final geometry before drawing any presented geometry. If
- // clear and draw are interleaved, a new panel can erase the old full-width
- // panel that was deliberately drawn underneath it at frame zero.
- for (tracks) |track|
- if (drawable(source, track) and (track.effect == .slide or track.effect == .zoom))
- clearBox(out, track.to, theme_bg);
-
- // A vertical opener starts over the exact old pixels in its fixed target
- // clip. Its new content then rises into that clip from below. Restore all
- // bases before painting anything so an opener cannot erase an earlier
- // moving panel merely because its pane slot sorts later.
- for (tracks) |track|
- if (drawable(source, track) and track.effect == .vertical and track.phase == .opening)
- restorePrevious(out, source, track.contentBox());
-
- // Stable layout motion first, newly opening panels above it, and closing
- // tombstones last. A closing pane no longer owns input or canonical cells,
- // but its frozen old content remains the top visual until it slides out.
- // A slide or a zoom is clipped by nothing but the screen.
- const screen: Box = .{ .w = @floatFromInt(out.cols), .h = @floatFromInt(out.rows) };
- for ([_]animation.Phase{ .moving, .opening, .closing }) |phase| {
- for (tracks) |track| {
- if (!drawable(source, track) or track.phase != phase) continue;
- switch (track.effect) {
- .off => {},
- .slide, .zoom => transformClipped(out, source.cols, source.rows, source.cells, track, screen),
- .dissolve => dissolve(out, source, track),
- // Pardes core has already composed every character effect
- // into source.cells — byte walks, glyph motion, and per-cell
- // locks are semantic. TTY only owns cursor suppression here.
- .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => {},
- .vertical => vertical(out, source, track),
- }
- }
- }
-}
-
-/// The tty's picture of the glide (glide.zig, anim 12): the body's rows
-/// moved by the offset rounded to whole rows (the position rounded, never
-/// the step, so a slowing glide's steps come further apart), the rows that
-/// left in the gap it opens, and a caret whose line rode the scroll carried
-/// with it. In place: the rows are walked from the side they move toward,
-/// so each is read before a move writes over it.
-pub fn glideRows(frame: *Frame, glide: *const Glide) !void {
- const surface = frame.shown();
- for (surface.panelTracks()) |track|
- if (track.active() and track.pane == glide.pane) return;
- const k: i32 = @intFromFloat(@round(glide.follow.offset));
- const w = glide.bw();
- const h = glide.body_h;
- const x0 = glide.rect.x + pardes.config.GUTTER;
- const y0 = glide.body_y;
- if (k == 0 or w == 0 or h == 0 or x0 + w > surface.cols or y0 + h > surface.rows) return;
- const out = try frame.own();
- const cols: usize = out.cols;
- for (0..h) |i| {
- const r = if (k > 0) i else h - 1 - i;
- const from = @as(i32, @intCast(r)) + k;
- const to = out.cells[(y0 + r) * cols + x0 ..][0..w];
- const kept: ?[]const pardes.Cell = if (from >= 0 and from < h)
- out.cells[(y0 + @as(usize, @intCast(from))) * cols + x0 ..][0..w]
- else if (from < 0 and -from - 1 < glide.nabove)
- glide.above[@as(usize, @intCast(-from - 1)) * w ..][0..w]
- else if (from >= h and from - h < glide.nbelow)
- glide.below[@as(usize, @intCast(from - h)) * w ..][0..w]
- else
- null;
- if (kept) |cells| @memcpy(to, cells) else @memset(to, .{});
- }
- if (out.cursor) |*c| if (glide.caret_rides and c.x >= x0 and c.x < x0 + w and c.y >= y0 and c.y < y0 + h) {
- const y = @as(i32, c.y) - k;
- if (y >= y0 and y < y0 + h) c.y = @intCast(y) else out.cursor = null;
- };
-}
-
-/// Content effects have no honest frame without the frozen old grid. In
-/// production the core drops such tracks before publishing Surface; retain
-/// this guard at the backend boundary so a partial/custom caller also snaps
-/// to canonical content instead of manufacturing blanks.
-fn drawable(source: *const pardes.Surface, track: Track) bool {
- return track.active() and
- (!track.effect.needsPreviousGrid() or source.hasPanelDiff());
-}
-
-fn dissolve(out: *pardes.Surface, source: *const pardes.Surface, track: Track) void {
- const area = clipped(track.to, out.cols, out.rows) orelse return;
- const amount = track.amount();
- var y = area.y0;
- while (y < area.y1) : (y += 1) {
- var x = area.x0;
- while (x < area.x1) : (x += 1) {
- if (!source.panelCellChanged(x, y)) continue;
- if (animation.dissolveRevealed(
- track.serial,
- x - area.x0,
- y - area.y0,
- amount,
- )) continue;
- out.at(x, y).* = previousCell(source, x, y).*;
- }
- }
-}
-
-fn previousCell(source: *const pardes.Surface, x: u16, y: u16) *const pardes.Cell {
- std.debug.assert(source.hasPanelDiff());
- return &source.previous_cells[@as(usize, y) * source.cols + x];
-}
-
-fn restorePrevious(out: *pardes.Surface, source: *const pardes.Surface, box: Box) void {
- const area = clipped(box, out.cols, out.rows) orelse return;
- var y = area.y0;
- while (y < area.y1) : (y += 1) {
- var x = area.x0;
- while (x < area.x1) : (x += 1)
- out.at(x, y).* = previousCell(source, x, y).*;
- }
-}
-
-fn vertical(out: *pardes.Surface, source: *const pardes.Surface, track: Track) void {
- const cells = if (track.phase == .closing) source.previous_cells else source.cells;
- transformClipped(out, source.cols, source.rows, cells, track, track.contentBox());
-}
-
-/// Translate one old/new canonical panel through a clip: a vertical
-/// panel's fixed lifecycle box, or the screen for a slide or a zoom.
-/// Sampling is always relative to contentBox: an opener and a moving panel
-/// read their new target, a closer the old box retained after that pane
-/// was destroyed (only a vertical one closes).
-fn transformClipped(
- out: *pardes.Surface,
- source_cols: u16,
- source_rows: u16,
- cells: []const pardes.Cell,
- track: Track,
- clip: Box,
-) void {
- const shown = track.presented();
- if (shown.w <= 0 or shown.h <= 0) return;
- const dst = clipped(shown, out.cols, out.rows) orelse return;
- const content = track.contentBox();
- var y = dst.y0;
- while (y < dst.y1) : (y += 1) {
- var x = dst.x0;
- while (x < dst.x1) : (x += 1) {
- // The core hit-tests cell CENTRES against this same half-open box.
- // floor/ceil clipping includes boundary cells for iteration, but
- // they are not visible unless their centre is actually inside.
- // Test that containment before division: at large u16 grids f32
- // can round an inside right-edge ratio to exactly 1.0.
- const cx = @as(f32, @floatFromInt(x)) + 0.5;
- const cy = @as(f32, @floatFromInt(y)) + 0.5;
- if (cx < shown.x or cx >= shown.x + shown.w or
- cy < shown.y or cy >= shown.y + shown.h or
- cx < clip.x or cx >= clip.x + clip.w or
- cy < clip.y or cy >= clip.y + clip.h) continue;
- const u = std.math.clamp((cx - shown.x) / shown.w, 0, 0.999_999);
- const v = std.math.clamp((cy - shown.y) / shown.h, 0, 0.999_999);
- const sx: i32 = @intFromFloat(@floor(content.x + u * content.w));
- const sy: i32 = @intFromFloat(@floor(content.y + v * content.h));
- if (sx < 0 or sy < 0 or sx >= source_cols or sy >= source_rows) continue;
- out.at(x, y).* = cells[@as(usize, @intCast(sy)) * source_cols + @as(usize, @intCast(sx))];
- }
- }
-}
-
-fn clearBox(surface: *pardes.Surface, box: Box, theme_bg: ?[3]u8) void {
- const area = clipped(box, surface.cols, surface.rows) orelse return;
- var blank: pardes.Cell = .{};
- if (theme_bg) |rgb| {
- blank.default = false;
- blank.style.bg = .{ .rgb = rgb };
- }
- var y = area.y0;
- while (y < area.y1) : (y += 1) {
- var x = area.x0;
- while (x < area.x1) : (x += 1) surface.at(x, y).* = blank;
- }
-}
-
-const GridBox = struct { x0: u16, y0: u16, x1: u16, y1: u16 };
-
-fn clipped(box: Box, cols: u16, rows: u16) ?GridBox {
- const x0: i32 = @intFromFloat(@floor(box.x));
- const y0: i32 = @intFromFloat(@floor(box.y));
- const x1: i32 = @intFromFloat(@ceil(box.x + box.w));
- const y1: i32 = @intFromFloat(@ceil(box.y + box.h));
- const area: GridBox = .{
- .x0 = @intCast(std.math.clamp(x0, 0, @as(i32, cols))),
- .y0 = @intCast(std.math.clamp(y0, 0, @as(i32, rows))),
- .x1 = @intCast(std.math.clamp(x1, 0, @as(i32, cols))),
- .y1 = @intCast(std.math.clamp(y1, 0, @as(i32, rows))),
- };
- return if (area.x0 < area.x1 and area.y0 < area.y1) area else null;
-}
-
-/// `compose` over a frame of `surface` (the tests): what the frame shows,
-/// `surface` itself when nothing was drawn (read through `at`).
-fn composed(arena: std.mem.Allocator, surface: *pardes.Surface, tracks: []const Track, theme_bg: ?[3]u8) !*pardes.Surface {
- var frame: Frame = .{ .arena = arena, .canonical = surface };
- try compose(&frame, tracks, theme_bg);
- return frame.copy orelse surface;
-}
-
-/// Each of `cells` a one-byte glyph of `glyphs`, in order.
-fn testGlyphs(cells: []pardes.Cell, glyphs: []const u8) void {
- for (cells, glyphs) |*cell, glyph| {
- cell.text[0] = glyph;
- cell.len = 1;
- cell.default = false;
- }
-}
-
-test "TTY consumes core-composed ASCII cells without reinterpreting glyphs" {
- var cells: [8]pardes.Cell = @splat(.{});
- var previous: [8]pardes.Cell = @splat(.{});
- const diffs: [8]pardes.PanelCellDiff = @splat(.visual);
- testGlyphs(&cells, "XXXXXXXX");
- testGlyphs(&previous, "OOOOOOOO");
- var surface: pardes.Surface = .{
- .cols = 4,
- .rows = 2,
- .cells = &cells,
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const track: Track = .{
- .serial = 9,
- .effect = .ascii,
- .frame = 0,
- .from = .{ .w = 4, .h = 2 },
- .to = .{ .w = 4, .h = 2 },
- };
- const animated = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expect(animated != &surface);
- try std.testing.expectEqualStrings("X", surface.at(0, 0).grapheme());
- for (animated.cells) |cell| try std.testing.expectEqualStrings("X", cell.grapheme());
-}
-
-test "dissolve changes only diff cells from old to new" {
- var cells: [2]pardes.Cell = @splat(.{});
- var previous: [2]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "NU");
- testGlyphs(&previous, "OU");
- const diffs = [_]pardes.PanelCellDiff{ .{ .ascii = .{ .from = 'O', .to = 'N' } }, .unchanged };
- var surface: pardes.Surface = .{
- .cols = 2,
- .rows = 1,
- .cells = &cells,
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- var track: Track = .{
- .serial = 1,
- .effect = .dissolve,
- .from = .{ .w = 2, .h = 1 },
- .to = .{ .w = 2, .h = 1 },
- };
-
- const first = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqualStrings("O", first.at(0, 0).grapheme());
- try std.testing.expectEqual(cells[1], first.at(1, 0).*);
-
- _ = arena.reset(.retain_capacity);
- track.frame = track.effect.frames() - 1;
- const final = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqual(cells[0], final.at(0, 0).*);
- try std.testing.expectEqual(cells[1], final.at(1, 0).*);
-}
-
-test "TTY content effects never touch cells outside the published diff" {
- var cells: [4]pardes.Cell = @splat(.{});
- var previous: [4]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "NUQV");
- // Deliberately disagree even where the mask says unchanged. This makes
- // the test prove that the compositor obeys the core cell diff rather than
- // merely appearing correct because old and new happened to match there.
- testGlyphs(&previous, "OXRY");
- const diffs = [_]pardes.PanelCellDiff{ .visual, .unchanged, .visual, .unchanged };
- var surface: pardes.Surface = .{
- .cols = 4,
- .rows = 1,
- .cells = &cells,
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
-
- for ([_]animation.Transition{ .ascii, .dissolve }) |effect| {
- const track: Track = .{
- .serial = 17,
- .effect = effect,
- .from = .{ .w = 4, .h = 1 },
- .to = .{ .w = 4, .h = 1 },
- };
- const animated = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqual(cells[1], animated.at(1, 0).*);
- try std.testing.expectEqual(cells[3], animated.at(3, 0).*);
- _ = arena.reset(.retain_capacity);
- }
-}
-
-test "content transition without a diff snaps to canonical surface" {
- var cells = [_]pardes.Cell{.{}};
- testGlyphs(&cells, "N");
- var surface: pardes.Surface = .{
- .cols = 1,
- .rows = 1,
- .cells = &cells,
- .cursor = .{ .x = 0, .y = 0 },
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
-
- for ([_]animation.Transition{ .dissolve, .ascii, .vertical }) |effect| {
- const track: Track = .{
- .effect = effect,
- .phase = .opening,
- .from = .{ .y = 1, .w = 1, .h = 1 },
- .to = .{ .w = 1, .h = 1 },
- };
- try std.testing.expectEqual(&surface, try composed(arena.allocator(), &surface, &.{track}, null));
- }
-}
-
-test "exact transition endpoint preserves the canonical cursor" {
- var cells = [_]pardes.Cell{.{}};
- var previous = cells;
- const diffs = [_]pardes.PanelCellDiff{.visual};
- var surface: pardes.Surface = .{
- .cols = 1,
- .rows = 1,
- .cells = &cells,
- .cursor = .{ .x = 0, .y = 0 },
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- const track: Track = .{
- .effect = .ascii,
- .frame = animation.Transition.ascii.frames() - 1,
- .from = .{ .w = 1, .h = 1 },
- .to = .{ .w = 1, .h = 1 },
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
-
- const result = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqual(&surface, result);
- try std.testing.expect(result.cursor != null);
-}
-
-test "vertical opening rises through a fixed old-grid clip" {
- var cells: [12]pardes.Cell = @splat(.{});
- var previous: [12]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "aaabbbcccddd");
- testGlyphs(&previous, "000111222333");
- const diffs: [12]pardes.PanelCellDiff = @splat(.visual);
- var surface: pardes.Surface = .{
- .cols = 3,
- .rows = 4,
- .cells = &cells,
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const target: Box = .{ .y = 1, .w = 3, .h = 2 };
- var track: Track = .{
- .serial = 5,
- .phase = .opening,
- .effect = .vertical,
- .from = animation.openingBox(.vertical, target, 3),
- .to = target,
- };
-
- const first = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqualStrings("1", first.at(0, 1).grapheme());
- try std.testing.expectEqualStrings("2", first.at(0, 2).grapheme());
- try std.testing.expectEqualStrings("a", first.at(0, 0).grapheme());
- try std.testing.expectEqualStrings("d", first.at(0, 3).grapheme());
-
- _ = arena.reset(.retain_capacity);
- track.frame = 2;
- const entering = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqualStrings("1", entering.at(0, 1).grapheme());
- try std.testing.expectEqualStrings("b", entering.at(0, 2).grapheme());
- try std.testing.expectEqualStrings("a", entering.at(0, 0).grapheme());
- try std.testing.expectEqualStrings("d", entering.at(0, 3).grapheme());
-
- _ = arena.reset(.retain_capacity);
- track.frame = track.effect.frames() - 1;
- const final = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqualStrings("b", final.at(0, 1).grapheme());
- try std.testing.expectEqualStrings("c", final.at(0, 2).grapheme());
-}
-
-test "vertical closing drops frozen content over canonical cells" {
- var cells: [12]pardes.Cell = @splat(.{});
- var previous: [12]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "aaabbbcccddd");
- testGlyphs(&previous, "000111222333");
- const diffs: [12]pardes.PanelCellDiff = @splat(.visual);
- var surface: pardes.Surface = .{
- .cols = 3,
- .rows = 4,
- .cells = &cells,
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const old_box: Box = .{ .y = 1, .w = 3, .h = 2 };
- var track: Track = .{
- .serial = 5,
- .phase = .closing,
- .effect = .vertical,
- .from = old_box,
- .to = animation.closingBox(.vertical, old_box),
- };
-
- const first = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqualStrings("1", first.at(0, 1).grapheme());
- try std.testing.expectEqualStrings("2", first.at(0, 2).grapheme());
-
- _ = arena.reset(.retain_capacity);
- track.frame = 8;
- const leaving = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqualStrings("b", leaving.at(0, 1).grapheme());
- try std.testing.expectEqualStrings("1", leaving.at(0, 2).grapheme());
- try std.testing.expectEqualStrings("a", leaving.at(0, 0).grapheme());
- try std.testing.expectEqualStrings("d", leaving.at(0, 3).grapheme());
-
- _ = arena.reset(.retain_capacity);
- track.frame = track.effect.frames() - 1;
- const final = try composed(arena.allocator(), &surface, &.{track}, null);
- try std.testing.expectEqual(cells[3], final.at(0, 1).*);
- try std.testing.expectEqual(cells[6], final.at(0, 2).*);
-}
-
-test "closing content paints after opening content regardless of track order" {
- var cells = [_]pardes.Cell{.{}};
- var previous = [_]pardes.Cell{.{}};
- testGlyphs(&cells, "N");
- testGlyphs(&previous, "O");
- const diffs = [_]pardes.PanelCellDiff{.visual};
- var surface: pardes.Surface = .{
- .cols = 1,
- .rows = 1,
- .cells = &cells,
- .previous_cells = &previous,
- .cell_diffs = &diffs,
- };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const box: Box = .{ .w = 1, .h = 1 };
- const closing: Track = .{
- .serial = 1,
- .phase = .closing,
- .effect = .vertical,
- .from = box,
- .to = animation.closingBox(.vertical, box),
- };
- const opening: Track = .{
- .serial = 2,
- .phase = .opening,
- .effect = .ascii,
- .frame = animation.Transition.ascii.frames() - 1,
- .from = box,
- .to = box,
- };
-
- const animated = try composed(arena.allocator(), &surface, &.{ closing, opening }, null);
- try std.testing.expectEqualStrings("O", animated.at(0, 0).grapheme());
-}
-
-test "opening panel cannot erase an existing panel drawn underneath" {
- var cells: [8]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "AAAABBBB");
- var surface: pardes.Surface = .{ .cols = 8, .rows = 1, .cells = &cells };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const tracks = [_]Track{
- .{
- .serial = 1,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .w = 8, .h = 1 },
- .to = .{ .w = 4, .h = 1 },
- },
- .{
- .serial = 2,
- .phase = .opening,
- .effect = .slide,
- .from = .{ .x = 8, .w = 4, .h = 1 },
- .to = .{ .x = 4, .w = 4, .h = 1 },
- },
- };
- const animated = try composed(arena.allocator(), &surface, &tracks, null);
- try std.testing.expectEqualStrings("A", animated.at(7, 0).grapheme());
-}
-
-test "geometry gap is a blank painted in an explicit theme background" {
- var cells: [4]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "ABCD");
- for (&cells) |*cell| {
- cell.style = .{
- .fg = .{ .rgb = .{ 220, 210, 200 } },
- .bg = .{ .rgb = .{ 30, 20, 10 } },
- .bold = true,
- .font_role = .tagline,
- };
- }
- var surface: pardes.Surface = .{ .cols = 4, .rows = 1, .cells = &cells };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const track: Track = .{
- .serial = 1,
- .effect = .slide,
- .from = .{ .x = 2, .w = 2, .h = 1 },
- .to = .{ .w = 4, .h = 1 },
- };
- const page_bg = [3]u8{ 248, 244, 232 };
- const animated = try composed(arena.allocator(), &surface, &.{track}, page_bg);
-
- const gap = animated.at(0, 0);
- try std.testing.expect(!gap.default);
- try std.testing.expectEqualStrings(" ", gap.grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = page_bg }, gap.style.bg);
- try std.testing.expectEqual(pardes.Color.default, gap.style.fg);
- try std.testing.expect(!gap.style.bold);
- try std.testing.expectEqual(pardes.FontRole.body, gap.style.font_role);
- // The clear supplies only exposed geometry. Cells sampled from the moving
- // panel retain all canonical content and style fields byte-for-byte.
- try std.testing.expectEqual(cells[1], animated.at(2, 0).*);
-}
-
-test "geometry gap stays terminal-default for a transparent theme" {
- var cells: [2]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "AB");
- var surface: pardes.Surface = .{ .cols = 2, .rows = 1, .cells = &cells };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const track: Track = .{
- .serial = 1,
- .effect = .slide,
- .from = .{ .x = 1, .w = 1, .h = 1 },
- .to = .{ .w = 2, .h = 1 },
- };
- const animated = try composed(arena.allocator(), &surface, &.{track}, null);
-
- const gap = animated.at(0, 0);
- try std.testing.expect(gap.default);
- try std.testing.expectEqualStrings(" ", gap.grapheme());
- try std.testing.expectEqual(pardes.Color.default, gap.style.bg);
-}
-
-test "fractional geometry draws exactly the cell centres core can hit" {
- var cells: [3]pardes.Cell = @splat(.{});
- testGlyphs(&cells, "ABC");
- var surface: pardes.Surface = .{ .cols = 3, .rows = 1, .cells = &cells };
- var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena.deinit();
- const track: Track = .{
- .serial = 1,
- .effect = .slide,
- .from = .{ .x = 0.9, .w = 1, .h = 1 },
- .to = .{ .x = 0, .w = 1, .h = 1 },
- };
- const animated = try composed(arena.allocator(), &surface, &.{track}, null);
- // Cell 0 lies in floor/ceil iteration bounds, but its centre (0.5) is
- // outside [0.9, 1.9); cell 1 is the only presented/hit-testable cell.
- try std.testing.expectEqualStrings(" ", animated.at(0, 0).grapheme());
- try std.testing.expectEqualStrings("A", animated.at(1, 0).grapheme());
-}
-
-test "large-grid right edge uses containment before rounded ratio" {
- const cols = std.math.maxInt(u16);
- const source_cells = try std.testing.allocator.alloc(pardes.Cell, cols);
- defer std.testing.allocator.free(source_cells);
- const output_cells = try std.testing.allocator.alloc(pardes.Cell, cols);
- defer std.testing.allocator.free(output_cells);
- @memset(source_cells, .{});
- @memset(output_cells, .{});
- for (source_cells) |*cell| {
- cell.text[0] = 'X';
- cell.len = 1;
- cell.default = false;
- }
- const source: pardes.Surface = .{ .cols = cols, .rows = 1, .cells = source_cells };
- var output: pardes.Surface = .{ .cols = cols, .rows = 1, .cells = output_cells };
- const track: Track = .{
- .serial = 1,
- .effect = .zoom,
- .frame = 8,
- .from = .{ .x = 56_796, .w = 8_299, .h = 1 },
- .to = .{ .x = 556, .w = 63_483, .h = 1 },
- };
- const shown = track.presented();
- try std.testing.expect(@as(f32, 63_935.5) < shown.x + shown.w);
- transformClipped(&output, source.cols, source.rows, source.cells, track, .{ .w = @floatFromInt(output.cols), .h = @floatFromInt(output.rows) });
- try std.testing.expectEqualStrings("X", output.at(63_935, 0).grapheme());
-}
-
-test "active panel transition hides only its own native attachment" {
- const tracks = [_]Track{
- .{ .serial = 41, .effect = .slide, .frame = 0 },
- .{ .serial = 42, .effect = .ascii, .frame = 0 },
- .{ .serial = 43, .effect = .zoom, .frame = animation.Transition.zoom.frames() - 1 },
- .{ .serial = 44, .effect = .zoom, .frame = animation.Transition.zoom.frames() },
- .{ .serial = 45, .phase = .opening, .effect = .vertical, .frame = 0 },
- };
-
- try std.testing.expect(hidesAttachment(&tracks, 41));
- try std.testing.expect(!hidesAttachment(&tracks, 42));
- try std.testing.expect(!hidesAttachment(&tracks, 43));
- try std.testing.expect(!hidesAttachment(&tracks, 44));
- try std.testing.expect(hidesAttachment(&tracks, 45));
- try std.testing.expect(!hidesAttachment(&tracks, 46));
-}
-
-test "the tty draws a glide at whole rows: once a flick or a spin slows, its steps a tick never grow and its one-row steps come further apart, to where the core is" {
- const gpa = std.testing.allocator;
- const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 30, .tty_only = true });
- defer core.deinit();
- var text: std.ArrayList(u8) = .empty;
- defer text.deinit(gpa);
- for (0..3000) |i| try text.print(gpa, "{d:0>5} line\n", .{i});
- _ = try core.setTestFile(text.items);
- core.settings.motion = .smooth;
- var arena: std.heap.ArenaAllocator = .init(gpa);
- defer arena.deinit();
- var glide: Glide = .{};
- defer glide.deinit(gpa);
- var now: u64 = std.time.ns_per_s;
- // One tick of the tty: its loop step, the frame, the picture.
- const tick = struct {
- fn f(c: *pardes.Pardes, g: *Glide, a: *std.heap.ArenaAllocator, t: u64) !i32 {
- c.advance(t);
- g.step(c, std.testing.allocator, null, null);
- _ = a.reset(.retain_capacity);
- const s = try c.render(a.allocator());
- if (g.pending) g.measure(std.testing.allocator, s);
- if (g.moving()) g.advance(t, g.motion);
- var frame: Frame = .{ .arena = a.allocator(), .canonical = s };
- try glideRows(&frame, g);
- return @intFromFloat(@round(g.follow.offset));
- }
- }.f;
- _ = try tick(core, &glide, &arena, now);
- for ([_]usize{ 4, 24 }) |notches| {
- for (0..notches) |i| {
- core.update(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = 20, .row = 10 } });
- if (i % 2 == 1) {
- now += pardes.animation.frame_ns;
- _ = try tick(core, &glide, &arena, now);
- }
- }
- var drawn = try tick(core, &glide, &arena, now + pardes.animation.frame_ns);
- now += pardes.animation.frame_ns;
- var last_step: i32 = std.math.maxInt(i32);
- var last_gap: usize = 0;
- var since: usize = 0;
- var ticks: usize = 0;
- while (glide.moving()) : (ticks += 1) {
- try std.testing.expect(ticks < 200);
- now += pardes.animation.frame_ns;
- const k = try tick(core, &glide, &arena, now);
- const step = k - drawn;
- drawn = k;
- since += 1;
- if (step == 0) continue;
- // Toward the core, never past it, each step no longer than the last.
- try std.testing.expect(step > 0 and k <= 0);
- try std.testing.expect(step <= last_step);
- if (step == 1 and last_step == 1) try std.testing.expect(since >= last_gap);
- if (step == 1) last_gap = since;
- last_step = step;
- since = 0;
- }
- try std.testing.expectEqual(@as(i32, 0), drawn);
- }
- // j held on the bottom row: the text glides a row a key under a caret
- // that stays on its cell (it does not ride: its row is kept).
- const keys = struct {
- fn j(c: *pardes.Pardes) void {
- c.update(.{ .key = .{ .cp = 'j', .text = "j" } });
- }
- };
- for (0..40) |_| keys.j(core);
- now += std.time.ns_per_s;
- _ = try tick(core, &glide, &arena, now);
- const row = (core.surface.cursor orelse return error.NoCursor).y;
- for (0..20) |i| {
- if (i % 2 == 0) keys.j(core);
- now += pardes.animation.frame_ns;
- _ = try tick(core, &glide, &arena, now);
- var frame: Frame = .{ .arena = arena.allocator(), .canonical = &core.surface };
- try glideRows(&frame, &glide);
- try std.testing.expectEqual(row, (frame.shown().cursor orelse return error.NoCursor).y);
- }
-}
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index fae55141..b2a198c7 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -12,7 +12,6 @@ const message = pardes.Messages.Message;
const file_watch = @import("../file_watch.zig");
const selection_pipe = @import("../selection_pipe.zig");
const ninep_io = @import("../9p_io.zig");
-const panel_compositor = @import("panel_compositor.zig");
const daemon = @import("../daemon.zig");
const host_io = @import("../host_io.zig");
const upgrade = @import("../upgrade.zig");
@@ -1408,7 +1407,6 @@ const Screen = struct {
caps_pending: bool = true,
/// Its size as last taken (`Shell.resized`).
size: ?vaxis.Winsize = null,
- tracks: []const pardes.animation.Track = &.{},
/// The view's glide, the GUI's motion drawn at whole rows (anim 12).
glide: pardes.glide.Glide = .{},
@@ -2601,7 +2599,6 @@ const Shell = struct {
const s = of(ctx);
const sc = s.term() orelse return;
const vx = &sc.vx;
- sc.tracks = canonical.panelTracks();
// The last frame is not answered yet: this one stays owed, and the
// answer's wake draws the state as it is then.
if (sc.feed.ack.holds(@intCast(std.Io.Clock.awake.now(s.io).nanoseconds), s.io)) {
@@ -2609,10 +2606,6 @@ const Shell = struct {
return;
}
_ = s.frame.reset(.retain_capacity);
- // Each pass below draws on the frame's one copy of the canonical
- // surface, made by the first that changes anything.
- var frame: panel_compositor.Frame = .{ .arena = s.frame.allocator(), .canonical = canonical };
- panel_compositor.compose(&frame, sc.tracks, s.core.theme().bg) catch return;
const tz_cells = tracy.zone(@src(), "surface->vaxis");
const win = vx.window();
// Each of the shell's own motions below asks for frames while it runs.
@@ -2620,13 +2613,11 @@ const Shell = struct {
if (sc.glide.moving()) sc.glide.advance(s.core.now_ns, sc.glide.motion);
s.core.shell_continuous = sc.glide.moving();
s.core.frames.scroll = @round(sc.glide.follow.offset);
- panel_compositor.glideRows(&frame, &sc.glide) catch {};
- const shown = frame.shown();
+ const shown = glideRows(s.frame.allocator(), canonical, &sc.glide) catch canonical;
paintCells(win, shown.cells, shown.cols, shown.rows);
if (s.remote) |c| if (c.link.notice_len > 0) noticeLine(win, c.link.notice(), shown.cols, shown.rows);
tz_cells.end();
for (canonical.images.items) |place| {
- if (panel_compositor.hidesAttachment(canonical.panelTracks(), place.serial)) continue;
if (comptime pardes.pdf_enabled) {
if (!kittyImageRepresentable(place)) continue;
}
@@ -2726,7 +2717,7 @@ const Shell = struct {
fn postPresent(ctx: ?*anyopaque) void {
const s = of(ctx);
- if (s.term()) |sc| s.core.acknowledgePanelPresentation(sc.tracks);
+ if (s.term() != null) s.core.presented();
tracy.frameMark();
}
@@ -3352,6 +3343,45 @@ fn noticeLine(win: vaxis.Window, text: []const u8, cols: u16, rows: u16) void {
/// (pardes's patch to Vaxis.zig in build.zig), since a blank's ink shows
/// nowhere. Deciding that here cost every cell of every frame a look at the
/// frame before; vaxis already makes that comparison.
+/// The tty's picture of the glide (glide.zig, anim 12): the body's rows
+/// moved by the offset rounded to whole rows (the position rounded, never
+/// the step, so a slowing glide's steps come further apart), the rows that
+/// left in the gap it opens, and a caret whose line rode the scroll carried
+/// with it; `canonical` itself while the picture is where the core is, else
+/// a copy of it in `arena`. The rows are walked from the side they move
+/// toward, so each is read before a move writes over it.
+fn glideRows(arena: std.mem.Allocator, canonical: *const pardes.Surface, glide: *const pardes.glide.Glide) !*const pardes.Surface {
+ const k: i32 = @intFromFloat(@round(glide.follow.offset));
+ const w = glide.bw();
+ const h = glide.body_h;
+ const x0 = glide.rect.x + pardes.config.GUTTER;
+ const y0 = glide.body_y;
+ if (k == 0 or w == 0 or h == 0 or x0 + w > canonical.cols or y0 + h > canonical.rows) return canonical;
+ const out = try arena.create(pardes.Surface);
+ out.* = canonical.*;
+ out.cells = try arena.dupe(pardes.Cell, canonical.cells);
+ const cols: usize = out.cols;
+ for (0..h) |i| {
+ const r = if (k > 0) i else h - 1 - i;
+ const from = @as(i32, @intCast(r)) + k;
+ const to = out.cells[(y0 + r) * cols + x0 ..][0..w];
+ const kept: ?[]const pardes.Cell = if (from >= 0 and from < h)
+ out.cells[(y0 + @as(usize, @intCast(from))) * cols + x0 ..][0..w]
+ else if (from < 0 and -from - 1 < glide.nabove)
+ glide.above[@as(usize, @intCast(-from - 1)) * w ..][0..w]
+ else if (from >= h and from - h < glide.nbelow)
+ glide.below[@as(usize, @intCast(from - h)) * w ..][0..w]
+ else
+ null;
+ if (kept) |cells| @memcpy(to, cells) else @memset(to, .{});
+ }
+ if (out.cursor) |*c| if (glide.caret_rides and c.x >= x0 and c.x < x0 + w and c.y >= y0 and c.y < y0 + h) {
+ const y = @as(i32, c.y) - k;
+ if (y >= y0 and y < y0 + h) c.y = @intCast(y) else out.cursor = null;
+ };
+ return out;
+}
+
fn paintCells(win: vaxis.Window, cells: []const pardes.Cell, cols: u16, rows: u16) void {
win.clear();
var y: u16 = 0;
@@ -3399,3 +3429,83 @@ test "a fade sends the text it dims, not the blanks beside it" {
try std.testing.expect(std.mem.indexOf(u8, sent[1], "90:90:90") != null);
try std.testing.expect(std.mem.indexOfScalar(u8, sent[1], 'a') != null);
}
+
+test "the tty draws a glide at whole rows: once a flick or a spin slows, its steps a tick never grow and its one-row steps come further apart, to where the core is" {
+ const gpa = std.testing.allocator;
+ const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 30, .tty_only = true });
+ defer core.deinit();
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(gpa);
+ for (0..3000) |i| try text.print(gpa, "{d:0>5} line\n", .{i});
+ _ = try core.setTestFile(text.items);
+ core.settings.motion = .smooth;
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ var glide: pardes.glide.Glide = .{};
+ defer glide.deinit(gpa);
+ var now: u64 = std.time.ns_per_s;
+ // One tick of the tty: its loop step, the frame, the picture.
+ const tick = struct {
+ fn f(c: *pardes.Pardes, g: *pardes.glide.Glide, a: *std.heap.ArenaAllocator, t: u64) !i32 {
+ c.advance(t);
+ g.step(c, std.testing.allocator, null, null);
+ _ = a.reset(.retain_capacity);
+ const s = try c.render(a.allocator());
+ if (g.pending) g.measure(std.testing.allocator, s);
+ if (g.moving()) g.advance(t, g.motion);
+ _ = try glideRows(a.allocator(), s, g);
+ return @intFromFloat(@round(g.follow.offset));
+ }
+ }.f;
+ _ = try tick(core, &glide, &arena, now);
+ for ([_]usize{ 4, 24 }) |notches| {
+ for (0..notches) |i| {
+ core.update(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = 20, .row = 10 } });
+ if (i % 2 == 1) {
+ now += pardes.animation.frame_ns;
+ _ = try tick(core, &glide, &arena, now);
+ }
+ }
+ var drawn = try tick(core, &glide, &arena, now + pardes.animation.frame_ns);
+ now += pardes.animation.frame_ns;
+ var last_step: i32 = std.math.maxInt(i32);
+ var last_gap: usize = 0;
+ var since: usize = 0;
+ var ticks: usize = 0;
+ while (glide.moving()) : (ticks += 1) {
+ try std.testing.expect(ticks < 200);
+ now += pardes.animation.frame_ns;
+ const k = try tick(core, &glide, &arena, now);
+ const step = k - drawn;
+ drawn = k;
+ since += 1;
+ if (step == 0) continue;
+ // Toward the core, never past it, each step no longer than the last.
+ try std.testing.expect(step > 0 and k <= 0);
+ try std.testing.expect(step <= last_step);
+ if (step == 1 and last_step == 1) try std.testing.expect(since >= last_gap);
+ if (step == 1) last_gap = since;
+ last_step = step;
+ since = 0;
+ }
+ try std.testing.expectEqual(@as(i32, 0), drawn);
+ }
+ // j held on the bottom row: the text glides a row a key under a caret
+ // that stays on its cell (it does not ride: its row is kept).
+ const keys = struct {
+ fn j(c: *pardes.Pardes) void {
+ c.update(.{ .key = .{ .cp = 'j', .text = "j" } });
+ }
+ };
+ for (0..40) |_| keys.j(core);
+ now += std.time.ns_per_s;
+ _ = try tick(core, &glide, &arena, now);
+ const row = (core.surface.cursor orelse return error.NoCursor).y;
+ for (0..20) |i| {
+ if (i % 2 == 0) keys.j(core);
+ now += pardes.animation.frame_ns;
+ _ = try tick(core, &glide, &arena, now);
+ const shown = try glideRows(arena.allocator(), &core.surface, &glide);
+ try std.testing.expectEqual(row, (shown.cursor orelse return error.NoCursor).y);
+ }
+}
diff --git a/src/views.zig b/src/views.zig
index 05eaef89..c796bd85 100644
--- a/src/views.zig
+++ b/src/views.zig
@@ -35,7 +35,7 @@ pub const fields = [_][:0]const u8{
"screen_w", "screen_h", "cell_pixels", "row_metrics",
"ncol", "col_weight", "col_panes", "col_n",
"col_tags", "col_serial", "finder", "rects",
- "col_x", "col_w", "presentation", "active",
+ "col_x", "col_w", "active",
"jumps", "njumps", "jcur", "jump_force",
"active_column", "cursor_glide",
"cursor_view", "cursor_crossing", "cursor_held", "shell_continuous",
@@ -497,7 +497,6 @@ pub fn close(p: *Pardes, k: u8) void {
const v = &p.parked[k].?.view;
for (&v.col_tags) |*t| t.deinit(p.gpa);
if (v.chord_arg) |a| p.gpa.free(a);
- v.presentation.deinit(p.gpa);
for (p.panes) |s| if (s) |pane| {
const sels = pane.pv[k].body.sels;
if (sels.len > 0) p.gpa.free(sels);
@@ -531,7 +530,6 @@ pub fn deinit(p: *Pardes) void {
const v = &slot.view;
for (&v.col_tags) |*t| t.deinit(p.gpa);
if (v.chord_arg) |a| p.gpa.free(a);
- v.presentation.deinit(p.gpa);
}
p.gpa.destroy(slot);
}
@@ -539,7 +537,7 @@ pub fn deinit(p: *Pardes) void {
/// What drawing a view keeps of its own (its animations, its panels as
/// presented), kept from a frame drawn while it was out.
-const drawn_fields = [_][:0]const u8{ "presentation", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "shell_continuous" };
+const drawn_fields = [_][:0]const u8{ "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "shell_continuous" };
/// Each view but the live one drawn and presented, the live one put back
/// after exactly as it was: no digested field moves, so a replica that
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index 5ad4b7eb..3a9d42df 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -246,7 +246,9 @@ test "settings: every on/off setting the root ctl reads flips when its word is w
if (!on) try std.testing.expect(!std.mem.endsWith(u8, after, " off"));
flipped += 1;
}
- try std.testing.expect(flipped > 20);
+ // A floor, so a ctl that lists none fails: a bare session's on/off
+ // words, Colors to PagerColor, are ten.
+ try std.testing.expect(flipped >= 10);
for ([_][]const u8{ "Colors off", "Wrap off", "Tagbottom on", "Debug on" }) |want|
try std.testing.expectEqualStrings(want, try setting(&s, want[0..std.mem.indexOfScalar(u8, want, ' ').?]));
try s.write("/ctl", "Theme acme\n");
diff --git a/test/column_drag.zig b/test/column_drag.zig
index f8f6344b..0e92e125 100644
--- a/test/column_drag.zig
+++ b/test/column_drag.zig
@@ -45,7 +45,6 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 180, .rows = 30 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.presentation.enabled = false;
p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
for (0..3) |_| {
try std.testing.expect(p.executeBuiltinLine(p.active, "New"));
@@ -125,7 +124,6 @@ test "column grip is separate from compact text and the resize seam" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.presentation.enabled = false;
p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "New"));
try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
@@ -172,7 +170,6 @@ test "column grips stay blank, and muted across focus and hover until grabbed" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 20 });
defer p.deinit();
_ = try p.setTestFile("left\n");
- p.presentation.enabled = false;
p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "New"));
try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
@@ -209,7 +206,6 @@ test "column grip dropped in its own place moves the column's left edge" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.presentation.enabled = false;
try std.testing.expect(p.executeBuiltinLine(0, "New"));
try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
p.update(.tick);
@@ -273,7 +269,6 @@ test "column grip drag previews where the column lands, in the seam beside its r
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.presentation.enabled = false;
for (0..2) |_| {
try std.testing.expect(p.executeBuiltinLine(p.active, "New"));
try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
diff --git a/test/gui-goldens.txt b/test/gui-goldens.txt
index 6b3960d8..1160cf92 100644
--- a/test/gui-goldens.txt
+++ b/test/gui-goldens.txt
@@ -14,4 +14,3 @@
15-theme-acme-light 6e2ba713570d3d2baeaf927218d21f497a43b1d1fc59e7a3eff68f213e5cf7f7
16-debug 776b774f85219e9ced28168e0b90ef4473a8687d1cf14747d21b129dd5aaea98
17-terminal 5f192b2fff53c66d154f4ad310d07c168838172d85cc59ba0fd51720d6abba2e
-18-mid-transition 14746e3f30abc862e3a25a5f6907d135898cb0f963436f4fe7cd6085eee9a874
diff --git a/test/mode.zig b/test/mode.zig
index 463b2748..42e61c79 100644
--- a/test/mode.zig
+++ b/test/mode.zig
@@ -28,7 +28,6 @@ fn customTag(pane: *pardes.Pane, text: []const u8) !void {
test "Mode cycles terminal modes and keeps legacy toggle and custom tags" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100 });
defer p.deinit();
- p.presentation.enabled = false;
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
try std.testing.expectEqual(panes.Text.Mode.tty, pane.body.mode);
@@ -62,7 +61,6 @@ test "Mode from actual tag Exec preserves parked file and output insert transact
for ([_]bool{ false, true }) |normal_tag| {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100 });
defer p.deinit();
- p.presentation.enabled = false;
const pane = try p.setTestFile("ab\n");
if (output) pane.file.?.output = .{ .from = .search };
try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagText(p, p.scratch.allocator(), pane), " Mode") == null);
diff --git a/test/output.zig b/test/output.zig
index e998ac66..c72668b4 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -94,7 +94,6 @@ test "output callers opt into location highlighting instead of matching prose co
defer p.deinit();
p.locations_config.layout = .@"inline";
_ = try p.setTestFile("ordinary\n");
- p.presentation.enabled = false;
if (origin == .cmd and origin.cmd == .LocationsConfig) {
p.locations_config.context = 5;
try std.testing.expect(p.executeBuiltinLine(0, "LocationsConfig"));
@@ -125,7 +124,6 @@ test "location producers retain rendered location match and diagnostic styles" {
defer p.deinit();
p.locations_config.layout = .@"inline";
_ = try p.setTestFile("ordinary\n");
- p.presentation.enabled = false;
const diagnostic = origin == .query and origin.query == .diagnostics;
const code = if (diagnostic) "warning: unused value" else "const value = 42;";
try panes.Output.fillResults(p, 0, "/", origin, "styles", try std.fmt.allocPrint(p.gpa, "source.zig:3:1-3 {s}\n", .{code}), null);
@@ -549,7 +547,7 @@ test "Config with no startup file opens a pane of its name, and Save makes its d
try std.testing.expectEqual(std.Io.File.Kind.directory, made.kind);
}
-test "a window's setting builtins (TaglineSize, Font, transitions) reach the report DumpConfig writes" {
+test "a window's setting builtins (TaglineSize, Font) reach the report DumpConfig writes" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -586,14 +584,7 @@ test "a window's setting builtins (TaglineSize, Font, transitions) reach the rep
try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig"));
const report = p.panes[p.active].?.file.?.content;
// The toggles, Theme and Shell are test/behaviour/settings.zig's, through
- // the root ctl; what is left is a window's (fonts, transitions).
- const transition = if (!builtins.viewCapabilities(p).panel_transitions)
- "PanelSlide unsupported\n"
- else if (p.settings.panel_transition == .off)
- "PanelSlide off\n"
- else
- try std.fmt.bufPrint(&buf, "{s} on\n", .{config.Runtime.findAction(.{ .transition = p.settings.panel_transition }).?.word});
- try std.testing.expect(std.mem.indexOf(u8, report, transition) != null);
+ // the root ctl; what is left is a window's (fonts).
const tagline = if (!builtins.viewCapabilities(p).tagline_font_size)
"TaglineSize unsupported\n"
else
@@ -653,7 +644,6 @@ test "LookNext/LookPrev skips formatted context and selects comment match locati
const source = try p.setTestFile(text);
p.gpa.free(source.file.?.path);
source.file.?.path = try p.gpa.dupe(u8, "/look-walk-context.zig");
- p.presentation.enabled = false;
p.locations_config = .{ .layout = .@"inline", .context = 1, .tscontext = true, .tslocations = tslocations };
const path = source.file.?.path;
const input = try std.fmt.allocPrint(p.gpa, "{s}:4:9 {s}\n{s}:6:9 {s}\n", .{
@@ -1146,7 +1136,6 @@ test "LSP occurrence tint follows the supplied source span through context" {
p.gpa.free(source.file.?.path);
source.file.?.path = try p.gpa.dupe(u8, "/occurrence.zig");
p.locations_config = .{ .layout = .@"inline", .context = 1, .tscontext = true };
- p.presentation.enabled = false;
var input: std.Io.Writer.Allocating = .init(p.gpa);
defer input.deinit();
const start = std.mem.lastIndexOf(u8, snippet, "foo").?;
@@ -1257,7 +1246,6 @@ test "stacked search and LSP results retain source tint navigation and dump owne
defer p.deinit();
try std.testing.expectEqual(.stacked, p.locations_config.layout);
p.locations_config = .{ .context = 1, .tscontext = true, .tslocations = visible };
- p.presentation.enabled = false;
const source = try p.setTestFile(source_text);
p.gpa.free(source.file.?.path);
source.file.?.path = try p.gpa.dupe(u8, "/stacked-界.zig");
diff --git a/test/panes.zig b/test/panes.zig
index 958c35a2..f3ae3cfc 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -2,7 +2,6 @@ const std = @import("std");
const pardes = @import("pardes");
const panes = pardes.panes;
const layout = pardes.layout;
-const animation = pardes.animation;
const Pardes = pardes.Pardes;
const Pane = pardes.Pane;
const Key = pardes.Key;
@@ -37,7 +36,6 @@ const TagLayerTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 16 });
defer p.deinit();
const pane = try p.setTestFile("body\n");
- p.presentation.enabled = false;
p.settings.tag_bottom = bottom;
p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
p.gpa.free(pane.file.?.path);
@@ -72,33 +70,6 @@ const TagLayerTests = struct {
try std.testing.expectEqual(@as(u16, 0), pane.tag_scroll);
try std.testing.expectEqualStrings("body\n", pane.file.?.content);
p.update(.{ .key = .{ .cp = Key.escape } });
- const rect = p.rects[0];
- const track: animation.Track = .{
- .serial = pane.serial,
- .pane = 0,
- .effect = .zoom,
- .frame = 4,
- .frame_count = 10,
- .from = .{ .x = @as(f32, @floatFromInt(rect.x)) + 2, .y = @floatFromInt(rect.y), .w = @floatFromInt(rect.w - 4), .h = @floatFromInt(rect.h) },
- .to = .{ .x = @floatFromInt(rect.x), .y = @floatFromInt(rect.y), .w = @floatFromInt(rect.w), .h = @floatFromInt(rect.h) },
- };
- p.presentation.shown_tracks[0] = track;
- p.presentation.pending = false;
- const shown = track.presented();
- const source_y = @as(f32, @floatFromInt(layer.viewport.y)) + 0.5;
- const painted_x = shown.x + (x / 10 - track.to.x) / track.to.w * shown.w;
- const painted_y = shown.y + (source_y - track.to.y) / track.to.h * shown.h;
- // Each is a first click, whatever cell the one before hit.
- p.last_click = null;
- for ([_]pardes.Mouse.Kind{ .press, .release }) |kind| {
- var event = mouse(layer, x, kind);
- // Hosts inverse the exact painted pixel into the tag envelope;
- // physical routing still receives the original body-grid cell.
- event.col = @intFromFloat(painted_x);
- event.row = @intFromFloat(painted_y);
- p.update(.{ .mouse = event });
- }
- try std.testing.expectEqual(at, @as(usize, @intCast(pane.tag.cur_col)));
}
}
@@ -106,7 +77,6 @@ const TagLayerTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.presentation.enabled = false;
p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "New"));
const second = p.active;
@@ -289,7 +259,6 @@ const TreeContextTests = struct {
const pane = try p.setTestFile(content);
p.gpa.free(pane.file.?.path);
pane.file.?.path = try p.gpa.dupe(u8, "/tree-context.zig");
- p.presentation.enabled = false;
return pane;
}
@@ -486,7 +455,6 @@ const TtySelectionTests = struct {
test "tty selection yields to a new modal cursor selection" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 });
defer p.deinit();
- p.presentation.enabled = false;
const pane = p.panes[0].?;
pane.tty_filter = false;
while (p.nextEffect()) |_| {}
@@ -514,7 +482,6 @@ const TtySelectionTests = struct {
const pane = p.panes[0].?;
pane.body.mode = .tty;
pane.tty_filter = false;
- p.presentation.enabled = false;
while (p.nextEffect()) |_| {}
p.update(.{ .output = .{ .pane = 0, .bytes = if (prompt)
"\x1b]133;A\x07$ \x1b]133;B\x07abc"
@@ -571,7 +538,6 @@ const TtySelectionTests = struct {
for ([_]bool{ false, true }) |reports_mouse| {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 24 });
defer p.deinit();
- p.presentation.enabled = false;
_ = pardes.exec.spawnTty(p, 0);
for (p.panes[0..2]) |slot| {
slot.?.body.mode = .tty;
@@ -727,7 +693,6 @@ const ClickCursorTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 14 });
defer p.deinit();
const pane = try p.setTestFile("zero\none\ntwo\nthree\nalpha beta\nfive\ngamma delta\nseven\n" ++ std.mem.asBytes(&@as([20][5]u8, @splat("tail\n".*))));
- p.presentation.enabled = false;
p.settings.wrap = false;
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
@@ -835,7 +800,6 @@ const TagNameTintTests = struct {
p.custom_theme = theme;
p.chrome_animation.snap(pardes.ChromeTheme.fromTheme(p.theme()));
p.settings.focus_tint = false;
- p.presentation.enabled = false;
}
fn check(p: *Pardes, id: usize, name: []const u8) !usize {
@@ -1586,7 +1550,6 @@ test "a failed Save to another name leaves a clean named file clean" {
test "unplaced terminal panes keep their allocated grid until placement" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
- p.presentation.enabled = false;
while (p.nextEffect()) |_| {}
const id = p.freeSlot().?;
const pane = try p.newShell(id, "");
@@ -1631,7 +1594,6 @@ test "document panes ignore terminal output without allocating terminal state" {
test "removed and recycled pane slots have no stale geometry" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
- p.presentation.enabled = false;
const id = p.freeSlot().?;
const original = try p.newDocPane(id);
pardes.layout.insert(p, 0, 1, id);
@@ -2123,7 +2085,6 @@ const OutputTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 });
defer p.deinit();
_ = try p.setTestFile("notes\n");
- p.presentation.enabled = false;
try std.testing.expect(p.executeBuiltinLine(0, "Help"));
const id = p.active;
const help = p.panes[id].?;
@@ -2200,7 +2161,6 @@ const OutputTests = struct {
defer p.deinit();
p.locations_config.layout = .@"inline";
_ = try p.setTestFile("notes\n");
- p.presentation.enabled = false;
try fillResults(p, 0, "/", .{ .query = .hover }, "", try p.gpa.dupe(u8, "first\nsecond\nthird\n"), null);
const id = for (p.panes, 0..) |slot, id| {
if (slot != null and slot.?.file != null and slot.?.file.?.output != null) break id;
@@ -2210,7 +2170,7 @@ const OutputTests = struct {
var frame: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer frame.deinit();
_ = try p.render(frame.allocator());
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
const rect = p.rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(result);
const y = bodyY(p, rect);
@@ -3701,7 +3661,6 @@ test "Zig keywords keep every rendered byte colored across line-number widths" {
pane.hscroll = view.horizontal;
p.settings.colors = true;
p.settings.wrap = view.wrap;
- p.presentation.enabled = false;
p.sync();
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -3825,7 +3784,6 @@ test {
test "a terminal keeps its tag and two body rows through a squeeze, a drag and a smaller window; a text pane does not" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
- p.presentation.enabled = false;
p.sync();
while (p.nextEffect()) |_| {}
const term = for (p.panes, 0..) |slot, i| {
diff --git a/test/pdf.zig b/test/pdf.zig
index 460a5734..af1f3095 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -46,7 +46,6 @@ const PdfLinkTests = struct {
defer std.testing.allocator.free(path);
const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 100, .rows = 36 });
p.native_images = true;
- p.presentation.enabled = false;
p.panes[0].?.pdf.?.fit = .height;
return p;
}
@@ -2047,7 +2046,6 @@ test "PDF Back and Forward clear selections and land on recorded pages" {
const p = try Pardes.init(std.testing.allocator, .{ .file = "docs/design.pdf", .cols = 80, .rows = 28 });
defer p.deinit();
p.native_images = true;
- p.presentation.enabled = false;
const pane = p.panes[0].?;
const state = pane.pdf.?;
try std.testing.expect(state.page_count > 1);
@@ -2125,7 +2123,6 @@ test "a PDF's jumps: Back after a far jump returns to the exact offset, two plac
const p = try Pardes.init(std.testing.allocator, .{ .file = jumpPdf(), .cols = 80, .rows = 28 });
defer p.deinit();
p.native_images = true;
- p.presentation.enabled = false;
const id = p.active;
const pane = p.panes[id].?;
const pv = pane.pdf.?;
@@ -2166,7 +2163,6 @@ test "a PDF's jumps: JumpScope file keeps to the PDF, and a closed PDF reopens a
const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 28 });
defer p.deinit();
p.native_images = true;
- p.presentation.enabled = false;
try std.testing.expectEqual(config.Runtime.JumpScope.file, p.settings.jump_scope);
const doc = p.active;
const pane = p.panes[doc].?;
diff --git a/test/process/window.zig b/test/process/window.zig
index 49c2d4f0..144013e1 100644
--- a/test/process/window.zig
+++ b/test/process/window.zig
@@ -55,7 +55,7 @@ fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, seed
var arena = std.heap.ArenaAllocator.init(gpa);
defer arena.deinit();
const a = arena.allocator();
- const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nPanelSlide\n", .{motion});
+ const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\n", .{motion});
var d = try process.Detached.start(gpa, exe, "monkey", .{ .init = init, .grid = .{ 80, 28 }, .env = &.{
.{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "0" },
} });
@@ -240,8 +240,7 @@ fn goldens(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
.root = root,
.file = root ++ "/shapes.zig",
.init = "Shell /bin/sh\nTheme forge\nMessageLinger 0\n",
- // The virtual clock: a transition's frames are the same frames on
- // any machine, so one partway through can be hashed too.
+ // The virtual clock: the same frames on any machine.
.grid = .{ 120, 40 },
.env = &.{ .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "7" } },
});
@@ -339,11 +338,6 @@ fn goldens(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
if (process.nowMs() > deadline) return error.NoTerminalOutput;
}
try shot(&d, a, &results, keep, "17-terminal", "latest.ppm");
- // Partway through a transition: the panes, the picture among them,
- // sliding over for a new column, frame 6 of PanelSlide's 12.
- try f.write("/ctl", "PanelSlide\n");
- try f.write(f.at("/pane/{d}/exec", .{first}), "Newcol\n");
- try shot(&d, a, &results, keep, "18-mid-transition", "transition-6.ppm");
const goldens_path = "test/gui-goldens.txt";
if (std.mem.eql(u8, mode, "update")) {
diff --git a/test/snapshots/ttyhelp.golden b/test/snapshots/ttyhelp.golden
index 71545a43..f60fe579 100644
--- a/test/snapshots/ttyhelp.golden
+++ b/test/snapshots/ttyhelp.golden
@@ -33,12 +33,12 @@
|11: 6 SPC P ClipPasteBefore
|12: 7 SPC R ClipReplace
|13: 8 SPC Y ClipYankMain
-|14: 9 SPC a a PanelAscii
-|15: 10 SPC a c PanelCurtain
-|16: 11 SPC a d PanelDissolve
-|17: 12 SPC a e PanelEdges
-|18: 13 SPC a f PanelFall
-|19: 14 SPC a r PanelScramble
-|20: 15 SPC a s PanelSlide
+|14: 9 SPC c d Delcol
+|15: 10 SPC c j Joincol topbar
+|16: 11 SPC c n Newcol topbar
+|17: 12 SPC d Del
+|18: 13 SPC f c Config topbar
+|19: 14 SPC f f Find topbar
+|20: 15 SPC f g Grep topbar
== snap leaderworks grid=100x31 cursor=7,6
|3: $
diff --git a/test/snapshots/ttyhelp.snap b/test/snapshots/ttyhelp.snap
index 24399848..30148d6c 100644
--- a/test/snapshots/ttyhelp.snap
+++ b/test/snapshots/ttyhelp.snap
@@ -17,8 +17,8 @@ stable 600 10000
key space
key ?
# The bare-tty boot now opens an empty pane under the shell, so the index is
-# half as tall and `SPC c n` is below its fold: wait on a row that is on
-# screen. What the leader route produced is the snapshot below, not this.
-wait 10000 SPC a a PanelAscii
+# half as tall: wait on a row that is on screen. What the leader route
+# produced is the snapshot below, not this.
+wait 10000 SPC Y ClipYankMain
stable 700 15000
snap leaderworks