mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-22 17:41:55 +00:00
- fixes to _wputch to get positioning and wrap working properly
- fixes to wborder (same) - addition of a few minor functions
This commit is contained in:
parent
95956443e1
commit
f778500739
@ -31,6 +31,7 @@ WINDOW _stdscr = {
|
||||
.ori_x = 0,
|
||||
.curs_y = 0,
|
||||
.curs_x = 0,
|
||||
.scr = curscr,
|
||||
};
|
||||
|
||||
/*
|
||||
@ -50,15 +51,15 @@ static void _wputch ( WINDOW *win, chtype ch, int wrap ) {
|
||||
win->scr->movetoyx( win->scr, win->ori_y + win->curs_y,
|
||||
win->ori_x + win->curs_x );
|
||||
win->scr->putc(win->scr, ch);
|
||||
if ( ++(win->curs_x) > win->width ) {
|
||||
if ( ++(win->curs_x) == win->width ) {
|
||||
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 */
|
||||
win->curs_y += ( ( win->curs_y - win->height ) == 0 ?
|
||||
-(win->curs_y) : 1 );
|
||||
if ( ++(win->curs_y) == win->height )
|
||||
win->curs_y = 0;
|
||||
} else {
|
||||
(win->curs_x)--;
|
||||
}
|
||||
@ -130,7 +131,10 @@ int wmove ( WINDOW *win, int y, int x ) {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
win->scr->movetoyx( win->scr, y, x );
|
||||
win->curs_y = y;
|
||||
win->curs_x = x;
|
||||
win->scr->movetoyx( win->scr, win->ori_y + win->curs_y,
|
||||
win->ori_x + win->curs_x );
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -253,6 +257,8 @@ inline chtype getbkgd ( WINDOW *win ) {
|
||||
WINDOW *initscr ( void ) {
|
||||
/* determine console size */
|
||||
/* initialise screen */
|
||||
stdscr->width = 80;
|
||||
stdscr->height = 25;
|
||||
/* set previously unknown window attributes */
|
||||
/* refresh screen */
|
||||
return stdscr;
|
||||
@ -274,6 +280,8 @@ WINDOW *newwin ( int nlines, int ncols, int begin_y, int begin_x ) {
|
||||
win->height = nlines;
|
||||
win->width = ncols;
|
||||
win->scr = stdscr->scr;
|
||||
win->parent = NULL;
|
||||
win->child = NULL;
|
||||
return win;
|
||||
}
|
||||
|
||||
@ -433,19 +441,19 @@ int wborder ( WINDOW *win, chtype ls, chtype rs,
|
||||
wmove(win,0,0);
|
||||
|
||||
_wputch(win,tl,WRAP);
|
||||
while ( win->width - win->curs_x ) {
|
||||
while ( ( win->width - 1 ) - win->curs_x ) {
|
||||
_wputch(win,ts,WRAP);
|
||||
}
|
||||
_wputch(win,tr,WRAP);
|
||||
|
||||
while ( ( win->height - 1 ) - win->curs_y ) {
|
||||
_wputch(win,ls,WRAP);
|
||||
wmove(win,win->curs_y,win->width-1);
|
||||
wmove(win,win->curs_y,(win->width)-1);
|
||||
_wputch(win,rs,WRAP);
|
||||
}
|
||||
|
||||
_wputch(win,bl,WRAP);
|
||||
while ( win->width - win->curs_x ) {
|
||||
while ( ( win->width -1 ) - win->curs_x ) {
|
||||
_wputch(win,bs,WRAP);
|
||||
}
|
||||
_wputch(win,br,NOWRAP); /* do not wrap last char to leave
|
||||
@ -507,3 +515,32 @@ int wcolour_set ( WINDOW *win, short colour_pair_number, void *opts ) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete character under the cursor in a window
|
||||
*
|
||||
* @v *win subject window
|
||||
* @ret rc return status code
|
||||
*/
|
||||
int wdelch ( WINDOW *win ) {
|
||||
struct cursor_pos pos;
|
||||
|
||||
_store_curs_pos( win, &pos );
|
||||
_wputch( win, (unsigned)' ', NOWRAP );
|
||||
_restore_curs_pos( win, &pos );
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete line under a window's cursor
|
||||
*
|
||||
* @v *win subject window
|
||||
* @ret rc return status code
|
||||
*/
|
||||
int wdeleteln ( WINDOW *win ) {
|
||||
/* let's just set the cursor to the beginning of the line and
|
||||
let wclrtoeol do the work :) */
|
||||
wmove( win, win->curs_y, 0 );
|
||||
wclrtoeol( win );
|
||||
return OK;
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ typedef struct _curses_window {
|
||||
unsigned int curs_x, curs_y;
|
||||
/** window dimensions */
|
||||
unsigned int width, height;
|
||||
/** parent/child ptrs */
|
||||
struct _curses_window *parent, *child;
|
||||
} WINDOW;
|
||||
|
||||
extern WINDOW _stdscr;
|
||||
@ -289,12 +291,12 @@ extern int curs_set ( int );
|
||||
extern int def_prog_mode ( void );
|
||||
extern int def_shell_mode ( void );
|
||||
extern int delay_output ( int );
|
||||
extern int delch ( void );
|
||||
extern int deleteln ( void );
|
||||
/*extern int delch ( void );*/
|
||||
/*extern int deleteln ( void );*/
|
||||
extern void delscreen ( SCREEN * );
|
||||
extern int delwin ( WINDOW * );
|
||||
extern WINDOW *derwin ( WINDOW *, int, int, int, int );
|
||||
extern int doupdate ( void );
|
||||
/*extern int doupdate ( void );*/
|
||||
extern WINDOW *dupwin ( WINDOW * );
|
||||
extern int echo ( void );
|
||||
extern int echochar ( const chtype );
|
||||
@ -324,8 +326,6 @@ extern int init_color ( short, short, short, short );
|
||||
extern int init_pair ( short, short, short );
|
||||
extern int innstr ( char *, int );
|
||||
extern int insch ( chtype );
|
||||
extern int insdelln ( int );
|
||||
extern int insertln ( void );
|
||||
extern int insnstr ( const char *, int );
|
||||
extern int insstr ( const char * );
|
||||
extern int instr ( char * );
|
||||
@ -346,7 +346,7 @@ extern int meta ( WINDOW *, bool );
|
||||
/*extern int mvaddnstr ( int, int, const char *, int );*/
|
||||
/*extern int mvaddstr ( int, int, const char * );*/
|
||||
extern int mvcur ( int, int, int, int );
|
||||
extern int mvdelch ( int, int );
|
||||
/*extern int mvdelch ( int, int );*/
|
||||
extern int mvderwin ( WINDOW *, int, int );
|
||||
extern int mvgetch ( int, int );
|
||||
extern int mvgetnstr ( int, int, char *, int );
|
||||
@ -368,7 +368,7 @@ extern int mvvline ( int, int, chtype, int );
|
||||
/*extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );*/
|
||||
/*extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );*/
|
||||
/*extern int mvwaddstr ( WINDOW *, int, int, const char * );*/
|
||||
extern int mvwdelch ( WINDOW *, int, int );
|
||||
/*extern int mvwdelch ( WINDOW *, int, int );*/
|
||||
extern int mvwgetch ( WINDOW *, int, int );
|
||||
extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
|
||||
extern int mvwgetstr ( WINDOW *, int, int, char * );
|
||||
@ -407,21 +407,17 @@ extern int printw ( char *, ... );
|
||||
extern int putp ( const char * );
|
||||
extern void qiflush ( void );
|
||||
extern int raw ( void );
|
||||
extern int redrawwin ( WINDOW * );
|
||||
extern int refresh ( void );
|
||||
/*extern int redrawwin ( WINDOW * );*/
|
||||
/*extern int refresh ( void );*/
|
||||
extern int reset_prog_mode ( void );
|
||||
extern int reset_shell_mode ( void );
|
||||
extern int resetty ( void );
|
||||
extern int ripoffline ( int, int ( *) ( WINDOW *, int) );
|
||||
extern int savetty ( void );
|
||||
extern int scanw ( char *, ... );
|
||||
extern int scr_dump ( const char * );
|
||||
extern int scr_init ( const char * );
|
||||
extern int scrl ( int );
|
||||
extern int scroll ( WINDOW * );
|
||||
extern int scrollok ( WINDOW *, bool );
|
||||
extern int scr_restore ( const char * );
|
||||
extern int scr_set ( const char * );
|
||||
extern int setscrreg ( int, int );
|
||||
extern SCREEN *set_term ( SCREEN * );
|
||||
extern int setupterm ( char *, int, int * );
|
||||
@ -503,18 +499,16 @@ extern int winchnstr ( WINDOW *, chtype *, int );
|
||||
extern int winchstr ( WINDOW *, chtype * );
|
||||
extern int winnstr ( WINDOW *, char *, int );
|
||||
extern int winsch ( WINDOW *, chtype );
|
||||
extern int winsdelln ( WINDOW *, int );
|
||||
extern int winsertln ( WINDOW * );
|
||||
extern int winsnstr ( WINDOW *, const char *, int );
|
||||
extern int winsstr ( WINDOW *, const char * );
|
||||
extern int winstr ( WINDOW *, char * );
|
||||
extern int wmove ( WINDOW *, int, int );
|
||||
extern int wnoutrefresh ( WINDOW * );
|
||||
extern int wprintw ( WINDOW *, char *, ... );
|
||||
extern int wredrawln ( WINDOW *, int, int );
|
||||
extern int wrefresh ( WINDOW * );
|
||||
/*extern int wredrawln ( WINDOW *, int, int );*/
|
||||
/*extern int wrefresh ( WINDOW * );*/
|
||||
extern int wscanw ( WINDOW *, char *, ... );
|
||||
extern int wscrl ( WINDOW *, int );
|
||||
/*extern int wscrl ( WINDOW *, int );*/
|
||||
extern int wsetscrreg ( WINDOW *, int, int );
|
||||
extern int wstandend ( WINDOW * );
|
||||
extern int wstandout ( WINDOW * );
|
||||
@ -580,6 +574,14 @@ static inline int clrtoeol ( void ) {
|
||||
return wclrtoeol( stdscr );
|
||||
}
|
||||
|
||||
static inline int delch ( void ) {
|
||||
return wdelch ( stdscr );
|
||||
}
|
||||
|
||||
static inline int deleteln ( void ) {
|
||||
return wdeleteln( stdscr );
|
||||
}
|
||||
|
||||
static inline int move ( int y, int x ) {
|
||||
return wmove ( stdscr, y, x );
|
||||
}
|
||||
@ -609,6 +611,11 @@ static inline int mvaddstr ( int y, int x, const char *str ) {
|
||||
? ERR : waddnstr ( stdscr, str, -1 ) );
|
||||
}
|
||||
|
||||
static inline int mvdelch ( int y, int x ) {
|
||||
return ( wmove ( stdscr, y, x ) == ERR
|
||||
? ERR : wdelch ( stdscr ) );
|
||||
}
|
||||
|
||||
static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
|
||||
return ( wmove( win, y, x ) == ERR
|
||||
? ERR : waddch ( win, ch ) );
|
||||
@ -634,6 +641,11 @@ static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
|
||||
? ERR : waddnstr ( win, str, -1 ) );
|
||||
}
|
||||
|
||||
static inline int mvwdelch ( WINDOW *win, int y, int x ) {
|
||||
return ( wmove ( win, y, x ) == ERR
|
||||
? ERR : wdelch ( win ) );
|
||||
}
|
||||
|
||||
static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
|
||||
return waddchnstr ( win, chstr, -1 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user