Ok, here's my first attempt:
I created two script buttons:
"Find by Elim"
-----------
import leo.scripts.leoFindScript as leoFindScript
def getInput(event=None):
stateName = 'get-input'
k = c.k
state = k.getState(stateName)
if state == 0:
k.setLabelBlue('Input: ',protect=True)
k.getArg(event,stateName,1,getInput)
else:
k.clearState()
find_by_elimination(k.arg)
getInput()
def find_by_elimination(text_to_find):
c.nodes_to_show = [result[0] for result in leoFindScript.findAll
(c,text_to_find,bodyFlag=False)]
c.redraw()
-----------------
and "Restore nodes"
-----------------
c.nodes_to_show = None
c.redraw()
-----------------
Then in "leoQtTree --> Drawing... --> Entry points --> full_redraw &
helpers", I added the node "should_display"
----------------
def should_display(self, p):
"""
Used for find by elimination.
A node should be displayed if either itself or one of it's
children is in
the c.nodes_to_show list.
The c.nodes_to_show_list is set via the find_by_elimination script
button.
"""
c = self.c
# If we aren't filtering any nodes, just show them all
if not hasattr(c, "nodes_to_show") or c.nodes_to_show is None:
return True
if p in c.nodes_to_show:
return True
for child in p.children_iter():
if self.should_display(child):
return True
return False
-----------
Finally, also in full_redraw & helpers, I added some code to drawTree,
so it looks like this:
----------
def drawTree (self,p,parent_item=None):
# Don't draw the tree if it's filtered out due to find by
elimination
should_display = self.should_display(p)
if not should_display:
return
# Draw the (visible) parent node.
item = self.drawNode(p,parent_item)
# Draw all the visible children.
self.drawChildren(p,parent_item=item)
-----------
It's not incremental like I described in my original post, and it only
searches headlines, but it seems to be working.
Also, I have a feeling that this post might not be the best way to
share my changes... What would be the proper way?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"leo-editor" 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.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---