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