initial commit
This commit is contained in:
commit
0c5413eb3a
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/zig-cache/
|
||||
/zig-out/
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "deps/zig-wayland"]
|
||||
path = deps/zig-wayland
|
||||
url = https://github.com/ifreund/zig-wayland.git
|
34
build.zig
Normal file
34
build.zig
Normal file
|
@ -0,0 +1,34 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
// Standard target options allows the person running `zig build` to choose
|
||||
// what target to build for. Here we do not override the defaults, which
|
||||
// means any target is allowed, and the default is native. Other options
|
||||
// for restricting supported target set are available.
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
||||
// Standard release options allow the person running `zig build` to select
|
||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const exe = b.addExecutable("zlurp", "src/main.zig");
|
||||
exe.setTarget(target);
|
||||
exe.setBuildMode(mode);
|
||||
exe.install();
|
||||
|
||||
const run_cmd = exe.run();
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const exe_tests = b.addTest("src/main.zig");
|
||||
exe_tests.setTarget(target);
|
||||
exe_tests.setBuildMode(mode);
|
||||
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&exe_tests.step);
|
||||
}
|
1
deps/zig-wayland
vendored
Submodule
1
deps/zig-wayland
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit cf165f481ed093f182edef39dbea398e937df4dc
|
57
src/main.zig
Normal file
57
src/main.zig
Normal file
|
@ -0,0 +1,57 @@
|
|||
const std = @import("std");
|
||||
|
||||
const VecN = std.meta.Vector;
|
||||
|
||||
const Rgba32 = union {
|
||||
comps: struct { r: u32, g: u32, b: u32, a: u32 },
|
||||
rgba: u64,
|
||||
};
|
||||
|
||||
const State = struct {
|
||||
colors: struct { background: Rgba32, border: Rgba32, selection: Rgba32, choice: Rgba32 },
|
||||
border_weight: u8,
|
||||
display_dimensions: bool,
|
||||
restrict_selection: bool,
|
||||
fixed_aspect_ratio: bool,
|
||||
aspect_ratio: f32,
|
||||
// font_family
|
||||
};
|
||||
|
||||
fn defaultState() State {
|
||||
return State{
|
||||
.colors = .{
|
||||
.background = .{ .rgba = 0xFFFFFF40 },
|
||||
.border = .{ .rgba = 0x000000FF },
|
||||
.selection = .{ .rgba = 0x00000000 },
|
||||
.choice = .{ .rgba = 0xFFFFFF40 },
|
||||
},
|
||||
.border_weight = 2,
|
||||
.display_dimensions = false,
|
||||
.restrict_selection = false,
|
||||
.fixed_aspect_ratio = false,
|
||||
.aspect_ratio = 0,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
// Prints to stderr (it's a shortcut based on `std.io.getStdErr()`)
|
||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
||||
|
||||
// stdout is for the actual output of your application, for example if you
|
||||
// are implementing gzip, then only the compressed bytes should be sent to
|
||||
// stdout, not any debugging messages.
|
||||
const stdout_file = std.io.getStdOut().writer();
|
||||
var bw = std.io.bufferedWriter(stdout_file);
|
||||
const stdout = bw.writer();
|
||||
|
||||
try stdout.print("Run `zig build test` to run the tests.\n", .{});
|
||||
|
||||
try bw.flush(); // don't forget to flush!
|
||||
}
|
||||
|
||||
test "simple test" {
|
||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
||||
try list.append(42);
|
||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
||||
}
|
Loading…
Reference in a new issue