Routine folding: display and cursor movement issues
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Aug 30, 2005
- 460 views
I've written some (experimental) code to implement folding. I just wonder if I am "doing it right" and/or if there is "a better way". I can't seem to google proper on this either ;-((. To begin with, when, say, a routine from line 8 to 12 inclusive is folded, I add an entry to the bookmark table (another goodie planned for 0.2.2), of {FOLD,8,12}. Easy. I also have code to update this as lines are inserted/deleted/etc. The "internal" struggle (as in conceptually) is how I display from line 1 to line 30 normally, but line 1 to 34 with a fold mark against line 8, and more critically how I cursor up/down from line 8 to line 13 and vice versa, as well as paging up and down, and opening the editor with eg the cursor on line 34 in the above described scenario - so I need to start with line 1 of display as line 1of the file, not line 4. (I plan to retain folds, btw). So my question is: how would you store the (run-time) info: a) a really packed table that is small but costs alot to scan, (in practice I probably have to keep that anyway), b) a full-on 1..length(filetext[currfile]) flag array (or two) that scans really easy but costs an arm and a leg to update, c) an array 1..visible lines (by default 1..len(f[c]), with significant overheads as per or perhaps even worse than b, d) some other scheme? Hopefully, Pete