iPXE
Data Structures | Functions
print.c File Reference

MuCurses printing functions. More...

#include <curses.h>
#include <stdio.h>
#include <stddef.h>
#include <ipxe/vsprintf.h>
#include "mucurses.h"

Go to the source code of this file.

Data Structures

struct  printw_context
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int waddch (WINDOW *win, const chtype ch)
 Add a single-byte character and rendition to a window and advance the cursor. More...
 
int waddnstr (WINDOW *win, const char *str, int n)
 Add string of single-byte characters to a window. More...
 
static void _printw_handler (struct printf_context *ctx, unsigned int c)
 
int vw_printw (WINDOW *win, const char *fmt, va_list varglist)
 Print formatted output in a window. More...
 
int wprintw (WINDOW *win, const char *fmt,...)
 Print formatted output to a window. More...
 

Detailed Description

MuCurses printing functions.

Definition in file print.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ waddch()

int waddch ( WINDOW win,
const chtype  ch 
)

Add a single-byte character and rendition to a window and advance the cursor.

Parameters
*winwindow to be rendered in
chcharacter to be added at cursor
Return values
rcreturn status code

Definition at line 23 of file print.c.

23  {
24  _wputch( win, ch, WRAP );
25  return OK;
26 }
Definition: sis900.h:208
uint8_t ch
Definition: registers.h:83
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50
#define WRAP
Definition: mucurses.h:12

References _wputch(), ch, OK, and WRAP.

Referenced by addch(), mvaddch(), and mvwaddch().

◆ waddnstr()

int waddnstr ( WINDOW win,
const char *  str,
int  n 
)

Add string of single-byte characters to a window.

Parameters
*winwindow to be rendered in
*strstandard c-style string
nmax number of chars from string to render
Return values
rcreturn status code

Definition at line 36 of file print.c.

36  {
37  _wputstr( win, str, WRAP, n );
38  return OK;
39 }
void _wputstr(WINDOW *win, const char *str, int wrap, int n) __nonnull
Write a standard c-style string to a window.
Definition: mucurses.c:121
Definition: sis900.h:208
#define WRAP
Definition: mucurses.h:12

References _wputstr(), OK, and WRAP.

Referenced by addnstr(), addstr(), mvaddnstr(), mvaddstr(), mvwaddnstr(), mvwaddstr(), and waddstr().

◆ _printw_handler()

static void _printw_handler ( struct printf_context ctx,
unsigned int  c 
)
static

Definition at line 46 of file print.c.

46  {
47  struct printw_context *wctx =
48  container_of ( ctx, struct printw_context, ctx );
49 
50  _wputch( wctx->win, c | wctx->win->attrs, WRAP );
51 }
uint32_t c
Definition: md4.c:30
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
attr_t attrs
window attributes
Definition: curses.h:93
WINDOW * win
Definition: print.c:43
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50
#define WRAP
Definition: mucurses.h:12

References _wputch(), _curses_window::attrs, c, container_of, ctx, printw_context::win, and WRAP.

Referenced by vw_printw().

◆ vw_printw()

int vw_printw ( WINDOW win,
const char *  fmt,
va_list  varglist 
)

Print formatted output in a window.

Parameters
*winsubject window
*fmtformatted string
varglistargument list
Return values
rcreturn status code

Definition at line 61 of file print.c.

61  {
62  struct printw_context wctx;
63 
64  wctx.win = win;
65  wctx.ctx.handler = _printw_handler;
66  vcprintf ( &(wctx.ctx), fmt, varglist );
67  return OK;
68 }
Definition: sis900.h:208
WINDOW * win
Definition: print.c:43
int ssize_t const char * fmt
Definition: vsprintf.h:72
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
Definition: vsprintf.c:187

References _printw_handler(), printw_context::ctx, fmt, printf_context::handler, OK, vcprintf(), and printw_context::win.

Referenced by vwprintw(), and wprintw().

◆ wprintw()

int wprintw ( WINDOW win,
const char *  fmt,
  ... 
)

Print formatted output to a window.

Parameters
*winsubject window
*fmtformatted string
...string arguments
Return values
rcreturn status code

Definition at line 78 of file print.c.

78  {
79  va_list args;
80  int i;
81 
82  va_start ( args, fmt );
83  i = vw_printw ( win, fmt, args );
84  va_end ( args );
85  return i;
86 }
#define va_end(ap)
Definition: stdarg.h:9
WINDOW * win
Definition: print.c:43
__builtin_va_list va_list
Definition: stdarg.h:6
int ssize_t const char * fmt
Definition: vsprintf.h:72
#define va_start(ap, last)
Definition: stdarg.h:7

References fmt, va_end, va_start, vw_printw(), and printw_context::win.