Example #1
0
/**
 * Draw borders from single-byte characters and renditions around a
 * window
 *
 * @v *win	window to be bordered
 * @v ls	left side
 * @v rs	right side
 * @v ts	top
 * @v bs	bottom
 * @v tl	top left corner
 * @v tr	top right corner
 * @v bl	bottom left corner
 * @v br	bottom right corner
 * @ret rc	return status code
 */
int wborder ( WINDOW *win, chtype ls, chtype rs,
	      chtype ts, chtype bs, chtype tl,
	      chtype tr, chtype bl, chtype br ) {
	struct cursor_pos pos;

	_store_curs_pos( win, &pos );
	wmove(win,0,0);

	_wputch(win,tl,WRAP);
	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);
		_wputch(win,rs,WRAP);
	}

	_wputch(win,bl,WRAP);
	while ( ( win->width -1 ) - win->curs_x ) {
		_wputch(win,bs,WRAP);
	}
	_wputch(win,br,NOWRAP); /* do not wrap last char to leave
				   cursor in last position */
	_restore_curs_pos( win, &pos );

	return OK;
}
Example #2
0
/**
 * Create a horizontal line in a window
 *
 * @v *win	subject window
 * @v ch	rendition and character
 * @v n		max number of chars (wide) to render
 * @ret rc	return status code
 */
int whline ( WINDOW *win, chtype ch, int n ) {
	struct cursor_pos pos;

	_store_curs_pos ( win, &pos );
	while ( ( win->curs_x - win->width ) && n-- ) {
		_wputch ( win, ch, NOWRAP );
	}
	_restore_curs_pos ( win, &pos );

	return OK;
}
Example #3
0
/**
 * Create a vertical line in a window
 *
 * @v *win	subject window
 * @v ch	rendition and character
 * @v n		max number of chars (high) to render
 * @ret rc	return status code
 */
int wvline ( WINDOW *win, chtype ch, int n ) {
	struct cursor_pos pos;

	_store_curs_pos ( win, &pos );
	while ( ( win->curs_y - win->height ) && n-- ) {
		_wputch ( win, ch, NOWRAP );
		wmove( win, ++(win->curs_y), pos.x);
	}
	_restore_curs_pos ( win, &pos );

	return OK;
}
Example #4
0
/**
 * Pop a character from the FIFO into a window
 *
 * @v *win	window in which to echo input
 * @ret c	char from input stream
 */
int wgetch ( WINDOW *win ) {
	int c;

	c = _wgetc( win );

	if ( m_echo ) {
		if ( c >= KEY_MIN ) {
			switch(c) {
			case KEY_LEFT :
			case KEY_BACKSPACE :
				_wcursback( win );
				wdelch( win );
				break;
			default :
				beep();
				break;
			}
		} else {
			_wputch( win, (chtype)( c | win->attrs ), WRAP );
		}
	}

	return c;
}
Example #5
0
static int _wgetc ( WINDOW *win ) {
	int timer, c;

	if ( win == NULL )
		return ERR;

	timer = INPUT_DELAY_TIMEOUT;
	while ( ! win->scr->peek( win->scr ) ) {
		if ( m_delay == 0 ) // non-blocking read
			return ERR;
		if ( timer > 0 ) {  // time-limited blocking read
			if ( m_delay > 0 )
				timer -= INPUT_DELAY;
			mdelay( INPUT_DELAY );
		} else { return ERR; } // non-blocking read
	}

	c = win->scr->getc( win->scr );

	if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters
		_wputch( win, (chtype) ( c | win->attrs ), WRAP );

	return c;
}
Example #6
0
/**
 * Write a single character to a window
 *
 * @v *win	window in which to write
 * @v c		character rendition to write
 * @v wrap	wrap "switch"
 */
void _wputc ( WINDOW *win, char c, int wrap ) {
	_wputch ( win, ( c | win->attrs ), wrap );
}
Example #7
0
/**
 * Write a chtype string to a window
 *
 * @v *win	window in which to write
 * @v *chstr	chtype string
 * @v wrap	wrap "switch"
 * @v n		write at most n chtypes
 */
void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) {
	for ( ; *chstr && n-- ; chstr++ ) {
		_wputch(win,*chstr,wrap);
	}
}
Example #8
0
/**
 * Write a single character to a window
 *
 * @v *win	window in which to write
 * @v c		character rendition to write
 * @v wrap	wrap "switch"
 */
void _wputc ( WINDOW *win, char c, int wrap ) {
	_wputch ( win, ( ( ( unsigned char ) c ) | win->attrs ), wrap );
}