I've added a @setting to leoscreen.py to include a prefix when pulling output
from the application back into leo, e.g. '-- ' for SQL work.
Docs. below. Also I realized there's no way to have a trailing space in a
@string setting.
@settings
---------
``leoscreen_prefix`` - prepended to output pulled in to Leo. The
substring SPACE in this setting will be replaced with a space character,
to allow for trailing spaces.
Example SQL setup
-----------------
In a Leo file full of interactive SQL analysis, I have::
@settings
@string leoscreen_prefix = --SPACE
@button rollback
import time
c.leo_screen.run_text('ROLLBACK; -- %s\n' % time.asctime())
@button commit
import time
cmd = 'COMMIT; -- %s' % time.asctime()
c.leo_screen.run_text(cmd)
c.leo_screen.insert_line(cmd)
On Tue, 2 Mar 2010 11:52:21 -0600
Terry Brown <[email protected]> wrote:
> For people who do a lot of stuff in a shell window and record / edit / manage
> that stuff in Leo. This might be command line computer / software management
> (bash or whatever), or SQL or R even ipython, although Ville's tools provide
> tighter integration in the last case.
>
> My first attempt at this was the interact.py plugin which attempted to use
> subprocess.Popen to interact with bash / R / psql / whatever. It worked ok,
> but not ok enough to be smooth for everyday use.
>
> Here's a new approach, which assumes you use 'screen', the shell session
> manager / switcher. If you're not, you should be.
>
> Basically this just streamlines the whole process of pasting commands from
> Leo to the shell window, and optionally pasting results back in to Leo as a
> record of what happened.
>
> leoscreen.py - interact with shell apps. via screen
> ===================================================
>
> (an simpler alternative to interact.py)
>
> Analysis environments like SQL, R, scipy, ipython, etc. can be
> used by pasting sections of text from an editor (Leo) and a
> shell window. Results can be pasted back into the editor.
>
> This plugin streamlines the process by communicating with ``screen``,
> the shell multiplexer
>
> Commands created
> ----------------
>
> leoscreen-run-text
> Send the text selected in Leo's body text to the shell app.
> leoscreen-get-line
> Insert a line of the last result from the shell into Leo's body text
> at the current insert point. Lines are pulled one at a time starting
> from the end of the output.
> leoscreen-next
> Switch screen session to next window.
> leoscreen-prev
> Switch screen session to preceeding window.
> leoscreen-other
> Switch screen session to last window displayed.
>
> **IMPORTANT IMPLEMENTATION NOTE**: screen behave's differently
> if screen -X is executed with the same stdout as the target
> screen, vs. a different stdout. Although stdout is ignored,
> Popen() needs to ensure it's not just inherited.
>
--
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.