]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_pad.3x
ncurses 6.4 - patch 20230923
[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.43 2023/09/23 22:49:51 tom Exp $
31 .TH curs_pad 3X 2023-09-23 "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>\fP
47 .PP
48 \fBWINDOW *newpad(int \fInlines\fB, int \fIncols\fB);\fR
49 \fBWINDOW *subpad(WINDOW *\fIorig\fB, int \fInlines\fB, int \fIncols\fB,\fR
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 to a call to \fB\%addch\fP
113 followed by a call to \fB\%refresh\fP(3X),
114 a call to \fB\%waddch\fP followed by a call
115 to \fB\%wrefresh\fP, or a call to \fB\%waddch\fP followed by a call to
116 \fB\%prefresh\fP.
117 The knowledge that only a single character is being output is
118 taken into consideration and, for non-control characters, a considerable
119 performance gain might be seen by using these routines instead of their
120 equivalents.
121 In the case of \fB\%pechochar\fP, the last location of the pad on
122 the screen is reused for the arguments to \fB\%prefresh\fP.
123 .SS pecho_wchar
124 The \fB\%pecho_wchar\fP function is the analogous wide-character
125 form of \fB\%pechochar\fP.
126 It outputs one character to a pad and immediately refreshes the pad.
127 It does this by a call to \fB\%wadd_wch\fP followed by a call 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 for \fB\%newpad\fP and \fB\%subpad\fP,
206 using this to help with the distinction between \fB\%wnoutrefresh\fP
207 and \fB\%pnoutrefresh\fP.
208 .IP
209 It does not check for the case where a subwindow is created in
210 a pad using \fB\%subwin\fP or \fB\%derwin\fP.
211 .IP
212 The \fB\%dupwin\fP function returns a regular window when duplicating a pad.
213 Likewise, \fB\%getwin\fP always returns a window, even if the saved
214 data was from a pad.
215 .PP
216 This implementation
217 .bP
218 sets a flag in the \fB\%WINDOW\fP structure for \fB\%newpad\fP and \fB\%subpad\fP,
219 .bP
220 allows a \fB\%subwin\fP or \fB\%derwin\fP call to succeed having a pad parent by
221 forcing the subwindow to be a pad,
222 .bP
223 checks in both \fB\%wnoutrefresh\fP and \fB\%pnoutrefresh\fP to ensure
224 that pads and windows are handled distinctly, and
225 .bP
226 ensures that \fB\%dupwin\fP and \fB\%getwin\fP treat
227 pads versus windows consistently.
228 .SH SEE ALSO
229 \fB\%curses\fP(3X),
230 \fB\%curs_refresh\fP(3X),
231 \fB\%curs_touch\fP(3X),
232 \fB\%curs_addch\fP(3X)