iPXE
Functions | Variables
mucurses.c File Reference

MuCurses core functions. More...

#include <curses.h>
#include "mucurses.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void _wupdcurs (WINDOW *win)
 Update cursor position. More...
 
void _wputch (WINDOW *win, chtype ch, int wrap)
 Write a single character rendition to a window. More...
 
void _wputc (WINDOW *win, char c, int wrap)
 Write a single character to a window. More...
 
void _wcursback (WINDOW *win)
 Retreat the cursor back one position (useful for a whole host of ops) More...
 
void _wputchstr (WINDOW *win, const chtype *chstr, int wrap, int n)
 Write a chtype string to a window. More...
 
void _wputstr (WINDOW *win, const char *str, int wrap, int n)
 Write a standard c-style string to a window. More...
 
int wmove (WINDOW *win, int y, int x)
 Move a window's cursor to the specified position. More...
 
int curs_set (int visibility)
 Set cursor visibility. More...
 

Variables

WINDOW _stdscr
 

Detailed Description

MuCurses core functions.

Definition in file mucurses.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ _wupdcurs()

static void _wupdcurs ( WINDOW win)
static

Update cursor position.

Parameters
*winwindow in which to update position

Definition at line 38 of file mucurses.c.

38  {
39  win->scr->movetoyx ( win->scr, win->ori_y + win->curs_y,
40  win->ori_x + win->curs_x );
41 }
unsigned int curs_y
Definition: curses.h:97
SCREEN * scr
screen with which window associates
Definition: curses.h:91
void(* movetoyx)(struct _curses_screen *scr, unsigned int y, unsigned int x)
Move cursor to position specified by x,y coords.
Definition: curses.h:55
unsigned int curs_x
window cursor position
Definition: curses.h:97
unsigned int ori_x
window origin coordinates
Definition: curses.h:95
unsigned int ori_y
Definition: curses.h:95

References _curses_window::curs_x, _curses_window::curs_y, _curses_screen::movetoyx, _curses_window::ori_x, _curses_window::ori_y, and _curses_window::scr.

Referenced by _wcursback(), _wputch(), and wmove().

◆ _wputch()

void _wputch ( WINDOW win,
chtype  ch,
int  wrap 
)

Write a single character rendition to a window.

Parameters
*winwindow in which to write
chcharacter rendition to write
wrapwrap "switch"

Definition at line 50 of file mucurses.c.

50  {
51  /* make sure we set the screen cursor to the right position
52  first! */
53  _wupdcurs(win);
54  win->scr->putc(win->scr, ch);
55  if ( ++(win->curs_x) - win->width == 0 ) {
56  if ( wrap == WRAP ) {
57  win->curs_x = 0;
58  /* specification says we should really scroll,
59  but we have no buffer to scroll with, so we
60  can only overwrite back at the beginning of
61  the window */
62  if ( ++(win->curs_y) - win->height == 0 )
63  win->curs_y = 0;
64  } else {
65  (win->curs_x)--;
66  }
67  }
68 }
unsigned int curs_y
Definition: curses.h:97
unsigned int height
Definition: curses.h:99
unsigned int width
window dimensions
Definition: curses.h:99
uint8_t ch
Definition: registers.h:83
SCREEN * scr
screen with which window associates
Definition: curses.h:91
void(* putc)(struct _curses_screen *scr, chtype c)
Write character to current cursor position.
Definition: curses.h:63
static void _wupdcurs(WINDOW *win) __nonnull
Update cursor position.
Definition: mucurses.c:38
#define WRAP
Definition: mucurses.h:12
unsigned int curs_x
window cursor position
Definition: curses.h:97

References _wupdcurs(), ch, _curses_window::curs_x, _curses_window::curs_y, _curses_window::height, _curses_screen::putc, _curses_window::scr, _curses_window::width, and WRAP.

Referenced by _printw_handler(), _wgetc(), _wputc(), _wputchstr(), delwin(), slk_restore(), waddch(), wborder(), wgetch(), whline(), and wvline().

◆ _wputc()

void _wputc ( WINDOW win,
char  c,
int  wrap 
)

Write a single character to a window.

Parameters
*winwindow in which to write
ccharacter rendition to write
wrapwrap "switch"

Definition at line 77 of file mucurses.c.

77  {
78  _wputch ( win, ( ( ( unsigned char ) c ) | win->attrs ), wrap );
79 }
static __always_inline void off_t int c
Definition: librm.h:173
attr_t attrs
window attributes
Definition: curses.h:93
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50

References _wputch(), _curses_window::attrs, and c.

Referenced by _wputstr(), wclrtobot(), wclrtoeol(), and wdelch().

◆ _wcursback()

void _wcursback ( WINDOW win)

Retreat the cursor back one position (useful for a whole host of ops)

Parameters
*winwindow in which to retreat

