Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmpdcurses/pdcurses/printw.c
3153 views
1
/* PDCurses */
2
3
#include <curspriv.h>
4
5
/*man-start**************************************************************
6
7
printw
8
------
9
10
### Synopsis
11
12
int printw(const char *fmt, ...);
13
int wprintw(WINDOW *win, const char *fmt, ...);
14
int mvprintw(int y, int x, const char *fmt, ...);
15
int mvwprintw(WINDOW *win, int y, int x, const char *fmt,...);
16
int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
17
int vw_printw(WINDOW *win, const char *fmt, va_list varglist);
18
19
### Description
20
21
The printw() functions add a formatted string to the window at the
22
current or specified cursor position. The format strings are the same
23
as used in the standard C library's printf(). (printw() can be used
24
as a drop-in replacement for printf().)
25
26
The duplication between vwprintw() and vw_printw() is for historic
27
reasons. In PDCurses, they're the same.
28
29
### Return Value
30
31
All functions return the number of characters printed, or ERR on
32
error.
33
34
### Portability
35
X/Open ncurses NetBSD
36
printw Y Y Y
37
wprintw Y Y Y
38
mvprintw Y Y Y
39
mvwprintw Y Y Y
40
vwprintw Y Y Y
41
vw_printw Y Y Y
42
43
**man-end****************************************************************/
44
45
#include <string.h>
46
47
int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
48
{
49
char printbuf[513];
50
int len;
51
52
PDC_LOG(("vwprintw() - called\n"));
53
54
#ifdef HAVE_VSNPRINTF
55
len = vsnprintf(printbuf, 512, fmt, varglist);
56
#else
57
len = vsprintf(printbuf, fmt, varglist);
58
#endif
59
return (waddstr(win, printbuf) == ERR) ? ERR : len;
60
}
61
62
int printw(const char *fmt, ...)
63
{
64
va_list args;
65
int retval;
66
67
PDC_LOG(("printw() - called\n"));
68
69
va_start(args, fmt);
70
retval = vwprintw(stdscr, fmt, args);
71
va_end(args);
72
73
return retval;
74
}
75
76
int wprintw(WINDOW *win, const char *fmt, ...)
77
{
78
va_list args;
79
int retval;
80
81
PDC_LOG(("wprintw() - called\n"));
82
83
va_start(args, fmt);
84
retval = vwprintw(win, fmt, args);
85
va_end(args);
86
87
return retval;
88
}
89
90
int mvprintw(int y, int x, const char *fmt, ...)
91
{
92
va_list args;
93
int retval;
94
95
PDC_LOG(("mvprintw() - called\n"));
96
97
if (move(y, x) == ERR)
98
return ERR;
99
100
va_start(args, fmt);
101
retval = vwprintw(stdscr, fmt, args);
102
va_end(args);
103
104
return retval;
105
}
106
107
int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
108
{
109
va_list args;
110
int retval;
111
112
PDC_LOG(("mvwprintw() - called\n"));
113
114
if (wmove(win, y, x) == ERR)
115
return ERR;
116
117
va_start(args, fmt);
118
retval = vwprintw(win, fmt, args);
119
va_end(args);
120
121
return retval;
122
}
123
124
int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
125
{
126
PDC_LOG(("vw_printw() - called\n"));
127
128
return vwprintw(win, fmt, varglist);
129
}
130
131