Back to front pageView on Hacker News (opens in a new tab)Show HN: Lite – A small, fast text editor (opens in a new tab)github.com607 pointsby rxi (on Hacker News)6 years agogithub.com (opens in a new tab)GitHub - rxi/lite: A lightweight text editor written in LuaA lightweight text editor written in Lua. Contribute to rxi/lite development by creating an account on GitHub.Comments (256) 54 threadsShow all commentsShowing thread 33 of 54[-]snissn6 years ago3 replies#Could you share what data structure you use to keep the text in? I'm curious how text editors work, since you need fast inserts anywhere, is the text a linked list?pkaye6 years ago#Check out this paper. It talks about the different ways to manage the data structures for text editors.https://www.cs.unm.edu/~crowley/papers/sds.pdf[-]thedirt01156 years ago2 replies#My Lua isn't strong, but I think this is what you're looking for:Data structure initialization: https://github.com/rxi/lite/blob/master/data/core/doc/init.l...How insertion works here, which illuminates how the table is used: https://github.com/rxi/lite/blob/143f8867a13a35f5688ad7c9771...aspaceman6 years ago#And if you want to take that a step further down the rabbit hole, here's how Lua allocates the table in memory: https://stackoverflow.com/a/29930168It's two dynamic arrays, of hashes and values, whose sizes grow as powers of two.dtf6 years ago#Looks like an array of lines, which is a completely reasonable structure to use.There's a good post on the Visual Studio Code blog about why and when they moved on from an array of lines to a new structure based on a piece table.https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...moonchild6 years ago#Look at ropes - https://en.wikipedia.org/wiki/Rope_(data_structure)
Show HN: Lite – A small, fast text editor (opens in a new tab)github.com607 pointsby rxi (on Hacker News)6 years ago
snissn6 years ago3 replies#Could you share what data structure you use to keep the text in? I'm curious how text editors work, since you need fast inserts anywhere, is the text a linked list?
pkaye6 years ago#Check out this paper. It talks about the different ways to manage the data structures for text editors.https://www.cs.unm.edu/~crowley/papers/sds.pdf
thedirt01156 years ago2 replies#My Lua isn't strong, but I think this is what you're looking for:Data structure initialization: https://github.com/rxi/lite/blob/master/data/core/doc/init.l...How insertion works here, which illuminates how the table is used: https://github.com/rxi/lite/blob/143f8867a13a35f5688ad7c9771...
aspaceman6 years ago#And if you want to take that a step further down the rabbit hole, here's how Lua allocates the table in memory: https://stackoverflow.com/a/29930168It's two dynamic arrays, of hashes and values, whose sizes grow as powers of two.
dtf6 years ago#Looks like an array of lines, which is a completely reasonable structure to use.There's a good post on the Visual Studio Code blog about why and when they moved on from an array of lines to a new structure based on a piece table.https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...
Comments (256) 54 threads
Show all comments
Showing thread 33 of 54
https://www.cs.unm.edu/~crowley/papers/sds.pdf
Data structure initialization: https://github.com/rxi/lite/blob/master/data/core/doc/init.l...
How insertion works here, which illuminates how the table is used: https://github.com/rxi/lite/blob/143f8867a13a35f5688ad7c9771...
It's two dynamic arrays, of hashes and values, whose sizes grow as powers of two.
There's a good post on the Visual Studio Code blog about why and when they moved on from an array of lines to a new structure based on a piece table.
https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...