~leon_plickat/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
7 5

[PATCH zig-spoon 0/1] update to current zig

Details
Message ID
<169548284133.31571.712672076772134069-0@git.sr.ht>
DKIM signature
missing
Download raw message
I updated it so I could try it in a project, here's the patch if you
want it.
Thanks for the lib!

owl (1):
  upgrade to current zig

 .builds/alpine.yml                |  8 +--
 build.zig                         | 93 +++++++++++++++++++++----------
 build.zig.zon                     |  4 ++
 example/menu.zig                  |  2 +-
 lib/Term.zig                      |  4 +-
 lib/input.zig                     |  6 +-
 lib/restricted_padding_writer.zig |  2 +-
 7 files changed, 78 insertions(+), 41 deletions(-)
 create mode 100644 build.zig.zon

-- 
2.38.5

[PATCH zig-spoon 1/1] upgrade to current zig

Details
Message ID
<169548284133.31571.712672076772134069-1@git.sr.ht>
In-Reply-To
<169548284133.31571.712672076772134069-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Patch: +78 -41
From: owl <owl@u8.is>

---
 .builds/alpine.yml                |  8 +--
 build.zig                         | 93 +++++++++++++++++++++----------
 build.zig.zon                     |  4 ++
 example/menu.zig                  |  2 +-
 lib/Term.zig                      |  4 +-
 lib/input.zig                     |  6 +-
 lib/restricted_padding_writer.zig |  2 +-
 7 files changed, 78 insertions(+), 41 deletions(-)
 create mode 100644 build.zig.zon

diff --git a/.builds/alpine.yml b/.builds/alpine.yml
index 8110f82..ad2c85c 100644
--- a/.builds/alpine.yml
+++ b/.builds/alpine.yml
@@ -6,10 +6,10 @@ sources:
  - https://git.sr.ht/~leon_plickat/zig-spoon
tasks:
  - install_deps: |
      wget -q https://ziglang.org/download/0.10.0/zig-linux-x86_64-0.10.0.tar.xz
      tar -xvf zig-linux-x86_64-0.10.0.tar.xz 1>/dev/null
      sudo mv zig-linux-x86_64-0.10.0/zig /usr/bin/
      sudo mv zig-linux-x86_64-0.10.0/lib /usr/lib/zig
      wget -q https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz
      tar -xvf zig-linux-x86_64-0.11.0.tar.xz 1>/dev/null
      sudo mv zig-linux-x86_64-0.11.0/zig /usr/bin/
      sudo mv zig-linux-x86_64-0.11.0/lib /usr/lib/zig
  - build: |
      cd zig-spoon
      zig build