Definition at line 87 of file mucurses.c.

87  {
88  if ( win->curs_x == 0 ) {
89  if ( win->curs_y == 0 )
90  win->curs_y = win->height - 1;
91  win->curs_x = win->width = 1;
92  } else {
93  win->curs_x--;
94  }
95 
96  _wupdcurs(win);
97 }
unsigned int curs_y
Definition: curses.h:97
unsigned int height
Definition: curses.h:99
unsigned int width
window dimensions
Definition: curses.h:99
static void _wupdcurs(WINDOW *win) __nonnull
Update cursor position.
Definition: mucurses.c:38
unsigned int curs_x
window cursor position
Definition: curses.h:97

References _wupdcurs(), _curses_window::curs_x, _curses_window::curs_y, _curses_window::height, and _curses_window::width.

Referenced by wdelch(), wgetch(), and wgetnstr().

◆ _wputchstr()

void _wputchstr ( WINDOW win,
const chtype chstr,
int  wrap,
int  n 
)

Write a chtype string to a window.

Parameters
*winwindow in which to write
*chstrchtype string
wrapwrap "switch"
nwrite at most n chtypes

Definition at line 107 of file mucurses.c.

107  {
108  for ( ; *chstr && n-- ; chstr++ ) {
109  _wputch(win,*chstr,wrap);
110  }
111 }
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50

References _wputch().

Referenced by waddchnstr().

◆ _wputstr()

void _wputstr ( WINDOW win,
const char *  str,
int  wrap,
int  n 
)

Write a standard c-style string to a window.

Parameters
*winwindow in which to write
*strstring
wrapwrap "switch"
nwrite at most n chars from *str

Definition at line 121 of file mucurses.c.

121  {
122  for ( ; *str && n-- ; str++ ) {
123  _wputc ( win, *str, wrap );
124  }
125 }
void _wputc(WINDOW *win, char c, int wrap) __nonnull
Write a single character to a window.
Definition: mucurses.c:77

References _wputc().

Referenced by _print_label(), and waddnstr().

◆ wmove()

int wmove ( WINDOW win,
int  y,
int  x 
)

Move a window's cursor to the specified position.

Parameters
*winwindow to be operated on
yY position
xX position
Return values
rcreturn status code

Definition at line 135 of file mucurses.c.

135  {
136  /* chech for out-of-bounds errors */
137  if ( ( (unsigned)y >= win->height ) ||
138  ( (unsigned)x >= win->width ) ) {
139  return ERR;
140  }
141 
142  win->curs_y = y;
143  win->curs_x = x;
144  _wupdcurs(win);
145  return OK;
146 }
unsigned int curs_y
Definition: curses.h:97
unsigned int height
Definition: curses.h:99
unsigned int width
window dimensions
Definition: curses.h:99
Definition: sis900.h:208
#define ERR
Definition: curses.h:18
unsigned int y
Definition: cursor.h:13
unsigned int x
Definition: cursor.h:13
static void _wupdcurs(WINDOW *win) __nonnull
Update cursor position.
Definition: mucurses.c:38
unsigned int curs_x
window cursor position
Definition: curses.h:97

References _wupdcurs(), _curses_window::curs_x, _curses_window::curs_y, ERR, _curses_window::height, OK, _curses_window::width, cursor_pos::x, and cursor_pos::y.

Referenced by _enter_slk(), _restore_curs_pos(), delwin(), move(), mvaddch(), mvaddchnstr(), mvaddchstr(), mvaddnstr(), mvaddstr(), mvdelch(), mvgetch(), mvgetnstr(), mvgetstr(), mvhline(), mvvline(), mvwaddch(), mvwaddchnstr(), mvwaddchstr(), mvwaddnstr(), mvwaddstr(), mvwdelch(), mvwgetch(), mvwgetnstr(), mvwgetstr(), mvwhline(), mvwvline(), wborder(), wdeleteln(), werase(), and wvline().

◆ curs_set()

int curs_set ( int  visibility)

Set cursor visibility.

Parameters
visibilitycursor visibility

Definition at line 153 of file mucurses.c.

153  {
154  stdscr->scr->cursor ( stdscr->scr, visibility );
155  return OK;
156 }
Definition: sis900.h:208
#define stdscr
Definition: curses.h:110

References OK, and stdscr.

Referenced by endwin(), main_loop(), settings_ui(), and show_menu().

Variable Documentation

◆ _stdscr

WINDOW _stdscr
Initial value:
= {
.attrs = A_DEFAULT,
.ori_y = 0,
.ori_x = 0,
.curs_y = 0,
.curs_x = 0,
.scr = &_ansi_screen,
}
#define A_DEFAULT
Definition: curses.h:135
SCREEN _ansi_screen
Definition: ansi_screen.c:93

Definition at line 20 of file mucurses.c.