Another project where I’m going to use my terminal widget toolkit is a hex editor. This is still very young, obviously, and there’s a lot of work to do (both in the toolkit and this particular application), but I’m making some progress:
https://movq.de/v/2bae14ed16/vid-1769283187.mp4
Since this program is UTF-8 clean (I hope), you can do things like enter multi-byte UTF-8 sequences or paste them from the system clipboard (another hex editor I just tried failed to do this correctly):
https://movq.de/v/e9241034c1/vid-1769283755.mp4
Under the hood, I’m using mmap() with MAP_PRIVATE, which is really cool: I get the entire file as a byte array, no matter how large it is, no need to actually read it upfront; and MAP_PRIVATE means that I can write to this area however I like without changing the underlying file. The kernel does copy-on-write for me. Only when you hit Save, it will write to the filesystem. And it’s just a couple lines of code. The kernel does all the magic. 🥳
When people “make plans”, I always respond like this:
https://movq.de/v/9a8712846d/at-night.jpg
Finally found the clip where this is from:
@bender@twtxt.net I’m already using it for tracktivity (meant for tracking activities and events, like weather, food consumption, stuff like that), which is basically a somewhat-fancy CSV editor:
https://movq.de/v/f26eb836ee/s.png
I have a couple of other projects where I could use it, because they are plain curses at the moment. Like, one of them has an “edit box”, but you can’t enter Unicode, because it was too complicated. That would benefit from the framework.
Either way, it’s the most satisfying project in a long time and I’m learning a ton of stuff.
Some work on the menu system to brighten my mood a little bit. No mouse support yet.