Saving and Setting the Terminal State

Vermont Views provides functions to save and set the state of the terminal driver. These functions enable you to set the terminal driver to a desired state before temporarily returning the user to the operating system or invoking some other program. When you return to the Vermont Views application, you must restore the terminal driver to the state used by Vermont Views.

Terminal states are saved in a TERMSTAT structure. The TERMSTAT structure is different for different operating systems. Any manipulations of the structure will be non-portable.

Two TERMSTAT structures are provided for two predefined terminal states. The structures are defined by vv_init() during initialization. After initialization the two structures contain:

BEGTERMSTAT Terminal state when vv_init() was called
VVTERMSTAT Terminal state set by Vermont Views in vv_init()

To save the current terminal state, use:

int ts_save(t_statep)

TERMSTATPTR t_statep;    /* Structure to save the terminal state        */

To set the terminal state, use:

int ts_set(t_statep)

TERMSTATPTR t_statep;    /* Structure containing the terminal state    */

In the following code example, the application temporarily leaves the Vermont Views system to go to a UNIX text editor. Before the application makes the system call, it sets the terminal driver to the state found by vv_init() when Vermont Views was initialized. When the operating system routine has completed, the terminal is returned to the pre-defined Vermont Views terminal state.

. . .

. . .
 
ts_set(&BEGTERMSTAT);
/* Set terminal state for next use
*/
system("vi some_file"):
/* Edit a file
*/
ts_set(&VVTERMSTAT);

. . .

. . .
/* Reset terminal for VV
*/

Under VMS, you would use the lib$spawn() library routine in place of system() to obtain similar results.

Alternatively, instead of writing this code yourself, you can call the Vermont Views function vv_spawn() to correctly handle the terminal driver state when calling another program from your application.


Home Contents Previous Next