mucurses.c File Reference

MuCurses core functions. More...

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

Go to the source code of this file.

Functions

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

Variables

WINDOW _stdscr


Detailed Description

MuCurses core functions.

Definition in file mucurses.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void _wupdcurs ( WINDOW win  )  [static]

Update cursor position.

Parameters:
*win window in which to update position

Definition at line 39 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().

00039                                       {
00040         win->scr->movetoyx ( win->scr, win->ori_y + win->curs_y,
00041                              win->ori_x + win->curs_x );
00042 }

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

Write a single character rendition to a window.

Parameters:
*win window in which to write
ch character rendition to write
wrap wrap "switch"

Definition at line 51 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().

00051                                                   {
00052         /* make sure we set the screen cursor to the right position
00053            first! */
00054         _wupdcurs(win);
00055         win->scr->putc(win->scr, ch);
00056         if ( ++(win->curs_x) - win->width == 0 ) {
00057                 if ( wrap == WRAP ) {
00058                         win->curs_x = 0;
00059                         /* specification says we should really scroll,
00060                            but we have no buffer to scroll with, so we
00061                            can only overwrite back at the beginning of
00062                            the window */
00063                         if ( ++(win->curs_y) - win->height == 0 )
00064                                 win->curs_y = 0;
00065                 } else {
00066                         (win->curs_x)--;
00067                 }
00068         }
00069 }

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

Write a single character to a window.

Parameters:
*win window in which to write
c character rendition to write
wrap wrap "switch"

Definition at line 78 of file mucurses.c.

References _wputch(), and _curses_window::attrs.

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

00078                                               {
00079         _wputch ( win, ( c | win->attrs ), wrap );
00080 }

void _wcursback ( WINDOW win  ) 

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

Parameters:
*win window in which to retreat

Definition at line 88 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().

00088                                 {
00089         if ( win->curs_x == 0 ) {
00090                 if ( win->curs_y == 0 )
00091                         win->curs_y = win->height - 1;
00092                 win->curs_x = win->width = 1;
00093         } else {
00094                 win->curs_x--;
00095         }
00096 
00097         _wupdcurs(win);
00098 }

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

Write a chtype string to a window.

Parameters:
*win window in which to write
*chstr chtype string
wrap wrap "switch"
n write at most n chtypes

Definition at line 108 of file mucurses.c.

References _wputch().

Referenced by waddchnstr().

00108                                                                       {
00109         for ( ; *chstr && n-- ; chstr++ ) {
00110                 _wputch(win,*chstr,wrap);
00111         }
00112 }

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

Write a standard c-style string to a window.

Parameters:
*win window in which to write
*str string
wrap wrap "switch"
n write at most n chars from *str

Definition at line 122 of file mucurses.c.

References _wputc().

Referenced by _print_label(), and waddnstr().

00122                                                                 {
00123         for ( ; *str && n-- ; str++ ) {
00124                 _wputc ( win, *str, wrap );
00125         }
00126 }

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

Move a window's cursor to the specified position.

Parameters:
*win window to be operated on
y Y position
x X position
Return values:
rc return status code

Definition at line 136 of file mucurses.c.

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

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

00136                                         {
00137         /* chech for out-of-bounds errors */
00138         if ( ( (unsigned)y >= win->height ) ||
00139              ( (unsigned)x >= win->width ) ) {
00140                 return ERR;
00141         }
00142 
00143         win->curs_y = y;
00144         win->curs_x = x;
00145         _wupdcurs(win);
00146         return OK;
00147 }


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 21 of file mucurses.c.


Generated on Tue Apr 6 20:01:46 2010 for gPXE by  doxygen 1.5.7.1