#Requesting a change to the standard library

1 messages · Page 1 of 1 (latest)

ember gulch
#

Hi, it wasn't super clear from the README what the appropriate way to make a feature request was. I have a small change in mind regarding std/io/tty. Could someone point me in the right direction? Thanks

willow lodge
#

you can open a regular issue, choose "blank issue" when creating the issue. the only thing that is off limits is language proposals

#

but if it's a small thing you'd like to fix yourself it's usually also fine to open a PR directly

#

if it's something you think you want to discuss with the core team first you can chat with them on https://zsf.zulipchat.com/

naive sluice
#

You can also run it by people in this server

#

Which I would recommend if you’re not an experienced Zig programmer

ember gulch
# naive sluice You can also run it by people in this server

it is very simple, basically the mappings between color enums and the associated []const u8 cannot be queried because they are inside a function which makes you use a "writer". I think it would make more sense to maintain the current function but allow the direct retrieval of the data via a function that just returns a []const u8. Imo there is no point to restrict something so simple behind a single data structure. Does that make any sense?

#

I am still a beginner in zig, so I don't know

#

I tried a zig a long time ago but never really got into it, but now I'm coming back around 😆

urban timber
#

std.io.tty also supports windows console iirc, which doesn't use escape codes

#

so there isn't always a []const u8 to map to

ember gulch
#

yeah I know

#

oh

#

I see

urban timber
#

as always, windows is weird :)

ember gulch
#

Well, it's not like I'm going to target windows anyway

#

I'll just copy the escape codes 🙃

urban timber
#

if you're not using std.io.tty it's probably because you're doing something more advanced, so you'll need to write your own escape codes anyway

ember gulch
#

yeah true. I'm just creating a special logging module for my toolkit and want to highlight the words "CRITICAL" in purple, "WARNING" in yellow, etc. So like this:

    std.debug.lockStdErr();
    defer std.debug.unlockStdErr();
    nosuspend {
        writer.print(
            "[ztk/{s}]|[{}:{:0>2}:{:0>2}:{:0>8}]> {s}: " ++ format ++ "\n",
            .{ self.module, hours, minutes, seconds, nanoseconds, level_txt } ++ args,
        ) catch return;
        bw.flush() catch return;
    }

I would wrap level_txt in that attribute

#

but yeah, thanks for the help

urban timber
ember gulch
urban timber
#

yeah, that's fine tho

ember gulch
#

Sorry I've been awake for a long ass time

urban timber
#

possibly more readable even

ember gulch
#

yeah perhaps

#

I'll just do that