Hi Rob, The folding is not necessarily done by the lexer. Scintilla recommendeds to implement lexing and folding with different code, but the lexer may contain the folder code. However these are Scintilla internals we don't have to worry about. From a quick look to the documentation, this is what matters:
"Generally, the fold points of a document are based on the hierarchical structure of the document contents." or in more detail: "The fundamental operation in folding is making lines invisible or visible. Line visibility is a property of the view rather than the document so each view may be displaying a different set of lines. From the point of view of the user, lines are hidden and displayed using fold points. Generally, the fold points of a document are based on the hierarchical structure of the document contents. In Python, the hierarchy is determined by indentation and in C++ by brace characters. This hierarchy can be represented within a Scintilla document object by attaching a numeric "fold level" to each line. The fold level is most easily set by a lexer, but you can also set it with messages." And these are the relevant calls: SCI_VISIBLEFROMDOCLINE(int docLine) SCI_DOCLINEFROMVISIBLE(int displayLine) SCI_SHOWLINES(int lineStart, int lineEnd) SCI_HIDELINES(int lineStart, int lineEnd) SCI_GETLINEVISIBLE(int line) SCI_SETFOLDLEVEL(int line, int level) SCI_GETFOLDLEVEL(int line) * SCI_SETFOLDFLAGS(int flags) SCI_GETLASTCHILD(int line, int level) * SCI_GETFOLDPARENT(int line) * SCI_SETFOLDEXPANDED(int line, bool expanded) SCI_GETFOLDEXPANDED(int line) SCI_TOGGLEFOLD(int line) SCI_ENSUREVISIBLE(int line) SCI_ENSUREVISIBLEENFORCEPOLICY(int line) The ones I masked with * can be of use for us. There are two approaches: one brutal force: check the fold levels of all line endings or try to build a smarter (this should be very easy), faster way with SCI_GETFOLDPARENT and SCI_GETLASTCHILD or other routines, but I don't know if that is possible. A first step is too do it for the whole source of the document. A second step could be to be able to work with small parts of the source which are being edited. For example I presume that you only need to scan for updates within the current working fold(level), which saves cpu and memory resources while updating the fold explorer or the style index. This is necessary for bigger files if you want to work with real-time updating (it updates while you are typing your code). There are already enough real class explorers for python in the existing IDE's. So they can be ported to peppy anyway. I don't know if one of the editors have implemented class explorers for other languages. Maybe other people on this list can react on that. The point of the new controls 'fold explorer' and 'style index' is that they are generic out of the box and that immediately they can make an IDE a nice environment for all the languages (and there are many) that scintilla supports. As far as I know no open source IDE does this at the moment, so this is a nice opportunity. Stani On 3/2/07, Rob McMullen <[EMAIL PROTECTED]> wrote: > > Hey Stani, > > Just a quick note to let you know that I'm thinking about this. I'm > not a night person, and here on the east coast of the US it's getting > late. :) > > Very interesting idea about the fold explorer -- do you mean that > scintilla can automatically fold code, and we don't have to tell it > any more about it than just specifying the lexer? I haven't ever > looked at code folding because I'd never used it, but I'll take a look > at it this weekend and further digest your note. I do think that your > idea is worth thinking about -- I'm still trying to wrap my head > around it. > > So, this weekend hopefully I'll be at the place where I can ask you > more questions about it. > > Rob > > > > -- http://pythonide.stani.be http://pythonide.stani.be/screenshots http://pythonide.stani.be/manual/html/manual.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyxides" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.nl/group/pyxides?hl=en -~----------~----~----~----~------~----~------~--~---
