start zig rewrite

This commit is contained in:
LordMZTE 2022-06-13 23:15:46 +02:00
parent aa995f1d7d
commit 99e60196e7
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
8 changed files with 76 additions and 26 deletions

7
.gitignore vendored
View File

@ -1,2 +1,5 @@
/target
Cargo.lock
zig-cache/
zig-out/
.gyro/
gyro.lock
deps.zig

View File

@ -1,9 +0,0 @@
[package]
name = "zellij-compact-status"
version = "0.1.0"
authors = ["LordMZTE <lord@mzte.de>"]
edition = "2018"
[dependencies]
owo-colors = "3.3.0"
zellij-tile = { git = "https://github.com/zellij-org/zellij" }

24
build.zig Normal file
View File

@ -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);
}

13
gyro.zzz Normal file
View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

28
src/main.zig Normal file
View File

@ -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;
}