Hi,
after fixing to run R inside of TM as interactive shell I tried to run irb and it also works. But one 'only' has to change the communication between irb and TM slightly. Is someone interested to do that? ;)
--Hans
On Dec 21, 2007, at 8:39 AM, Hans-Jörg Bibiko wrote:
Hi,
after fixing to run R inside of TM as interactive shell I tried to run irb and it also works. But one 'only' has to change the communication between irb and TM slightly. Is someone interested to do that? ;)
--Hans
DO WHAT?!!!!1! :O Please don't tease us here. You can run IRB interactively from within TextMate? How? What do we need to do to make that work?
—Thomas Aylott – subtleGradient—
On 21.12.2007, at 20:18, Thomas Aylott - subtleGradient wrote:
On Dec 21, 2007, at 8:39 AM, Hans-Jörg Bibiko wrote:
Hi,
after fixing to run R inside of TM as interactive shell I tried to run irb and it also works. But one 'only' has to change the communication between irb and TM slightly. Is someone interested to do that? ;)
--Hans
DO WHAT?!!!!1! :O Please don't tease us here. You can run IRB interactively from within TextMate? How? What do we need to do to make that work?
Give me a moment. I will try to modify a bit in order to show something basic.
--Hans
On 21.12.2007, at 20:18, Thomas Aylott - subtleGradient wrote:
On Dec 21, 2007, at 8:39 AM, Hans-Jörg Bibiko wrote:
after fixing to run R inside of TM as interactive shell I tried to run irb and it also works. But one 'only' has to change the communication between irb and TM slightly. Is someone interested to do that? ;)
DO WHAT?!!!!1! :O Please don't tease us here. You can run IRB interactively from within TextMate? How? What do we need to do to make that work?
Give me a moment. I will try to modify a bit in order to show something basic.
Hi, here comes at least a screencast of an IRBdaemon. To be honest, I've never used all of irb's possibilities but the basics seem to work.
http://www.bibiko.de/irbdaemon.mov (600kB)
My general approach – in very short terms:
If I have an application which runs in a normal Terminal without any graphical environment (including such as Midnight Commander, vi, etc.) **AND** I can find a definable return pattern coming from that application then I can do the following.
Example for R but it's also applicable in modified form to irb, etc.
If I run R in a Terminal I will have a prompt '> ', I can type a command '2+3', press RETURN, and R writes into that Terminal '[1] 5\n> '. Fine. Now I run R in a pseudo terminal (meaning a terminal which is hidden for the user) using Ruby's lib 'pty' (a spawned process). The output of that pseudo terminal will be written into ~/Rdaemon/ r_out (together with stderr). Then I created in beforehand a named pipe on ~/Rdaemon/r_in. Into that pipe I send all commands coming from TM or elsewhere.
Here the daemon as simplified version:
cmd = "R 2&> ~/Rdaemon/r_out" PTY.spawn(cmd) { |r,w,pid| # write r into the nirvana Thread.new {r.read} fin = File.open('~/Rdaemon/r_in', "r+") while TRUE #wait for a new task and send it to R task = fin.gets w.puts task end }
That means the named pipe r_in is my keyboard and r_out is the terminal content
Before I send a command to r_in I look for the end of r_out. Then, after sending, the Rdaemon wrote something into r_out. I wait until R wrote at the end the pattern '> ' (synchronization). Then I only take the new piece of r_out and I insert it as snippet (fine-tuned for irb because irb has a changeable prompt). That's it. The daemon runs in a while TRUE loop. Caused by the line 'task = fin.gets' this process needs no cpu while waiting. If I send 'quit' to r_in it destroys itself.
--Hans
Hi,
here comes the VERY VERY work in progress irb bundle. (It's only a clone of my my Rdaemon, but one should understand the workflow) If someone is interested, give me a hint.
-open gear menu IRB daemon > Install -open new doc ; open gear menu IRB daemon > Start daemon -type someting and press RETURN -type quit to quit
Cheers,
--Hans
On 22.12.2007, at 14:32, Hans-Jörg Bibiko wrote:
Hi,
here comes the VERY VERY work in progress irb bundle. (It's only a clone of my my Rdaemon, but one should understand the workflow) If someone is interested, give me a hint.
-open gear menu IRB daemon > Install -open new doc ; open gear menu IRB daemon > Start daemon -type someting and press RETURN -type quit to quit
I forgot. You have to set the language grammar to IRB daemon!
--Hans
Am 22.12.2007 um 14:33 schrieb Hans-Jörg Bibiko:
Hi,
here comes the VERY VERY work in progress irb bundle. (It's only a clone of my my Rdaemon, but one should understand the workflow) If someone is interested, give me a hint.
Very/Merry-Big Congrats for this Hans-Jörg Bibiko,
a couple of month ago a thread about "command-completion" showed up where you and Thomas Allyot were pretty active. It's aim was to end up with a sort of universal-protocol for command-completion inside TextMate. At that time i tried to use the command-completion provided by the iPython-shell and make this usable inside TM. The iPython- shell belongs to THE tools for interactive work with Python and i guess similar can be said about irb-shell for Ruby. I have not published my 'framework' which was based on 'expect' at first and later on remote-object-lib and a tiny daemon-like extension for the shell. Though it works for me i found out that certain limitations will remain, as long as TM doesn't provide a sort of interface/ protocol for smart enhancements like these. Having this said, i truly welcome the tight integration of the irb- shell that you've presented here. I want to clearly point out that if this will remain the only scripting-language-integration, then maybe TM-Users who are not that much interested in the Ruby-Dialect but prefer Python, Perl, Lua ... - u name it - might be rethink their preferred editor.
just my 20c, merry christmas, andreas