Idea: buttons in vr pane? or in body text hyperlinks?

36 views
Skip to first unread message

Matt Wilkie

unread,
Jul 30, 2019, 12:03:03 PM7/30/19
to leo-editor
One of Leo's coolest features is being able to add buttons to the toolbar in a context-aware or context-dependent way. It'd be really cool if this could be extended so that the "button" could be somewhere else. For example what if the text within [ ... ] could initiate an action, a Leo script?

[Register-leo] - Creates registry keys for Leo file type and .leo file
association. Afterwards .leo files will show Leo icon and
double-clicking them will open in Leo Editor.


Already ctrl-click on a URL in body text launches a browser, so there's at least some plumbing to enable action-on-text. No idea at this point what the triggers could be*, there's no way we want any ol' text fragment to be actionable, but figured I'd throw the idea out and see what sprouts.

*
#leonine
script://@button node-headline

#asciidoc
link:script://
thing.leo-->path-to-node[button text]

#markdown inline
[
button text](script://thing.leo-->path-to-node)

#markdown footnote
[button text][0]
...
[0]:
script://thing.leo-->path-to-node



-matt

Chris George

unread,
Jul 30, 2019, 12:37:17 PM7/30/19
to leo-e...@googlegroups.com
Ctrl-click on a word could action something like wordnet, which I already have an @button for. (Must install wordnet) This button acts on the highlighted text. Ctrl-click would have to act on the word under the cursor.

Select this, copy and paste as a node.

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo: http://leoeditor.com/leo_toc.html -->
<leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
<leo_header file_format="2"/>
<vnodes>
<v t="chris.20180422063034.1"><vh>@button wordnet</vh>
<v t="chris.20180422063034.2"><vh>@rclick wordnet</vh></v>
<v t="chris.20180422063034.3"><vh>@rclick wordnet-synonym</vh></v>
<v t="chris.20180805095858.1"><vh>@rclick wordnet-meronyms</vh></v>
</v>
</vnodes>
<tnodes>
<t tx="chris.20180422063034.1"></t>
<t tx="chris.20180422063034.2">w = c.frame.body.wrapper
p = w.getSelectedText()
message = p.replace('"', "'")
command = '/usr/bin/wn %s -over' % message

c.controlCommands.executeSubprocess(
    event=None,
    command=command,
)</t>
<t tx="chris.20180422063034.3">w = c.frame.body.wrapper
p = w.getSelectedText()
message = p.replace('"', "'")
command = '/usr/bin/wn %s -simsv' % message

c.controlCommands.executeSubprocess(
    event=None,
    command=command,
)</t>
<t tx="chris.20180805095858.1">w = c.frame.body.wrapper
p = w.getSelectedText()
message = p.replace('"', "'")
command = '/usr/bin/wn %s -hmern' % message

c.controlCommands.executeSubprocess(
    event=None,
    command=command,
)</t>
</tnodes>
</leo_file>

--
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 leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/4e813bd0-eb1f-40c5-a105-4c87c51cbcd8%40googlegroups.com.

Edward K. Ream

unread,
Jul 31, 2019, 5:35:26 AM7/31/19
to leo-editor
On Tue, Jul 30, 2019 at 11:03 AM Matt Wilkie <map...@gmail.com> wrote:
One of Leo's coolest features is being able to add buttons to the toolbar in a context-aware or context-dependent way. It'd be really cool if this could be extended so that the "button" could be somewhere else. For example what if the text within [ ... ] could initiate an action, a Leo script?

Leo already has lots of machinery to handle url's and unl's.  See @file leoGlobals.py-->g.Urls.

Leo's colorizer colorizes these and Leo handles control clicks in them.

In short, I'm not sure anything more needs to be done.

Edward

Matt Wilkie

unread,
Aug 1, 2019, 7:26:20 PM8/1/19
to leo-editor
Ctrl-click on a word could action something like wordnet, which I already have an @button for. (Must install wordnet) This button acts on the highlighted text. Ctrl-click would have to act on the word under the cursor.

Select this, copy and paste as a node.

Thanks! A few editing changes for win/linux and off to the races. Wordnet is seriously useful. How did I not know about it?

-matt

Matt Wilkie

unread,
Aug 1, 2019, 7:26:50 PM8/1/19
to leo-editor
Leo already has lots of machinery to handle url's and unl's.  See @file leoGlobals.py-->g.Urls.

studying, thanks

-matt
Reply all
Reply to author
Forward
0 new messages