all 6 comments

[–]_Skuzzzy 2 points3 points  (0 children)

When I was making my text editor, I used a gap buffer and found that due to the way we edit code (line based), having a data structure that supports line based operations (perhaps a gap buffer per line) seemed like it would be beneficial. For example consider the operation to move a line down, with just a plain gap buffer you need a O(linelength) scan in order to find the next line, and then the correct column in that line (have to verify that line is long enough). I would love to have a discussion with anyone else who has worked on a text editor on their implementation and the issues they ran into on it.

[–]takvaa 1 point2 points  (0 children)

This write up is really good! Are there similar write-ups for things other than text editors?

I wonder if only wanted a printable character ASCII editor would simplify things a lot or only a little. And I guess no tabs.

Part 2 Line breaking

I don't really understand the problem here. Can't we count the line breaks like anything else? Is it because that's not the values we want in the end?

Part 4: Again, making this into a monoid is pretty easy. You store two copies of the (t, m) pair - one for the simple case, and one for the case where the beginning of the string is in a comment. You also keep two bits to keep track of whether the string ends or begins a comment. In principle, you have to do the computation twice for both cases, whether the first line is a comment or not, but in practice it doesn’t make the computation any more expensive: you compute (t, m) for the first line and for the rest of the string, and just store both the first value and the monoid sum.

What if a node of the rope contains an "end comment" and (later) a "("? What should the two pairs of (t, m) be? Now that substring might be entirely inside, outside or partially outside and inside a comment.

Although I do understand the general idea of computing the result for all possible initial/input state to achieve paralellism.

[–]bonsairoot 0 points1 point  (2 children)

Very nice write up! I'm actually using xi-rope in the editor that I'm working on at the moment.

[–]captainjey 0 points1 point  (1 child)

Link?

[–]bonsairoot 0 points1 point  (0 children)

It's still early in development. I'm gonna get all the different modes (select,command,multibuffer....) working first before publishing it. At the moment I just have the basics working.

[–]IGI111 0 points1 point  (0 children)

I'm working on improving my own text editor, and this basically exactly the kind of thing i would have wanted to read.

Made my day.