diff --git a/.gitignore b/.gitignore index 96ef6c0..734d94e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -/target -Cargo.lock +zig-cache/ +zig-out/ +.gyro/ +gyro.lock +deps.zig diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 6aacd9e..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "zellij-compact-status" -version = "0.1.0" -authors = ["LordMZTE "] -edition = "2018" - -[dependencies] -owo-colors = "3.3.0" -zellij-tile = { git = "https://github.com/zellij-org/zellij" } diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..1bd7c4e --- /dev/null +++ b/build.zig @@ -0,0 +1,24 @@ +const std = @import("std"); +const pkgs = @import("deps.zig").pkgs; + +pub fn build(b: *std.build.Builder) void { + // Standard release options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. + const mode = b.standardReleaseOptions(); + + const lib = b.addSharedLibrary("zellij-compact-status", "src/main.zig", .{ .unversioned = {} }); + lib.setBuildMode(mode); + + lib.target.cpu_arch = .wasm32; + lib.target.os_tag = .wasi; + + pkgs.addAllTo(lib); + + lib.install(); + + const main_tests = b.addTest("src/main.zig"); + main_tests.setBuildMode(mode); + + const test_step = b.step("test", "Run library tests"); + test_step.dependOn(&main_tests.step); +} diff --git a/gyro.zzz b/gyro.zzz new file mode 100644 index 0000000..147d8f7 --- /dev/null +++ b/gyro.zzz @@ -0,0 +1,13 @@ +pkgs: + zellij-compact-status: + version: 0.0.0 + description: A compact replacement for the zellij status bar + license: GPL-3.0 + source_url: "https://mzte.de/git/LordMZTE/zellij-compact-status" + root: src/main.zig +deps: + zellzig: + git: + url: "https://mzte.de/git/LordMZTE/zellzig.git" + ref: master + root: src/main.zig diff --git a/justfile b/justfile index 87c4208..3b86766 100644 --- a/justfile +++ b/justfile @@ -1,9 +1,12 @@ release: - cargo build --release + gyro build -Drelease-fast + +run: release + zellij --layout-path plugin.yaml install: release cp -f \ - target/wasm32-wasi/release/zellij-compact-status.wasm \ + zig-out/lib/zellij-compact-status.wasm \ ~/.local/share/zellij/plugins/compact-status.wasm uninstall: diff --git a/plugin.yaml b/plugin.yaml index 3b22b41..62071cb 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -17,6 +17,6 @@ template: Fixed: 1 run: plugin: - location: "file:target/wasm32-wasi/debug/zellij-compact-status.wasm" + location: "file:zig-out/lib/zellij-compact-status.wasm" tabs: - direction: Vertical diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 1059111..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1,12 +0,0 @@ -unstable_features = true -binop_separator = "Back" -format_code_in_doc_comments = true -format_macro_matchers = true -format_strings = true -imports_layout = "HorizontalVertical" -match_block_trailing_comma = true -merge_imports = true -normalize_comments = true -use_field_init_shorthand = true -use_try_shorthand = true -wrap_comments = true diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..19a7950 --- /dev/null +++ b/src/main.zig @@ -0,0 +1,28 @@ +const std = @import("std"); +const zz = @import("zellzig"); + +comptime { + zz.createPlugin(@This()); +} + +var gpa = std.heap.GeneralPurposeAllocator(.{}){}; +var mode = zz.types.InputMode.Normal; + +pub fn init() void { + zz.allocator = gpa.allocator(); + zz.api.setSelectable(false); + zz.api.subscribe(&[_]zz.types.EventType{.ModeUpdate}) catch + @panic("unable to subscribe to events"); +} + +pub fn update(ev: zz.Event) void { + switch (ev) { + .ModeUpdate => |mi| mode = mi.mode, + else => {}, + } +} + +pub fn render(rows: i32, cols: i32) void { + _ = rows; + _ = cols; +}