Efficient Text Editing Buffer

I pushed a demo up here:

This is using my gap buffer implementation to hold the text. When the cursor is moved with up/down arrows or page up/down, the zipper focus is shifted to the line where the cursor is - so the underlying arrays are sliced and appended as you move around.

The demo is running 10K lines, locally I tried 100K and it was just as fast. At 1M it becomes very unresponsive - there is still some efficiency could be squeezed out of the buffer algorithms, since my zipper refocussing is not optimal. I am also wondering, where do I draw the line? I would very rarely edit a 100K line file, let alone 1M.

Next is to implement some basic editing and better cursor behaviour.

2 Likes