示例#1
0
文件: console.cpp 项目: tica/TimbOS
void CONSOLE::printn( const char ch, size_t count )
{
	for( size_t i = 0; i < count; ++i )
	{
		write_char_to_console( ch, this );
	}

	if( this->visible )
	{
		video_display( this->buffer + this->top_row * this->buffer_width );
		video_move_cursor( this->cursor_column, this->cursor_row - this->top_row );
	}
}
示例#2
0
文件: console.cpp 项目: tica/TimbOS
void CONSOLE::printf( const char* format, ... )
{
	va_list ap;
	va_start( ap, format );	
	format_string_varg( CONSOLE::write_char_to_console, this, format, ap );	
	va_end( ap );

	if( this->visible )
	{
		video_display( this->buffer + this->top_row * this->buffer_width );
		video_move_cursor( this->cursor_column, this->cursor_row - this->top_row );
	}
}
示例#3
0
/**************************************************************************
* Write blanks to the entire buffer of the selected console.
* console - The address of the selected console.
**************************************************************************/
void video_clrscr( console_t *console ) {
	u32int flags;

	disable_and_save_interrupts(flags);

	memset16((u16int *)(console->vid_buffer ), BLANK, crt_width*crt_height*2);
	console->cursor_x = 0;
	console->cursor_y = 0;

	// Update the cursor position only for current console.
	if( console==get_console_addr(0) )
		video_move_cursor( console->cursor_x, console->cursor_y);

	restore_interrupts(flags);
}
示例#4
0
/**************************************************************************
* Put a character to the next space in the specified console.
// console 	- The address of the selected console.
// c 		- The ASCII code of the character to print.
 * **************************************************************************/
void video_put_char( u08int c, console_t *console) {

	u32int flags;

	disable_and_save_interrupts(flags);

	switch (c) {
		case '\n':		//New line
			(console->cursor_y) += 1;	//Move down a line
			(console->cursor_x) = 0; 	//And back to the start of the line
			break;
		case '\r':		// Handle carriage return
			(console->cursor_x) = 0; 	//And back to the start of the line
			break;
		case '\b':		//handle a backspaced request.
			if(console->cursor_x == 0){	// If we are at the beginning of a line
				if(console->cursor_y == 0) {	//first check whether we are at the top left of screen
					return;
				}
				//move the cursor to the end of the last line
				(console->cursor_y) -= 1;
				console->cursor_x = crt_width;
			} else {
				//If we are in the middle of a line just move the cursor back
				(console->cursor_x) += 1;
				// and "erase" what is there by over writing it with a space.
				video_place_char(console->cursor_x, console->cursor_y, ' ', console);
			}
			break;
		case '\t':
			// Handle a tab by moving the cursor 8 spaces and then truncating it back to a division of 8
			// a simple example is to snap 13 to 4 spaces we take 13 (1101) and & it with (4-1)->'s complement -> (~3) 1100
			// so 1101 & 1100 = 1100 (12)
			console->cursor_x = (console->cursor_x + 8) & ~(8-1);
			break;
		case '\a': // CTRL+G => system beep! //
			//Implement a system beep
			return;
			break;
		default: 		{
			video_place_char(console->cursor_x, console->cursor_y, c, console);
			(console->cursor_x) += 1;
			break;
		}
	}

	// Check if we need to insert a new line because we have reached the end
	// of the screen.
	if (console->cursor_x >= crt_width)	{
		(console->cursor_x) = 0;
		(console->cursor_y) += 1;
	}
	// Check if cursor is at the bottom of the screen.
	// Scroll the screen if needed.
	video_scroll_console(console);

	// Update the cursor position only for current console.
	if( console == get_console_addr(0) ) {
		video_move_cursor(console->cursor_x, console->cursor_y);
	}


	restore_interrupts(flags);
}