Hi Rob,

Good job!

Concerning the hierarchy in SPE that is most simple part of the
answer. As said before I use my own custom classes:
realtime.TreeCtrl
realtime.ListCtrl

Their API is (nearly) identical to the wx.TreeCtrl and wx.ListCtrl.
There is a small, subtle difference in resetting them, but don't worry
about that. So I would suggest you implement it with normal a
wx.TreeCtrl (for hierarchy) or wx.ListCtrl (for sorted list). If you
manage to do that I'll help you porting them to my realtime classes if
you want to use them.

The lexer gives already a lot of information, but as you noticed it is
not enough for a tree. However maybe you should start with an index
list which can be sorted by its columns (by name, style or line
number). I think that is step 1.

Step 2 would be trying to find out the hierarchy. This is more
difficult, not so much for python, but to make it work in a generic
way for all the lexers is more difficult. For that probably we need to
use the folding information as well.

These are some issues I immediately notice, although I am not expert:
- the style bits are not the same across languages as in some
languages classes are not even highlighted (C++) For example:

* python
# Class name definition
style.python.8=fore:#0000FF,bold
# Function or method name definition
style.python.9=fore:#007F7F,bold

* C++
# UUIDs (only in IDL)
style.cpp.8=fore:#804080
# Preprocessor
style.cpp.9=$(colour.preproc)

* Pascal
# Symbols
style.pascal.8=fore:#007F7F
# Preprocessor
style.pascal.9=fore:#7F7F00

But languages as Python and Ruby do share the same style bits. So
maybe it boils down grouping the supported languages by Scintilla in
groups, which still might be less work than writing it yourself for
every language. (The grouping could be done automatically by mapping
the style bits with their labels in dictionaries and scan for
similarities.) But as classes and functions in C++ are not
highlighted, how can you extract them? Maybe you or someone else
(anyone?) on this list has better ideas. Otherwise it could be good to
ask Neil if this is utopia or realistic.

Even if this approach doesn't work it still would be good to develop a
generic hierarchic parser api, for which maybe with regular
expressions we can write plugins.

Stani

On 2/25/07, Rob McMullen <[EMAIL PROTECTED]> wrote:
>
> Stani,
>
> I'm looking through your explorer implementation and have incorporated
> it as a minor mode in peppy.  It was pretty straightforward to
> incorporate, although I haven't grokked the internals yet.  Still
> reading the code. :)
>
> I threw together this code that looks at the stc and grabs anything
> that is of the requested styles -- it outputs a list of tuples: (start
> pos, end pos, style type, and text).  This is the totally naive
> approach of just marching through the text and gathering styles that
> are marked as the same.
>
> In your Panel, for example, I added this method:
>
>     def updateExploreGeneric(self):
>         classes = {wx.stc.STC_P_CLASSNAME: 'Class definition',
>                    wx.stc.STC_P_DEFNAME: 'Function or method',
>                    }
>         getLexedItems(self.source, classes)
>
> that calls this function:
>
> def getLexedItems(stc, classes):
>     length = stc.GetTextLength()*2
>     text = stc.GetStyledText(0, length)
>     bits = (2**stc.GetStyleBits()) -1
>     print "seaching for %s" % classes
>
>     i=1 # styling bytes are the odd bytes
>     parsed = []
>     while i<length:
>         # get the style, stripping off the the indicator bits
>         style = ord(text[i]) & bits
>         if style in classes:
>             # it's a style we're interested in, so gather
>             # characters until the style changes.
>             found = i-1
>             i+=2
>             while i < length:
>                 s = ord(text[i]) & bits
>                 if style != s:
>                     parsed.append((found, i-1, style, text[found:i-1:2]))
>                     break
>                 i+=2
>         else:
>             i+=2
>     print parsed
>
>
> So...  It's a start.  I've got to figure out your hierarchies and I'll
> see if I can merge a generic implementation into your Panel.
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to