]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_pad.3x
ncurses 6.4 - patch 20231125
[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.49 2023/11/25 14:08:35 tom Exp $
31 .TH curs_pad 3X 2023-11-25 "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 valid to call \fB\%wrefresh\fP with a \fIpad\fP argument;
72 call \fB\%prefresh\fP or \fB\%pnoutrefresh\fP instead.
73 They require additional parameters to specify the part of the pad to be
74 displayed and the location on the screen to be used for the display.
75 .SS subpad
76 The \fB\%subpad\fP routine creates and returns a pointer to a subwindow within a
77 pad with the given number of lines, \fInlines\fP, and columns, \fIncols\fP.
78 Unlike \fB\%subwin\fP, which uses screen coordinates, the window is at position
79 (\fIbegin\fR_\fIx\fB,\fR \fIbegin\fR_\fIy\fR) on the pad.
80 The window is
81 made in the middle of the window \fIorig\fP, so that changes made to one window
82 affect both windows.
83 During the use of this routine, it will often be
84 necessary to call \fB\%touchwin\fP or \fB\%touchline\fP on \fIorig\fP before
85 calling \fB\%prefresh\fP.
86 .SS prefresh, pnoutrefresh
87 The \fB\%prefresh\fP and \fB\%pnoutrefresh\fP routines are analogous to
88 \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP except that they relate to pads instead
89 of windows.
90 The additional parameters are needed to indicate what part of the
91 pad and screen are involved.
92 .bP
93 The \fIpminrow\fP and \fIpmincol\fP parameters specify the upper
94 left-hand corner of the rectangle to be displayed in the pad.
95 .bP
96 The \fIsminrow\fP,
97 \fIsmincol\fP, \fIsmaxrow\fP, and \fIsmaxcol\fP
98 parameters specify the edges of the
99 rectangle to be displayed on the screen.
100 .PP
101 The lower right-hand corner of the
102 rectangle to be displayed in the pad is calculated from the screen coordinates,
103 since the rectangles must be the same size.
104 Both rectangles must be entirely
105 contained within their respective structures.
106 Negative values of
107 \fIpminrow\fP, \fIpmincol\fP, \fIsminrow\fP, or \fIsmincol\fP are treated as if
108 they were zero.
109 .SS pechochar
110 The \fB\%pechochar\fP routine is functionally equivalent
111 to a call to \fB\%addch\fP
112 followed by a call to \fB\%refresh\fP(3X),
113 a call to \fB\%waddch\fP followed by a call
114 to \fB\%wrefresh\fP, or a call to \fB\%waddch\fP followed by a call to
115 \fB\%prefresh\fP.
116 The knowledge that only a single character is being output is
117 taken into consideration and, for non-control characters, a considerable
118 performance gain might be seen by using these routines instead of their
119 equivalents.
120 In the case of \fB\%pechochar\fP, the last location of the pad on
121 the screen is reused for the arguments to \fB\%prefresh\fP.
122 .SS pecho_wchar
123 The \fB\%pecho_wchar\fP function is the analogous wide-character
124 form of \fB\%pechochar\fP.
125 It outputs one character to a pad and immediately refreshes the pad.
126 It does this by a call to \fB\%wadd_wch\fP followed by a call
127 to \fB\%prefresh\fP.
128 .SH RETURN VALUE
129 Routines that return an integer return \fBERR\fP upon failure and \fBOK\fP
130 (SVr4 only specifies "an integer value other than \fBERR\fP") upon successful
131 completion.
132 .PP
133 Routines that return pointers return \fBNULL\fP on error, and set \fB\%errno\fP
134 to \fB\%ENOMEM\fP.
135 .PP
136 X/Open does not define any error conditions.
137 In this implementation
138 .RS 3
139 .TP 5
140 \fB\%prefresh\fP and \fB\%pnoutrefresh\fP
141 return an error
142 if the window pointer is null, or
143 if the window is not really a pad or
144 if the area to refresh extends off-screen or
145 if the minimum coordinates are greater than the maximum.
146 .TP 5
147 \fBpechochar\fP
148 returns an error
149 if the window is not really a pad, and the associated call
150 to \fB\%wechochar\fP returns an error.
151 .TP 5
152 \fBpecho_wchar\fP
153 returns an error
154 if the window is not really a pad, and the associated call
155 to \fB\%wecho_wchar\fP returns an error.
156 .RE
157 .SH NOTES
158 Note that \fB\%pechochar\fP may be a macro.
159 .SH PORTABILITY
160 BSD \fIcurses\fP has no \fIpad\fP feature.
161 .PP
162 SVr2 \fIcurses\fP (1986) provided the \fB\%newpad\fP and related functions,
163 documenting them in a single line each.
164 SVr3 (1987) provided more extensive documentation.
165 .PP
166 The documentation does not explain the term \fIpad\fP.
167 However, the Apollo \fIAegis\fP workstation operating system
168 supported a graphical \fIpad\fP feature:
169 .bP
170 These graphical pads could be much larger than the computer's display.
171 .bP
172 The read-only output from a command could be scrolled back to inspect,
173 and select text from the pad.
174 .PP
175 The two uses may be related.
176 .PP
177 The XSI Curses standard, Issue 4 describes these functions,
178 without significant change from the SVr3 documentation.
179 It describes no error conditions.
180 The behavior of \fB\%subpad\fP if the parent window is not
181 a pad is undocumented,
182 and is not checked by the vendor Unix implementations:
183 .bP
184 SVr4 \fIcurses\fP sets a flag in the \fB\%WINDOW\fP structure in \fB\%newpad\fP
185 which tells if the window is a \fIpad\fP.
186 .IP
187 However, it uses this information only in
188 \fB\%waddch\fP (to decide if it should call \fB\%wrefresh\fP) and
189 \fB\%wscrl\fP (to avoid scrolling a pad),
190 and does not check in \fB\%wrefresh\fP to ensure that the pad
191 is refreshed properly.
192 .bP
193 Solaris X/Open Curses checks if a window is a pad in \fB\%wnoutrefresh\fP,
194 returning \fBERR\fP in that case.
195 .IP
196 However, it only sets the flag for subwindows if the parent window is a pad.
197 Its \fB\%newpad\fP function does not set this information.
198 Consequently, the check will never fail.
199 .IP
200 It makes no comparable check in \fB\%pnoutrefresh\fP,
201 though interestingly enough, a comment in the source code
202 states that the lack of a check was an MKS extension.
203 .bP
204 NetBSD 7 \fIcurses\fP
205 sets a flag in the \fB\%WINDOW\fP structure
206 for \fB\%newpad\fP and \fB\%subpad\fP,
207 using this to help with the distinction between \fB\%wnoutrefresh\fP
208 and \fB\%pnoutrefresh\fP.
209 .IP
210 It does not check for the case where a subwindow is created in
211 a pad using \fB\%subwin\fP or \fB\%derwin\fP.
212 .IP
213 The \fB\%dupwin\fP function returns a regular window when duplicating a pad.
214 Likewise, \fB\%getwin\fP always returns a window, even if the saved
215 data was from a pad.
216 .PP
217 This implementation
218 .bP
219 sets a flag in the \fB\%WINDOW\fP structure
220 for \fB\%newpad\fP and \fB\%subpad\fP,
221 .bP
222 allows a \fB\%subwin\fP or \fB\%derwin\fP call to succeed having a pad parent by
223 forcing the subwindow to be a pad,
224 .bP
225 checks in both \fB\%wnoutrefresh\fP and \fB\%pnoutrefresh\fP to ensure
226 that pads and windows are handled distinctly, and
227 .bP
228 ensures that \fB\%dupwin\fP and \fB\%getwin\fP treat
229 pads versus windows consistently.
230 .SH SEE ALSO
231 \fB\%curses\fP(3X),
232 \fB\%curs_addch\fP(3X),
233 \fB\%curs_refresh\fP(3X),
234 \fB\%curs_touch\fP(3X)