diff --git a/build.zig b/build.zig
index b45bd87..f92ea45 100644
--- a/build.zig
@@ -1,54 +1,87 @@
const std = @import("std");
const Builder = std.build.Builder;

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

    const tests = b.addTest("test_main.zig");
    tests.setTarget(target);
    tests.setBuildMode(mode);
    const spoon_mod = b.addModule("spoon", .{
        .source_file = .{ .path = "import.zig" },
    });

    const tests = b.addTest(
        .{
            .root_source_file = .{ .path = "test_main.zig" },
            .target = target,
            .optimize = optimize,
        },
    );
    const test_step = b.step("test", "Run all tests");
    test_step.dependOn(&tests.step);

    {
        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(
            .{
                .name = "menu",
                .root_source_file = .{ .path = "example/menu.zig" },
                .target = target,
                .optimize = optimize,
            },
        );
        exe.addModule("spoon", spoon_mod);
        b.installArtifact(exe);
    }

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

    {
        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(
            .{
                .name = "input-demo",
                .root_source_file = .{ .path = "example/input-demo.zig" },
                .target = target,
                .optimize = optimize,
            },
        );
        exe.addModule("spoon", spoon_mod);
        b.installArtifact(exe);
    }

    {
        const exe = b.addExecutable("colours", "example/colours.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        exe.install();
        const exe = b.addExecutable(
            .{
                .name = "colours",
                .root_source_file = .{ .path = "example/colours.zig" },
                .target = target,
                .optimize = optimize,
            },
        );
        exe.addModule("spoon", spoon_mod);
        b.installArtifact(exe);
    }

    {
        const exe = b.addExecutable("table-256-colours", "example/table-256-colours.zig");
        exe.setTarget(target);
        exe.setBuildMode(mode);
        exe.addPackagePath("spoon", "import.zig");
        exe.install();
        const exe = b.addExecutable(
            .{
                .name = "table-256-colours",
                .root_source_file = .{ .path = "example/table-256-colours.zig" },
                .target = target,
                .optimize = optimize,
            },
        );
        exe.addModule("spoon", spoon_mod);
        b.installArtifact(exe);
    }
}
diff --git a/build.zig.zon b/build.zig.zon
new file mode 100644
index 0000000..e6ffd66
--- /dev/null
@@ -0,0 +1,4 @@
.{
    .name = "spoon",
    .version = "0.1.0",
}
diff --git a/example/menu.zig b/example/menu.zig
index a978fd1..fac21e9 100644
--- a/example/menu.zig
+++ b/example/menu.zig
@@ -95,7 +95,7 @@ fn render() !void {
    try rpw.writer().writeAll(" Up and Down arrows to select, q to exit.");
    try rpw.finish(); // No need to pad here, since there is no background.

    const entry_width = math.min(term.width - 2, 8);
    const entry_width = @min(term.width - 2, 8);
    try menuEntry(&rc, " foo", 3, entry_width);
    try menuEntry(&rc, " bar", 4, entry_width);
    try menuEntry(&rc, " baz", 5, entry_width);
diff --git a/lib/Term.zig b/lib/Term.zig
index 3cf2519..db030c2 100644
--- a/lib/Term.zig
+++ b/lib/Term.zig
@@ -211,9 +211,9 @@ pub fn fetchSize(self: *Self) !void {

    if (self.cooked) return;
    var size = mem.zeroes(constants.winsize);
    const err = os.system.ioctl(self.tty.?, constants.T.IOCGWINSZ, @ptrToInt(&size));
    const err = os.system.ioctl(self.tty.?, constants.T.IOCGWINSZ, @intFromPtr(&size));
    if (os.errno(err) != .SUCCESS) {
        return os.unexpectedErrno(@intToEnum(os.system.E, err));
        return os.unexpectedErrno(@as(os.system.E, @enumFromInt(err)));
    }
    self.height = size.ws_row;
    self.width = size.ws_col;
diff --git a/lib/input.zig b/lib/input.zig
index a559445..3e53ce4 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.isAlphabetic(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.38.5

[zig-spoon/patches/alpine.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CVQEIQFU1W1B.1TN5JGGV66MFX@cirno2>
In-Reply-To
<169548284133.31571.712672076772134069-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
zig-spoon/patches/alpine.yml: FAILED in 35s

[update to current zig][0] from [~alva][1]

[0]: https://lists.sr.ht/~leon_plickat/public-inbox/patches/44965
[1]: a@u8.is

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

Re: [PATCH zig-spoon 1/1] upgrade to current zig

Details
Message ID
<CVQGQU425IJ7.31DFGNA65HSRB@void>
In-Reply-To
<169548284133.31571.712672076772134069-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
On Sat Sep 23, 2023 at 2:34 PM CEST, ~alva wrote:
>      const test_step = b.step("test", "Run all tests");
>      test_step.dependOn(&tests.step);

It seems that with zig 0.11 tests are not run with this, using
`zig build test`, or at least not every time. I haven't found
or investigate too much why yet, but it seems that using
`test_step.dependOn(&b.addRunArtifact(tests).step);` instead fix it.

> +        return os.unexpectedErrno(@as(os.system.E, @enumFromInt(err)));

I don't think @as() is needed here.
Details
Message ID
<CVSH482ZBPKN.2CTS4OINPDD9K@kasten>
In-Reply-To
<169548284133.31571.712672076772134069-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Thanks for the patch!

I'll look at it once I'll have some more time, my life is a bit
turbulent right now unfortunately. That may take a few weeks.

-- 
Friendly greetings,
Leon Henrik Plickat
Details
Message ID
<CVSNM488Z1WC.220V7EJ97GTJB@u8.is>
In-Reply-To
<CVSH482ZBPKN.2CTS4OINPDD9K@kasten> (view parent)
DKIM signature
missing
Download raw message
> I'll look at it once I'll have some more time, my life is a bit
> turbulent right now unfortunately. That may take a few weeks.

Sorry to hear that, yeah don't worry about this, take care of yourself!

Re: [PATCH zig-spoon 1/1] upgrade to current zig

Details
Message ID
<CW11KJE3JN51.2MKGMGCXBP7HG@stud.uni-goettingen.de>
In-Reply-To
<169548284133.31571.712672076772134069-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Found a few minutes of time and applied your path. Thanks!

-- 
Friendly greetings,
Leon Henrik Plickat

Re: [PATCH zig-spoon 1/1] upgrade to current zig

Details
Message ID
<CW8GN6UKQOHX.38C37XW4W7IKW@stud.uni-goettingen.de>
In-Reply-To
<CVQGQU425IJ7.31DFGNA65HSRB@void> (view parent)
DKIM signature
missing
Download raw message
On Sat Sep 23, 2023 at 7:16 PM CEST, Hugo Machet wrote:
> On Sat Sep 23, 2023 at 2:34 PM CEST, ~alva wrote:
> >      const test_step = b.step("test", "Run all tests");
> >      test_step.dependOn(&tests.step);
>
> It seems that with zig 0.11 tests are not run with this, using
> `zig build test`, or at least not every time. I haven't found
> or investigate too much why yet, but it seems that using
> `test_step.dependOn(&b.addRunArtifact(tests).step);` instead fix it.

You are correct, feel free to send a patch.

BTW, same issue in rivers next-zig branch, if someone wants an easy PR.

-- 
Friendly greetings,
Leon Henrik Plickat
Reply to thread Export thread (mbox)