1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. *
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: *
12 .\" The above copyright notice and this permission notice shall be included *
13 .\" in all copies or substantial portions of the Software. *
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. *
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 *
27 .\"***************************************************************************
29 .\" $Id: curs_pad.3x,v 1.25 2018/07/28 22:20:54 tom Exp $
43 \fBpecho_wchar\fR \- create and display \fBcurses\fR pads
47 \fB#include <curses.h>\fR
49 \fBWINDOW *newpad(int \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB);\fR
51 \fBWINDOW *subpad(WINDOW *\fP\fIorig\fP\fB, int \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB,\fR
52 \fBint \fP\fIbegin_y\fP\fB, int \fP\fIbegin_x\fP\fB);\fR
54 \fBint prefresh(WINDOW *\fP\fIpad\fP\fB, int \fP\fIpminrow\fP\fB, int \fP\fIpmincol\fP\fB,\fR
55 \fBint \fP\fIsminrow\fP\fB, int \fP\fIsmincol\fP\fB, int \fP\fIsmaxrow\fP\fB, int \fP\fIsmaxcol\fP\fB);\fR
57 \fBint pnoutrefresh(WINDOW *\fP\fIpad\fP\fB, int \fP\fIpminrow\fP\fB, int \fP\fIpmincol\fP\fB,\fR
58 \fBint \fP\fIsminrow\fP\fB, int \fP\fIsmincol\fP\fB, int \fP\fIsmaxrow\fP\fB, int \fP\fIsmaxcol\fP\fB);\fR
60 \fBint pechochar(WINDOW *\fP\fIpad\fP\fB, chtype \fP\fIch\fP\fB);\fR
62 \fBint pecho_wchar(WINDOW *\fP\fIpad\fP\fB, const cchar_t *\fP\fIwch\fP\fB);\fR
65 The \fBnewpad\fR routine creates and returns a pointer to a new pad data
66 structure with the given number of lines, \fInlines\fR, and columns,
68 A pad is like a window, except that it is not restricted by the
69 screen size, and is not necessarily associated with a particular part of the
71 Pads can be used when a large window is needed, and only a part of the
72 window will be on the screen at one time.
73 Automatic refreshes of pads
74 (e.g., from scrolling or echoing of input) do not occur.
77 legal to call \fBwrefresh\fR with a \fIpad\fR as an argument; the routines
78 \fBprefresh\fR or \fBpnoutrefresh\fR should be called instead.
80 routines require additional parameters to specify the part of the pad to be
81 displayed and the location on the screen to be used for the display.
84 The \fBsubpad\fR routine creates and returns a pointer to a subwindow within a
85 pad with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
86 Unlike \fBsubwin\fR, which uses screen coordinates, the window is at position
87 (\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad.
89 made in the middle of the window \fIorig\fR, so that changes made to one window
91 During the use of this routine, it will often be
92 necessary to call \fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before
93 calling \fBprefresh\fR.
94 .SS prefresh, pnoutrefresh
96 The \fBprefresh\fR and \fBpnoutrefresh\fR routines are analogous to
97 \fBwrefresh\fR and \fBwnoutrefresh\fR except that they relate to pads instead
99 The additional parameters are needed to indicate what part of the
100 pad and screen are involved.
102 The \fIpminrow\fR and \fIpmincol\fR parameters specify the upper
103 left-hand corner of the rectangle to be displayed in the pad.
106 \fIsmincol\fR, \fIsmaxrow\fR, and \fIsmaxcol\fR
107 parameters specify the edges of the
108 rectangle to be displayed on the screen.
110 The lower right-hand corner of the
111 rectangle to be displayed in the pad is calculated from the screen coordinates,
112 since the rectangles must be the same size.
113 Both rectangles must be entirely
114 contained within their respective structures.
116 \fIpminrow\fR, \fIpmincol\fR, \fIsminrow\fR, or \fIsmincol\fR are treated as if
120 The \fBpechochar\fR routine is functionally equivalent to a call to \fBaddch\fR
121 followed by a call to \fBrefresh\fR(3X),
122 a call to \fBwaddch\fR followed by a call
123 to \fBwrefresh\fR, or a call to \fBwaddch\fR followed by a call to
125 The knowledge that only a single character is being output is
126 taken into consideration and, for non-control characters, a considerable
127 performance gain might be seen by using these routines instead of their
129 In the case of \fBpechochar\fR, the last location of the pad on
130 the screen is reused for the arguments to \fBprefresh\fR.
133 The \fBpecho_wchar\fR function is the analogous wide-character
134 form of \fBpechochar\fR.
135 It outputs one character to a pad and immediately refreshes the pad.
136 It does this by a call to \fBwadd_wch\fR followed by a call to \fBprefresh\fR.
138 Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
139 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
142 Routines that return pointers return \fBNULL\fR on error, and set \fBerrno\fR
145 X/Open does not define any error conditions.
146 In this implementation
149 \fBprefresh\fP and \fBpnoutrefresh\fP
151 if the window pointer is null, or
152 if the window is not really a pad or
153 if the area to refresh extends off-screen or
154 if the minimum coordinates are greater than the maximum.
158 if the window is not really a pad, and the associated call
159 to \fBwechochar\fP returns an error.
163 if the window is not really a pad, and the associated call
164 to \fBwecho_wchar\fP returns an error.
167 Note that \fBpechochar\fR may be a macro.
169 BSD curses has no \fIpad\fP feature.
171 SVr2 curses (1986) provided the \fBnewpad\fP and related functions,
172 documenting them in a single line each.
173 SVr3 (1987) provided more extensive documentation.
175 The documentation does not explain the term \fIpad\fP.
176 However, the Apollo \fIAegis\fP workstation operating system
177 supported a graphical \fIpad\fP feature:
179 These graphical pads could be much larger than the computer's display.
181 The read-only output from a command could be scrolled back to inspect,
182 and select text from the pad.
184 The two uses may be related.
186 The XSI Curses standard, Issue 4 describes these functions,
187 without significant change from the SVr3 documentation.
188 It describes no error conditions.
189 The behavior of \fBsubpad\fP if the parent window is not
190 a pad is undocumented,
191 and is not checked by the vendor Unix implementations:
193 SVr4 curses sets a flag in the \fBWINDOW\fP structure in \fBnewpad\fP
194 which tells if the window is a \fIpad\fP.
196 However, it uses this information only in
197 \fBwaddch\fP (to decide if it should call \fBwrefresh\fP) and
198 \fBwscrl\fP (to avoid scrolling a pad),
199 and does not check in \fBwrefresh\fP to ensure that the pad
200 is refreshed properly.
202 Solaris X/Open Curses checks if a window is a pad in \fBwnoutrefresh\fP,
203 returning \fBERR\fP in that case.
205 However, it only sets the flag for subwindows if the parent window is a pad.
206 Its \fBnewpad\fP function does not set this information.
207 Consequently, the check will never fail.
209 It makes no comparable check in \fBpnoutrefresh\fP,
210 though interestingly enough, a comment in the source code
211 states that the lack of a check was an MKS extension.
214 sets a flag in the \fBWINDOW\fP structure for \fBnewpad\fP and \fBsubpad\fP,
215 using this to help with the distinction between \fBwnoutrefresh\fP
216 and \fBpnoutrefresh\fP.
218 It does not check for the case where a subwindow is created in
219 a pad using \fBsubwin\fP or \fBderwin\fP.
221 The \fBdupwin\fP function returns a regular window when duplicating a pad.
222 Likewise, \fBgetwin\fP always returns a window, even if the saved
227 sets a flag in the \fBWINDOW\fP structure for \fBnewpad\fP and \fBsubpad\fP,
229 allows a \fBsubwin\fP or \fBderwin\fP call to succeed having a pad parent by
230 forcing the subwindow to be a pad,
232 checks in both \fBwnoutrefresh\fP and \fBpnoutrefresh\fP to ensure
233 that pads and windows are handled distinctly, and
235 ensures that \fBdupwin\fP and \fBgetwin\fP treat
236 pads versus windows consistently.
239 \fBcurs_refresh\fR(3X),
240 \fBcurs_touch\fR(3X),
241 \fBcurs_addch\fR(3X).