Archived

This topic is now archived and is closed to further replies.

stefu

Text editor?

Recommended Posts

Guest Anonymous Poster
http://freespace.virgin.net/james.brown7/tuts/bigmem01.htm
http://freespace.virgin.net/james.brown7/tuts/bigmem02.htm

Share this post


Link to post
Share on other sites
Linked lists sounds like a good solution to me. Text editors have lots of line insertions/deletions so having O(1) for those is pretty much top priority.

Share this post


Link to post
Share on other sites
quote:
Original post by Kylotan
Ropes?



Now, this is interesting. Could have whole text in single rope.

I am writing a little c++ editor. I still think that it would be good idea to use list of string (string for each line). Lines are not usually very long, so std::string would work just fine. Or propably list of ropes. Having big single rope, managing cursor (row,col) seems to be harder.

Share this post


Link to post
Share on other sites
I''ve built an editor (wysiwyg java applet) where i used a linked list of strings (java''s StringBuffer class, which resembles std::string) with each string representing a paragraph (text between two newlines). That way, as long as the user hits enter every now and then insertion should not be too slow, and you also do not get a huge linked list that you would get if you used one big list of characters. In my implementation this worked fine (no performance issues at all, even though it used java). You''ll need to write some code for splitting/merging paragraphs but that is pretty straightforward.

Marijn

Share this post


Link to post
Share on other sites