4 #include <gpxe/vsprintf.h>
9 * MuCurses printing functions
13 FILE_LICENCE ( GPL2_OR_LATER
);
16 * Add a single-byte character and rendition to a window and advance
19 * @v *win window to be rendered in
20 * @v ch character to be added at cursor
21 * @ret rc return status code
23 int waddch ( WINDOW
*win
, const chtype ch
) {
24 _wputch( win
, ch
, WRAP
);
29 * Add string of single-byte characters to a window
31 * @v *win window to be rendered in
32 * @v *str standard c-style string
33 * @v n max number of chars from string to render
34 * @ret rc return status code
36 int waddnstr ( WINDOW
*win
, const char *str
, int n
) {
37 _wputstr( win
, str
, WRAP
, n
);
41 struct printw_context
{
42 struct printf_context ctx
;
46 static void _printw_handler ( struct printf_context
*ctx
, unsigned int c
) {
47 struct printw_context
*wctx
=
48 container_of ( ctx
, struct printw_context
, ctx
);
50 _wputch( wctx
->win
, c
| wctx
->win
->attrs
, WRAP
);
54 * Print formatted output in a window
56 * @v *win subject window
57 * @v *fmt formatted string
58 * @v varglist argument list
59 * @ret rc return status code
61 int vw_printw ( WINDOW
*win
, const char *fmt
, va_list varglist
) {
62 struct printw_context wctx
;
65 wctx
.ctx
.handler
= _printw_handler
;
66 vcprintf ( &(wctx
.ctx
), fmt
, varglist
);
71 * Print formatted output to a window
73 * @v *win subject window
74 * @v *fmt formatted string
75 * @v ... string arguments
76 * @ret rc return status code
78 int wprintw ( WINDOW
*win
, const char *fmt
, ... ) {
82 va_start ( args
, fmt
);
83 i
= vw_printw ( win
, fmt
, args
);