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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---