termdef Subroutine
Purpose
Queries terminal characteristics.
Library
Standard C Library (libc.a)
Syntax
Description
The termdef subroutine returns a pointer to a null-terminated, static character string that contains the value of a characteristic defined for the terminal specified by the FileDescriptor parameter.
Asynchronous Terminal Support
Shell profiles usually set the TERM environment variable each time you log in. The stty command allows you to change the lines and columns (by using the lines and cols options). This is preferred over changing the LINES and COLUMNS environment variables, since the termdef subroutine examines the environment variables last. You consider setting LINES and COLUMNS environment variables if:
- You
are using an asynchronous
terminal and want to override the lines and cols setting
in the terminfo database
OR
- Your asynchronous terminal has an unusual number of lines or
columns and you are running an application that uses the termdef subroutine but not an
application which uses the terminfo database (for example, curses).
This is because the curses initialization subroutine, setupterm (setupterm Subroutine), calls the termdef subroutine to determine 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.
Parameters
Item | Description |
---|---|
FileDescriptor | Specifies an open file descriptor. |
Characteristic | Specifies the characteristic that is to be queried. The following
values can be specified:
|
Examples
- To display the terminal
type of the standard input device, enter:
printf("%s\n", termdef(0, 't'));
- To display the current
lines and columns of the standard output device, enter:
printf("lines\tcolumns\n%s\t%s\n", termdef(2, 'l'), termdef(2, 'c'));
Note: If the termdef subroutine is unable to determine a value for lines or columns, it returns pointers to null strings.