Interacting with a Ruby program

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Interacting with a Ruby program

Andrew Stewart
Hello,

I'd like to get MacVim to give focus to a MacRuby program, which
accepts some input from the user via a GUI and then returns the input
(and focus) back to MacVim.

Right now I can get MacVim to execute a non-interactive Ruby program,
though when I try a console-based interactive Ruby program it simply
blocks MacVim indefinitely.  I think this is because the Ruby is
trying to interact with the user via stdin, and there's no console as
such when the program is launched via MacVim.  However I don't want to
get bogged down with this because my real aim is to interact with the
user via a MacRuby GUI.

So I just wanted to ask, before I embark on this, is it feasible?  If
so, what's the recommended way to launch another program and wait for
it to return something to MacVim?

Thanks and regards,

Andy Stewart
------
http://airbladesoftware.com

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

Björn Winckler
On 23 March 2010 14:09, Andrew Stewart wrote:

>
> I'd like to get MacVim to give focus to a MacRuby program, which
> accepts some input from the user via a GUI and then returns the input
> (and focus) back to MacVim.
>
> Right now I can get MacVim to execute a non-interactive Ruby program,
> though when I try a console-based interactive Ruby program it simply
> blocks MacVim indefinitely.  I think this is because the Ruby is
> trying to interact with the user via stdin, and there's no console as
> such when the program is launched via MacVim.  However I don't want to
> get bogged down with this because my real aim is to interact with the
> user via a MacRuby GUI.
>
> So I just wanted to ask, before I embark on this, is it feasible?  If
> so, what's the recommended way to launch another program and wait for
> it to return something to MacVim?

To open some other GUI program you could use (from within MacVim):

:!open -a ProgramName filename

Maybe that's enough for your needs.  As far as I know there is no
universal way on Mac OS X to wait for a GUI app to finish (let alone
return focus to the calling program).

Björn

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

Chris Eidhof
I'm not sure if it helps, but you could do it the other way around. MacVim implements the client part of the ODB editor suite [1]. So you could have a MacRuby program that implements the server part and then call MacVim.

Alternatively, it shouldn't be to hard to patch MacVim to implement the server part of the ODB Editor Suite as well. Then the MacRuby program has to implement the client part.

-chris

[1]: http://www.barebones.com/support/develop/odbsuite.html

On 24 mrt 2010, at 22:32, björn wrote:

> On 23 March 2010 14:09, Andrew Stewart wrote:
>>
>> I'd like to get MacVim to give focus to a MacRuby program, which
>> accepts some input from the user via a GUI and then returns the input
>> (and focus) back to MacVim.
>>
>> Right now I can get MacVim to execute a non-interactive Ruby program,
>> though when I try a console-based interactive Ruby program it simply
>> blocks MacVim indefinitely.  I think this is because the Ruby is
>> trying to interact with the user via stdin, and there's no console as
>> such when the program is launched via MacVim.  However I don't want to
>> get bogged down with this because my real aim is to interact with the
>> user via a MacRuby GUI.
>>
>> So I just wanted to ask, before I embark on this, is it feasible?  If
>> so, what's the recommended way to launch another program and wait for
>> it to return something to MacVim?
>
> To open some other GUI program you could use (from within MacVim):
>
> :!open -a ProgramName filename
>
> Maybe that's enough for your needs.  As far as I know there is no
> universal way on Mac OS X to wait for a GUI app to finish (let alone
> return focus to the calling program).
>
> Björn
>
> --
> You received this message from the "vim_mac" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

Andrew Stewart
In reply to this post by Björn Winckler

On 24 Mar 2010, at 21:32, björn wrote:
> To open some other GUI program you could use (from within MacVim):
>
> :!open -a ProgramName filename

Thank you, that's perfect.


> Maybe that's enough for your needs.  As far as I know there is no
> universal way on Mac OS X to wait for a GUI app to finish (let alone
> return focus to the calling program).


