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

Variables

WINDOW _stdscr

Detailed Description

MuCurses core functions.

Definition in file mucurses.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void _wupdcurs ( WINDOW win) [static]

Update cursor position.

Parameters:
*winwindow in which to update position

Definition at line 38 of file mucurses.c.

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().

                                      {
        win->scr->movetoyx ( win->scr, win->ori_y + win->curs_y,
                             win->ori_x + win->curs_x );
}
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.

References _wupdcurs(), _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().

                                                  {
        /* make sure we set the screen cursor to the right position
           first! */
        _wupdcurs(win);
        win->scr->putc(win->scr, ch);
        if ( ++(win->curs_x) - win->width == 0 ) {
                if ( wrap == WRAP ) {
                        win->curs_x = 0;
                        /* specification says we should really scroll,
                           but we have no buffer to scroll with, so we
                           can only overwrite back at the beginning of
                           the window */
                        if ( ++(win->curs_y) - win->height == 0 )
                                win->curs_y = 0;
                } else {
                        (win->curs_x)--;
                }
        }
}
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.

References _wputch(), and _curses_window::attrs.

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

                                              {
        _wputch ( win, ( ( ( unsigned char ) c ) | win->attrs ), wrap );
}
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.

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

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

                                {
        if ( win->curs_x == 0 ) {
                if ( win->curs_y == 0 )
                        win->curs_y = win->height - 1;
                win->curs_x = win->width = 1;
        } else {
                win->curs_x--;
        }

        _wupdcurs(win);
}
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.

References _wputch().

Referenced by waddchnstr().

                                                                      {
        for ( ; *chstr && n-- ; chstr++ ) {
                _wputch(win,*chstr,wrap);
        }
}
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.

References _wputc().

Referenced by _print_label(), and waddnstr().

                                                                {
        for ( ; *str && n-- ; str++ ) {
                _wputc ( win, *str, wrap );
        }
}
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.

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(), draw_editbox(), 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().

                                        {
        /* chech for out-of-bounds errors */
        if ( ( (unsigned)y >= win->height ) ||
             ( (unsigned)x >= win->width ) ) {
                return ERR;
        }

        win->curs_y = y;
        win->curs_x = x;
        _wupdcurs(win);
        return OK;
}
int curs_set ( int  visibility)

Set cursor visibility.

Parameters:
visibilitycursor visibility

Definition at line 153 of file mucurses.c.

References OK, and stdscr.

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

                                {
        stdscr->scr->cursor ( stdscr->scr, visibility );
        return OK;
}

Variable Documentation

Initial value:
 {
        .attrs = A_DEFAULT,
        .ori_y = 0,
        .ori_x = 0,
        .curs_y = 0,
        .curs_x = 0,
        .scr = &_ansi_screen,
}

Definition at line 20 of file mucurses.c.