~leon_plickat/public-inbox

zig-spoon: update to current zig master v1 PROPOSED

Tested with:
zig version
0.11.0-dev.1987+a2c6ecd6d

Tobias Simetsreiter (1):
  update to current zig master

 build.zig                         | 73 ++++++++++++++-----------------
 example/menu.zig                  |  3 +-
 lib/input.zig                     |  6 +--
 lib/restricted_padding_writer.zig |  2 +-
 4 files changed, 38 insertions(+), 46 deletions(-)

-- 
2.34.7
#958398 alpine.yml failed
zig-spoon/patches/alpine.yml: FAILED in 33s

[update to current zig master][0] from [~backpackjoe][1]

[0]: https://lists.sr.ht/~leon_plickat/public-inbox/patches/39782
[1]: mailto:dasimmet@gmail.com

✗ #958398 FAILED zig-spoon/patches/alpine.yml https://builds.sr.ht/~leon_plickat/job/958398
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~leon_plickat/public-inbox/patches/39782/mbox | git am -3
Learn more about email & git

[PATCH zig-spoon 1/1] update to current zig master Export this patch

From: Tobias Simetsreiter <tobias.simetsreiter@meliot.de>

---
 build.zig                         | 73 ++++++++++++++-----------------
 example/menu.zig                  |  3 +-
 lib/input.zig                     |  6 +--
 lib/restricted_padding_writer.zig |  2 +-
 4 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/build.zig b/build.zig
index b45bd87..c55a7fc 100644
--- a/build.zig
@@ -3,52 +3,43 @@ const Builder = std.build.Builder;

pub fn build(b: *Builder) void {
    const target = b.standardTargetOptions(.{});
    const mode = b.standardReleaseOptions();
    const mode = b.standardOptimizeOption(.{});

    const tests = b.addTest("test_main.zig");
    tests.setTarget(target);
    tests.setBuildMode(mode);
    const tests = b.addTest(.{
        .root_source_file = .{.path = "test_main.zig" },
        .target = target,
        .optimize = mode,
    });
    const test_step = b.step("test", "Run all tests");
    test_step.dependOn(&tests.step);
    const spoon = b.createModule(.{
        .source_file = .{ .path = "import.zig" },
    });

    {
        const exe = b.addExecutable("menu", "example/menu.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        exe.install();
    }

    {
        const exe = b.addExecutable("menu-libc", "example/menu.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        exe.linkLibC();
        exe.install();
    }

    {
        const exe = b.addExecutable("input-demo", "example/input-demo.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        exe.install();
    }

    {
        const exe = b.addExecutable("colours", "example/colours.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        exe.install();
    }
    inline for (.{
        .{ .name="menu", },
        .{ .name="menu-libc", .linkC = true, .src = "example/menu.zig" },
        .{ .name="input-demo" },
        .{ .name="colours" },
        .{ .name="table-256-colours" },
    }) |example| {
        const src = if (@hasField(@TypeOf(example), "src"))
            example.src
        else
            "example/"++example.name++".zig";

    {
        const exe = b.addExecutable("table-256-colours", "example/table-256-colours.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        const exe = b.addExecutable(.{
            .name = example.name,
            .root_source_file = .{.path = src },
            .target = target,
            .optimize = mode,
        });
        exe.addModule("spoon", spoon);
        if ( @hasField(@TypeOf(example), "linkC") and example.linkC == true ){
            exe.linkLibC();
        }
        exe.install();
        const run = exe.run();
        b.step("run-"++example.name, "Run Example "++example.name).dependOn(&run.step);
    }
}
diff --git a/example/menu.zig b/example/menu.zig
index a978fd1..c50085b 100644
--- a/example/menu.zig
+++ b/example/menu.zig
@@ -66,12 +66,13 @@ pub fn main() !void {
}

fn render() !void {
    try term.fetchSize();
    var rc = try term.getRenderContext();
    defer rc.done() catch {};

    try rc.clear();

    if (term.width < 6) {
    if (term.width < 30) {
        try rc.setAttribute(.{ .fg = .red, .bold = true });
        try rc.writeAllWrapping("Terminal too small!");
        return;
diff --git a/lib/input.zig b/lib/input.zig
index a559445..c605162 100644
--- a/lib/input.zig
+++ b/lib/input.zig
@@ -167,7 +167,7 @@ const InputParser = struct {
        // This may be either a M-[a-z] code, or we accidentally received an
        // escape key press and a letter key press together. There is literally
        // no way to differentiate. However the second case is less likely.
        if (ascii.isAlpha(self.bytes.?[1]) and ascii.isLower(self.bytes.?[1])) {
        if (ascii.isAlphanumeric(self.bytes.?[1]) and ascii.isLower(self.bytes.?[1])) {
            defer self.advanceBufferBy("\x1Ba".len);
            return Input{ .content = .{ .codepoint = self.bytes.?[1] }, .mod_alt = true };
        }
@@ -229,7 +229,7 @@ const InputParser = struct {
        // 1) the sequence starts with '\x1B[' (well... duh)
        // 2) self.bytes.?[3] is an ascii numeric caracter
        if (self.bytes.?.len > 3) {
            for (self.bytes.?[3..]) |byte, i| {
            for (self.bytes.?[3..], 0..) |byte, i| {
                if (!ascii.isDigit(byte)) {
                    const first_num_bytes = self.bytes.?[2 .. i + 3];
                    switch (byte) {
@@ -303,7 +303,7 @@ const InputParser = struct {
    fn doubleNumericEscapeSequence(self: *Self, first_num_bytes: []const u8) Input {
        const semicolon_index = "\x1B[".len + first_num_bytes.len;
        if (self.bytes.?.len > semicolon_index + 1) {
            for (self.bytes.?[semicolon_index + 1 ..]) |byte, i| {
            for (self.bytes.?[semicolon_index + 1 ..], 0..) |byte, i| {
                if (!ascii.isDigit(byte)) {
                    const second_num_bytes = self.bytes.?[semicolon_index + 1 .. i + semicolon_index + 1];
                    switch (byte) {
diff --git a/lib/restricted_padding_writer.zig b/lib/restricted_padding_writer.zig
index cb23210..05ad2cf 100644
--- a/lib/restricted_padding_writer.zig
+++ b/lib/restricted_padding_writer.zig
@@ -118,7 +118,7 @@ pub fn RestrictedPaddingWriter(comptime UnderlyingWriter: type) type {
                return bytes.len;
            }

            for (bytes) |c, i| {
            for (bytes, 0..) |c, i| {
                if (self.len_left == 0) break;

                // If we are building up a codepoint right now, just add the
-- 
2.34.7
zig-spoon/patches/alpine.yml: FAILED in 33s

[update to current zig master][0] from [~backpackjoe][1]

[0]: https://lists.sr.ht/~leon_plickat/public-inbox/patches/39782
[1]: mailto:dasimmet@gmail.com

✗ #958398 FAILED zig-spoon/patches/alpine.yml https://builds.sr.ht/~leon_plickat/job/958398