save and regerate the current screen before and after a command

Balakrishna Raghunath rags at hpcuhc.cup.hp.com
Sat Jan 12 10:37:35 AEST 1991


If you wish to save a screen from an application; exit the application and
then regenerate the screen when you restart the application; then I think the
only way out is to program it yourself. The unix kernel does not retain any
state on the layout of the current screen....and it would be stupid to try 
and do so within the kernel. It is really not too much of trouble to do this
in a program...I have done it. All you have to do is to maintain the state
of the screen in a text buffer and write it out to a file. When you restart
the application; read this back in and use the curses functions to redisplay 
the screen. Of course; when you have highlighting etc. in a screen the 
scheme has to be somewhat more complicated. But there are not many additional 
data structures required. All you have to remember now is that instead
of using a char buffer use a chtype buffer. 'chtype' is the curses defined
type for characters with attributes(at least in sys V curses). It is 
probably typedefed to a long in curses.h 

If you need something to do this save and restart from outside of the 
application (i.e if you need something more generic), you mave have a more
difficult time...You could still do it if you write a program to checkpoint
the state of a program and restart it. I think a public domain checkpointing
program was posted to the net sometime back.

If what you want is a way of taking a screen dump(a la printscreen); your   
application can make use of the curses function screendump() (I think...
I know there is a curses function for dumping the screen, at least in sys V
curses..I have used it).

rags



More information about the Comp.unix.programmer mailing list