Anyline is a drop in replacement for GNU Readline, with the added benefit of not only supporting Linux and MaOS, but also Windows!
I was inspired by @matklad 's blog on Comptime Zig ORM where he mentions that the best way to learn how a piece of software works it to write your own toy version. I was curious how CLI apps could manipulate string in a terminal, so I decided to give it a try.
But I didn’t want to stop there. I decided I wanted to leverage Zig’s excellent cross compilation and support more platforms than just the usual Unix operating systems. With a little bit of help from LLMs and a lot of help from Ziggit.dev, I was able to get Windows 11 supported. I also exported all public functions to be C-ABI compatible, so all languages with a C FFI are supported as well.
For version 0.1.0, I implemented all the “Bare Essentials” features from the docs, plus a handful of features from it’s adjacent History library.
This is my first open source project. I made a best effort to dot all my I’s and cross all my T’s, but I’m sure it’s still rough around the edges. Any constructive criticism is welcome!
Cool project, I like the way you handle the OS-specific code.
Reminds me of linenoise and bestline more than GNU readline itself. Which isn’t any kind of critique, more of a prompt to check them out if you haven’t already.
My one bit of feedback is that it would be good to make the error sets for the public API explicit, and add some documentation for said API.
You can make the compiler tell you what the error set actually is by changing !void to error{NotReally}!void, in the process of complaining about the spurious error set, it will inform you of the real one.
That’s just what I need and hadn’t been able to find. I was looking for a minimal, portable readline alternative for GitHub - AndyA/z65: 6502 in zig (which is a 40 year old Basic ROM image for a BBC Micro 2nd processor wrapped in a 65C02 emulator and minimal OS in Zig). It’s nice for interactively playing with BBC Basic but the ergonomics are terrible without a line editor.
I’ll let you know how I get on with it - thank you!
Version 0.2.0 is out. It includes a few more movement features, plus so few bug fixes I found along the way. Apparently PowerShell 7 doesn’t follow the Ctrl-c terminate convention when you uncook it, so I made sure to add that functionality.
Version 0.4.0 is out. More specifically, it’s been out since October, but I completely forgot to post about it. It includes a major refactor that enables arguments to be supported!
It also includes a bug fix for BSD users. More details are include in the release notes.
As a sidebar, I noticed that the uploaded compiled libraries had a bug that prevented C compilers from using them. Quite an embarrassing miss To rectify the situations, I recompiled all the tagged versions and re-uploaded the fixed compiled libraries. Going forward, I will include linking against the compiled libraries with an app compiled with GCC to prevent this mistake going forward.