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. 🥳
#ihycs7q