1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey *
3 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
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: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
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. *
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 *
28 .\"***************************************************************************
30 .\" $Id: curs_pad.3x,v 1.45 2023/10/21 10:29:45 tom Exp $
31 .TH curs_pad 3X 2023-10-21 "ncurses 6.4" "Library calls"
42 \fB\%pecho_wchar\fP \-
43 create and display \fIcurses\fR pads
46 \fB#include <curses.h>
48 \fBWINDOW *newpad(int \fInlines\fP, int \fIncols\fP);
49 \fBWINDOW *subpad(WINDOW *\fIorig\fP, int \fInlines\fP, int \fIncols\fP,
50 \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
51 \fBint prefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
52 \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
53 \fBint pnoutrefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
54 \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
55 \fBint pechochar(WINDOW *\fIpad\fB, chtype \fIch\fB);\fR
56 \fBint pecho_wchar(WINDOW *\fIpad\fB, const cchar_t *\fIwch\fB);\fR
60 The \fB\%newpad\fP routine creates and returns a pointer to a new pad data
61 structure with the given number of lines, \fInlines\fP, and columns,
63 A pad is like a window, except that it is not restricted by the
64 screen size, and is not necessarily associated with a particular part of the
66 Pads can be used when a large window is needed, and only a part of the
67 window will be on the screen at one time.
68 Automatic refreshes of pads
69 (e.g., from scrolling or echoing of input) do not occur.
72 legal to call \fB\%wrefresh\fP with a \fIpad\fP as an argument; the routines
73 \fB\%prefresh\fP or \fB\%pnoutrefresh\fP should be called instead.
75 routines require additional parameters to specify the part of the pad to be
76 displayed and the location on the screen to be used for the display.
78 The \fB\%subpad\fP routine creates and returns a pointer to a subwindow within a
79 pad with the given number of lines, \fInlines\fP, and columns, \fIncols\fP.
80 Unlike \fB\%subwin\fP, which uses screen coordinates, the window is at position
81 (\fIbegin\fR_\fIx\fB,\fR \fIbegin\fR_\fIy\fR) on the pad.
83 made in the middle of the window \fIorig\fP, so that changes made to one window
85 During the use of this routine, it will often be
86 necessary to call \fB\%touchwin\fP or \fB\%touchline\fP on \fIorig\fP before
87 calling \fB\%prefresh\fP.
88 .SS prefresh, pnoutrefresh
89 The \fB\%prefresh\fP and \fB\%pnoutrefresh\fP routines are analogous to
90 \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP except that they relate to pads instead
92 The additional parameters are needed to indicate what part of the
93 pad and screen are involved.
95 The \fIpminrow\fP and \fIpmincol\fP parameters specify the upper
96 left-hand corner of the rectangle to be displayed in the pad.
99 \fIsmincol\fP, \fIsmaxrow\fP, and \fIsmaxcol\fP
100 parameters specify the edges of the
101 rectangle to be displayed on the screen.
103 The lower right-hand corner of the
104 rectangle to be displayed in the pad is calculated from the screen coordinates,
105 since the rectangles must be the same size.
106 Both rectangles must be entirely
107 contained within their respective structures.
109 \fIpminrow\fP, \fIpmincol\fP, \fIsminrow\fP, or \fIsmincol\fP are treated as if
112 The \fB\%pechochar\fP routine is functionally equivalent
113 to a call to \fB\%addch\fP
114 followed by a call to \fB\%refresh\fP(3X),
115 a call to \fB\%waddch\fP followed by a call
116 to \fB\%wrefresh\fP, or a call to \fB\%waddch\fP followed by a call to
118 The knowledge that only a single character is being output is
119 taken into consideration and, for non-control characters, a considerable
120 performance gain might be seen by using these routines instead of their
122 In the case of \fB\%pechochar\fP, the last location of the pad on
123 the screen is reused for the arguments to \fB\%prefresh\fP.
125 The \fB\%pecho_wchar\fP function is the analogous wide-character
126 form of \fB\%pechochar\fP.
127 It outputs one character to a pad and immediately refreshes the pad.
128 It does this by a call to \fB\%wadd_wch\fP followed by a call
131 Routines that return an integer return \fBERR\fP upon failure and \fBOK\fP
132 (SVr4 only specifies "an integer value other than \fBERR\fP") upon successful
135 Routines that return pointers return \fBNULL\fP on error, and set \fB\%errno\fP
138 X/Open does not define any error conditions.
139 In this implementation
142 \fB\%prefresh\fP and \fB\%pnoutrefresh\fP
144 if the window pointer is null, or
145 if the window is not really a pad or
146 if the area to refresh extends off-screen or
147 if the minimum coordinates are greater than the maximum.
151 if the window is not really a pad, and the associated call
152 to \fB\%wechochar\fP returns an error.
156 if the window is not really a pad, and the associated call
157 to \fB\%wecho_wchar\fP returns an error.
160 Note that \fB\%pechochar\fP may be a macro.
162 BSD \fIcurses\fP has no \fIpad\fP feature.
164 SVr2 \fIcurses\fP (1986) provided the \fB\%newpad\fP and related functions,
165 documenting them in a single line each.
166 SVr3 (1987) provided more extensive documentation.
168 The documentation does not explain the term \fIpad\fP.
169 However, the Apollo \fIAegis\fP workstation operating system
170 supported a graphical \fIpad\fP feature:
172 These graphical pads could be much larger than the computer's display.
174 The read-only output from a command could be scrolled back to inspect,
175 and select text from the pad.
177 The two uses may be related.
179 The XSI Curses standard, Issue 4 describes these functions,
180 without significant change from the SVr3 documentation.
181 It describes no error conditions.
182 The behavior of \fB\%subpad\fP if the parent window is not
183 a pad is undocumented,
184 and is not checked by the vendor Unix implementations:
186 SVr4 \fIcurses\fP sets a flag in the \fB\%WINDOW\fP structure in \fB\%newpad\fP
187 which tells if the window is a \fIpad\fP.
189 However, it uses this information only in
190 \fB\%waddch\fP (to decide if it should call \fB\%wrefresh\fP) and
191 \fB\%wscrl\fP (to avoid scrolling a pad),
192 and does not check in \fB\%wrefresh\fP to ensure that the pad
193 is refreshed properly.
195 Solaris X/Open Curses checks if a window is a pad in \fB\%wnoutrefresh\fP,
196 returning \fBERR\fP in that case.
198 However, it only sets the flag for subwindows if the parent window is a pad.
199 Its \fB\%newpad\fP function does not set this information.
200 Consequently, the check will never fail.
202 It makes no comparable check in \fB\%pnoutrefresh\fP,
203 though interestingly enough, a comment in the source code
204 states that the lack of a check was an MKS extension.
206 NetBSD 7 \fIcurses\fP
207 sets a flag in the \fB\%WINDOW\fP structure
208 for \fB\%newpad\fP and \fB\%subpad\fP,
209 using this to help with the distinction between \fB\%wnoutrefresh\fP
210 and \fB\%pnoutrefresh\fP.
212 It does not check for the case where a subwindow is created in
213 a pad using \fB\%subwin\fP or \fB\%derwin\fP.
215 The \fB\%dupwin\fP function returns a regular window when duplicating a pad.
216 Likewise, \fB\%getwin\fP always returns a window, even if the saved
221 sets a flag in the \fB\%WINDOW\fP structure
222 for \fB\%newpad\fP and \fB\%subpad\fP,
224 allows a \fB\%subwin\fP or \fB\%derwin\fP call to succeed having a pad parent by
225 forcing the subwindow to be a pad,
227 checks in both \fB\%wnoutrefresh\fP and \fB\%pnoutrefresh\fP to ensure
228 that pads and windows are handled distinctly, and
230 ensures that \fB\%dupwin\fP and \fB\%getwin\fP treat
231 pads versus windows consistently.
234 \fB\%curs_refresh\fP(3X),
235 \fB\%curs_touch\fP(3X),
236 \fB\%curs_addch\fP(3X)