Hacker News new | past | comments | ask | show | jobs | submit login
Gap Buffers: a data structure for editable text (routley.io)
27 points by jmlr on Oct 17, 2017 | hide | past | favorite | 1 comment

I think implementing a simple text editor with undo/redo support is a worthwhile exercise for everyone to do at least once in their career. It's a great example of something that on first glance seems simple, but has quite a bit of subtlety especially when you get into styled text.

Piece chains are another good data structure to know for this application, though their implementation is more complex than a gap buffer. See http://www.catch22.net/tuts/piece-chains for a nice tutorial.

Also worth reading for insight and motivation is the 1985 CACM article "Concepts of the text editor Lara" by J. Gutknecht.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact