You are not logged in.

#1 2012-02-09 21:02:49

rubdos
Member
Registered: 2011-09-22
Posts: 61

c++ 'subshell'

Hi guys.

I'm building something (GPL'ed ofcousre wink) in c++. It's terminal-based and it is interactive. Now I'd like to do the following:

Program is running in about 5 threads (boost AND pthread. Yeh. Getting difficult). Each one's writing to the terminal (which works now).
Like I said, it's interactive, so the user should be able to write a command at ANY time the software is running. ATM, I've got a separate thread who reads from stdin. Which, obviously, messes up when I'm writing to stdout at the same moment.

Can I make something that keeps the last row on the terminal free for the user to type and the software to write at the second last row? So redirect stdout and get stdin NOT messed up?

Example is bukkit (minecraft server system) which is taking user commands at any time and still is writing 'User connected' to the stdout of my terminal. Bukkit is in java. It's open, but the source has been taken from the internet, because of system failures and such...

Any ideas?

Rub

EDIT: Ofcourse the commands written in stdin are to be processed in my program itself wink

Last edited by rubdos (2012-02-09 21:03:41)

Offline

#2 2012-02-09 22:21:13

Goran
Member
Registered: 2012-01-24
Posts: 92

Re: c++ 'subshell'

Maybe I don't understand your situation well enough, but it seems to me like you could simply use ncurses to reserve the bottom row for input, while using the remaining rows as an output stream.

Offline

#3 2012-02-10 16:25:19

rubdos
Member
Registered: 2011-09-22
Posts: 61

Re: c++ 'subshell'

Goran wrote:

Maybe I don't understand your situation well enough, but it seems to me like you could simply use ncurses to reserve the bottom row for input, while using the remaining rows as an output stream.

Yep. That's what you should understand. It's not easy to explain for me (I'm no native speaker sad ). I was thinking about ncurses, but the software will also be running on windows machines. I guess it'll be possible to compile ncurses for windows? BTW: Don't blame me. I'd rather write linux/BSD only software if I hadn't got any people who would like to use it on windows...

And perhaps it's even better to just separate library and program and make two interfaces for it -_-

Ruben

Offline

#4 2012-02-11 02:06:44

Goran
Member
Registered: 2012-01-24
Posts: 92

Re: c++ 'subshell'

rubdos wrote:

I was thinking about ncurses, but the software will also be running on windows machines. I guess it'll be possible to compile ncurses for windows?

I think it could probably run under cygwin, but I never actually tried, so I'm not sure.

Another possible option, although I don't know if this is acceptable for your application: Use a cross-platform gui library, like wxWidgets, and then use their text and/or label widgets to create your own "terminal-like" environment, where the bottom field is for command input, and the top field is used to show the output stream.

Maybe that could work?

Offline

#5 2012-02-11 09:52:16

rubdos
Member
Registered: 2011-09-22
Posts: 61

Re: c++ 'subshell'

Goran wrote:
rubdos wrote:

I was thinking about ncurses, but the software will also be running on windows machines. I guess it'll be possible to compile ncurses for windows?

I think it could probably run under cygwin, but I never actually tried, so I'm not sure.

Another possible option, although I don't know if this is acceptable for your application: Use a cross-platform gui library, like wxWidgets, and then use their text and/or label widgets to create your own "terminal-like" environment, where the bottom field is for command input, and the top field is used to show the output stream.

Maybe that could work?

I'll indeed build a gui later on. I'd like to compile under gcc for windows, because it's an interface for a raytracer, and it should run natively... I'll try wx later on, I solved right now by making verbose = 0 for the library.

Rub

Offline

#6 2012-02-11 23:26:01

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: c++ 'subshell'

rubdos wrote:
Goran wrote:

Maybe I don't understand your situation well enough, but it seems to me like you could simply use ncurses to reserve the bottom row for input, while using the remaining rows as an output stream.

Yep. That's what you should understand. It's not easy to explain for me (I'm no native speaker sad ). I was thinking about ncurses, but the software will also be running on windows machines. I guess it'll be possible to compile ncurses for windows? BTW: Don't blame me. I'd rather write linux/BSD only software if I hadn't got any people who would like to use it on windows...

And perhaps it's even better to just separate library and program and make two interfaces for it -_-

Ruben

pdcurses runs on Windows.

Offline

Board footer

Powered by FluxBB