1resizeterm(3X) resizeterm(3X)
2
3
4
6 is_term_resized, resize_term, resizeterm - change the curses terminal
7 size
8
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
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).
20
21 resizeterm
22 The function resizeterm resizes the standard and current windows to the
23 specified dimensions, and adjusts other bookkeeping data used by the
24 ncurses library that record the window dimensions such as the LINES and
25 COLS variables.
26
27 resize_term
28 Most of the work is done by the inner function resize_term. The outer
29 function resizeterm adds bookkeeping for the SIGWINCH handler, as well
30 as repainting the soft-key area (see slk_touch(3X)).
31
32 When resizing the windows, resize_term blank-fills the areas that are
33 extended. The calling application should fill in these areas with ap‐
34 propriate data.
35
36 The resize_term function attempts to resize all windows. However, due
37 to the calling convention of pads, it is not possible to resize these
38 without additional interaction with the application.
39
40 When resizing windows, resize_term recursively adjusts subwindows,
41 keeping them within the updated parent window's limits. If a top-level
42 window happens to extend to the screen's limits, then on resizing the
43 window, resize_term will keep the window extending to the corresponding
44 limit, regardless of whether the screen has shrunk or grown.
45
46 is_term_resized
47 A support function is_term_resized is provided so that applications can
48 check if the resize_term function would modify the window structures.
49 It returns TRUE if the windows would be modified, and FALSE otherwise.
50
52 Except as noted, these functions return the integer ERR upon failure
53 and OK on success. They will fail if either of the dimensions are less
54 than or equal to zero, or if an error occurs while (re)allocating mem‐
55 ory for the windows.
56
58 While these functions are intended to be used to support a signal han‐
59 dler (i.e., for SIGWINCH), care should be taken to avoid invoking them
60 in a context where malloc or realloc may have been interrupted, since
61 it uses those functions.
62
63 If ncurses is configured to supply its own SIGWINCH handler,
64
65 • on receipt of a SIGWINCH, the handler sets a flag
66
67 • which is tested in wgetch(3X) and doupdate,
68
69 • in turn, calling the resizeterm function,
70
71 • which ungetch's a KEY_RESIZE which will be read on the next call to
72 wgetch.
73
74 The KEY_RESIZE alerts an application that the screen size has
75 changed, and that it should repaint special features such as pads
76 that cannot be done automatically.
77
78 Calling resizeterm or resize_term directly from a signal handler is
79 unsafe. This indirect method is used to provide a safe way to re‐
80 size the ncurses data structures.
81
82 If the environment variables LINES or COLUMNS are set, this overrides
83 the library's use of the window size obtained from the operating sys‐
84 tem. Thus, even if a SIGWINCH is received, no screen size change may
85 be recorded.
86
88 It is possible to resize the screen with SVr4 curses, by
89
90 • exiting curses with endwin(3X) and
91
92 • resuming using refresh(3X).
93
94 Doing that clears the screen and is visually distracting.
95
96 This extension of ncurses was introduced in mid-1995. It was adopted
97 in NetBSD curses (2001) and PDCurses (2003).
98
100 curs_getch(3X), curs_variables(3X), wresize(3X).
101
103 Thomas Dickey (from an equivalent function written in 1988 for BSD
104 curses).
105
106
107
108 resizeterm(3X)