]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_pad.3x
ncurses 6.4 - patch 20230701
[ncurses.git] / man / curs_pad.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 1998-2015,2017 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_pad.3x,v 1.33 2023/07/01 15:43:20 tom Exp $
31 .de bP
32 .ie n  .IP \(bu 4
33 .el    .IP \(bu 2
34 ..
35 .TH curs_pad 3X 2023-07-01 "ncurses 6.4" "Library calls"
36 .na
37 .hy 0
38 .SH NAME
39 \fBnewpad\fP,
40 \fBsubpad\fP,
41 \fBprefresh\fP,
42 \fBpnoutrefresh\fP,
43 \fBpechochar\fP,
44 \fBpecho_wchar\fP \- create and display \fBcurses\fP pads
45 .ad
46 .hy
47 .SH SYNOPSIS
48 \fB#include <curses.h>\fP
49 .sp
50 \fBWINDOW *newpad(int \fInlines\fB, int \fIncols\fB);\fR
51 .br
52 \fBWINDOW *subpad(WINDOW *\fIorig\fB, int \fInlines\fB, int \fIncols\fB,\fR
53       \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
54 .br
55 \fBint prefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
56       \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
57 .br
58 \fBint pnoutrefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
59       \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
60 .br
61 \fBint pechochar(WINDOW *\fIpad\fB, chtype \fIch\fB);\fR
62 .br
63 \fBint pecho_wchar(WINDOW *\fIpad\fB, const cchar_t *\fIwch\fB);\fR
64 .SH DESCRIPTION
65 .SS newpad
66 The \fBnewpad\fP routine creates and returns a pointer to a new pad data
67 structure with the given number of lines, \fInlines\fP, and columns,
68 \fIncols\fP.
69 A pad is like a window, except that it is not restricted by the
70 screen size, and is not necessarily associated with a particular part of the
71 screen.
72 Pads can be used when a large window is needed, and only a part of the
73 window will be on the screen at one time.
74 Automatic refreshes of pads
75 (e.g., from scrolling or echoing of input) do not occur.
76 .PP
77 It is not
78 legal to call \fBwrefresh\fP with a \fIpad\fP as an argument; the routines
79 \fBprefresh\fP or \fBpnoutrefresh\fP should be called instead.
80 Note that these
81 routines require additional parameters to specify the part of the pad to be
82 displayed and the location on the screen to be used for the display.
83 .SS subpad
84 The \fBsubpad\fP routine creates and returns a pointer to a subwindow within a
85 pad with the given number of lines, \fInlines\fP, and columns, \fIncols\fP.
86 Unlike \fBsubwin\fP, which uses screen coordinates, the window is at position
87 (\fIbegin\fR_\fIx\fB,\fR \fIbegin\fR_\fIy\fR) on the pad.
88 The window is
89 made in the middle of the window \fIorig\fP, so that changes made to one window
90 affect both windows.
91 During the use of this routine, it will often be
92 necessary to call \fBtouchwin\fP or \fBtouchline\fP on \fIorig\fP before
93 calling \fBprefresh\fP.
94 .SS prefresh, pnoutrefresh
95 The \fBprefresh\fP and \fBpnoutrefresh\fP routines are analogous to
96 \fBwrefresh\fP and \fBwnoutrefresh\fP except that they relate to pads instead
97 of windows.
98 The additional parameters are needed to indicate what part of the
99 pad and screen are involved.
100 .bP
101 The \fIpminrow\fP and \fIpmincol\fP parameters specify the upper
102 left-hand corner of the rectangle to be displayed in the pad.
103 .bP
104 The \fIsminrow\fP,
105 \fIsmincol\fP, \fIsmaxrow\fP, and \fIsmaxcol\fP
106 parameters specify the edges of the
107 rectangle to be displayed on the screen.
108 .PP
109 The lower right-hand corner of the
110 rectangle to be displayed in the pad is calculated from the screen coordinates,
111 since the rectangles must be the same size.
112 Both rectangles must be entirely
113 contained within their respective structures.
114 Negative values of
115 \fIpminrow\fP, \fIpmincol\fP, \fIsminrow\fP, or \fIsmincol\fP are treated as if
116 they were zero.
117 .SS pechochar
118 The \fBpechochar\fP routine is functionally equivalent to a call to \fBaddch\fP
119 followed by a call to \fBrefresh\fP(3X),
120 a call to \fBwaddch\fP followed by a call
121 to \fBwrefresh\fP, or a call to \fBwaddch\fP followed by a call to
122 \fBprefresh\fP.
123 The knowledge that only a single character is being output is
124 taken into consideration and, for non-control characters, a considerable
125 performance gain might be seen by using these routines instead of their
126 equivalents.
127 In the case of \fBpechochar\fP, the last location of the pad on
128 the screen is reused for the arguments to \fBprefresh\fP.
129 .SS pecho_wchar
130 The \fBpecho_wchar\fP function is the analogous wide-character
131 form of \fBpechochar\fP.
132 It outputs one character to a pad and immediately refreshes the pad.
133 It does this by a call to \fBwadd_wch\fP followed by a call to \fBprefresh\fP.
134 .SH RETURN VALUE
135 Routines that return an integer return \fBERR\fP upon failure and \fBOK\fP
136 (SVr4 only specifies "an integer value other than \fBERR\fP") upon successful
137 completion.
138 .PP
139 Routines that return pointers return \fBNULL\fP on error, and set \fBerrno\fP
140 to \fBENOMEM\fP.
141 .PP
142 X/Open does not define any error conditions.
143 In this implementation
144 .RS 3
145 .TP 5
146 \fBprefresh\fP and \fBpnoutrefresh\fP
147 return an error
148 if the window pointer is null, or
149 if the window is not really a pad or
150 if the area to refresh extends off-screen or
151 if the minimum coordinates are greater than the maximum.
152 .TP 5
153 \fBpechochar\fP
154 returns an error
155 if the window is not really a pad, and the associated call
156 to \fBwechochar\fP returns an error.
157 .TP 5
158 \fBpecho_wchar\fP
159 returns an error
160 if the window is not really a pad, and the associated call
161 to \fBwecho_wchar\fP returns an error.
162 .RE
163 .SH NOTES
164 Note that \fBpechochar\fP may be a macro.
165 .SH PORTABILITY
166 BSD curses has no \fIpad\fP feature.
167 .PP
168 SVr2 curses (1986) provided the \fBnewpad\fP and related functions,
169 documenting them in a single line each.
170 SVr3 (1987) provided more extensive documentation.
171 .PP
172 The documentation does not explain the term \fIpad\fP.
173 However, the Apollo \fIAegis\fP workstation operating system
174 supported a graphical \fIpad\fP feature:
175 .bP
176 These graphical pads could be much larger than the computer's display.
177 .bP
178 The read-only output from a command could be scrolled back to inspect,
179 and select text from the pad.
180 .PP
181 The two uses may be related.
182 .PP
183 The XSI Curses standard, Issue 4 describes these functions,
184 without significant change from the SVr3 documentation.
185 It describes no error conditions.
186 The behavior of \fBsubpad\fP if the parent window is not
187 a pad is undocumented,
188 and is not checked by the vendor Unix implementations:
189 .bP
190 SVr4 curses sets a flag in the \fBWINDOW\fP structure in \fBnewpad\fP
191 which tells if the window is a \fIpad\fP.
192 .IP
193 However, it uses this information only in
194 \fBwaddch\fP (to decide if it should call \fBwrefresh\fP) and
195 \fBwscrl\fP (to avoid scrolling a pad),
196 and does not check in \fBwrefresh\fP to ensure that the pad
197 is refreshed properly.
198 .bP
199 Solaris X/Open Curses checks if a window is a pad in \fBwnoutrefresh\fP,
200 returning \fBERR\fP in that case.
201 .IP
202 However, it only sets the flag for subwindows if the parent window is a pad.
203 Its \fBnewpad\fP function does not set this information.
204 Consequently, the check will never fail.
205 .IP
206 It makes no comparable check in \fBpnoutrefresh\fP,
207 though interestingly enough, a comment in the source code
208 states that the lack of a check was an MKS extension.
209 .bP
210 NetBSD 7 curses
211 sets a flag in the \fBWINDOW\fP structure for \fBnewpad\fP and \fBsubpad\fP,
212 using this to help with the distinction between \fBwnoutrefresh\fP
213 and \fBpnoutrefresh\fP.
214 .IP
215 It does not check for the case where a subwindow is created in
216 a pad using \fBsubwin\fP or \fBderwin\fP.
217 .IP
218 The \fBdupwin\fP function returns a regular window when duplicating a pad.
219 Likewise, \fBgetwin\fP always returns a window, even if the saved
220 data was from a pad.
221 .PP
222 This implementation
223 .bP
224 sets a flag in the \fBWINDOW\fP structure for \fBnewpad\fP and \fBsubpad\fP,
225 .bP
226 allows a \fBsubwin\fP or \fBderwin\fP call to succeed having a pad parent by
227 forcing the subwindow to be a pad,
228 .bP
229 checks in both \fBwnoutrefresh\fP and \fBpnoutrefresh\fP to ensure
230 that pads and windows are handled distinctly, and
231 .bP
232 ensures that \fBdupwin\fP and \fBgetwin\fP treat
233 pads versus windows consistently.
234 .SH SEE ALSO
235 \fBcurses\fP(3X),
236 \fBcurs_refresh\fP(3X),
237 \fBcurs_touch\fP(3X),
238 \fBcurs_addch\fP(3X).