]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_pad.3x
ncurses 6.4 - patch 20231111
[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.47 2023/11/11 11:47:10 tom Exp $
31 .TH curs_pad 3X 2023-11-11 "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\%newpad\fP,
38 \fB\%subpad\fP,
39 \fB\%prefresh\fP,
40 \fB\%pnoutrefresh\fP,
41 \fB\%pechochar\fP,
42 \fB\%pecho_wchar\fP \-
43 create and display \fIcurses\fR pads
44 .SH SYNOPSIS
45 .nf
46 \fB#include <curses.h>
47 .PP
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
57 .fi
58 .SH DESCRIPTION
59 .SS newpad
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,
62 \fIncols\fP.
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
65 screen.
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.
70 .PP
71 It is not
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.
74 Note that these
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.
77 .SS subpad
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.
82 The window is
83 made in the middle of the window \fIorig\fP, so that changes made to one window
84 affect both windows.
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
91 of windows.
92 The additional parameters are needed to indicate what part of the
93 pad and screen are involved.
94 .bP
95 The \fIpminrow\fP and \fIpmincol\fP parameters specify the upper
96 left-hand corner of the rectangle to be displayed in the pad.
97 .bP
98 The \fIsminrow\fP,
99 \fIsmincol\fP, \fIsmaxrow\fP, and \fIsmaxcol\fP
100 parameters specify the edges of the
101 rectangle to be displayed on the screen.
102 .PP
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.
108 Negative values of
109 \fIpminrow\fP, \fIpmincol\fP, \fIsminrow\fP, or \fIsmincol\fP are treated as if
110 they were zero.
111 .SS pechochar
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
117 \fB\%prefresh\fP.
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
121 equivalents.
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.
124 .SS pecho_wchar
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
129 to \fB\%prefresh\fP.
130 .SH RETURN VALUE
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
133 completion.
134 .PP
135 Routines that return pointers return \fBNULL\fP on error, and set \fB\%errno\fP
136 to \fB\%ENOMEM\fP.
137 .PP
138 X/Open does not define any error conditions.
139 In this implementation
140 .RS 3
141 .TP 5
142 \fB\%prefresh\fP and \fB\%pnoutrefresh\fP
143 return an error
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.
148 .TP 5
149 \fBpechochar\fP
150 returns an error
151 if the window is not really a pad, and the associated call
152 to \fB\%wechochar\fP returns an error.
153 .TP 5
154 \fBpecho_wchar\fP
155 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.
158 .RE
159 .SH NOTES
160 Note that \fB\%pechochar\fP may be a macro.
161 .SH PORTABILITY
162 BSD \fIcurses\fP has no \fIpad\fP feature.
163 .PP
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.
167 .PP
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:
171 .bP
172 These graphical pads could be much larger than the computer's display.
173 .bP
174 The read-only output from a command could be scrolled back to inspect,
175 and select text from the pad.
176 .PP
177 The two uses may be related.
178 .PP
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:
185 .bP
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.
188 .IP
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.
194 .bP
195 Solaris X/Open Curses checks if a window is a pad in \fB\%wnoutrefresh\fP,
196 returning \fBERR\fP in that case.
197 .IP
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.
201 .IP
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.
205 .bP
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.
211 .IP
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.
214 .IP
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
217 data was from a pad.
218 .PP
219 This implementation
220 .bP
221 sets a flag in the \fB\%WINDOW\fP structure
222 for \fB\%newpad\fP and \fB\%subpad\fP,
223 .bP
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,
226 .bP
227 checks in both \fB\%wnoutrefresh\fP and \fB\%pnoutrefresh\fP to ensure
228 that pads and windows are handled distinctly, and
229 .bP
230 ensures that \fB\%dupwin\fP and \fB\%getwin\fP treat
231 pads versus windows consistently.
232 .SH SEE ALSO
233 \fB\%curses\fP(3X),
234 \fB\%curs_addch\fP(3X),
235 \fB\%curs_refresh\fP(3X),
236 \fB\%curs_touch\fP(3X)