This is a description of how to actually use the screen package. For simplicity, we assume all updating, reading, etc. is applied to although a different window can of course be specified. In order to use the screen package, the routines must know about terminal characteristics, and the space for and must be allocat- ed. These functions are performed by Since it must allocate space for the windows, it can overflow core when attempting to do so. On this rather rare occasion, returns ERR. must be called before any of the routines which affect windows are used. If it is not, the program will core dump as soon as either or are ref- erenced. However, it is usually best to wait to call it until after you are sure you will need it, like after checking for startup errors. Terminal status changing routines like and should be called after After the initial window allocation done by specific window characteristics can be set. Scrolling can be enabled by calling If you want the cursor to be left after the last change, use If this isn't done, will move the cursor to the window's current after updating it. Additional windows can be created by using the functions and allows you to delete an ex- isiting window. The variables and control the size of the termi- nal. They are initially implicitly set by but can be altered ex- plicitly by the user followed by a call to Note that any call to will always delete any existing and/or before creating new ones so this change is best done before the initial call to The basic functions used to change what will go on a window are and adds a character at the current , returning ERR if it would cause the window to illegally scroll, printing a character in the lower right-hand corner of a terminal which automatically scrolls if scrolling is not allowed. changes the current to whatever you want them to be. It returns ERR if you try to move off the win- dow. As mentioned above, you can combine the two into to do both things in one call. The other output functions (such as and all call to add characters to the window. After a change has been made to the window, you must call when you want the portion of the terminal covered by the window to reflect the change. In or- der to optimize finding changes, assumes that any part of the window not changed since the last of that window has not been changed on the terminal, that you have not refreshed a portion of the terminal with an overlapping window. If this is not the case, the routines and are provided to make it look like a de- sired part of window has been changed, thus forcing to check that whole subsection of the terminal for changes. If you call with it will make the screen look like the image of This is useful for implementing a command which would redraw the screen in case it got messed up. Input is essentially a mirror image of output. The complementary function to is which, if echo is set, will call to echo the character. Since the screen package needs to know what is on the terminal at all times, if characters are to be echoed, the tty must be in raw or cbreak mode. If it is not, sets it to be cbreak, and then reads in the character. In order to perform certain optimizations, and, on some terminals, to work at all, some things must be done before the screen routines start up. These functions are performed in and which are called by In order to clean up after the routines, the routine is provided. It restores tty modes to what they were when was first called. The terminal state module uses the variable to save the original terminal state which is then restored upon a call to Thus, any- time after the call to initscr, should be called before exiting. Note however, that should always be called the final calls to which free the storage of the windows.