print.c
Go to the documentation of this file.00001 #include <curses.h>
00002 #include <stdio.h>
00003 #include <stddef.h>
00004 #include <gpxe/vsprintf.h>
00005 #include "mucurses.h"
00006
00007
00008
00009
00010
00011
00012
00013 FILE_LICENCE ( GPL2_OR_LATER );
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 int waddch ( WINDOW *win, const chtype ch ) {
00024 _wputch( win, ch, WRAP );
00025 return OK;
00026 }
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 int waddnstr ( WINDOW *win, const char *str, int n ) {
00037 _wputstr( win, str, WRAP, n );
00038 return OK;
00039 }
00040
00041 struct printw_context {
00042 struct printf_context ctx;
00043 WINDOW *win;
00044 };
00045
00046 static void _printw_handler ( struct printf_context *ctx, unsigned int c ) {
00047 struct printw_context *wctx =
00048 container_of ( ctx, struct printw_context, ctx );
00049
00050 _wputch( wctx->win, c | wctx->win->attrs, WRAP );
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 int vw_printw ( WINDOW *win, const char *fmt, va_list varglist ) {
00062 struct printw_context wctx;
00063
00064 wctx.win = win;
00065 wctx.ctx.handler = _printw_handler;
00066 vcprintf ( &(wctx.ctx), fmt, varglist );
00067 return OK;
00068 }
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 int wprintw ( WINDOW *win, const char *fmt, ... ) {
00079 va_list args;
00080 int i;
00081
00082 va_start ( args, fmt );
00083 i = vw_printw ( win, fmt, args );
00084 va_end ( args );
00085 return i;
00086 }