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