Debian Codegraph @

upstream/opensuse-leap-16-1/man3/resizeterm.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
4 .\" *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
12 .\" *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
15 .\" *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
27 .\" authorization. *
28 .\"***************************************************************************
29 .\"
30 .\" Author: Thomas E. Dickey 1996-on
31 .\"
32 .\" $Id: resizeterm.3x,v 1.63 2025/04/05 22:26:38 tom Exp $
33 .TH resizeterm 3NCURSES 2025-04-05 "ncurses 6.5" "Library calls"
34 .de bP
35 .ie n .IP \(bu 4
36 .el .IP \(bu 2
37 ..
38 .SH NAME
39 \fB\%is_term_resized\fP,
40 \fB\%resize_term\fP,
41 \fB\%resizeterm\fP \-
42 manage the terminal dimensions understood by \fIcurses\fR
43 .SH SYNOPSIS
44 .nf
45 \fB#include <ncursesw/curses.h>
46 .PP
47 \fBbool is_term_resized(int \fIlines\fP, int \fIcolumns\fP);
48 \fBint resize_term(int \fIlines\fP, int \fIcolumns\fP);
49 \fBint resizeterm(int \fIlines\fP, int \fIcolumns\fP);
50 .fi
51 .SH DESCRIPTION
52 This is an extension to the \fIcurses\fP library.
53 It provides callers with a hook into the \fI\%ncurses\fP data to resize
54 windows,
55 primarily for use by programs running in an X Window terminal (e.g., xterm)
56 when the terminal's screen size is changed by the user:
57 .bP
58 \fIcurses\fP windows cannot extend outside the screen.
59 If the terminal is shrunk, \fIcurses\fP windows must be shrunk to fit.
60 .bP
61 If the terminal is stretched,
62 rows and/or columns can be added to existing windows.
63 The added cells should match the current attributes of the windows.
64 .PP
65 If the application has not set up a handler for
66 .I \%SIGWINCH
67 when it initializes
68 .I \%ncurses
69 (by calling \fB\%initscr\fP(3NCURSES) or \fB\%newterm\fP(3NCURSES)),
70 then
71 .I \%ncurses
72 establishes a
73 .I \%SIGWINCH
74 handler that notifies the library
75 when a window-resizing event has occurred.
76 The library checks for this notification
77 .bP
78 when reading input data,
79 .bP
80 when implicitly resuming program mode
81 (e.g., between \fB\%endwin\fP(3NCURSES) and \fB\%wrefresh\fP(3NCURSES)),
82 and
83 .bP
84 when explicitly resuming program mode in \fB\%restartterm\fP(3NCURSES).
85 .PP
86 When the library has found that the terminal's window-size has
87 changed, it calls \fB\%resizeterm\fP to update its data structures.
88 .PP
89 An application which establishes its own \fB\%SIGWINCH\fP handler
90 can call \fB\%resizeterm\fP, but in that case, the library will not
91 see \fB\%SIGWINCH\fP, and proper layout will rely upon the application.
92 .SS resizeterm
93 The function \fB\%resizeterm\fP resizes the standard and current windows
94 (i.e., \fB\%stdscr\fP and \fB\%curscr\fP)
95 to the specified dimensions, and adjusts other bookkeeping data used by
96 the \fI\%ncurses\fP library that record the window dimensions
97 such as the \fB\%LINES\fP and \fB\%COLS\fP variables.
98 .SS resize_term
99 Most of the work for \fB\%resizeterm\fP is
100 done by the inner function \fB\%resize_term\fP.
101 The outer function \fB\%resizeterm\fP adds bookkeeping
102 for the \fB\%SIGWINCH\fP handler,
103 as well as repainting the soft-key area (see \fB\%slk_touch\fP(3NCURSES)).
104 .PP
105 The \fB\%resize_term\fP function attempts to resize all windows.
106 This helps with simple applications.
107 However:
108 .bP
109 It is not possible to automatically resize pads.
110 .bP
111 Applications which have complicated layouts should check for
112 \fB\%KEY_RESIZE\fP returned from \fB\%wgetch\fP,
113 and adjust their layout, e.g., using \fB\%wresize\fP and \fB\%mvwin\fP,
114 or by recreating the windows.
115 .PP
116 When resizing windows, \fB\%resize_term\fP recursively adjusts subwindows,
117 keeping them within the updated parent window's limits.
118 If a top-level window happens to extend to the screen's limits,
119 then on resizing the window, \fB\%resize_term\fP will keep the window
120 extending to the corresponding limit, regardless of whether the
121 screen has shrunk or grown.
122 .SS is_term_resized
123 A support function \fB\%is_term_resized\fP is provided so that applications
124 can check if the \fB\%resize_term\fP function would modify
125 the window structures.
126 It returns \fBTRUE\fP if the windows would be modified,
127 and \fBFALSE\fP otherwise.
128 .SH RETURN VALUE
129 Except as noted, these functions return
130 the integer \fBERR\fP upon failure and \fBOK\fP on success.
131 They will fail if either of the dimensions are less than or equal to zero,
132 or if an error occurs while (re)allocating memory for the windows.
133 .SH NOTES
134 While these functions are intended to be used to support a signal handler
135 (i.e., for \fB\%SIGWINCH\fP), care should be taken to avoid invoking them in a
136 context where \fB\%malloc\fP or \fB\%realloc\fP may have been interrupted,
137 since it uses those functions.
138 .PP
139 If \fI\%ncurses\fP is configured to supply its own \fB\%SIGWINCH\fP
140 handler,
141 .bP
142 on receipt of a \fB\%SIGWINCH\fP, the handler sets a flag
143 .bP
144 which is tested in
145 \fB\%wgetch\fP(3NCURSES),
146 \fB\%doupdate\fP(3NCURSES) and
147 \fB\%restartterm\fP(3NCURSES),
148 .bP
149 in turn, calling the \fB\%resizeterm\fP function,
150 .bP
151 which \fB\%ungetch\fP's a \fB\%KEY_RESIZE\fP which
152 will be read on the next call to \fB\%wgetch\fP.
153 .IP
154 The \fB\%KEY_RESIZE\fP alerts an application that the screen size has changed,
155 and that it should repaint special features such as pads that cannot
156 be done automatically.
157 .IP
158 Calling \fB\%resizeterm\fP or \fB\%resize_term\fP
159 directly from a signal handler is unsafe.
160 This indirect method is used to provide a safe way to resize the
161 \fI\%ncurses\fP data structures.
162 .PP
163 If the environment variables \fILINES\fP or \fI\%COLUMNS\fP are set,
164 this overrides the library's use of the window size obtained from
165 the operating system.
166 Thus, even if a \fB\%SIGWINCH\fP is received,
167 no screen size change may be recorded.
168 .SH PORTABILITY
169 It is possible to resize the screen with SVr4 \fIcurses\fP,
170 by
171 .bP
172 exiting \fIcurses\fP with \fB\%endwin\fP(3NCURSES) and
173 .bP
174 resuming using \fB\%refresh\fP(3NCURSES).
175 .PP
176 Doing that clears the screen and is visually distracting.
177 .PP
178 .I \%ncurses
179 introduced this extension in mid-1995.
180 NetBSD
181 .I curses
182 adopted it in 2001 and
183 .I \%PDCurses
184 in 2003.
185 .SH AUTHORS
186 Thomas Dickey (from an equivalent function written in 1988 for BSD \fIcurses\fP)
187 .SH SEE ALSO
188 \fB\%getch\fP(3NCURSES),
189 \fB\%curses_variables\fP(3NCURSES),
190 \fB\%wresize\fP(3NCURSES)