summaryrefslogtreecommitdiff
path: root/src/macos.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos.zig')
-rw-r--r--src/macos.zig124
1 files changed, 63 insertions, 61 deletions
diff --git a/src/macos.zig b/src/macos.zig
index 20463481..50fa04fa 100644
--- a/src/macos.zig
+++ b/src/macos.zig
@@ -724,7 +724,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void {
// in Debug, libc's malloc otherwise. libc's measured at least as fast as
// std.heap.smp_allocator everywhere and faster on MuPDF's page-sized
// rasters, so this shell no longer differs.
- const gpa = if (builtin.mode == .Debug) debug_gpa.allocator() else std.heap.c_allocator;
+ const gpa = if (builtin.mode == .debug) debug_gpa.allocator() else std.heap.c_allocator;
const allocs = pardes.memory.init(gpa);
errdefer pardes.memory.deinit();
@@ -858,7 +858,7 @@ export fn pardes_deinit() void {
st.gpa.destroy(st.threaded);
pardes.memory.deinit();
// Leaks are logged and do not fail, as std.start treats the others'.
- if (builtin.mode == .Debug) {
+ if (builtin.mode == .debug) {
_ = debug_gpa.deinit();
debug_gpa = .init;
}
@@ -1110,7 +1110,7 @@ fn refreshCwds(ctx: ?*anyopaque) void {
stale.* = false;
const pt = st.ptys[id] orelse continue;
var buf: [1024]u8 = undefined;
- if (host_io.shellCwd(pt.pid, &buf)) |wd| st.core.setCwd(id, wd);
+ if (host_io.ttyCwd(pt.pid, pt.file.handle, st.core.settings.shell.effective.get(), &buf)) |wd| st.core.setCwd(id, wd);
}
}
@@ -1717,18 +1717,20 @@ fn mouseWithHit(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u3
3 => .drag,
else => return,
};
- st.core.update(.{ .mouse = .{
- .body_hit = hit,
- .tag_hit = tag_hit,
- .button = button,
- .kind = kind,
- .col = col,
- .row = row,
- .ctrl = mods & 1 != 0,
- // Option-click is B2 and Cmd-click B3 (mouse.emulateButton).
- .alt = mods & 2 != 0,
- .super = mods & 8 != 0,
- } });
+ st.core.update(.{
+ .mouse = .{
+ .body_hit = hit,
+ .tag_hit = tag_hit,
+ .button = button,
+ .kind = kind,
+ .col = col,
+ .row = row,
+ .ctrl = mods & 1 != 0,
+ // Option-click is B2 and Cmd-click B3 (mouse.emulateButton).
+ .alt = mods & 2 != 0,
+ .super = mods & 8 != 0,
+ },
+ });
}
export fn pardes_pointer_leave() void {
@@ -2156,7 +2158,7 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 {
const layer = &st.core.surface.tag_layers[index];
return switch (field) {
0 => layer.cols,
- 1 => @intFromEnum(layer.kind),
+ 1 => @backingInt(layer.kind),
2 => layer.id,
3 => layer.serial,
4 => layer.viewport.x,
@@ -2238,7 +2240,7 @@ export fn pardes_pointer_shape() u32 {
pardes.turn.wake();
defer pardes.turn.rest();
const st = &(state orelse return 0);
- return @intFromEnum(st.core.surface.pointer_shape);
+ return @backingInt(st.core.surface.pointer_shape);
}
export fn pardes_cursor_y() i32 {
@@ -2646,7 +2648,7 @@ fn encodeAttrs(style: pardes.CellStyle) u16 {
attrs |= @as(u16, @intFromBool(style.reverse)) << 4;
attrs |= @as(u16, @intFromBool(style.invisible)) << 5;
attrs |= @as(u16, @intFromBool(style.strikethrough)) << 6;
- attrs |= @as(u16, @intFromEnum(style.ul)) << 8;
+ attrs |= @as(u16, @backingInt(style.ul)) << 8;
return attrs;
}
@@ -2871,22 +2873,22 @@ test "pardes.h matches the Zig boundary" {
try expectEqual(@offsetOf(c.pardes_cell_s, "len"), @offsetOf(Cell, "len"));
try expectEqual(@offsetOf(c.pardes_cell_s, "flags"), @offsetOf(Cell, "flags"));
try expectEqual(@sizeOf(c.pardes_scene_s), @sizeOf(Scene));
- inline for (@typeInfo(Scene).@"struct".fields) |field|
- try expectEqual(@offsetOf(c.pardes_scene_s, field.name), @offsetOf(Scene, field.name));
+ inline for (@typeInfo(Scene).@"struct".field_names) |name|
+ try expectEqual(@offsetOf(c.pardes_scene_s, name), @offsetOf(Scene, name));
try expectEqual(@sizeOf(c.pardes_panel_box_s), @sizeOf(PanelBox));
- inline for (@typeInfo(PanelBox).@"struct".fields) |field|
- try expectEqual(@offsetOf(c.pardes_panel_box_s, field.name), @offsetOf(PanelBox, field.name));
+ inline for (@typeInfo(PanelBox).@"struct".field_names) |name|
+ try expectEqual(@offsetOf(c.pardes_panel_box_s, name), @offsetOf(PanelBox, name));
try expectEqual(@sizeOf(c.pardes_panel_track_s), @sizeOf(PanelTrack));
- inline for (@typeInfo(PanelTrack).@"struct".fields) |field| {
- const c_name = comptime if (std.mem.eql(u8, field.name, "motion"))
+ inline for (@typeInfo(PanelTrack).@"struct".field_names) |name| {
+ const c_name = comptime if (std.mem.eql(u8, name, "motion"))
"reserved0"
else
- field.name;
- try expectEqual(@offsetOf(c.pardes_panel_track_s, c_name), @offsetOf(PanelTrack, field.name));
+ name;
+ try expectEqual(@offsetOf(c.pardes_panel_track_s, c_name), @offsetOf(PanelTrack, name));
}
try expectEqual(@sizeOf(c.pardes_image_s), @sizeOf(Image));
- inline for (@typeInfo(Image).@"struct".fields) |field|
- try expectEqual(@offsetOf(c.pardes_image_s, field.name), @offsetOf(Image, field.name));
+ inline for (@typeInfo(Image).@"struct".field_names) |name|
+ try expectEqual(@offsetOf(c.pardes_image_s, name), @offsetOf(Image, name));
try expectEqual(@sizeOf(c.pardes_runtime_s), @sizeOf(Runtime));
try expectEqual(@as(u32, c.PARDES_COLOR_DEFAULT), color_default);
@@ -2896,21 +2898,21 @@ test "pardes.h matches the Zig boundary" {
try expectEqual(@as(u8, c.PARDES_CELL_HOVER), cell_flag_hover);
try expectEqual(@as(u16, c.PARDES_TOPBAR_H), pardes.TOPBAR_H);
try expectEqual(@as(u32, c.PARDES_SCENE_CRT), scene_flag_crt);
- try expectEqual(@as(u8, c.PARDES_PANEL_OPENING), @intFromEnum(animation.Phase.opening));
- try expectEqual(@as(u8, c.PARDES_PANEL_MOVING), @intFromEnum(animation.Phase.moving));
- try expectEqual(@as(u8, c.PARDES_PANEL_CLOSING), @intFromEnum(animation.Phase.closing));
- try expectEqual(@as(u8, c.PARDES_PANEL_OFF), @intFromEnum(animation.Transition.off));
- try expectEqual(@as(u8, c.PARDES_PANEL_SLIDE), @intFromEnum(animation.Transition.slide));
- try expectEqual(@as(u8, c.PARDES_PANEL_ZOOM), @intFromEnum(animation.Transition.zoom));
- try expectEqual(@as(u8, c.PARDES_PANEL_DISSOLVE), @intFromEnum(animation.Transition.dissolve));
- try expectEqual(@as(u8, c.PARDES_PANEL_ASCII), @intFromEnum(animation.Transition.ascii));
- try expectEqual(@as(u8, c.PARDES_PANEL_VERTICAL), @intFromEnum(animation.Transition.vertical));
- try expectEqual(@as(u8, c.PARDES_PANEL_EDGES), @intFromEnum(animation.Transition.edges));
- try expectEqual(@as(u8, c.PARDES_PANEL_FALL), @intFromEnum(animation.Transition.fall));
- try expectEqual(@as(u8, c.PARDES_PANEL_WAVE), @intFromEnum(animation.Transition.wave));
- try expectEqual(@as(u8, c.PARDES_PANEL_CURTAIN), @intFromEnum(animation.Transition.curtain));
- try expectEqual(@as(u8, c.PARDES_PANEL_SCRAMBLE), @intFromEnum(animation.Transition.scramble));
- try expectEqual(@as(u8, c.PARDES_PANEL_TYPEWRITER), @intFromEnum(animation.Transition.typewriter));
+ try expectEqual(@as(u8, c.PARDES_PANEL_OPENING), @backingInt(animation.Phase.opening));
+ try expectEqual(@as(u8, c.PARDES_PANEL_MOVING), @backingInt(animation.Phase.moving));
+ try expectEqual(@as(u8, c.PARDES_PANEL_CLOSING), @backingInt(animation.Phase.closing));
+ try expectEqual(@as(u8, c.PARDES_PANEL_OFF), @backingInt(animation.Transition.off));
+ try expectEqual(@as(u8, c.PARDES_PANEL_SLIDE), @backingInt(animation.Transition.slide));
+ try expectEqual(@as(u8, c.PARDES_PANEL_ZOOM), @backingInt(animation.Transition.zoom));
+ try expectEqual(@as(u8, c.PARDES_PANEL_DISSOLVE), @backingInt(animation.Transition.dissolve));
+ try expectEqual(@as(u8, c.PARDES_PANEL_ASCII), @backingInt(animation.Transition.ascii));
+ try expectEqual(@as(u8, c.PARDES_PANEL_VERTICAL), @backingInt(animation.Transition.vertical));
+ try expectEqual(@as(u8, c.PARDES_PANEL_EDGES), @backingInt(animation.Transition.edges));
+ try expectEqual(@as(u8, c.PARDES_PANEL_FALL), @backingInt(animation.Transition.fall));
+ try expectEqual(@as(u8, c.PARDES_PANEL_WAVE), @backingInt(animation.Transition.wave));
+ try expectEqual(@as(u8, c.PARDES_PANEL_CURTAIN), @backingInt(animation.Transition.curtain));
+ try expectEqual(@as(u8, c.PARDES_PANEL_SCRAMBLE), @backingInt(animation.Transition.scramble));
+ try expectEqual(@as(u8, c.PARDES_PANEL_TYPEWRITER), @backingInt(animation.Transition.typewriter));
try expectEqual(@as(u21, c.PARDES_KEY_ENTER), pardes.Key.enter);
try expectEqual(@as(u21, c.PARDES_KEY_ESCAPE), pardes.Key.escape);
@@ -2926,24 +2928,24 @@ test "pardes.h matches the Zig boundary" {
try expectEqual(@as(u21, c.PARDES_KEY_PAGE_DOWN), pardes.Key.page_down);
try expectEqual(@as(u21, c.PARDES_KEY_DELETE), pardes.Key.delete);
- try expectEqual(c.PARDES_MOUSE_LEFT, @intFromEnum(pardes.Mouse.Button.left));
- try expectEqual(c.PARDES_MOUSE_MIDDLE, @intFromEnum(pardes.Mouse.Button.middle));
- try expectEqual(c.PARDES_MOUSE_RIGHT, @intFromEnum(pardes.Mouse.Button.right));
- try expectEqual(c.PARDES_MOUSE_WHEEL_UP, @intFromEnum(pardes.Mouse.Button.wheel_up));
- try expectEqual(c.PARDES_MOUSE_WHEEL_DOWN, @intFromEnum(pardes.Mouse.Button.wheel_down));
- try expectEqual(c.PARDES_MOUSE_WHEEL_LEFT, @intFromEnum(pardes.Mouse.Button.wheel_left));
- try expectEqual(c.PARDES_MOUSE_WHEEL_RIGHT, @intFromEnum(pardes.Mouse.Button.wheel_right));
- try expectEqual(c.PARDES_MOUSE_NONE, @intFromEnum(pardes.Mouse.Button.none));
- try expectEqual(c.PARDES_MOUSE_BACK, @intFromEnum(pardes.Mouse.Button.back));
- try expectEqual(c.PARDES_MOUSE_FORWARD, @intFromEnum(pardes.Mouse.Button.forward));
- try expectEqual(c.PARDES_MOUSE_PRESS, @intFromEnum(pardes.Mouse.Kind.press));
- try expectEqual(c.PARDES_MOUSE_RELEASE, @intFromEnum(pardes.Mouse.Kind.release));
- try expectEqual(c.PARDES_MOUSE_MOTION, @intFromEnum(pardes.Mouse.Kind.motion));
- try expectEqual(c.PARDES_MOUSE_DRAG, @intFromEnum(pardes.Mouse.Kind.drag));
+ try expectEqual(c.PARDES_MOUSE_LEFT, @backingInt(pardes.Mouse.Button.left));
+ try expectEqual(c.PARDES_MOUSE_MIDDLE, @backingInt(pardes.Mouse.Button.middle));
+ try expectEqual(c.PARDES_MOUSE_RIGHT, @backingInt(pardes.Mouse.Button.right));
+ try expectEqual(c.PARDES_MOUSE_WHEEL_UP, @backingInt(pardes.Mouse.Button.wheel_up));
+ try expectEqual(c.PARDES_MOUSE_WHEEL_DOWN, @backingInt(pardes.Mouse.Button.wheel_down));
+ try expectEqual(c.PARDES_MOUSE_WHEEL_LEFT, @backingInt(pardes.Mouse.Button.wheel_left));
+ try expectEqual(c.PARDES_MOUSE_WHEEL_RIGHT, @backingInt(pardes.Mouse.Button.wheel_right));
+ try expectEqual(c.PARDES_MOUSE_NONE, @backingInt(pardes.Mouse.Button.none));
+ try expectEqual(c.PARDES_MOUSE_BACK, @backingInt(pardes.Mouse.Button.back));
+ try expectEqual(c.PARDES_MOUSE_FORWARD, @backingInt(pardes.Mouse.Button.forward));
+ try expectEqual(c.PARDES_MOUSE_PRESS, @backingInt(pardes.Mouse.Kind.press));
+ try expectEqual(c.PARDES_MOUSE_RELEASE, @backingInt(pardes.Mouse.Kind.release));
+ try expectEqual(c.PARDES_MOUSE_MOTION, @backingInt(pardes.Mouse.Kind.motion));
+ try expectEqual(c.PARDES_MOUSE_DRAG, @backingInt(pardes.Mouse.Kind.drag));
- try expectEqual(c.PARDES_HAPTIC_NONE, @intFromEnum(pardes.Haptic.none));
- try expectEqual(c.PARDES_HAPTIC_EXEC, @intFromEnum(pardes.Haptic.exec));
- try expectEqual(c.PARDES_HAPTIC_LOOK, @intFromEnum(pardes.Haptic.look));
+ try expectEqual(c.PARDES_HAPTIC_NONE, @backingInt(pardes.Haptic.none));
+ try expectEqual(c.PARDES_HAPTIC_EXEC, @backingInt(pardes.Haptic.exec));
+ try expectEqual(c.PARDES_HAPTIC_LOOK, @backingInt(pardes.Haptic.look));
try expectEqual(@as(u16, c.PARDES_ATTR_BOLD), encodeAttrs(.{ .bold = true }));
try expectEqual(@as(u16, c.PARDES_ATTR_DIM), encodeAttrs(.{ .dim = true }));
@@ -3177,7 +3179,7 @@ test "mac tag layer ABI preserves logical capacity and physical grip" {
});
try std.testing.expectEqual(@as(u32, 11), pardes_tag_layer_value(0, 8));
try std.testing.expectEqual(@as(u8, 'Z'), pardes_tag_layer_cells(0).?[11].text[0]);
- var canonical: [24]Cell = @splat(encodeCell(.{ .text = .{'G'} ++ .{0} ** 6, .len = 1, .default = false }));
+ var canonical: [24]Cell = @splat(encodeCell(.{ .text = .{ 'G', 0, 0, 0, 0, 0, 0 }, .len = 1, .default = false }));
var source: [24]pardes.Cell = @splat(.{});
blankTagCells(&canonical, 8, 3, &source, &core.surface.tag_layers);
try std.testing.expectEqual(@as(u8, 'G'), canonical[9].text[0]);