1resizeterm(3X)                                                  resizeterm(3X)
2
3
4

NAME

6       is_term_resized,  resize_term,  resizeterm - change the curses terminal
7       size
8

SYNOPSIS

10       #include <curses.h>
11
12       bool is_term_resized(int lines, int columns);
13       int resize_term(int lines, int columns);
14       int resizeterm(int lines, int columns);
15

DESCRIPTION

17       This is an extension to the curses library.  It provides callers with a
18       hook into the ncurses data to resize windows, primarily for use by pro‐
19       grams running in an X Window terminal (e.g., xterm) when the terminal's
20       screen size is changed by the user:
21
22       •   Curses  windows  cannot extend outside the screen.  If the terminal
23           is shrunk, curses windows must be shrunk to fit.
24
25       •   If the terminal is stretched, rows and/or columns can be  added  to
26           existing  windows.   The  added  cells should match the current at‐
27           tributes of the windows.
28
29       If the calling program has not set up a handler for  SIGWINCH  when  it
30       initializes  ncurses  (e.g.,  using  initscr(3X)  or newterm(3X)), then
31       ncurses sets a handler for SIGWINCH which notifies the library  when  a
32       window-size  event has occurred.  The library checks for this notifica‐
33       tion
34
35       •   when reading input data,
36
37       •   when implicitly resuming program mode (e.g., between endwin(3X) and
38           wrefresh(3X)), and
39
40       •   when explicitly resuming program mode in restartterm(3X).
41
42       When the library has found that the terminal's window-size has changed,
43       it calls resizeterm to update its data structures.
44
45       An application which establishes its own SIGWINCH handler can call  re‐
46       sizeterm,  but  in  that  case,  the library will not see SIGWINCH, and
47       proper layout will rely upon the application.
48

FUNCTIONS

50   resizeterm
51       The function resizeterm resizes the standard and current windows (i.e.,
52       stdscr and curscr) to the specified dimensions, and adjusts other book‐
53       keeping data used by the ncurses library that record the window  dimen‐
54       sions such as the LINES and COLS variables.
55
56   resize_term
57       Most  of  the  work  for  resizeterm  is done by the inner function re‐
58       size_term.  The outer function resizeterm adds bookkeeping for the SIG‐
59       WINCH   handler,   as   well  as  repainting  the  soft-key  area  (see
60       slk_touch(3X)).
61
62       The resize_term function attempts to resize all  windows.   This  helps
63       with simple applications.  However:
64
65       •   It is not possible to automatically resize pads.
66
67       •   Applications  which  have  complicated  layouts  should  check  for
68           KEY_RESIZE returned from wgetch, and adjust their layout, e.g., us‐
69           ing wresize and mvwin, or by recreating the windows.
70
71       When  resizing  windows,  resize_term  recursively  adjusts subwindows,
72       keeping them within the updated parent window's limits.  If a top-level
73       window  happens  to extend to the screen's limits, then on resizing the
74       window, resize_term will keep the window extending to the corresponding
75       limit, regardless of whether the screen has shrunk or grown.
76
77   is_term_resized
78       A support function is_term_resized is provided so that applications can
79       check if the resize_term function would modify the  window  structures.
80       It returns TRUE if the windows would be modified, and FALSE otherwise.
81

RETURN VALUE

83       Except  as  noted,  these functions return the integer ERR upon failure
84       and OK on success.  They will fail if either of the dimensions are less
85       than  or equal to zero, or if an error occurs while (re)allocating mem‐
86       ory for the windows.
87

NOTES

89       While these functions are intended to be used to support a signal  han‐
90       dler  (i.e., for SIGWINCH), care should be taken to avoid invoking them
91       in a context where malloc or realloc may have been  interrupted,  since
92       it uses those functions.
93
94       If ncurses is configured to supply its own SIGWINCH handler,
95
96       •   on receipt of a SIGWINCH, the handler sets a flag
97
98       •   which is tested in wgetch(3X), doupdate(3X) and restartterm(3X),
99
100       •   in turn, calling the resizeterm function,
101
102       •   which ungetch's a KEY_RESIZE which will be read on the next call to
103           wgetch.
104
105           The KEY_RESIZE alerts an  application  that  the  screen  size  has
106           changed,  and  that it should repaint special features such as pads
107           that cannot be done automatically.
108
109           Calling resizeterm or resize_term directly from a signal handler is
110           unsafe.   This indirect method is used to provide a safe way to re‐
111           size the ncurses data structures.
112
113       If the environment variables LINES or COLUMNS are set,  this  overrides
114       the  library's  use of the window size obtained from the operating sys‐
115       tem.  Thus, even if a SIGWINCH is received, no screen size  change  may
116       be recorded.
117

PORTABILITY

119       It is possible to resize the screen with SVr4 curses, by
120
121       •   exiting curses with endwin(3X) and
122
123       •   resuming using refresh(3X).
124
125       Doing that clears the screen and is visually distracting.
126
127       This  extension  of ncurses was introduced in mid-1995.  It was adopted
128       in NetBSD curses (2001) and PDCurses (2003).
129

SEE ALSO

131       curs_getch(3X), curs_variables(3X), wresize(3X).
132

AUTHOR

134       Thomas Dickey (from an equivalent function  written  in  1988  for  BSD
135       curses).
136
137
138
139                                                                resizeterm(3X)
Impressum