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