I have created a command line app that takes commands as user input in a
loop. I need to simulate up arrow key and down arrow key so that user can
navigate through the commands just like it is done in command prompt and
irb. I could not find a way catch up arrow key and down arrow key.
The original C based library for that kind of thing was called
"Curses", if I understand the question right. You may find some gem
or something with the string "curses" in it that will help. That is
for Unix/Linux though, and there may be a cross platform thing. GTK
is a windowing manager thingy that may have access for it for
Ubuntu/Unix side.
I hope there is a cross platform thing. It would be cool. I've not
found Ruby to work that well on Windows anyway, however.
xc
···
On Fri, Sep 2, 2016 at 10:48 AM, Rob Biedenharn <rob.biedenharn@gmail.com> wrote:
On 2016-Sep-2, at 09:05 , Devashish Bhardwaj <devashish.vhardwaj@gmail.com> > wrote:
I have created a command line app that takes commands as user input in a
loop. I need to simulate up arrow key and down arrow key so that user can
navigate through the commands just like it is done in command prompt and
irb. I could not find a way catch up arrow key and down arrow key.You should be able to use or at least learn from:
GitHub - ConnorAtherton/rb-readline: Pure-Ruby Readline Implementation-Rob
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
You should be able to use or at least learn from: GitHub - ConnorAtherton/rb-readline: Pure-Ruby Readline Implementation
-Rob
···
On 2016-Sep-2, at 09:05 , Devashish Bhardwaj <devashish.vhardwaj@gmail.com> wrote:
I have created a command line app that takes commands as user input in a loop. I need to simulate up arrow key and down arrow key so that user can navigate through the commands just like it is done in command prompt and irb. I could not find a way catch up arrow key and down arrow key.
I don't know if this will work for you, but a simple alternative is
just to wrap your program with the "rlwrap" utility:
$ rlwrap ruby script.rb
From within ruby, yes, you will need to use readline or any other
line-editing library with history support.
Did you try searching google for "creating Ruby REPL
<Google;
"?
In particular, I used something like this for a project:
https://www.fedux.org/articles/2015/08/26/creating-an-irb-based-repl-console-for-your-project.html
Best of luck.
···
On Fri, Sep 2, 2016 at 6:05 AM Devashish Bhardwaj < devashish.vhardwaj@gmail.com> wrote:
I have created a command line app that takes commands as user input in a
loop. I need to simulate up arrow key and down arrow key so that user can
navigate through the commands just like it is done in command prompt and
irb. I could not find a way catch up arrow key and down arrow key.
I've used ncurses for this kind of stuff quite successfully in the past,
maybe you can give it a try.
···
Em sáb, 3 de set de 2016 18:36, Lucas Buchala <lucasbuchala@gmail.com> escreveu:
I don't know if this will work for you, but a simple alternative is
just to wrap your program with the "rlwrap" utility:$ rlwrap ruby script.rb
From within ruby, yes, you will need to use readline or any other
line-editing library with history support.Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Thanks for the responses guys. The readLine method used in irb finally did
it.
···
On 17 Sep 2016 7:05 a.m., "James Pacheco" <james.pacheco@gmail.com> wrote:
On Fri, Sep 2, 2016 at 6:05 AM Devashish Bhardwaj < > devashish.vhardwaj@gmail.com> wrote:
I have created a command line app that takes commands as user input in a
loop. I need to simulate up arrow key and down arrow key so that user can
navigate through the commands just like it is done in command prompt and
irb. I could not find a way catch up arrow key and down arrow key.Did you try searching google for "creating Ruby REPL
<Google;
"?In particular, I used something like this for a project:
https://www.fedux.org/articles/2015/08/26/creating-
an-irb-based-repl-console-for-your-project.htmlBest of luck.
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Linux has an interface for this which is used for a lot of script automation...
···
On Mon, Sep 5, 2016 at 12:42 AM, Samuel Brandão <gb.samuel@gmail.com> wrote:
I've used ncurses for this kind of stuff quite successfully in the past,
maybe you can give it a try.Em sáb, 3 de set de 2016 18:36, Lucas Buchala <lucasbuchala@gmail.com> > escreveu:
I don't know if this will work for you, but a simple alternative is
just to wrap your program with the "rlwrap" utility:$ rlwrap ruby script.rb
From within ruby, yes, you will need to use readline or any other
line-editing library with history support.Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Rerun comes up, but that's not what I remember. There is a facility
that is callable from Bash, for instance, that is used in things like
installs.
···
On Mon, Sep 5, 2016 at 8:57 AM, Xeno Campanoli <xeno.campanoli@gmail.com> wrote:
Linux has an interface for this which is used for a lot of script automation...
On Mon, Sep 5, 2016 at 12:42 AM, Samuel Brandão <gb.samuel@gmail.com> wrote:
I've used ncurses for this kind of stuff quite successfully in the past,
maybe you can give it a try.Em sáb, 3 de set de 2016 18:36, Lucas Buchala <lucasbuchala@gmail.com> >> escreveu:
I don't know if this will work for you, but a simple alternative is
just to wrap your program with the "rlwrap" utility:$ rlwrap ruby script.rb
From within ruby, yes, you will need to use readline or any other
line-editing library with history support.Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
are you thinking of expect?
martin
···
On Sep 5, 2016 8:58 AM, "Xeno Campanoli" <xeno.campanoli@gmail.com> wrote:
Rerun comes up, but that's not what I remember. There is a facility
that is callable from Bash, for instance, that is used in things like
installs.On Mon, Sep 5, 2016 at 8:57 AM, Xeno Campanoli <xeno.campanoli@gmail.com> > wrote:
> Linux has an interface for this which is used for a lot of script
automation...
>
>
> On Mon, Sep 5, 2016 at 12:42 AM, Samuel Brandão <gb.samuel@gmail.com> > wrote:
>> I've used ncurses for this kind of stuff quite successfully in the past,
>> maybe you can give it a try.
>>
>>
>> Em sáb, 3 de set de 2016 18:36, Lucas Buchala <lucasbuchala@gmail.com> > >> escreveu:
>>>
>>> I don't know if this will work for you, but a simple alternative is
>>> just to wrap your program with the "rlwrap" utility:
>>>
>>> $ rlwrap ruby script.rb
>>>
>>> From within ruby, yes, you will need to use readline or any other
>>> line-editing library with history support.
>>>
>>> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=
>
>>> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>>
>>
>>
>> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=
>
>> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>>Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>