Excellent! This is really a great help for me. I'm still experimenting, but one thing I will find useful is that I can open several of these panes and navigate through each of the "views". Plus (and this has been a longtime wishlist item for those with fading sight), I can increase the text size for reading big chunks of text.
(Another plus, and this is a big one, I can actually read your code well enough that I start to have some inkling about how to do this kind of addition to Leo. I could never begin to write it myself, but Leo makes it accessible even for shambling hackers.) One question: is there a way to delete an inserted pane? It looks useful to have an inserted pane, but refreshing will require killing the pane and reinserting.... I'm going to use this a lot -- many thanks! Bill On Wednesday, February 6, 2013 7:36:41 AM UTC-8, Terry wrote: > > On Tue, 5 Feb 2013 22:43:30 -0600 > Terry Brown <[email protected] <javascript:>> wrote: > > > It wouldn't be hard to do something with HTML formatting and links to > > display the outline and jump to a node when you click on the display, > > I'll try and get to it. > > 1) Paste the code below into a node, then hit the "run-script" > button. > > 2) Then select a node with some hierarchy, not too much. > > 3) Then right click on the panel dividers between the tree / body / log > panes, you should see a context menu with an "Open Window" sub-menu, > which should contain an "Overview" item. > > You should get a continuous view of the hierarchy with clickable > headlines which take you to the node. > > You can select multiple nodes in step 2 above, with normal list Ctrl- > or Shift- click operations. Nodes are shown in the overview in the > order selected. This is how you'd generate the overview for a whole > outline - i.e. contract the whole outline, click the first top level > node, shift click the last top level node, and then step 3. > > You can also embed the overview in a pane in the Leo window by select > "Insert" rather than "Open window" in step 3, click the action button > and select Overview. > > This was the low hanging fruit, based on code used in bookmarks.py. A > refresh button for the outline wouldn't be too hard, but right now > you need to close the window / pane and open it again to refresh. > > Cheer -Terry > > --- cut here --- > @language python > > from PyQt4 import QtGui, QtCore > from xml.sax.saxutils import escape > > def add_html(html, nd): > """recursively add to an html list with links to nodes""" > > unl = nd.get_UNL() > html.append("<div class='level'>" > "<div><a href='%s' title='%s'>%s</a></div>" % > (unl, unl, escape(nd.h))) > html.append("<pre>%s</pre>"%escape(nd.b)) > for child in nd.children(): > add_html(html, child) > html.append("</div>") > > def make_overview(c): > """build the overview widget""" > > te = QtGui.QTextBrowser() > te.setReadOnly(True) > te.setOpenLinks(False) > > def anchorClicked(url, c=c): > url = str(url.toString()) > g.handleUrl(url,c=c,p=c.p) > > te.anchorClicked.connect(anchorClicked) > > html = ["""<html><head><style> > .level .level {margin-left: 1.5em} > a {text-decoration: none; font-size: 120%} > </style></head><body>"""] > > for nd in c.getSelectedPositions(): > add_html(html, nd) > > html.append("</body></html>") > > html = '\n'.join(html) > > te.setHtml(html) > > return te > > class OverviewPaneProvider: > def __init__(self, c): > self.c = c > # Careful: we may be unit testing. > if hasattr(c, 'free_layout'): > splitter = c.free_layout.get_top_splitter() > if splitter: > splitter.register_provider(self) > def ns_provides(self): > return[('Overview', '_add_overview_pane')] > def ns_provide(self, id_): > if id_ == '_add_overview_pane': > w = make_overview(c) > return w > def ns_title(self, id_): > if id_ == '_add_overview_pane': > return "Leo Outline Overview" > def ns_provider_id(self): > # used by register_provider() to unregister previously registered > # providers of the same service > return "outline overview window" > > OverviewPaneProvider(c) > > --- cut here --- > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
