Initializes the terminal structure with the values in the terminfo database.
Curses Library (libcurses.a)
#include <curses.h>
#include <term.h>
setupterm( Term, FileNumber, ErrorCode)
char *Term;
int FileNumber;
int *ErrorCode;
The setupterm subroutine determines the number of lines and columns available on the output terminal. The setupterm subroutine calls the termdef subroutine to define the number of lines and columns on the display. If the termdef subroutine cannot supply this information, the setupterm subroutine uses the values in the terminfo database.
The setupterm subroutine initializes the terminal structure with the terminal-dependent capabilities from terminfo. This routine is automatically called by the initscr and newterm subroutines. The setupterm subroutine deals directly with the terminfo database.
Two of the terminal-dependent capabilities are the lines and columns. The setupterm subroutine populates the lines and column fields in the terminal structure in the following manner:
The simplest call is setupterm((char*) 0, 1, (int*) 0), which uses all defaults.
After the call to the setupterm subroutine, the cur_term global variable is set to point to the current structure of terminal capabilities. A program can use more than one terminal at a time by calling the setupterm subroutine for each terminal and then saving and restoring the cur_term variable.
One of the following status values is stored into the integer pointed to by the ErrorCode parameter:
1 | Successful completion. |
0 | No such terminal. |
-1 | An error occurred while locating the terminfo database. |
To determine the current terminal's capabilities using $TERM as the terminal name, standard output as output, and returning no error codes, enter:
setupterm((char*) 0, 1, (int*) 0);
The termdef (termdef Subroutine) subroutine.
Curses Overview for Programming, List of Curses Subroutines, Understanding Terminals with Curses in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.