diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e01653..cd7b474 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - uses: mlugg/setup-zig@v1 with: - version: 0.13.0 + version: "master" - run: zig build lint: diff --git a/.gitignore b/.gitignore index 260156c..365abe3 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ target/ *.jpg src/temp-main.zig lima.yaml +.vscode +vaxis.log \ No newline at end of file diff --git a/build.zig b/build.zig index a133207..5a16b8a 100755 --- a/build.zig +++ b/build.zig @@ -98,6 +98,8 @@ pub fn build(b: *std.Build) void { exe.root_module.addImport("vaxis", deps.vaxis.module("vaxis")); exe.root_module.addImport("fzwatch", deps.fzwatch.module("fzwatch")); + exe.root_module.addAnonymousImport("metadata", .{ .root_source_file = b.path("build.zig.zon") }); + if (useVendorMupdf) { exe.step.dependOn(&mupdf_build_step.step); addMupdfStatic(exe, b, location); diff --git a/build.zig.zon b/build.zig.zon index 02b3361..82d9d10 100755 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,19 +1,19 @@ .{ .name = "fancy-cat", - .version = "0.3.0", - .minimum_zig_version = "0.13.0", + .version = "0.4.0", + .minimum_zig_version = "0.14.0", .dependencies = .{ .vaxis = .{ - .url = "https://github.com/freref/libvaxis/archive/b2e2588e69bb227a16ec50bdb3bedabe48b7f58a.tar.gz", - .hash = "122098b207673eb55bf51b9981b7b7f5c852149dac82d49d70f07c7227323f8c0617", + .url = "https://github.com/freref/libvaxis/archive/d409f2f168192374aa7c625f61f6fe64fdb66818.zip", + .hash = "1220ef263fb9e45c2725b3781d342d746313751db9cdb61e7a737dbc72c94c184dc4", }, .fzwatch = .{ .url = "https://github.com/freref/fzwatch/archive/refs/heads/master.tar.gz", .hash = "1220a6181ec8374f37e49914204b98ff4cc326bfca1a46594364886fe962f998c9dd", }, .fastb64z = .{ - .url = "git+https://github.com/freref/fastb64z#3bfba44545042f00cc908890a652da00dc3d7670", - .hash = "12206695fbabe2c3f981ea79d97afe8d4fdb7790773a4153543c63ac7e0d11e564c7", + .url = "https://github.com/freref/fastb64z/archive/fa3f34a4528609a8778124641b080e90d93c357a.tar.gz", + .hash = "1220b5a0e9aa8d4c9b0e09c41ec3a58092888e7516c05cb78b74c9be77acaebab303", }, }, .paths = .{ diff --git a/src/Context.zig b/src/Context.zig index 1259c27..05db116 100644 --- a/src/Context.zig +++ b/src/Context.zig @@ -38,7 +38,7 @@ pub const Context = struct { cache: Cache, check_cache: bool, - pub fn init(allocator: std.mem.Allocator, args: [][]const u8) !Self { + pub fn init(allocator: std.mem.Allocator, args: [][:0]u8) !Self { const path = args[1]; const initial_page = if (args.len == 3) try std.fmt.parseInt(u16, args[2], 10) diff --git a/src/config/Config.zig b/src/config/Config.zig index 57d8780..f5565e9 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -68,7 +68,7 @@ pub fn init(allocator: std.mem.Allocator) !Self { const home = try std.process.getEnvVarOwned(allocator, "HOME"); defer if (home.len != 1) allocator.free(home); - var config_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; + var config_path_buf: [std.fs.max_path_bytes]u8 = undefined; const config_dir = try std.fmt.bufPrint(&config_path_buf, "{s}/.config/fancy-cat", .{home}); std.fs.makeDirAbsolute(config_dir) catch |err| { @@ -150,6 +150,7 @@ fn parseKeyBinding(value: std.json.Value, allocator: std.mem.Allocator) !vaxis.K } if (vaxis.Key.name_map.get(key)) |codepoint| { + std.debug.print("key_value: {any}, key: {s}, codepoint: {any}\n", .{ key_value, key, codepoint }); return vaxis.Key{ .codepoint = codepoint, .mods = modifiers, @@ -241,7 +242,7 @@ fn parseStatusBar(value: std.json.Value, allocator: std.mem.Allocator) !StatusBa const bg_rgb = bg.get("rgb").?.array; const fg_rgb = fg.get("rgb").?.array; - const style = .{ + const style: vaxis.Cell.Style = .{ .bg = .{ .rgb = .{ try std.json.innerParseFromValue(u8, allocator, bg_rgb.items[0], .{}), try std.json.innerParseFromValue(u8, allocator, bg_rgb.items[1], .{}), diff --git a/src/main.zig b/src/main.zig index d7e1b43..5d160c3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,7 +1,29 @@ const std = @import("std"); const Context = @import("Context.zig").Context; -pub const FANCY_CAT_VERSION = "0.3.0"; +// Types for build.zig.zon +// For now metadata is only used in main.zig, but can move it to types.zig if needed eleswhere +// This wont be necessary once https://github.com/ziglang/zig/pull/22907 is merged +const DependencyType = struct { + url: []const u8, + hash: []const u8, +}; + +const DependenciesType = struct { + vaxis: DependencyType, + fzwatch: DependencyType, + fastb64z: DependencyType, +}; + +const MetadataType = struct { + name: []const u8, + version: []const u8, + minimum_zig_version: []const u8, + dependencies: DependenciesType, + paths: []const []const u8, +}; + +const metadata: MetadataType = @import("metadata"); pub fn main() !void { const args = try std.process.argsAlloc(std.heap.page_allocator); @@ -9,7 +31,7 @@ pub fn main() !void { if (args.len == 2 and (std.mem.eql(u8, args[1], "--version") or std.mem.eql(u8, args[1], "-v"))) { const stdout = std.io.getStdOut().writer(); - try stdout.print("fancy-cat version {s}\n", .{FANCY_CAT_VERSION}); + try stdout.print("fancy-cat version {s}\n", .{metadata.version}); return; }