summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/Post.zig19
-rw-r--r--src/gui/gui.zig32
2 files changed, 24 insertions, 27 deletions
diff --git a/src/gui/Post.zig b/src/gui/Post.zig
index 8d0e14d9..17e8d7e9 100644
--- a/src/gui/Post.zig
+++ b/src/gui/Post.zig
@@ -623,15 +623,15 @@ test "the uniform block is ghostty's, offset for offset, and the prefix names it
try std.testing.expectEqual(@offsetOf(GhosttyUniforms, "selection_background_color"), @offsetOf(Uniforms, "selection_foreground_color"));
// The prefix's block, member by member, in ghostty's GLSL names and types.
const glsl = [_]struct { []const u8, []const u8 }{
- .{ "vec3", "iResolution" }, .{ "float", "iTime" }, .{ "float", "iTimeDelta" },
- .{ "float", "iFrameRate" }, .{ "int", "iFrame" }, .{ "float", "iChannelTime[4]" },
- .{ "vec3", "iChannelResolution[4]" }, .{ "vec4", "iMouse" }, .{ "vec4", "iDate" },
- .{ "float", "iSampleRate" }, .{ "vec4", "iCurrentCursor" }, .{ "vec4", "iPreviousCursor" },
- .{ "vec4", "iCurrentCursorColor" }, .{ "vec4", "iPreviousCursorColor" }, .{ "int", "iCurrentCursorStyle" },
- .{ "int", "iPreviousCursorStyle" }, .{ "int", "iCursorVisible" }, .{ "float", "iTimeCursorChange" },
- .{ "float", "iTimeFocus" }, .{ "int", "iFocus" }, .{ "vec3", "iPalette[256]" },
- .{ "vec3", "iBackgroundColor" }, .{ "vec3", "iForegroundColor" }, .{ "vec3", "iCursorColor" },
- .{ "vec3", "iCursorText" }, .{ "vec3", "iSelectionForegroundColor" }, .{ "vec3", "iSelectionBackgroundColor" },
+ .{ "vec3", "iResolution" }, .{ "float", "iTime" }, .{ "float", "iTimeDelta" },
+ .{ "float", "iFrameRate" }, .{ "int", "iFrame" }, .{ "float", "iChannelTime[4]" },
+ .{ "vec3", "iChannelResolution[4]" }, .{ "vec4", "iMouse" }, .{ "vec4", "iDate" },
+ .{ "float", "iSampleRate" }, .{ "vec4", "iCurrentCursor" }, .{ "vec4", "iPreviousCursor" },
+ .{ "vec4", "iCurrentCursorColor" }, .{ "vec4", "iPreviousCursorColor" }, .{ "int", "iCurrentCursorStyle" },
+ .{ "int", "iPreviousCursorStyle" }, .{ "int", "iCursorVisible" }, .{ "float", "iTimeCursorChange" },
+ .{ "float", "iTimeFocus" }, .{ "int", "iFocus" }, .{ "vec3", "iPalette[256]" },
+ .{ "vec3", "iBackgroundColor" }, .{ "vec3", "iForegroundColor" }, .{ "vec3", "iCursorColor" },
+ .{ "vec3", "iCursorText" }, .{ "vec3", "iSelectionForegroundColor" }, .{ "vec3", "iSelectionBackgroundColor" },
};
try std.testing.expectEqual(ours.field_names.len, glsl.len);
// Its three blocks (Globals, Palette, Colors) read as one, in order.
@@ -673,7 +673,6 @@ test "a moved cursor becomes the previous one, stamped with the time of the move
try std.testing.expectEqual([4]f32{ 1.0 / 255.0, 2.0 / 255.0, 3.0 / 255.0, 1 }, post.uniforms.selection_foreground_color);
}
-
test "a still pass asks for no idle frames; one that reads the clock does" {
var post: Post = .{};
const fake: *Pipeline = @ptrFromInt(0x1000);
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index b8687fd3..f0dd0682 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -1888,7 +1888,6 @@ const Gui = struct {
sel_glow: SelGlow = .{},
hover_glow: SelGlow = .{},
/// G14: the cells last drawn and when each last changed.
-
/// The cursor's blink (blinkNow): when the frame drawn last arrived,
/// a redraw owed for an edge, and this frame's cursor mode and alpha.
frame_arrival_ns: u64 = 0,
@@ -2291,7 +2290,7 @@ fn setTransitionFields(
instance.present_y0 = presented[1];
instance.present_x1 = presented[2];
instance.present_y1 = presented[3];
- instance.effect = @intFromEnum(active.effect);
+ instance.effect = @backingInt(active.effect);
instance.progress_bits = @bitCast(active.amount());
instance.serial = active.serial;
instance.cell_coord = cell_coord;
@@ -3356,8 +3355,8 @@ fn setStdinRaw() !void {
term.lflag.ICANON = false;
term.lflag.IEXTEN = false;
term.lflag.ISIG = false;
- term.cc[@intFromEnum(posix.V.MIN)] = 1;
- term.cc[@intFromEnum(posix.V.TIME)] = 0;
+ term.cc[@backingInt(posix.V.MIN)] = 1;
+ term.cc[@backingInt(posix.V.TIME)] = 0;
try posix.tcsetattr(0, .NOW, term);
}
@@ -5484,7 +5483,6 @@ test "a notch scrolls the core at once and the picture glides after it, a wrappe
try std.testing.expect(!g.glide.pending and !g.glide.moving());
}
-
fn resetScroll(g: *Gui) void {
g.scroll_pane = null;
g.scroll_delta = 0;
@@ -5519,13 +5517,15 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void {
const down = left > 0;
left += if (down) -1 else 1;
const was = pane.scroll();
- core.update(.{ .mouse = .{
- .button = if (down) .wheel_down else .wheel_up,
- .kind = .press,
- .col = g.scroll_col,
- .row = g.scroll_row,
- .shift = true, // pardes's own scroll, never a program's wheel
- } });
+ core.update(.{
+ .mouse = .{
+ .button = if (down) .wheel_down else .wheel_up,
+ .kind = .press,
+ .col = g.scroll_col,
+ .row = g.scroll_row,
+ .shift = true, // pardes's own scroll, never a program's wheel
+ },
+ });
if (pane.scroll() == was) {
resetScroll(g);
return;
@@ -7251,7 +7251,7 @@ test "a rising pane past its mark stays inside its box" {
var g: Gui = undefined;
g.cell_w = 10;
g.cell_h = 20;
- var track: pardes.animation.Track = .{ .serial = 3, .phase = .opening, .effect = .vertical, .motion = @intFromEnum(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 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) {
@@ -8788,7 +8788,6 @@ fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f3
instance.effect |= checker_bit;
}
-
/// How a lift of 0 to 1 stands off the page: the shadow's blur and offset
/// in cell heights, and its darkest, where it leaves the caster's edge.
/// Within ยง8.2's budget: sigma 0.4-0.8 cell, at most 30% darker at the edge.
@@ -8926,7 +8925,6 @@ fn clipToBodies(g: *Gui, gpa: std.mem.Allocator, first: usize, bodies: []const [
};
}
-
/// Like shadowCeiling for a light colour laid over at `a` (sRGB blend, as
/// the decor pipeline blends a colour that is not black): the largest `a`
/// that keeps text and page apart by min(their contrast, 4.5).
@@ -10099,7 +10097,7 @@ test "decor is read from the regions, each pane's in its own group" {
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, @intFromEnum(pardes.animation.Transition.slide)), item.effect);
+ 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);
}
@@ -10468,7 +10466,7 @@ fn appendCursorGlide(g: *Gui, surface: *const pardes.Surface, builder: *OverlayB
fn appendWorkspacePet(g: *Gui, core: ?*const pardes.Pardes, surface: *const pardes.Surface, builder: *OverlayBuilder) void {
const p = core orelse return;
- const kind: pet.Kind = @enumFromInt(@intFromEnum(p.settings.pet));
+ const kind: pet.Kind = @fromBackingInt(@intCast(@backingInt(p.settings.pet)));
if (kind == .off or surface.rows == 0 or surface.cols == 0) {
g.pet_state = .{};
return;