1

According to this (@ Programs using ncurses):

http://en.wikipedia.org/wiki/Ncurses

and this:

http://aperiodic.net/screen/faq#when_i_split_the_display_and_then_detach_screen_forgets_the_split

Screen handles the window splitting using termcap (which I barely know how to use) and not a text library. I'm developing a small C++ console application where I need to do the same thing. I tried with ncurses, which is the obvious choice, but it doesn't support ANSI escape sequences for colors (http://ascii-table.com/ansi-escape-sequences.php) and what I'm essentially doing is fork()/exec() 4 bash shells in the same tty, which is a piece of cake in ncurses, but, with no colors and lots of failed escape sequences that looks like garbage. Methods like printf() and std::cout, works perfectly with the colors but are useless in this case as ncurses relies in its own functions to keep things in place.

Before suggesting parsing the escape sequences into ncurses to colorize the output with native attributes of the library, keep in mind that is too much work and there should be a more elegant way to deal with it (like GNU Screen does)

So, any ideas of how to work it out?

Thanks in advance

Adrian Frühwirth
  • 42,970
  • 10
  • 60
  • 71
  • How about just making a wrapper system (script?) that starts `screen` configured as you need it AND then launches your console app to run inside. Good luck. – shellter Jun 03 '11 at 22:16
  • The main power of unix-like systems is, than can build bigger thing from the smaller ones. So @Lucas Black's comment is the best answer what you can get. Don't try reinventing a wheel, because you can end with the squares and use the already perfectly working wheels = gnu screen. Use the screen to split your terminal (and will work on non-ansi ones too) and after you should star your programs inside... – clt60 Jun 03 '11 at 22:55

1 Answers1

3

You cannot allow the subordinate programs to emit their own escape sequences. If you do, they will destroy your screen formatting.

GNU screen is in fact emulating its own terminal, that is, parses escape sequences, executes their logic, builds an internal representation of the screen, and then transfers that on whatever terminal it's running on. That's the only sane way to do that. Unfortunately it's a lot of work.

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243