]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_window.3x
ncurses 6.5 - patch 20240601
[ncurses.git] / man / curs_window.3x
1 .\"***************************************************************************
2 .\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 1998-2015,2016 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 .\" $Id: curs_window.3x,v 1.52 2024/06/01 22:29:08 tom Exp $
31 .TH curs_window 3X 2024-06-01 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32 .SH NAME
33 \fB\%newwin\fP,
34 \fB\%delwin\fP,
35 \fB\%mvwin\fP,
36 \fB\%subwin\fP,
37 \fB\%derwin\fP,
38 \fB\%mvderwin\fP,
39 \fB\%dupwin\fP,
40 \fB\%wsyncup\fP,
41 \fB\%syncok\fP,
42 \fB\%wcursyncup\fP,
43 \fB\%wsyncdown\fP \-
44 create and manipulate \fIcurses\fR windows
45 .SH SYNOPSIS
46 .nf
47 \fB#include <curses.h>
48 .PP
49 \fBWINDOW *newwin(
50       \fBint \fInlines\fB, int \fIncols\fB,\fR
51       \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
52 \fBint delwin(WINDOW *\fIwin\fB);\fR
53 \fBint mvwin(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB);\fR
54 \fBWINDOW *subwin(WINDOW *\fIorig\fB,\fR
55       \fBint \fInlines\fB, int \fIncols\fB,\fR
56       \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
57 \fBWINDOW *derwin(WINDOW *\fIorig\fB,\fR
58       \fBint \fInlines\fB, int \fIncols\fB,\fR
59       \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
60 \fBint mvderwin(WINDOW *\fIwin\fB, int \fIpar_y\fB, int \fIpar_x\fB);\fR
61 \fBWINDOW *dupwin(WINDOW *\fIwin\fB);\fR
62 \fBvoid wsyncup(WINDOW *\fIwin\fB);\fR
63 \fBint syncok(WINDOW *\fIwin\fB, bool \fIbf\fB);\fR
64 \fBvoid wcursyncup(WINDOW *\fIwin\fB);\fR
65 \fBvoid wsyncdown(WINDOW *\fIwin\fB);\fR
66 .fi
67 .SH DESCRIPTION
68 .SS newwin
69 Calling \fBnewwin\fP creates and returns a pointer to a new window with the
70 given number of lines and columns.
71 The upper left-hand corner of the window is
72 at
73 .RS
74 line \fIbegin\fR_\fIy\fP,
75 .br
76 column \fIbegin\fR_\fIx\fP
77 .RE
78 .PP
79 If either
80 \fInlines\fP or \fIncols\fP is zero, they default to
81 .RS
82 \fBLINES \-\fP \fIbegin\fR_\fIy\fP and
83 .br
84 \fBCOLS \-\fP \fIbegin\fR_\fIx\fP.
85 .RE
86 .PP
87 A new full-screen window is created by calling \fBnewwin(0,0,0,0)\fP.
88 .PP
89 Regardless of the function used for creating a new window
90 (e.g., \fBnewwin\fP, \fBsubwin\fP, \fBderwin\fP, \fBnewpad\fP),
91 rather than a duplicate (with \fBdupwin\fP),
92 all of the window modes are initialized to the default values.
93 These functions set window modes after a window is created:
94 .RS
95 .PP
96 \fB\%idcok\fP
97 \fB\%idlok\fP
98 \fB\%immedok\fP
99 \fB\%keypad\fP
100 \fB\%leaveok\fP
101 \fB\%nodelay\fP
102 \fB\%scrollok\fP
103 \fB\%setscrreg\fP
104 \fB\%syncok\fP
105 \fB\%wbkgdset\fP
106 \fB\%wbkgrndset\fP and
107 \fB\%wtimeout\fP.
108 .RE
109 .SS delwin
110 Calling \fBdelwin\fP deletes the named window, freeing all memory
111 associated with it (it does not actually erase the window's screen
112 image).
113 Subwindows must be deleted before the main window can be deleted.
114 .SS mvwin
115 Calling \fBmvwin\fP moves the window so that the upper left-hand
116 corner is at position (\fIx\fP, \fIy\fP).
117 If the move would cause the window to be off the screen,
118 it is an error and the window is not moved.
119 Moving subwindows is allowed, but should be avoided.
120 .SS subwin
121 Calling \fBsubwin\fP creates and returns a pointer to a new window
122 with the given number of lines, \fInlines\fP, and columns, \fIncols\fP.
123 The window is at position (\fIbegin\fR_\fIy\fP,
124 \fIbegin\fR_\fIx\fP) on the screen.
125 The subwindow shares memory with the window \fIorig\fP,
126 its \fIancestor\fP,
127 so that changes made to one window
128 will affect both windows.
129 When using this routine, it is necessary to call
130 \fBtouchwin\fP or \fBtouchline\fP on \fIorig\fP before calling
131 \fBwrefresh\fP on the subwindow.
132 .SS derwin
133 Calling \fBderwin\fP is the same as calling \fBsubwin,\fP except that
134 \fIbegin\fR_\fIy\fP and \fIbegin\fR_\fIx\fP are relative to the origin
135 of the window \fIorig\fP rather than the screen.
136 There is no difference between the subwindows and the derived windows.
137 .SS mvderwin
138 Calling \fBmvderwin\fP moves a derived window (or subwindow)
139 inside its parent window.
140 The screen-relative parameters of the window are not changed.
141 This routine is used to display different
142 parts of the parent window at the same physical position on the
143 screen.
144 .SS dupwin
145 Calling \fBdupwin\fP creates an exact duplicate of the window \fIwin\fP.
146 .SS wsyncup
147 Calling \fBwsyncup\fP touches all locations in ancestors of \fIwin\fP that are
148 changed in \fIwin\fP.
149 If \fBsyncok\fP is called with second argument
150 \fBTRUE\fP then \fBwsyncup\fP is called automatically whenever there is a
151 change in the window.
152 .SS wsyncdown
153 The \fBwsyncdown\fP routine touches each location in \fIwin\fP that has been
154 touched in any of its ancestor windows.
155 This routine is called by
156 \fBwrefresh\fP, so it should almost never be necessary to call it manually.
157 .SS wcursyncup
158 The routine \fBwcursyncup\fP updates the current cursor position of all the
159 ancestors of the window to reflect the current cursor position of the
160 window.
161 .SH RETURN VALUE
162 Routines that return an integer return the integer \fBERR\fP upon failure and
163 \fBOK\fP (SVr4 only specifies "an integer value other than \fBERR\fP") upon
164 successful completion.
165 .PP
166 Routines that return pointers return \fBNULL\fP on error.
167 .PP
168 X/Open defines no error conditions.
169 In this implementation
170 .TP 5
171 \fBdelwin\fP
172 returns
173 .B ERR
174 if the window pointer is null, or
175 if the window is the parent of another window.
176 .TP 5
177 \fBderwin\fP
178 returns
179 .B ERR
180 if the parent window pointer is null, or
181 if any of its ordinates or dimensions is negative, or
182 if the resulting window does not fit inside the parent window.
183 .TP 5
184 \fBdupwin\fP
185 returns
186 .B ERR
187 if the window pointer is null.
188 .IP
189 This implementation also maintains a list of windows,
190 and checks that the pointer passed to \fBdelwin\fP is one that
191 it created, returning an error if it was not..
192 .TP 5
193 \fBmvderwin\fP
194 returns
195 .B ERR
196 if the window pointer is null, or
197 if some part of the window would be placed off-screen.
198 .TP 5
199 \fBmvwin\fP
200 returns
201 .B ERR
202 if the window pointer is null, or
203 if the window is really a pad, or
204 if some part of the window would be placed off-screen.
205 .TP 5
206 \fBnewwin\fP
207 will fail if either of its beginning ordinates is negative, or
208 if either the number of lines or columns is negative.
209 .TP 5
210 \fBsyncok\fP
211 returns
212 .B ERR
213 if the window pointer is null.
214 .TP 5
215 \fBsubwin\fP
216 returns
217 .B ERR
218 if the parent window pointer is null, or
219 if any of its ordinates or dimensions is negative, or
220 if the resulting window does not fit inside the parent window.
221 .PP
222 The functions which return a window pointer
223 may also fail if there is insufficient memory for its data structures.
224 Any of these functions will fail if the screen has not been initialized,
225 i.e., with \fBinitscr\fP or \fBnewterm\fP.
226 .SH NOTES
227 If many small changes are made to the window, the \fBwsyncup\fP option could
228 degrade performance.
229 .PP
230 Note that \fBsyncok\fP may be a macro.
231 .SH PORTABILITY
232 X/Open Curses, Issue 4 describes these functions.
233 .PP
234 Regarding
235 .IR \%delwin ","
236 X/Open Curses states that
237 .RS
238 .PP
239 [t]he application must delete subwindows before deleting the main
240 window.
241 .RE
242 .PP
243 If
244 .I \%delwin
245 is asked to delete a parent window,
246 it can succeed only if the
247 .I curses
248 library keeps a list of its subwindows.
249 SVr4
250 .I curses
251 kept a count of the number of subwindows rather than a list.
252 It simply returned
253 .B ERR
254 when asked to delete a subwindow.
255 Solaris X/Open
256 .I curses
257 .RI \%( xcurses )
258 does not make even that check,
259 and will delete a parent window that still has subwindows.
260 .I \%PDCurses
261 also behaves this way.
262 .PP
263 .I \%ncurses
264 4.0 (1996) and later maintains a list of windows for each screen
265 to ensure that a window has no subwindows before allowing its deletion.
266 NetBSD
267 .I curses
268 has followed suit since 2003.
269 .PP
270 SVr4
271 .I curses
272 documentation is unclear about what
273 .I \%wsyncup
274 and
275 .I \%wsyncdown
276 actually do.
277 It seems to imply that they are supposed to touch only those lines that
278 are affected by changes to a window's ancestors.
279 The description and behavior of these functions in
280 .I \%ncurses
281 is patterned on the X/Open Curses standard;
282 this approach may result in slower updates.
283 .SH SEE ALSO
284 \fB\%curses\fP(3X),
285 \fB\%curs_initscr\fP(3X),
286 \fB\%curs_refresh\fP(3X),
287 \fB\%curs_touch\fP(3X),
288 \fB\%curs_variables\fP(3X)