Reading the source would be definitive, but for the fainthearted, the manual is the place to go. If there is no command-line option, the terminal database in combination with environment variables will provide your script with whatever it might need:
Searching for enlightenment, you might try the ncurses manual page.
- In the section on Environment, it lists
LINES, it just says to see
COLUMNS gives more information:
Specify the width of the screen in characters. Applications running in a windowing environment usually are able
to obtain the width of the window in which they are executing. If neither the
COLUMNS value nor the terminal's
screen size is available, ncurses uses the size which may
be specified in the terminfo database (i.e., the
Now, for this question, it would have been nice if the manual page were more direct, saying that
tputs for output and also uses
setupterm for initialization. Occasionally (when this information is readily available in the changelog) no one notices that it is not explicit in the manual. For instance this item from 2002:
+ modify setupterm() to ensure that it initializes the baudrate, for
applications such as tput (report by Frank Henigman).
Back to the thread:
- The Initialization section of
- in the normal case, where
use_env has not been called,
setupterm allows the
COLUMNS variables to override the terminal database values.
use_env manual page reiterates that, as well as commenting that the values might be obtained from the operating system.
Again, the changelog mentions that
tput does this (gets the values from the operating system), e.g., this from 2007:
+ restore a call to obtain screen-size in _nc_setupterm(), which
is used in tput and other non-screen applications via setupterm()
(Debian #433357, reported by Florent Bayle, Christian Ohm,
In summary, the existing documentation provides answers to almost all questions about the behavior of ncurses, but you have to do some reading.