i wonder if anyone's ever written a text editor that memory-maps the text area
@bjornsdottirs what do you mean by this
@croissant i mean the text editor being a mmap()d file rather than the result of malloc()
otherwise every single insert and delete would involve a massive memcpy() of all the text after the cursor
@LunaDragofelis @bjornsdottirs 🌟 Yeah.
I know GNU ed(1) for instance represents text through ASCII strings organized into a linked list data structure—one entry per line in the file. So in that program, adding lines is very simple which matches how you used ed(1) anyway. Wouldn't be surprised if most other editors used linked lists to index lines.
I once hacked on an editor that used UTF-32 to represent characters. An extremely weird choice until you remember that you get complete Unicode coverage while being able to easily jump to specific characters in a file, because each character is 4 bytes, or one 32-bit word. UTF-8 is really only good for storing and transmitting over the wire. Working in it is a bit of a pain.
But yeah memory-mapped plaintext is just a bad idea.
@LunaDragofelis @croissant yeah.