summaryrefslogtreecommitdiff
path: root/src/macos.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos.zig')
-rw-r--r--src/macos.zig44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/macos.zig b/src/macos.zig
index 685e9d2f..3fa018c0 100644
--- a/src/macos.zig
+++ b/src/macos.zig
@@ -228,7 +228,7 @@ const FileWatches = struct {
if (!std.mem.eql(u8, watched.path, path)) return;
switch (watched.generation_on_disk) {
.text => watched.generation_on_disk = .{ .text = hash },
- .pdf => {},
+ .kind => {},
}
}
@@ -289,9 +289,9 @@ test "mac file watch generations own paths, coalesce, and reject stale callbacks
try std.testing.expect(!watches.retry(3, second));
try std.testing.expect(watches.entries[3] == null);
- _ = try watches.replace(std.testing.allocator, 4, "/tmp/book.pdf", 77, .{ .pdf = null });
+ _ = try watches.replace(std.testing.allocator, 4, "/tmp/book.pdf", 77, .{ .kind = null });
watches.restampText(4, "/tmp/book.pdf", 123);
- try std.testing.expect(watches.entries[4].?.generation_on_disk.pdf == null);
+ try std.testing.expect(watches.entries[4].?.generation_on_disk.kind == null);
}
const file_watcher_swift = @embedFile("macos/Sources/FileWatcher.swift");
@@ -499,7 +499,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void {
.boot = .tty,
.frame_allocator = allocs.frame,
.image_allocator = allocs.image,
- .pdf_allocator = allocs.pdf,
+
.tree_sitter_allocator = allocs.tree_sitter,
};
if (captureEnv(config_arena.allocator())) |*env| {
@@ -510,14 +510,9 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void {
if (found.dir) |d| crash.setDir(d);
}
- if (comptime pardes.pdf_enabled) {
- pardes.TerminalImages.start(io, allocs.image);
- pardes.pdf.start(allocs.pdf);
- }
- errdefer if (comptime pardes.pdf_enabled) {
- pardes.TerminalImages.stop();
- pardes.pdf.stop();
- };
+ pardes.TerminalImages.start(io, allocs.image);
+ pardes.Kind.heap = allocs.addon;
+ errdefer pardes.TerminalImages.stop();
pardes.syntax.start(allocs.tree_sitter);
errdefer pardes.syntax.stop();
@@ -607,10 +602,7 @@ export fn pardes_deinit() void {
if (st.changed_cells.len > 0) st.gpa.free(st.changed_cells);
if (st.images.len > 0) st.gpa.free(st.images);
st.core.deinit();
- if (comptime pardes.pdf_enabled) {
- pardes.TerminalImages.stop();
- pardes.pdf.stop();
- }
+ pardes.TerminalImages.stop();
pardes.syntax.stop();
st.config_arena.deinit();
st.prompt_rcs.deinit();
@@ -870,7 +862,7 @@ fn refreshCwds(ctx: ?*anyopaque) void {
fn paneWatchPath(core: *const pardes.Pardes, pane: u8) ?[]const u8 {
const value = core.panes[pane] orelse return null;
if (value.file) |file| return file.path;
- if (comptime pardes.pdf_enabled) if (value.pdfPath()) |path| return path;
+ if (value.addon) |k| if (k.path.len > 0) return k.path;
return null;
}
@@ -878,8 +870,8 @@ fn watchInitialGeneration(st: *State, pane: u8, path: []const u8) ?file_watch.Ge
const value = st.core.panes[pane] orelse return null;
if (value.file) |file| if (std.mem.eql(u8, file.path, path))
return .{ .text = std.hash.Wyhash.hash(0, file.content) };
- if (comptime pardes.pdf_enabled) if (value.pdf) |pdf| if (std.mem.eql(u8, pdf.path, path))
- return .{ .pdf = null };
+ if (value.addon) |k| if (std.mem.eql(u8, k.path, path))
+ return .{ .kind = null };
return null;
}
@@ -943,7 +935,7 @@ fn reloadWatchedTheme(st: *State, announce: bool) bool {
const hash = std.hash.Wyhash.hash(0, bytes);
switch (watched.generation_on_disk) {
.text => |accepted| if (accepted == hash) return false,
- .pdf => unreachable,
+ .kind => unreachable,
}
if (!colors.loadThemeFile(st.core, watched.serial, bytes, true)) return false;
const live = if (st.file_watches.entries[theme_watch_pane]) |*entry| entry else return false;
@@ -994,9 +986,8 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool {
active.retries_left = 0;
break :text .committed;
},
- .pdf => |old_identity| pdf: {
- if (comptime !pardes.pdf_enabled) break :pdf .no_change;
- const state_before = if (current.pdf) |pdf_before| pdf_before else break :pdf .no_change;
+ .kind => |old_identity| pdf: {
+ const state_before = if (current.addon) |k| k else break :pdf .no_change;
if (!std.mem.eql(u8, state_before.path, watched.path)) break :pdf .no_change;
const before = file_watch.identify(st.io, watched.path) catch {
retryWatchedFile(st, pane, generation);
@@ -1010,7 +1001,7 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool {
const after = st.core.panes[pane] orelse break :pdf .changed_uncommitted;
if (after.serial != watched.serial) break :pdf .changed_uncommitted;
- const pdf_state = if (after.pdf) |pdf_after| pdf_after else break :pdf .changed_uncommitted;
+ const pdf_state = if (after.addon) |k| k else break :pdf .changed_uncommitted;
if (!std.mem.eql(u8, pdf_state.path, watched.path)) break :pdf .changed_uncommitted;
const after_identity = file_watch.identify(st.io, watched.path) catch {
retryWatchedFile(st, pane, generation);
@@ -1023,7 +1014,7 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool {
const active = if (st.file_watches.entries[pane]) |*entry| entry else break :pdf .changed_uncommitted;
if (active.generation != generation or active.serial != after.serial)
break :pdf .changed_uncommitted;
- active.generation_on_disk = .{ .pdf = after_identity };
+ active.generation_on_disk = .{ .kind = after_identity };
active.retries_left = 0;
break :pdf .committed;
},
@@ -2099,7 +2090,6 @@ export fn pardes_active_dirty() bool {
fn activeFilePath(st: *State) ?[]const u8 {
const pane = st.core.panes[st.core.view().active] orelse return null;
if (pane.file) |*f| return if (f.output == null) f.path else null;
- if (comptime pardes.pdf_enabled) if (pane.pdfPath()) |path| return path;
if (pane.addon) |k| return k.path;
return null;
}
@@ -2820,7 +2810,7 @@ test "mac row metrics ABI preserves PDF cell dimensions and the unrendered grid"
state.?.config_arena.deinit();
state = null;
}
- if (comptime pardes.pdf_enabled) core.view().cell_pixels = .{ .w = 22, .h = 39 };
+ core.view().cell_pixels = .{ .w = 22, .h = 39 };
const pixels = core.view().cell_pixels;
try std.testing.expectEqual(@as(u16, 0), core.surface.cols);
pardes_row_metrics(22, 39, 17, 30);