]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/resizeterm.3x
ncurses 6.2 - patch 20210306
[ncurses.git] / man / resizeterm.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2019,2020 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.28 2020/10/17 23:55:41 tom Exp $
33 .TH resizeterm 3X ""
34 .de bP
35 .ie n  .IP \(bu 4
36 .el    .IP \(bu 2
37 ..
38 .SH NAME
39 \fBis_term_resized\fR,
40 \fBresize_term\fR,
41 \fBresizeterm\fR \- change the curses terminal size
42 .SH SYNOPSIS
43 \fB#include <curses.h>\fR
44 .sp
45 \fBbool is_term_resized(int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
46 .br
47 \fBint resize_term(int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
48 .br
49 \fBint resizeterm(int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
50 .SH DESCRIPTION
51 .PP
52 This is an extension to the curses library.
53 It provides callers with a hook into the \fBncurses\fR data to resize windows,
54 primarily for use by programs running in an X Window terminal (e.g., xterm).
55 .SS resizeterm
56 .PP
57 The function \fBresizeterm\fR resizes the standard and current windows
58 to the specified dimensions, and adjusts other bookkeeping data used by
59 the \fBncurses\fR library that record the window dimensions
60 such as the \fBLINES\fP and \fBCOLS\fP variables.
61 .SS resize_term
62 .PP
63 Most of the work is done by the inner function \fBresize_term\fR.
64 The outer function \fBresizeterm\fR adds bookkeeping
65 for the \fBSIGWINCH\fP handler,
66 as well as repainting the soft-key area (see \fBslk_touch\fP(3X)).
67 .PP
68 When resizing the windows,
69 \fBresize_term\fR blank-fills the areas that are extended.
70 The calling application should fill in these areas with appropriate data.
71 .PP
72 The \fBresize_term\fR function attempts to resize all windows.
73 However, due to the calling convention of pads,
74 it is not possible to resize these
75 without additional interaction with the application.
76 .PP
77 When resizing windows, \fBresize_term\fR recursively adjusts subwindows,
78 keeping them within the updated parent window's limits.
79 If a top-level window happens to extend to the screen's limits,
80 then on resizing the window, \fBresize_term\fR will keep the window
81 extending to the corresponding limit, regardless of whether the
82 screen has shrunk or grown.
83 .SS is_term_resized
84 .PP
85 A support function \fBis_term_resized\fR is provided so that applications
86 can check if the \fBresize_term\fR function would modify the window structures.
87 It returns \fBTRUE\fP if the windows would be modified,
88 and \fBFALSE\fP otherwise.
89 .SH RETURN VALUE
90 Except as noted, these functions return
91 the integer \fBERR\fR upon failure and \fBOK\fR on success.
92 They will fail if either of the dimensions are less than or equal to zero,
93 or if an error occurs while (re)allocating memory for the windows.
94 .SH NOTES
95 While these functions are intended to be used to support a signal handler
96 (i.e., for \fBSIGWINCH\fP), care should be taken to avoid invoking them in a
97 context where \fBmalloc\fR or \fBrealloc\fR may have been interrupted,
98 since it uses those functions.
99 .PP
100 If ncurses is configured to supply its own \fBSIGWINCH\fP handler,
101 .bP
102 on receipt of a \fBSIGWINCH\fP, the handler sets a flag
103 .bP
104 which is tested in \fBwgetch\fP(3X) and \fBdoupdate\fP,
105 .bP
106 in turn, calling the \fBresizeterm\fR function,
107 .bP
108 which \fBungetch\fP's a \fBKEY_RESIZE\fR which
109 will be read on the next call to \fBwgetch\fR.
110 .IP
111 The \fBKEY_RESIZE\fP alerts an application that the screen size has changed,
112 and that it should repaint special features such as pads that cannot
113 be done automatically.
114 .IP
115 Calling \fBresizeterm\fP or \fBresize_term\fP
116 directly from a signal handler is unsafe.
117 This indirect method is used to provide a safe way to resize the ncurses
118 data structures.
119 .PP
120 If the environment variables \fBLINES\fP or \fBCOLUMNS\fP are set,
121 this overrides the library's use of the window size obtained from
122 the operating system.
123 Thus, even if a \fBSIGWINCH\fP is received,
124 no screen size change may be recorded.
125 .SH PORTABILITY
126 .PP
127 It is possible to resize the screen with SVr4 curses,
128 by
129 .bP
130 exiting curses with \fBendwin\fP(3X) and
131 .bP
132 resuming using \fBrefresh\fP(3X).
133 .PP
134 Doing that clears the screen and is visually distracting.
135 .PP
136 This extension of ncurses was introduced in mid-1995.
137 It was adopted in NetBSD curses (2001) and PDCurses (2003).
138 .SH SEE ALSO
139 \fBcurs_getch\fR(3X),
140 \fBcurs_variables\fR(3X),
141 \fBwresize\fR(3X).
142 .SH AUTHOR
143 Thomas Dickey (from an equivalent function written in 1988 for BSD curses).