Esempio n. 1
0
/**
 * Read at most n characters from the FIFO into a window
 *
 * @v *win	window in which to echo input
 * @v *str	pointer to string in which to store result
 * @v n		maximum number of characters to read into string (inc. NUL)
 * @ret rc	return status code
 */
int wgetnstr ( WINDOW *win, char *str, int n ) {
	char *_str;
	int c;

	if ( n == 0 ) {
		*str = '\0';
		return OK;
	}

	_str = str;

	while ( ( c = _wgetc( win ) ) != ERR ) {
		/* termination enforcement - don't let us go past the
		   end of the allocated buffer... */
		if ( n == 0 && ( c >= 32 && c <= 126 ) ) {
			_wcursback( win );
			wdelch( win );
		} else {
			if ( c >= 32 && c <= 126 ) {
				*(_str++) = c; n--;
			} else {
				switch(c) {
				case KEY_LEFT :
				case KEY_BACKSPACE :
					_wcursback( win );
					wdelch( win );
					break;
				case KEY_ENTER :
					*_str = '\0';
					return OK;
				default :
					beep();
					break;
				}
			}
		}
	}

	return ERR;
}
Esempio n. 2
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;
}
Esempio n. 3
0
File: clear.c Progetto: 42wim/ipxe
/**
 * Delete character under the cursor in a window
 *
 * @v *win	subject window
 * @ret rc	return status code
 */
int wdelch ( WINDOW *win ) {
	_wputc( win, ' ', NOWRAP );
	_wcursback( win );

	return OK;
}