]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_printw.3x
ncurses 6.2 - patch 20200831
[ncurses.git] / man / curs_printw.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
3 .\" Copyright 1998-2010,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_printw.3x,v 1.27 2020/07/10 23:06:23 William.Pursell Exp $
31 .TH curs_printw 3X ""
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .na
41 .hy 0
42 .SH NAME
43 \fBprintw\fR,
44 \fBwprintw\fR,
45 \fBmvprintw\fR,
46 \fBmvwprintw\fR,
47 \fBvwprintw\fR, \fBvw_printw\fR \- print formatted output in \fBcurses\fR windows
48 .ad
49 .hy
50 .SH SYNOPSIS
51 \fB#include <curses.h>\fR
52 .sp
53 \fBint printw(const char *fmt, ...);\fR
54 .br
55 \fBint wprintw(WINDOW *win, const char *fmt, ...);\fR
56 .br
57 \fBint mvprintw(int y, int x, const char *fmt, ...);\fR
58 .br
59 \fBint mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...);\fR
60 .br
61 \fBint vw_printw(WINDOW *win, const char *fmt, va_list varglist);\fR
62 .sp
63 /* obsolete */
64 .br
65 \fBint vwprintw(WINDOW *win, const char *fmt, va_list varglist);\fR
66 .SH DESCRIPTION
67 The \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR and \fBmvwprintw\fR
68 routines are analogous to \fBprintf\fR [see \fBprintf\fR(3)].
69 In
70 effect, the string that would be output by \fBprintf\fR is output
71 instead as though \fBwaddstr\fR were used on the given window.
72 .PP
73 The \fBvwprintw\fR and \fBvw_printw\fR routines are analogous
74 to \fBvprintf\fR [see \fBprintf\fR(3)]
75 and perform a \fBwprintw\fR using a variable argument list.
76 The third argument is a \fBva_list\fR, a pointer to a
77 list of arguments, as defined in \fB<stdarg.h>\fR.
78 .SH RETURN VALUE
79 Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
80 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
81 completion.
82 .PP
83 X/Open defines no error conditions.
84 In this implementation,
85 an error may be returned if it cannot allocate enough memory for the
86 buffer used to format the results.
87 It will return an error if the window pointer is null.
88 .PP
89 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
90 \fBwmove\fP, and return an error if the position is outside the window,
91 or if the window pointer is null.
92 .SH HISTORY
93 While \fBprintw\fP was implemented in 4BSD,
94 it was unused until 4.2BSD (which used it in games).
95 That early version of curses was before the ANSI C standard.
96 It did not use <varargs.h>, though that was available.
97 In 1991 (a couple of years after SVr4 was generally available,
98 and after the C standard was published),
99 other developers updated the library,
100 using <stdarg.h> internally in 4.4BSD curses.
101 Even with this improvement,
102 BSD curses did not use function prototypes (or even declare
103 functions) in the <curses.h> header until 1992.
104 .PP
105 SVr2 documented
106 \fBprintw\fP,
107 \fBwprintw\fP
108 tersely as \*(``printf on \fIstdscr\fP\*('' and
109 tersely as \*(``printf on \fIwin\fP\*('', respectively.
110 .PP
111 SVr3 added
112 \fBmvprintw\fP, and
113 \fBmvwprintw\fP, with a three-line summary saying that they were analogous
114 to \fBprintf\fP(3),
115 explaining that the string which would be output from \fBprintf\fP(3) would
116 instead be output using \fBwaddstr\fP on the given window.
117 SVr3 also added \fBvwprintw\fP, saying that the third parameter
118 is a \fBva_list\fP, defined in <varargs.h>,
119 and referring the reader to the manual pages for \fIvarargs\fP and
120 \fIvprintf\fP for detailed descriptions.
121 .PP
122 SVr4 added no new variations of \fBprintw\fP,
123 but provided for using <varargs.h> or <stdarg.h> to define the \fBva_list\fP
124 type.
125 .PP
126 X/Open Curses added \fBvw_printw\fP to replace \fBvwprintw\fP,
127 stating that its \fBva_list\fP definition requires <stdarg.h>.
128 .SH PORTABILITY
129 In this implementation, \fBvw_printw\fP and \fBvwprintw\fP are equivalent,
130 to support legacy applications.
131 However, the latter (\fBvwprintw\fP) is obsolete:
132 .bP
133 The XSI Curses standard, Issue 4 described these functions.
134 The function
135 \fBvwprintw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
136 \fBvw_printw\fR using the \fB<stdarg.h>\fR interface.
137 .bP
138 The Single Unix Specification, Version 2 states that
139 \fBvw_printw\fR  is preferred to \fBvwprintw\fR since the latter requires
140 including \fB<varargs.h>\fR, which
141 cannot be used in the same file as \fB<stdarg.h>\fR.
142 This implementation uses \fB<stdarg.h>\fR for both,
143 because that header is included in \fB<curses.h\fR>.
144 .bP
145 X/Open Curses, Issue 5 (December 2007) marked \fBvwprintw\fP (along with
146 \fBvwscanw\fP and the termcap interface) as withdrawn.
147 .SH SEE ALSO
148 .na
149 \fBcurses\fR(3X),
150 \fBcurs_addstr\fR(3X),
151 \fBcurs_scanw\fR(3X),
152 \fBcurs_termcap\fP(3X),
153 \fBprintf\fR(3),
154 \fBvprintf\fR(3).