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