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