newterm Subroutine
Purpose
Initializes curses and its data structures for a specified terminal.
Library
Curses Library (libcurses.a)
Syntax
Description
The newterm subroutine initializes curses and its data structures for a specified terminal. Use this subroutine instead of the initscr subroutine if you are writing a program that sends output to more than one terminal. You should also use this subroutine if your program requires indication of error conditions so that it can run in a line-oriented mode on terminals that do not support a screen-oriented program.
If you are directing your program's output to more than one terminal, you must call the newterm subroutine once for each terminal. You must also call the endwin subroutine for each terminal to stop curses and restore the terminal to its previous state.
Parameters
Item | Description |
---|---|
InFile | Identifies the input device file. |
OutFile | Identifies the output device file. |
Type | Specifies the type of output terminal. This parameter is the same as the $TERM environment variable for that terminal. |
Return Values
The newterm subroutine returns a variable of type SCREEN *. You should save this reference to the terminal within your program.
Examples
- To initialize curses on a terminal represented by the lft device
file as both the input and output terminal, open the device file with
the following:
fdfile = fopen("/dev/lft0", "r+");
Then, use the newterm subroutine to initialize curses on the terminal and save the new terminal in the my_terminal variable as follows:
char termname [] = "terminaltype"; SCREEN *my_terminal; my_terminal = newterm(termname,fdfile, fdfile);
- To open the device file /dev/lft0 as the input terminal
and the /dev/tty0 (an ibm3151) as the output terminal,
do the following:
fdifile = fopen("/dev/lft0", "r"); fdofile = fopen("/dev/tty0", "w"); SCREEN *my_terminal2; my_terminal2 = newterm("ibm3151",fdofile, fdifile);
- To use stdin for input and stdout for output, do the following:
char termname [] = "terminaltype"; SCREEN *my_terminal; my_terminal = newterm(termname,stdout,stdin);