Lucas Black
Lucas Black

Reputation: 11

Spliting a terminal like GNU screen, programatically

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

Upvotes: 1

Views: 1054

Answers (1)

n. m. could be an AI
n. m. could be an AI

Reputation: 119877

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.

Upvotes: 3

Related Questions