void terminal_putchar(char character) { switch(character) { case '\n': new_line(); break; case '\b': if(cursor_x > 0) { cursor_x--; terminal_putentryat(' ', terminal_color,cursor_x,cursor_y); } break; case '\r': cursor_x = 0; break; case '\t': cursor_x = (cursor_x + tab_size) & ~(tab_size - 1); break; default: terminal_putentryat(character, terminal_color, cursor_x, cursor_y); cursor_x++; break; } new_line_check(); update_cursor(); }
void terminal_putchar(char c) { if(c == '\n'){ terminal_row++; terminal_column = 0; return; } else if(c == '\t'){ for(int i = 0; i < SPACES_IN_TAB; i++){ terminal_putentryat(' ', terminal_color, terminal_column, terminal_row); if ( ++terminal_column == VGA_WIDTH ) { terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_scroll(); } return; } } return; } terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if ( ++terminal_column == VGA_WIDTH ) { terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_scroll(); } } }
void terminal_putcharc(char c, enum vga_color fg, enum vga_color bg) { static size_t terminal_row = 0; static size_t terminal_col = 0; if (c == '\n') { /* blank the rest of the line */ for (; terminal_col < VGA_WIDTH; terminal_col++) terminal_putentryat(' ', fg, bg, terminal_row, terminal_col); } else { terminal_putentryat(c, fg, bg, terminal_row, terminal_col); terminal_col++; } if (terminal_col == VGA_WIDTH) { terminal_col = 0; terminal_row++; if (terminal_row == VGA_HEIGHT) { terminal_scroll(); terminal_row = VGA_HEIGHT - 1; } } }
void terminal_putchar(char c) { if (serial_echo_port != 0) { serial_write(c, serial_echo_port); } if (c == '\t') { terminal_column += 8 - (terminal_column % 8) - 1; } else if (c == '\n') { terminal_column = VGA_WIDTH - 1; } else if (c == '\b') { terminal_column--; terminal_putentryat(0, terminal_color, terminal_column, terminal_row); terminal_column--; } else { terminal_putentryat(c, terminal_color, terminal_column, terminal_row); } if(++terminal_column == VGA_WIDTH) { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_roll(); } } terminal_update_hardware_cursor(); }
/* * Appends a new character to the terminal buffer and then flushes the * buffer to update the screen. Scrolls the terminal when full. */ void terminal_putchar(char c) { //support for newline character if (c == '\n') { terminal_row++; terminal_column = 0; }//support for backspace else if (c == 0x08) { t_char tc = {' ', terminal_color}; terminal_column--; if (terminal_column > VGA_WIDTH) { terminal_row--; terminal_column = VGA_WIDTH - 1; } terminal_putentryat(tc, terminal_column, terminal_row); }//support for other characters else { t_char tc = {c, terminal_color}; terminal_putentryat(tc, terminal_column, terminal_row); terminal_column++; } //horizontal wrapping if (terminal_column == VGA_WIDTH) { //reset to first column and increment row terminal_column = 0; terminal_row++; } //scroll up console if bottom is reached if (terminal_row >= VGA_HEIGHT) { for (size_t y = 1; y < VGA_HEIGHT; y++) { for (size_t x = 0; x < VGA_WIDTH; x++) { //find where this character is now and where it should go size_t index = buffer_index(x, y); size_t newIndex = buffer_index(x, y - 1); //move this character up a line buffer[newIndex].t = buffer[index].t; buffer[newIndex].colour = buffer[index].colour; //clear the old character buffer[index].t = ' '; buffer[index].colour = terminal_color; } } terminal_row = VGA_HEIGHT - 1; } //flush display terminal_flush(); }
/* * --------------------------------------------------------------------------- * Name : terminal_write * Purpose: Write a string to the buffer. * Args : const char* data, * size_t size * Returns: void * --------------------------------------------------------------------------- */ void terminal_write(const char* data, size_t size) { for ( size_t i = 0; i < size; i++ ) if(data[i] == '\n') { terminal_column = 0; if(++terminal_row == VGA_HEIGHT) { terminal_scroll(); } } else if(data[i] == '\t') { size_t i = 0; while(i++ < 4 - (terminal_column % 4)) terminal_putchar(' '); } else if(data[i] == '\r') { while(terminal_column-- >= 0) terminal_putentryat(' ', make_color(COLOR_LIGHT_GREY, COLOR_BLACK), terminal_column, terminal_row); } else if(data[i] == '\x1b') { i += terminal_escape_sequence(data + i); } else { terminal_putchar(data[i]); } }
void terminal_putchar(char c) { /* handle newline char */ if (c == '\n') { terminal_clear_row_from(terminal_column, terminal_row); terminal_column = 0; if( ++terminal_row == VGA_HEIGHT) { terminal_scroll(); terminal_row--; } return; } uint16_t vga_entry = make_vgaentry(c, terminal_color); terminal_putentryat(vga_entry, terminal_column, terminal_row); /* handle moving to next line */ if ( ++terminal_column == VGA_WIDTH ) { terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_scroll(); terminal_row--; } } }
void terminal_putchar(char c) { switch(c) { case '\n': terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_row = VGA_HEIGHT-1; terminal_scroll(); } break; default: terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if ( ++terminal_column == VGA_WIDTH ) { terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_row = VGA_HEIGHT-1; terminal_scroll(); } } break; } }
void terminal_putchar(char c) { if ( c == '\n' ) { terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_scroll(); terminal_row--; } move_csr(); return; } terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if ( ++terminal_column == VGA_WIDTH ) { terminal_column = 0; if ( ++terminal_row == VGA_HEIGHT ) { terminal_scroll(); terminal_row--; } } move_csr(); }
static void terminal_clear_row_from(size_t col, size_t row) { size_t i; uint16_t vga_entry = make_vgaentry(' ', terminal_color); for(i = col; i < VGA_WIDTH; i++) terminal_putentryat(vga_entry, i, row); }
void terminal_putchar(char c) { if(c == '\n'){// this for loop is for the backgroud color! for (size_t x = terminal_column; x < VGA_WIDTH; x++) { const size_t index = terminal_row * VGA_WIDTH + x; terminal_buffer[index] = make_vgaentry(' ', terminal_color); } terminal_row++; terminal_column=0; if(terminal_row==VGA_HEIGHT){ terminal_scrolling(); terminal_row--; } return ; } if(terminal_column < VGA_WIDTH && terminal_row < VGA_HEIGHT) terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if (++terminal_column == VGA_WIDTH){ terminal_column = 0; if (++terminal_row == VGA_HEIGHT){ terminal_scrolling(); terminal_row--; } } }
void terminal_putchar(char c) { if(c == '\n') { if(terminal_row + 1 == VGA_HEIGHT) { terminal_scroll(); terminal_row = 24; } else { terminal_row++; } terminal_column = 0; } else { terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if(++terminal_column == VGA_WIDTH) { terminal_column = 0; if(++terminal_row == VGA_HEIGHT) { terminal_scroll(); terminal_row = 24; } } } }
void terminal_putchar(char c) { switch (c) { case '\n': terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row = 0; } break; case '\t': if (terminal_column += 4 == VGA_WIDTH) { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row = 0; } } break; case '\b': if (--terminal_column <= 0) { if (--terminal_row <= 0) { terminal_row = 0; } terminal_column = 0; } break; default: terminal_putentryat(c, terminal_color, terminal_column, terminal_row); __next_cell(); break; } __update_cursor(); }
void terminal_putchar(char c) { terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if (++terminal_column == VGA_WIDTH) { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row = 0; } } }
void terminal_update(){ for ( size_t y = 0; y < VGA_HEIGHT; y++ ) { for ( size_t x = 0; x < VGA_WIDTH; x++ ) { terminal_putentryat(text[x][y], make_color(fg[x][y], bg[x][y]), x, y); } } auto_update_cursor(); }
void terminal_moveAllUp(uint8_t li_to_cl) { for (size_t y = 0; y < VGA_HEIGHT - li_to_cl; y++) { for (size_t x = 0; x < VGA_WIDTH; x++) { terminal_buffer[makeIndex(x, y)] = terminal_buffer[makeIndex(x, y+li_to_cl)]; terminal_putentryat(' ', terminal_color, x, y+li_to_cl); } } terminal_row -= li_to_cl; }
void terminal_initialize() { terminal_row = 0; terminal_column = 0; terminal_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK); terminal_buffer = (uint16_t*) 0xB8000; for (size_t y = 0; y < VGA_HEIGHT; y++) { for (size_t x = 0; x < VGA_WIDTH; x++) { terminal_putentryat(' ', terminal_color, x, y); } } }
void terminal_putchar(char c) { terminal_putentryat(c, terminal_color, terminal_column, terminal_row); terminal_column++; if (terminal_column == VGA_WIDTH) { terminal_column = 0; terminal_row++; if (terminal_row == VGA_HEIGHT) { terminal_moveAllUp(1); } } }
void terminal_initialize() { terminal_bg = COLOR_BLACK; terminal_fg = COLOR_LIGHT_GREY; /* clear screen */ for (size_t row = 0; row < VGA_HEIGHT; row++) { for (size_t col = 0; col < VGA_WIDTH; col++) { terminal_putentryat(' ', terminal_fg, terminal_bg, row, col); } } }
void terminal_backspace() { __vga_write_lock.lock(); if(--terminal_column > VGA_WIDTH) { if(--terminal_row > VGA_HEIGHT) { terminal_scroll(-1); terminal_row = 0; } } terminal_putentryat(' ', terminal_color, terminal_column, terminal_row); __vga_write_lock.unlock(); }
void putchar(char c) { if(c == '\n') { terminal_column = 0; advance_row(); } else if (c == '\b') { back(); }else { terminal_putentryat(c, terminal_color, terminal_column, terminal_row); advance_column(); } move_cursor_to(terminal_column, terminal_row); }
void terminal_putchar(char c) { if (c == '\n') { terminal_row++; terminal_column = 0; return; } terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if (++terminal_column == VGA_WIDTH) { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row = 0; } } }
void terminal_putchar(const char c) { if (c == '\n') { terminal_row++; if (terminal_row == VGA_HEIGHT) { ScrollDown(1); terminal_row = 23; }; terminal_column = 0; return; }; if (terminal_column++ == VGA_WIDTH) { terminal_putchar('\n'); }; terminal_putentryat(c, terminal_color, terminal_column, terminal_row); };
static void terminal_scroll() { /* shift all rows up one */ for (size_t row = 1; row < VGA_HEIGHT; row++) { for (size_t col = 0; col < VGA_WIDTH; col++) { size_t src_idx = row * VGA_WIDTH + col; size_t dst_idx = (row - 1) * VGA_WIDTH + col; terminal_buffer[dst_idx] = terminal_buffer[src_idx]; } } /* clear last row */ size_t row = VGA_HEIGHT - 1; for (size_t col = 0; col < VGA_WIDTH; col++) { terminal_putentryat(' ', terminal_fg, terminal_bg, row, col); } }
void terminal_putchar(char c) { if (c == '\n') { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row--; terminal_scrolldown(); } } else { terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if (++terminal_column == VGA_WIDTH) { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row--; terminal_scrolldown(); } } } }
void terminal_roll() { for (size_t x = 0; x < VGA_HEIGHT - 1; x++) { for (size_t y = 0; y < VGA_WIDTH; y++) { terminal_buffer[x * VGA_WIDTH + y] = terminal_buffer[(x + 1) * VGA_WIDTH + y]; } } for (size_t i = 0; i < VGA_WIDTH; i++) { terminal_putentryat(' ', terminal_color, i, VGA_HEIGHT - 1); } terminal_row = VGA_HEIGHT - 1; terminal_column = 0; }
void terminal_putchar(char c) { if (c == '\n') { terminal_column = 0; if (terminal_row == VGA_HEIGHT - 1) { terminal_scroll_up(); } else { ++terminal_row; } return; } terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if (++terminal_column == VGA_WIDTH) { terminal_column = 0; } }
static void terminal_scroll(void) { /* need to move all rows up by one index losing information about row 0 */ size_t temp_row, temp_column; /* for each row */ for(temp_row = 1; temp_row < VGA_HEIGHT; temp_row++) { for(temp_column = 0; temp_column < VGA_WIDTH; temp_column++){ uint16_t ventry = terminal_getentryat(temp_column, temp_row); terminal_putentryat(ventry, temp_column, temp_row - 1); } } /* clear the last row, making 'space' */ terminal_clear_row_from(0, VGA_HEIGHT - 1); }
void terminal_putchar(char c) { if (c == '\n') { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row--; terminal_scroll_ugly(); } return; } else { terminal_putentryat(c, terminal_colour, terminal_column, terminal_row); } if (++terminal_column == VGA_WIDTH) { terminal_column = 0; if (++terminal_row == VGA_HEIGHT) { terminal_row--; terminal_scroll_ugly(); //terminal_row = 0; } } }
void terminal_putchar(char c) { if (c == '\n') { terminal_column = 0; terminal_row += 1; } else { if (terminal_row+1 == VGA_HEIGHT ) { terminal_scroll_down(); --terminal_row; } terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if ( ++terminal_column == VGA_WIDTH ) { terminal_column = 0; } } }