Re: Routine folding: display and cursor movement issues
- Posted by Greg Haberek <ghaberek at gmail.com> Aug 30, 2005
- 464 views
Here's how I would tackle it, kinda. :)=20
-- this is pretty much pseudo-eu code -- i'm not sure how you display text, -- but this seems like a fairly straight- -- forward approach=20 constant TEXT = 1, FLAG = 2 constant FOLD_ON = 1, FOLD_OFF = 0 sequence textBuffer textBuffer[1][TEXT] = {"Line 1", "Line 2", ... } textBuffer[1][FLAG] = { FOLD_OFF, FOLD_OFF, ... } integer topLine, foldState topLine = 1 foldState = FOLD_OFF for i = topLine to length( textBuffer[1][TEXT] ) do -- check fold state if foldState = FOLD_OFF then -- display line i displayLine( textBuffer[1][TEXT][i] ) -- check fold flag if textBuffer[1][FLAG][i] = FOLD_ON then -- show fold button [+] on line i showFoldButton( i ) -- save fold state foldState = FOLD_ON end if elsif foldState = FOLD_ON then -- check fold flag if textBuffer[1][FLAG][i] = FOLD_OFF then -- display line i displayLine( textBuffer[1][TEXT][i] ) -- save fold state foldState = FOLD_OFF end if end if -- check for bottom of screen if textReachedBottom() then -- done exit end if end for
~Greg