Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2010,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: curs_printw.3x,v 1.53 2024/04/20 19:18:18 tom Exp $ |
| 31 | .TH curs_printw 3X 2024-04-20 "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 Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 a \fIcurses\fR window |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 | .PP |
| 64 | \fBint vw_printw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP); |
| 65 | .PP |
| 66 | \fI/* obsolete */\fP |
| 67 | \fBint vwprintw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP); |
| 68 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 70 | \fB\%printw\fP, |
| 71 | \fB\%wprintw\fP, |
| 72 | \fB\%mvprintw\fP, |
| 73 | and |
| 74 | \fB\%mvwprintw\fP |
| 75 | are analogous to \fI\%printf\fP(3). |
| 76 | In effect, |
| 77 | the string that would be output by \fI\%printf\fP(3) is instead output |
| 78 | as though \fB\%waddstr\fP(3X) were used with |
| 79 | .I win |
| 80 | (or |
| 81 | .BR \%stdscr ) |
| 82 | as its first argument. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 83 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 84 | \fB\%vwprintw\fP |
| 85 | and |
| 86 | \fB\%vw_printw\fP are analogous to \fI\%vprintf\fP(3), |
| 87 | and perform a \fB\%wprintw\fP using a variable argument list. |
| 88 | The third argument is a \fI\%va_list\fP, |
| 89 | a pointer to a list of arguments, |
| 90 | as defined in \fI\%stdarg.h\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 91 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 92 | These functions return |
| 93 | .B ERR |
| 94 | upon failure and |
| 95 | .B OK |
| 96 | upon success. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 97 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 98 | In |
| 99 | .IR \%ncurses , |
| 100 | failure occurs if the library cannot allocate enough memory for the |
| 101 | buffer into which the output is formatted, |
| 102 | or if the window pointer |
| 103 | .I win |
| 104 | is null. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 105 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 106 | Functions prefixed with \*(``mv\*('' first perform cursor movement and |
| 107 | fail if the position |
| 108 | .RI ( y , |
| 109 | .IR x ) |
| 110 | is outside the window boundaries. |
| 111 | .SH NOTES |
| 112 | No wide character counterpart functions are defined by the |
| 113 | \*(``wide\*('' |
| 114 | .I \%ncurses |
| 115 | configuration nor by any standard. |
| 116 | To format and write a wide-character string to a |
| 117 | .I curses |
| 118 | window, |
| 119 | consider using \fI\%swprintf\fP(3) and \fB\%waddwstr\fP(3X) or similar. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 120 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 121 | X/Open Curses, |
| 122 | Issue 4 describes these functions. |
| 123 | It specifies no error conditions for them. |
| 124 | .PP |
| 125 | .I \%ncurses |
| 126 | defines \fB\%vw_printw\fP and \fB\%vwprintw\fP identically to support |
| 127 | legacy applications. |
| 128 | However, |
| 129 | the latter is obsolete. |
| 130 | .bP |
| 131 | X/Open Curses, |
| 132 | Issue 4 Version 2 (1996), |
| 133 | marked \fB\%vwprintw\fP as requiring \fI\%varargs.h\fP and |
| 134 | \*(``TO BE WITHDRAWN\*('', |
| 135 | and specified \fB\%vw_printw\fP using the \fI\%stdarg.h\fP interface. |
| 136 | .bP |
| 137 | X/Open Curses, Issue 5, Draft 2 |
| 138 | (December 2007) marked \fBvwprintw\fP (along with |
| 139 | \fBvwscanw\fP and the \fItermcap\fP interface) as withdrawn. |
| 140 | After incorporating review comments, |
| 141 | this became |
| 142 | X/Open Curses, Issue 7 (2009). |
| 143 | .bP |
| 144 | .I \%ncurses |
| 145 | provides \fB\%vwprintw\fP, |
| 146 | but marks it as deprecated. |
| 147 | .SH HISTORY |
| 148 | While \fB\%printw\fP was implemented in 4BSD |
| 149 | (November 1980), |
| 150 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\ |
| 151 | .\" libcurses/printw.c |
| 152 | it was unused until 4.2BSD |
| 153 | (August 1983), |
| 154 | which employed it for games. |
| 155 | That early version of |
| 156 | .I curses |
| 157 | preceded the ANSI C standard of 1989. |
| 158 | It did not use \fI\%varargs.h\fP, |
| 159 | though that had been available since Seventh Edition Unix (1979). |
| 160 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/include/\ |
| 161 | .\" varargs.h |
| 162 | In 1991 |
| 163 | (a couple of years after SVr4 was generally available, |
| 164 | and after the C standard was published), |
| 165 | other developers updated the library, |
| 166 | using \fI\%stdarg.h\fP internally in 4.4BSD |
| 167 | .IR curses . |
| 168 | Even with this improvement, |
| 169 | BSD |
| 170 | .I curses |
| 171 | did not use function prototypes |
| 172 | (nor even declare functions) |
| 173 | in \fI\%curses.h\fP until 1992. |
| 174 | .PP |
| 175 | SVr2 (1984) documented \fB\%printw\fP and \fB\%wprintw\fP tersely as |
| 176 | \*(``printf on \fB\%stdscr\fP\*('' and |
| 177 | \*(``printf on \fIwin\fP\*('', |
| 178 | respectively. |
| 179 | .PP |
| 180 | SVr3 (1987) added \fB\%mvprintw\fP and \fB\%mvwprintw\fP, |
| 181 | with a three-line summary asserting that they were analogous to |
| 182 | \fI\%printf\fP(3), |
| 183 | explaining that the string that \fI\%printf\fP(3) would write to the |
| 184 | standard output stream would instead be output using \fB\%waddstr\fP to |
| 185 | the given window. |
| 186 | SVr3 also implemented \fB\%vwprintw\fP, |
| 187 | describing its third parameter as a \fI\%va_list\fP, |
| 188 | defined in \fI\%varargs.h\fP, |
| 189 | and referred the reader to the manual pages for \fI\%varargs\fP and |
| 190 | \fI\%vprintf\fP for detailed descriptions. |
| 191 | .PP |
| 192 | SVr4 (1989) introduced no new variations of \fI\%printw\fP, |
| 193 | but provided for using either \fI\%varargs.h\fP or \fI\%stdarg.h\fP to |
| 194 | define the \fI\%va_list\fP type. |
| 195 | .\" either header declares "va_list", but only one can be used |
| 196 | .PP |
| 197 | X/Open Curses, Issue 4 (1995), |
| 198 | defined \fB\%vw_printw\fP to replace \fB\%vwprintw\fP, |
| 199 | stating that its \fI\%va_list\fP type is defined in \fI\%stdarg.h\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 200 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 201 | \fB\%curses\fP(3X), |
| 202 | \fB\%curs_addstr\fP(3X), |
| 203 | \fB\%curs_scanw\fP(3X), |
| 204 | \fB\%printf\fP(3), |
| 205 | \fB\%vprintf\fP(3) |