3 ms·
Or you could implement a gap buffer, and then your complicated editor is using a simple trope. Emacs is an example of a full-featured editor based on a gap buf
by greglindahl 9y ago
Or you could implement a gap buffer, and then your complicated editor is using a simple trope.
Emacs is an example of a full-featured editor based on a gap buffer.
- ggm 9y agoSure. You could leap to the best solution first. Probably, you lucked out in the gene pool and your future fate is not to write bad code. The rest of us, who did not acquire sufficiently complex frontal lobes, struggle with concepts and probably dive into stupider solutions first, like I did at uni in the 1980s allocating a fixed size buffer (big initial mistake)_ and maintaining a huge linked list of edits sequence events into it. I passed the course, but future evidence suggests I didn't learn as much as I hoped!
- greglindahl 9y agoHa ha, well, I'll confess, I got lucky and discovered the existence of gap buffers before I tried to write a simple editor. And these days, there's a Wikipedia article on quite a few of the fundamental editor data structures. It's worth noting that no widely-used editor since emacs uses a gap buffer, so it's not like it's won the hearts and minds of implementers.
- eftychis 9y agoI wouldn't say a gap buffer is the "complicated and crazy" data structure for text editing. Certainly not the best. There's no free lunch, every approach has its downsides :)
- deleted 9y ago[deleted]
- continuational 9y agoGap buffers can’t support multiple cursors efficiently. This is a core feature in eg. Sublime Text.
- dsego 9y agoSublime doesn't use a gap buffer?