pdcurses/printw.c

branch
protocol5
changeset 106
7b156b764d11
parent 97
2d43f05b284c
equal deleted inserted replaced
104:a76af67a3a4b 106:7b156b764d11
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: printw.c,v 1.40 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: printw
10
11 Synopsis:
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 The printw() functions add a formatted string to the window at
21 the current or specified cursor position. The format strings are
22 the same as used in the standard C library's printf(). (printw()
23 can be used as a drop-in replacement for printf().)
24
25 Return Value:
26 All functions return the number of characters printed, or
27 ERR on error.
28
29 Portability X/Open BSD SYS V
30 printw Y Y Y
31 wprintw Y Y Y
32 mvprintw Y Y Y
33 mvwprintw Y Y Y
34 vwprintw Y - 4.0
35 vw_printw Y
36
37 **man-end****************************************************************/
38
39 #include <string.h>
40
41 int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
42 {
43 char printbuf[513];
44 int len;
45
46 PDC_LOG(("vwprintw() - called\n"));
47
48 #ifdef HAVE_VSNPRINTF
49 len = vsnprintf(printbuf, 512, fmt, varglist);
50 #else
51 len = vsprintf(printbuf, fmt, varglist);
52 #endif
53 return (waddstr(win, printbuf) == ERR) ? ERR : len;
54 }
55
56 int printw(const char *fmt, ...)
57 {
58 va_list args;
59 int retval;
60
61 PDC_LOG(("printw() - called\n"));
62
63 va_start(args, fmt);
64 retval = vwprintw(stdscr, fmt, args);
65 va_end(args);
66
67 return retval;
68 }
69
70 int wprintw(WINDOW *win, const char *fmt, ...)
71 {
72 va_list args;
73 int retval;
74
75 PDC_LOG(("wprintw() - called\n"));
76
77 va_start(args, fmt);
78 retval = vwprintw(win, fmt, args);
79 va_end(args);
80
81 return retval;
82 }
83
84 int mvprintw(int y, int x, const char *fmt, ...)
85 {
86 va_list args;
87 int retval;
88
89 PDC_LOG(("mvprintw() - called\n"));
90
91 if (move(y, x) == ERR)
92 return ERR;
93
94 va_start(args, fmt);
95 retval = vwprintw(stdscr, fmt, args);
96 va_end(args);
97
98 return retval;
99 }
100
101 int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
102 {
103 va_list args;
104 int retval;
105
106 PDC_LOG(("mvwprintw() - called\n"));
107
108 if (wmove(win, y, x) == ERR)
109 return ERR;
110
111 va_start(args, fmt);
112 retval = vwprintw(win, fmt, args);
113 va_end(args);
114
115 return retval;
116 }
117
118 int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
119 {
120 PDC_LOG(("vw_printw() - called\n"));
121
122 return vwprintw(win, fmt, varglist);
123 }

mercurial