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