OK, well knowing that is in itself useful.

Cheers,

Andy Stewart
-------
http://airbladesoftware.com

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

PitPalme
In reply to this post by Björn Winckler
Am 24.03.10 22:32, schrieb björn:
> To open some other GUI program you could use (from within MacVim):
>
> :!open -a ProgramName filename
>
> Maybe that's enough for your needs.  As far as I know there is no
> universal way on Mac OS X to wait for a GUI app to finish (let alone
> return focus to the calling program).

I don't know about OS X < 10.6, but over here 'man open' gives

[...]
     -W  Causes open to wait until the applications it opens
         (or that were already open) have exited. [...]

And 'open -a MacVim -W file.txt' in fact gives focus to running MacVim
instance and opens 'file.txt' in a new tab. After quitting MacVim terminal
(iTerm) prompt returns to 'input state'.

That's not making any statement about "focus returning", sure.

Having MacVim opened ':!open -a TextEdit -W %' opens current file in TextEdit
and waits until TextEdit is closed. Sure, this example is quiet silly, but for
demonstration purposes it seemed to be good enough to me :-)
--
Regards,

Peter Palmreuther

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

Björn Winckler
On 25 March 2010 19:10, Peter Palmreuther wrote:

> Am 24.03.10 22:32, schrieb björn:
>> To open some other GUI program you could use (from within MacVim):
>>
>> :!open -a ProgramName filename
>>
>> Maybe that's enough for your needs.  As far as I know there is no
>> universal way on Mac OS X to wait for a GUI app to finish (let alone
>> return focus to the calling program).
>
> I don't know about OS X < 10.6, but over here 'man open' gives
>
> [...]
>     -W  Causes open to wait until the applications it opens
>         (or that were already open) have exited. [...]
>
> And 'open -a MacVim -W file.txt' in fact gives focus to running MacVim
> instance and opens 'file.txt' in a new tab. After quitting MacVim terminal
> (iTerm) prompt returns to 'input state'.

Thanks Peter for pointing that out -- I was not aware of this flag.

Björn

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

Andrew Stewart
In reply to this post by PitPalme

On 25 Mar 2010, at 18:10, Peter Palmreuther wrote:

> I don't know about OS X < 10.6, but over here 'man open' gives
>
> [...]
>     -W  Causes open to wait until the applications it opens
>         (or that were already open) have exited. [...]
>
> And 'open -a MacVim -W file.txt' in fact gives focus to running MacVim
> instance and opens 'file.txt' in a new tab. After quitting MacVim  
> terminal
> (iTerm) prompt returns to 'input state'.
>
> That's not making any statement about "focus returning", sure.
>
> Having MacVim opened ':!open -a TextEdit -W %' opens current file in  
> TextEdit
> and waits until TextEdit is closed. Sure, this example is quiet  
> silly, but for
> demonstration purposes it seemed to be good enough to me :-)

Nice!  That's exactly what I'm after.

I thought I knew how `open` worked: next time I'll be sure to check  
the man page.

Thanks and regards,

Andy Stewart
------
http://airbladesoftware.com

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Interacting with a Ruby program

Andrew Stewart
In reply to this post by Chris Eidhof

On 25 Mar 2010, at 10:45, Chris Eidhof wrote:
> I'm not sure if it helps, but you could do it the other way around.  
> MacVim implements the client part of the ODB editor suite [1]. So  
> you could have a MacRuby program that implements the server part and  
> then call MacVim.
>
> Alternatively, it shouldn't be to hard to patch MacVim to implement  
> the server part of the ODB Editor Suite as well. Then the MacRuby  
> program has to implement the client part.

Chris,

Thanks, that's an interesting approach and I'd be intrigued to pursue  
it later.  For now, though, I'll stick with the simpler `open`  
mechanism and get that going first.

Thanks and regards,

Andy Stewart
------
http://airbladesoftware.com

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.