I set about coding my own version of the classic MS-DOS EDIT.COM for GNU/Linux systems four years ago and it this is where the project is at... still rough around the edges but works well with Termux! :)
Demo:
https://www.youtube.com/watch?v=H7bneUX_kVA
However, my two suggestions would be:
- add Unicode support (it's the 21st century, so ∑, ®, etc. should finally work); this is not easy, but the earlier you do it the less dramatic the changes will be (check out https://github.com/unicode-org/icu/tree/main/icu4c);
- don't allocate the lines individually (as you do now with malloc, having looked at the code); at least use an arena allocator, i.e. allocate larger chunks of memory and the provide your own alloc_line function that uses the larger chunks (called arenas) piecemeal. This will speed things up and reduce fragmentation. A more advanced approach would be not to use per-line buffers but to switch to rope data structures e.g. https://github.com/josephg/librope).