From: Slava P. <sl...@je...> - 2001-04-28 01:50:22
|
On Fri, Apr 27, 2001 at 02:37:42PM +0100, Tom Locke wrote: > >I will add a FoldHandler interface to jEdit 3.2pre2 (not pre1) then > >we can work on adding explicit folding. > > What do you have in mind? The decision as to which lines are fold start and > fold ends is made by any implementer of this interface? My current idea is something like: interface FoldHandler { /** * Returns the fold level of the specified line. * @param buffer The buffer * @param line The line number * @param fold Initially, this single-element array contains * the previous line's Fold object. If this line is also part * of that fold, it should leave the array as-is; if it is the * start of a new fold, it should create a new Fold object * and store it in the array. */ int getFoldLevel(Buffer buffer, int line, Fold[] fold); } Buffer.getFoldLevel() will check if the line changed since the last time it was called, if so, it will call the interface (which can perform parsing, etc) otherwise it will return the cached value. Having a Fold object will complicate matters somewhat, but it will allow stuff like the fold navigator to be implemented. I haven't thought about how Fold objects will be stored (a vector? a link list? a hash table?) nor what fields/methods the Fold class will have. > Another issue is whether the fold markers '{{{' and '}}}' should be just > sitting there in the buffer where they can be edited. This approach would > give the user plenty of opportunity to screw things up. Ripple stores the > fold locations in non-editable meta-data and polices editing so that the > fold structure is always consistent. I don't see why this is a problem. getFoldLevel() will just return prevLineFoldLevel + 1 if the current line contains {{{, and prevLineFoldLevel - 1 if the previous line contains }}}. Slava |