]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/resizeterm.3x
ncurses 6.1 - patch 20180407
[ncurses.git] / man / resizeterm.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2015,2017 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" Author: Thomas E. Dickey 1996-on
30 .\"
31 .\" $Id: resizeterm.3x,v 1.24 2017/11/18 23:47:37 tom Exp $
32 .TH resizeterm 3X ""
33 .de bP
34 .ie n  .IP \(bu 4
35 .el    .IP \(bu 2
36 ..
37 .SH NAME
38 \fBis_term_resized\fR,
39 \fBresize_term\fR,
40 \fBresizeterm\fR \- change the curses terminal size
41 .SH SYNOPSIS
42 \fB#include <curses.h>\fR
43 .sp
44 \fBbool is_term_resized(int lines, int columns);\fR
45 .br
46 \fBint resize_term(int lines, int columns);\fR
47 .br
48 \fBint resizeterm(int lines, int columns);\fR
49 .SH DESCRIPTION
50 .PP
51 This is an extension to the curses library.
52 It provides callers with a hook into the \fBncurses\fR data to resize windows,
53 primarily for use by programs running in an X Window terminal (e.g., xterm).
54 .SS resizeterm
55 .PP
56 The function \fBresizeterm\fR resizes the standard and current windows
57 to the specified dimensions, and adjusts other bookkeeping data used by
58 the \fBncurses\fR library that record the window dimensions
59 such as the \fBLINES\fP and \fBCOLS\fP variables.
60 .SS resize_term
61 .PP
62 Most of the work is done by the inner function \fBresize_term\fR.
63 The outer function \fBresizeterm\fR adds bookkeeping for the \fBSIGWINCH\fP handler.
64 When resizing the windows,
65 \fBresize_term\fR blank-fills the areas that are extended.
66 The calling application should fill in these areas with appropriate data.
67 The \fBresize_term\fR function attempts to resize all windows.
68 However, due to the calling convention of pads,
69 it is not possible to resize these
70 without additional interaction with the application.
71 .SS is_term_resized
72 .PP
73 A support function \fBis_term_resized\fR is provided so that applications
74 can check if the \fBresize_term\fR function would modify the window structures.
75 It returns \fBTRUE\fP if the windows would be modified, and \fBFALSE\fP otherwise.
76 .SH RETURN VALUE
77 Except as noted, these functions return
78 the integer \fBERR\fR upon failure and \fBOK\fR on success.
79 They will fail if either of the dimensions are less than or equal to zero,
80 or if an error occurs while (re)allocating memory for the windows.
81 .SH NOTES
82 While these functions are intended to be used to support a signal handler
83 (i.e., for \fBSIGWINCH\fP), care should be taken to avoid invoking them in a
84 context where \fBmalloc\fR or \fBrealloc\fR may have been interrupted,
85 since it uses those functions.
86 .PP
87 If ncurses is configured to supply its own \fBSIGWINCH\fP handler,
88 .bP
89 on receipt of a \fBSIGWINCH\fP, the handler sets a flag
90 .bP
91 which is tested in \fBwgetch\fP(3X) and \fBdoupdate\fP,
92 .bP
93 in turn, calling the \fBresizeterm\fR function,
94 .bP
95 which \fBungetch\fP's a \fBKEY_RESIZE\fR which
96 will be read on the next call to \fBwgetch\fR.
97 .IP
98 The \fBKEY_RESIZE\fP alerts an application that the screen size has changed,
99 and that it should repaint special features such as pads that cannot
100 be done automatically.
101 .IP
102 Calling \fBresizeterm\fP or \fBresize_term\fP
103 directly from a signal handler is unsafe.
104 This indirect method is used to provide a safe way to resize the ncurses
105 data structures.
106 .PP
107 If the environment variables \fBLINES\fP or \fBCOLUMNS\fP are set,
108 this overrides the library's use of the window size obtained from
109 the operating system.
110 Thus, even if a \fBSIGWINCH\fP is received,
111 no screen size change may be recorded.
112 .SH PORTABILITY
113 .PP
114 It is possible to resize the screen with SVr4 curses,
115 by
116 .bP
117 exiting curses with \fBendwin\fP(3X) and
118 .bP
119 resuming using \fBrefresh\fP(3X).
120 .PP
121 Doing that clears the screen and is visually distracting.
122 .PP
123 This extension of ncurses was introduced in mid-1995.
124 It was adopted in NetBSD curses (2001) and PDCurses (2003).
125 .SH SEE ALSO
126 \fBcurs_getch\fR(3X),
127 \fBcurs_variables\fR(3X),
128 \fBwresize\fR(3X).
129 .SH AUTHOR
130 Thomas Dickey (from an equivalent function written in 1988 for BSD curses).