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