Simple, Two-Frame Terminal Application

Hello All,

I am in need of a way to develop a simple, two-frame terminal
application that can display event-driven data in one frame and allow
for the input of commands in a different frame. Without having to go to
the extremes of something like ncurses, does anyone know of a way to do
this? Nothing fancy is needed like CTRL key bindings and such, just two
simple frames.

···

--
Thanks!
Bryan

--
Posted via http://www.ruby-forum.com/.

I am in need of a way to develop a simple, two-frame terminal
application that can display event-driven data in one frame and allow
for the input of commands in a different frame. Without having to go
to the extremes of something like ncurses, does anyone know of a way
to do this? Nothing fancy is needed like CTRL key bindings and such,
just two simple frames.

What about having two processes that communicate over DRb, and use
screen to put them in different frames?

screen has an -X switch which you can use to send commands to the
currently running screen (like split, focus etc)

My project, CARPS, needs to do this because it currently has no GUI, but
to be cross platform, it allows the user to specify a command which
wraps the subprocess (ie, start /wait %cmd, if you are on windows)

John

There are other options too:

Are you on a unix/osx or on Windows ?

1. Have 2 threads. One takes user input, and another displays or does
work.
I;ve done a small program like this that plays music while giving me a
prompt so user can pause, halt etc.

If your work is not in the background, then you don't need threads. You
can position the cursor using system("tput cup"). You would do this for
always taking input on top or bottom line. Not clean but it works.

2. Another simple option is to use Liveconsole. You can open another
terminal window and pass commands on the prompt (an irb prompt).
Liveconsole gives you samples, its very easy.

···

--
Posted via http://www.ruby-forum.com/.

Hi Rahul,

Thanks for responding. I like your option 1 with threading... how can I
get my terminal split up such that one thread can be displaying data in
one section of the terminal and the other thread can be waiting for
input in another section of the terminal? Does your suggestion of using
tcup apply here as well, or is there a "cleaner" way to do it?

Oh, and I am on Linux.

···

--
Thanks!
Bryan

--
Posted via http://www.ruby-forum.com/.

If your work is not in the background, then you don't need threads.
You can position the cursor using system("tput cup"). You would do
this for always taking input on top or bottom line. Not clean but it
works.

Ace, cheers for the tidbit! I've never seen that before. Time to make
some more lolsome text-based programs :slight_smile:

I've always used ncurses for that. I found the book "Unix Programming with Curses" to be useful and entertaining when people see it...

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.

···

On Sat, 20 Nov 2010, Bryan Richardson wrote:

Hi Rahul,

Thanks for responding. I like your option 1 with threading... how can I
get my terminal split up such that one thread can be displaying data in
one section of the terminal and the other thread can be waiting for
input in another section of the terminal? Does your suggestion of using
tcup apply here as well, or is there a "cleaner" way to do it?

Oh, and I am on Linux.

Bryan Richardson wrote in post #962617:

Hi Rahul,

Thanks for responding. I like your option 1 with threading... how can I
get my terminal split up such that one thread can be displaying data in
one section of the terminal and the other thread can be waiting for
input in another section of the terminal? Does your suggestion of using
tcup apply here as well, or is there a "cleaner" way to do it?

In my case, the terminal was not split up. I would use the last row for
inputting user commands, and display on top. Yes, that requires me to
position the cursor using tput cup, and also to clear the line first, so
the previous command is erased.

I also used readline, so that the user can search or reuse previous
commands. The cleaner way perhaps is the screen option someone else
mentioned (which i have not used yet). Best would be to use ncurses or
ffi-ncurses.

···

--
Posted via http://www.ruby-forum.com/\.

Yeah, I just haven't found the documentation for Ruby's ncurses
bindings to be very helpful at all, and for something as simple as I'm
wanting to do I was hoping there was a simpler alternative. Oh well,
maybe this is a good, simple entry level program to get my feet wet
with ncurses.

···

On Fri, Nov 19, 2010 at 10:09 AM, Matt Lawrence <matt@technoronin.com> wrote:

On Sat, 20 Nov 2010, Bryan Richardson wrote:

Hi Rahul,

Thanks for responding. I like your option 1 with threading... how can I
get my terminal split up such that one thread can be displaying data in
one section of the terminal and the other thread can be waiting for
input in another section of the terminal? Does your suggestion of using
tcup apply here as well, or is there a "cleaner" way to do it?

Oh, and I am on Linux.

I've always used ncurses for that. I found the book "Unix Programming with
Curses" to be useful and entertaining when people see it...

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.

Have you read the C documentation? IMO ncurses is lovely! It's
off-topic but I wrote a stupid platform game with curses in haskell.
Have fun!

John

···

On Sat, 20 Nov 2010 07:22:29 +0900 Bryan Richardson <btricha@gmail.com> wrote:

Yeah, I just haven't found the documentation for Ruby's ncurses
bindings to be very helpful at all, and for something as simple as I'm
wanting to do I was hoping there was a simpler alternative. Oh well,
maybe this is a good, simple entry level program to get my feet wet
with ncurses.