blob: 21cc405c731b83f3ad662a62febe950a8be31fed [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_pad.3x,v 1.61 2024/04/27 17:55:43 tom Exp $
31.TH curs_pad 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32.ie \n(.g \{\
33.ds `` \(lq
34.ds '' \(rq
35.\}
36.el \{\
37.ie t .ds `` ``
38.el .ds `` ""
39.ie t .ds '' ''
40.el .ds '' ""
41.\}
42.
43.de bP
44.ie n .IP \(bu 4
45.el .IP \(bu 2
46..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040048\fB\%newpad\fP,
49\fB\%subpad\fP,
50\fB\%prefresh\fP,
51\fB\%pnoutrefresh\fP,
52\fB\%pechochar\fP,
53\fB\%pecho_wchar\fP \-
54create and display \fIcurses\fR pads
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053055.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040056.nf
57\fB#include <curses.h>
58.PP
59\fBWINDOW *newpad(int \fInlines\fP, int \fIncols\fP);
60\fBWINDOW *subpad(WINDOW *\fIparent\fP, int \fInlines\fP, int \fIncols\fP,
61 \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
62.PP
63\fBint prefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
64 \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
65\fBint pnoutrefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
66 \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
67.PP
68\fBint pechochar(WINDOW *\fIpad\fB, chtype \fIch\fB);\fR
69\fBint pecho_wchar(WINDOW *\fIpad\fB, const cchar_t *\fIwch\fB);\fR
70.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053071.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040072A
73.I curses
74.I pad
75is like a window,
76except that it is not restricted by the screen size,
77and is not necessarily associated with a particular part of the screen.
78Pads can be used when a large window is needed,
79only part of which is to be visible on the screen.
80Pads are not automatically refreshed by scrolling or input-echoing
81operations.
82.PP
83Pads cannot be refreshed with \fB\%wrefresh\fP(3X);
84use
85.B \%prefresh
86or
87.B \%pnoutrefresh
88instead.
Steve Kondikae271bc2015-11-15 02:50:53 +010089.SS newpad
micky3879b9f5e72025-07-08 18:04:53 -040090\fB\%newpad\fP creates and returns a pointer to a new pad data structure
91with the given number of lines,
92.IR nlines ,
93and columns,
94.IR ncols .
Steve Kondikae271bc2015-11-15 02:50:53 +010095.SS subpad
micky3879b9f5e72025-07-08 18:04:53 -040096.B \%subpad
97creates and returns a pointer to a subwindow within a pad
98with the given number of lines,
99.IR nlines ,
100and columns,
101.IR ncols .
102Unlike \fB\%subwin\fP(3X),
103which uses screen coordinates,
104the new pad is placed at position
105.RI ( begin_y ,
106.IR begin_x )
107relative to its parent.
108Thus,
109changes made to one pad can affect both.
110When operating on a subpad,
111it is often necessary to call \fB\%touchwin\fP(3X) or
112\fB\%touchline\fP(3X) on
113.I parent
114before calling
115.BR \%prefresh .
116.SS "prefresh, pnoutrefresh"
117.B \%prefresh\fP
118and
119.B \%pnoutrefresh
120are analogous to \fB\%wrefresh\fP(3X) and \fB\%wnoutrefresh\fP(3X)
121except that they operate on pads rather than windows.
122They require additional parameters are needed to indicate what portions
123of the pad and screen are involved.
124.bP
125.I pminrow
126and
127.I pmincol
128specify the upper left-hand corner of a rectangular view of the pad.
129.bP
130.IR sminrow ,
131.IR smincol ,
132.IR smaxrow ,
133and
134.I smaxcol
135specify the vertices of the rectangle to be displayed on the screen.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530136.PP
micky3879b9f5e72025-07-08 18:04:53 -0400137The lower right-hand corner
138of the rectangle to be displayed in the pad
139is calculated from the screen coordinates,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530140since the rectangles must be the same size.
micky3879b9f5e72025-07-08 18:04:53 -0400141Both rectangles must be entirely contained
142within their respective structures.
143.I curses
144treats
145negative values of any of these parameters as zero.
Steve Kondikae271bc2015-11-15 02:50:53 +0100146.SS pechochar
micky3879b9f5e72025-07-08 18:04:53 -0400147.B \%pechochar
148is functionally equivalent to calling \fB\%waddch\fP(3X) followed by
149.BR \%prefresh .
150It suggests to the
151.I curses
152optimizer that only a single character is being output;
153a considerable performance benefit may be thus enjoyed.
154The location of the character
155.I ch
156written to the pad is used to populate the arguments to
157.BR \%prefresh .
Steve Kondikae271bc2015-11-15 02:50:53 +0100158.SS pecho_wchar
micky3879b9f5e72025-07-08 18:04:53 -0400159.B \%pecho_wchar\fP
160is functionally equivalent to calling \fB\%wadd_wch\fP(3X) followed by
161.BR \%prefresh .
162It suggests to the
163.I curses
164optimizer that only a single wide character is being output;
165a considerable performance benefit may be thus enjoyed.
166The location of the character
167.I wch
168written to the pad is used to populate the arguments to
169.BR \%prefresh .
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530170.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400171Functions that return an integer return \fBERR\fP upon failure and
172\fBOK\fP
173(SVr4 specifies only
174\*(``an integer value other than \fBERR\fP\*('')
175upon successful completion.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530176.PP
micky3879b9f5e72025-07-08 18:04:53 -0400177Functions that return pointers return \fBNULL\fP on error,
178and set \fB\%errno\fP to \fB\%ENOMEM\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530179.PP
micky3879b9f5e72025-07-08 18:04:53 -0400180X/Open Curses does not specify any error conditions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530181In this implementation
Steve Kondikae271bc2015-11-15 02:50:53 +0100182.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530183.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400184\fB\%prefresh\fP and \fB\%pnoutrefresh\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530185return an error
186if the window pointer is null, or
187if the window is not really a pad or
188if the area to refresh extends off-screen or
189if the minimum coordinates are greater than the maximum.
190.TP 5
191\fBpechochar\fP
192returns an error
193if the window is not really a pad, and the associated call
micky3879b9f5e72025-07-08 18:04:53 -0400194to \fB\%wechochar\fP returns an error.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530195.TP 5
196\fBpecho_wchar\fP
197returns an error
198if the window is not really a pad, and the associated call
micky3879b9f5e72025-07-08 18:04:53 -0400199to \fB\%wecho_wchar\fP returns an error.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530200.RE
201.SH NOTES
micky3879b9f5e72025-07-08 18:04:53 -0400202\fB\%pechochar\fP may be a macro.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530203.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400204BSD \fIcurses\fP has no \fIpad\fP feature.
205.PP
206SVr2 \fIcurses\fP (1986) provided the \fB\%newpad\fP and related functions,
207documenting them in a single line each.
208SVr3 (1987) provided more extensive documentation.
209.PP
210The documentation does not explain the term \fIpad\fP.
211However, the Apollo \fIAegis\fP workstation operating system
212supported a graphical \fIpad\fP feature:
213.bP
214These graphical pads could be much larger than the computer's display.
215.bP
216The read-only output from a command could be scrolled back to inspect,
217and select text from the pad.
218.PP
219The two uses may be related.
220.PP
221X/Open Curses, Issue 4 describes these functions,
222without significant change from the SVr3 documentation.
223It describes no error conditions.
224The behavior of \fB\%subpad\fP if the parent window is not
225a pad is undocumented,
226and is not checked by the vendor Unix implementations:
227.bP
228SVr4 \fIcurses\fP sets a flag in the \fI\%WINDOW\fP structure in
229\fB\%newpad\fP which tells if the window is a \fIpad\fP.
230.IP
231However, it uses this information only in
232\fB\%waddch\fP (to decide if it should call \fB\%wrefresh\fP) and
233\fB\%wscrl\fP (to avoid scrolling a pad),
234and does not check in \fB\%wrefresh\fP to ensure that the pad
235is refreshed properly.
236.bP
237Solaris \fI\%xcurses\fP checks whether a window is a pad in
238\fB\%wnoutrefresh\fP,
239returning \fBERR\fP in that case.
240.IP
241However,
242it only sets the flag for subwindows if the parent window is a pad.
243Its \fB\%newpad\fP function does not set this information.
244Consequently, the check will never fail.
245.IP
246It makes no comparable check in \fB\%pnoutrefresh\fP,
247though interestingly enough, a comment in the source code
248states that the lack of a check was an MKS extension.
249.bP
250NetBSD 7 \fIcurses\fP
251sets a flag in the \fI\%WINDOW\fP structure
252for \fB\%newpad\fP and \fB\%subpad\fP,
253using this to help with the distinction between \fB\%wnoutrefresh\fP
254and \fB\%pnoutrefresh\fP.
255.IP
256It does not check for the case where a subwindow is created in
257a pad using \fB\%subwin\fP or \fB\%derwin\fP.
258.IP
259The \fB\%dupwin\fP function returns a regular window when duplicating a pad.
260Likewise, \fB\%getwin\fP always returns a window, even if the saved
261data was from a pad.
262.PP
263This implementation
264.bP
265sets a flag in the \fI\%WINDOW\fP structure
266for \fB\%newpad\fP and \fB\%subpad\fP,
267.bP
268allows a \fB\%subwin\fP or \fB\%derwin\fP call to succeed having a pad parent by
269forcing the subwindow to be a pad,
270.bP
271checks in both \fB\%wnoutrefresh\fP and \fB\%pnoutrefresh\fP to ensure
272that pads and windows are handled distinctly, and
273.bP
274ensures that \fB\%dupwin\fP and \fB\%getwin\fP treat
275pads versus windows consistently.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530276.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400277\fB\%curses\fP(3X),
278\fB\%curs_addch\fP(3X),
279\fB\%curs_refresh\fP(3X),
280\fB\%curs_touch\fP(3X)