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(); }
// clear everything including scrollback void cls(void) { memsetw(&buffer, blank, BUFFER_SIZE); clear_screen(); buf_csr = &buffer; view_offset = &buffer; move_csr(); }
/* Clears the screen */ void cls() { uint16_t blank; int i; /* Again, we need the 'short' that will be used to * represent a space with color */ blank = 0x20 | (attrib << 8); /* set background color of status line */ for (i=0; i < screen_w; i++) *((uint8_t*)(textmemptr + i)+1) = attrib_status; /* Sets the entire screen to spaces in our current * color */ /* skip first line (used as status monitor) */ for(i = 1; i < screen_h; i++) memsetw (textmemptr + i * screen_w, blank, screen_w); /* Update out virtual cursor, and then move the * hardware cursor */ csr_x = 0; csr_y = 0; # if !defined(EARLY) && SCROLLBACK_BUF_SIZE buf_x = 0; buf_y++; if (buf_y > SCROLLBACK_BUF_SIZE) { buf_y = 0; printf("Scrollback overflow!\n"); } # endif move_csr(); }
void scr_scroll_up(void) { if (view_offset > &buffer) { view_offset -= SCR_WIDTH; move_csr(); redraw(); } }
void scr_scroll_down(void) { if (view_offset + SCR_WIDTH < &buffer + BUFFER_SIZE) { view_offset += SCR_WIDTH; move_csr(); redraw(); } }
void putch(char ch) { size_t i; int j; unsigned att = attrib << 8; unsigned short *eob; unsigned short *eolwrite; if (is_eob()) push_scrollback(); // do the backspace key later // when we actually write a shell. if (ch == KEY_BACKSPACE) return; if (ch == KEY_TAB) { for (j = 0; j < TAB_SPACES; j++) putch(' '); } else if (ch == '\n') { i = eol_distance(); //easiest implementation? just fill to end of line with spaces? while (i > 0) { putch(' '); //replace with memset later? --i; } } else if (ch >= ' ') { *buf_csr = ch | att; buf_csr++; move_csr(); redraw(); } }
void putch(unsigned char c) { unsigned short *loc; unsigned att = attrib << 8; if (c == 0x08) { if (csr_x != 0)csr_x--; } else if (c == 0x09) { csr_x = (csr_x + 8) & ~(8 - 1); } else if (c == '\r') { csr_x = 0; } else if (c == '\n') { csr_x = 0; csr_y++; } else if (c >= ' ') { loc = txtMemPtr + (csr_y * 80 + csr_x); //*loc = att; //*++loc = c; *loc = c | att; //*loc = c; //*loc = att; csr_x++; } if (csr_x >= 80) { csr_x = 0; csr_y++; } scroll(); move_csr(); }
/* Puts a single character on the screen */ void putch(const char c){ unsigned short *where; unsigned att = attrib << 8; /* Handle a backspace, by moving the cursor back one space */ if(c == 0x08) { if(csr_x != 0) { csr_x--; putch(' '); csr_x--; }; } /* Handles a tab by incrementing the cursor's x, but only * to a point that will make it divisible by 8 */ else if(c == 0x09) { csr_x = (csr_x + 8) & ~(8 - 1); } /* Handles a 'Carriage Return', which simply brings the * cursor back to the margin */ else if(c == '\r') { csr_x = 0; } /* We handle our newlines the way DOS and the BIOS do: we * treat it as if a 'CR' was also there, so we bring the * cursor to the margin and we increment the 'y' value */ else if(c == '\n') { csr_x = 0; csr_y++; } /* Any character greater than and including a space, is a * printable character. The equation for finding the index * in a linear chunk of memory can be represented by: * Index = [(y * width) + x] */ else if(c >= ' ') { where = textmemptr + (csr_y * 80 + csr_x); *where = c | att; /* Character AND attributes: color */ csr_x++; } /* If the cursor has reached the edge of the screen's width, we * insert a new line in there */ if(csr_x >= 80) { csr_x = 0; csr_y++; } /* Scroll the screen if needed, and finally move the cursor */ scroll(); move_csr(); }
void Printf(char *str) { WriteString(str, curserX, curserY); curserX += strlen(str); if(curserX > screenWidth) { curserY++; curserX -= screenWidth; } move_csr(); }
void cls(void) { unsigned blank; int i; blank = 0x20 | (attrib << 8); for (i = 0; i < 25; i++) memsetw(((unsigned short *) txtMemPtr) + i * 80, blank, 80); csr_x = 0; csr_y = 0; move_csr(); }
void insert_char(char c, int pos) { for (int i = com_len; i >= pos; i--) { if (line[i-1] == ' ') line[i] = ' '; else line[i] = line[i - 1]; } line[pos] = c; com_len++; refresh_com(); csr_x++; move_csr(); }
/* Coloca um caractere único na tela */ void putch(unsigned char c) { unsigned short *where; unsigned att = attrib << 8; /* Trata um backspace, recuando o cursor um espaço */ if(c == 0x08) { if(csr_x != 0) csr_x--; } /* Trata um tab incrementando o cursor x, mas somente * para um ponto que seja divisível por 8 */ else if(c == 0x09) { csr_x = (csr_x + 8) & ~(8 - 1); } /* Trata um 'Retorno de Carruagem', que simplesmente traz o * cursor novamente para a margem */ else if(c == '\r') { csr_x = 0; } /* Nós tratamos nossas novas linhas (newlines) do mesmo modo do DOS e BIOS fazem: nós * trataremos isso como se um 'CR' estivesse lá também, assim nós trazemos o * cursor para a margem e nós incrementamos o valor 'y' */ else if(c == '\n') { csr_x = 0; csr_y++; } /* Qualquer caractere maior que e incluindo um espaço, é um * caractere que pode ser impresso. A equação para achar o índice * em um pedaço da memória linear pode ser representado por: * Índice = [(y * largura) + x] */ else if(c >= ' ') { where = textmemptr + (csr_y * 80 + csr_x); *where = c | att; /* Caractere E atributos: cor */ csr_x++; } /* Se o cursor alcançou a margem de largura da tela, nós * inserimos uma nova linha lá */ if(csr_x >= 80) { csr_x = 0; csr_y++; } /* Rola a tela se necessário, e finalmente move o cursor */ scroll(); move_csr(); }
void cls() { unsigned blank; int i; blank = 0x20 | (attrib << 8); for(i = 0; i < ROWS/*25*/; i++) memset16 (textmemptr + i * COLS, blank, COLS); csr_x = 0; csr_y = 0; move_csr(); }
void cls() { unsigned blank; int i; blank = 0x20 | (attrib << 8); for(i = 0; i < 25; i++) memsetw (textmemptr + i * 80, blank, 80); csr_x = 0; csr_y = 0; move_csr(); }
void alert(char s[], int line) { clear_line(line); int cur_y = csr_y; int cur_x = csr_x; csr_y = line; csr_x = 0; putch('|'); for (int i = 0; i < 70; i++) { putch(s[i]); } putch('|'); csr_y = cur_y; csr_x = cur_x; move_csr(); }
void select_vc(unsigned which_vc) { unsigned i; if(which_vc >= _num_vcs) return; _curr_vc = _vc + which_vc; i = _curr_vc->fb_adr - _vga_fb_adr; outportb(_crtc_io_adr + 0, 12); outportb(_crtc_io_adr + 1, i >> 8); outportb(_crtc_io_adr + 0, 13); outportb(_crtc_io_adr + 1, i); /* oops, forgot this: */ move_csr(); }
void cls() /// Clear The screen { unsigned blank; int i; blank = 0x20 | (attrib << 8); // Make the "blank" (space + attribute) for(i = 0; i < 25; i++) // Do it on every Line of the screen memsetw (textmemptr + i * 80, blank, 80); // Clear a line on the screen csr_x = 0; // Set Cursor Coords csr_y = 0; move_csr(); // Push the change to the VGA controller }
void cls(){ unsigned blank; int i; blank = 0x20 | (attrib << 8); //Blank character with black background // Clear entire screen for(i = 0; i < 25; i++) memsetw (textmemptr + i * 80, blank, 80); /* Update out virtual cursor, and then move the * hardware cursor */ csr_x = 0; csr_y = 0; move_csr(); }
void terminal_initialize() { uint16_t vga_entry; terminal_row = 0; terminal_column = 0; move_csr(); terminal_color = make_color(COLOR_WHITE, COLOR_BLACK); terminal_buffer = (uint16_t *) VGA_BUFFER; vga_entry = make_vgaentry(FILLCHAR, terminal_color); memset16(terminal_buffer, vga_entry, VGA_WIDTH * VGA_HEIGHT); VGA_BUFFER_SIZE = VGA_WIDTH * VGA_HEIGHT; }
void refresh_com() { int cur_y = csr_y; int cur_x = csr_x; for (int i = start_line; i <= csr_y; i++) { clear_line(i); } csr_y = start_line; csr_x = 0; wait_com(); for (int i = 0; i < com_len; i++) { putch(line[i]); } csr_y = cur_y; csr_x = cur_x; move_csr(); }
void putch(char c) /// Output a single charecter to the screen { unsigned short *where; unsigned att = attrib << 8; if(c == 0x08) // Handle a Backspace as a control charecter { if(csr_x != 0) { csr_x--; // Move it back one space where = textmemptr + (csr_y * 80 + csr_x); // Find where we are *where = ' ' | att; // Make it blank. } } else if(c == 0x09) // Handle a Tab { csr_x = (csr_x + 8) & ~(8 - 1); // Move the cursor forward modulus 8 } else if(c == '\r') // Carriage return { csr_x = 0; // Return the cursor to the beginning of the screen } else if(c == '\n') // Newline! { csr_x = 0; // Carriage return is included in the newline csr_y++; // Next line on the screen } else if(c >= ' ') // Any ASCII non-Controll code: { where = textmemptr + (csr_y * 80 + csr_x); *where = c | att; // Character AND attributes: color csr_x++; } if(csr_x >= 80) // Check to see if we overflowed into next line { csr_x = 0; // Adjust the line appropriately csr_y++; // Increment line pointer } scroll(); // Check to see if we need to scroll the screen move_csr(); // Move the cursor to it's new home. }
/* Clears the screen */ void cls() { unsigned blank; int i; /* Again, we need the 'short' that will be used to * represent a space with color */ blank = 0x20 | (attrib << 8); /* Sets the entire screen to spaces in our current * color */ for(i = 0; i < 25; i++) memsetw (textmemptr + i * 80, blank, 80); /* Update out virtual cursor, and then move the * hardware cursor */ csr_x = 0; csr_y = 0; move_csr(); }
void putch(unsigned c) { unsigned att; att = _attrib << 8; /* backspace */ if(c == 0x08) { if(_csr_x != 0) _csr_x--; } /* tab */ else if(c == 0x09) _csr_x = (_csr_x + 8) & ~(8 - 1); /* carriage return */ else if(c == '\r') /* 0x0D */ _csr_x = 0; /* line feed */ // else if(c == '\n') /* 0x0A */ // _csr_y++; /* CR/LF */ else if(c == '\n') /* ### - 0x0A again */ { _csr_x = 0; _csr_y++; } /* printable ASCII */ else if(c >= ' ') { unsigned short *where; where = _vga_fb_adr + (_csr_y * _vc_width + _csr_x); *where = c | att; _csr_x++; } if(_csr_x >= _vc_width) { _csr_x = 0; _csr_y++; } scroll(); move_csr(); }
/* Limpa a tela */ void cls() { unsigned blank; int i; /* Outra vez, nós necessitamos o 'short' que vai ser usada para * representar um espaço com cor */ blank = 0x20 | (attrib << 8); /* Atribui a tela inteira com espaços para nossa cor * corrente */ for(i = 0; i < 25; i++) memsetw (textmemptr + i * 80, blank, 80); /* Atualiza o cursor virtual, e então move o * cursor do hardware */ csr_x = 0; csr_y = 0; move_csr(); }
void putch(unsigned char c) { unsigned short *where; unsigned att = attrib << 8; if(c == 0x08) { if(csr_x != 0) csr_x--; } else if(c == 0x09) { csr_x = (csr_x + 8) & ~(8 - 1); } else if(c == '\r') { csr_x = 0; } else if(c == '\n') { csr_x = 0; csr_y++; } else if(c >= ' ') { where = textmemptr + (csr_y * 80 + csr_x); *where = c | att; csr_x++; } if(csr_x >= 80) { csr_x = 0; csr_y++; } scroll(); move_csr(); }
void putch(unsigned char c) { unsigned short *where; unsigned att = attrib << 8; if(c == 0x08) { if(csr_x != 0) csr_x--; } else if(c == 0x09) { csr_x = (csr_x + 8) & ~(8 - 1); } else if(c == '\r') { csr_x = 0; } else if(c == '\n') { csr_x = 0; csr_y++; } else if(c >= ' ') { where = textmemptr + (csr_y * COLS + csr_x); *where = c | att; /* Character AND attributes: color */ csr_x++; } if(csr_x >= COLS) { csr_x = 0; csr_y++; } scroll(); move_csr(); }
/// NOTE: What purpose does this function serve? void shell_csr_fix() /// Fix the cursor back a line. { csr_y--; // Move cursor back a line move_csr(); // Tell the hardware to move it }
static void putch_help(console_t *con, unsigned c) { unsigned short *fb_adr; unsigned att; att = (unsigned)con->attrib << 8; fb_adr = con->fb_adr; /* state machine to handle the escape sequences ESC */ if(con->esc == 1) { if(c == '[') { con->esc++; con->esc1 = 0; return; } /* else fall-through: zero esc and print c */ } /* ESC[ */ else if(con->esc == 2) { if(isdigit(c)) { con->esc1 = con->esc1 * 10 + c - '0'; return; } else if(c == ';') { con->esc++; con->esc2 = 0; return; } /* ESC[2J -- clear screen */ else if(c == 'J') { if(con->esc1 == 2) { memsetw(fb_adr, ' ' | att, _vc_height * _vc_width); con->csr_x = con->csr_y = 0; } } /* ESC[num1m -- set attribute num1 */ else if(c == 'm') set_attrib(con, con->esc1); con->esc = 0; /* anything else with one numeric arg */ return; } /* ESC[num1; */ else if(con->esc == 3) { if(isdigit(c)) { con->esc2 = con->esc2 * 10 + c - '0'; return; } else if(c == ';') { con->esc++; /* ESC[num1;num2; */ con->esc3 = 0; return; } /* ESC[num1;num2H -- move cursor to num1,num2 */ else if(c == 'H') { if(con->esc2 < _vc_width) con->csr_x = con->esc2; if(con->esc1 < _vc_height) con->csr_y = con->esc1; } /* ESC[num1;num2m -- set attributes num1,num2 */ else if(c == 'm') { set_attrib(con, con->esc1); set_attrib(con, con->esc2); } con->esc = 0; return; } /* ESC[num1;num2;num3 */ else if(con->esc == 4) { if(isdigit(c)) { con->esc3 = con->esc3 * 10 + c - '0'; return; } /* ESC[num1;num2;num3m -- set attributes num1,num2,num3 */ else if(c == 'm') { set_attrib(con, con->esc1); set_attrib(con, con->esc2); set_attrib(con, con->esc3); } con->esc = 0; return; } con->esc = 0; /* escape character */ if(c == 0x1B) { con->esc = 1; return; } /* backspace */ if(c == 0x08) { if(con->csr_x != 0) con->csr_x--; } /* tab */ else if(c == 0x09) con->csr_x = (con->csr_x + 8) & ~(8 - 1); /* carriage return */ else if(c == '\r') /* 0x0D */ con->csr_x = 0; /* line feed */ // else if(c == '\n') /* 0x0A */ // con->csr_y++; /* CR/LF */ else if(c == '\n') /* ### - 0x0A again */ { con->csr_x = 0; con->csr_y++; } /* printable ASCII */ else if(c >= ' ') { unsigned short *where; where = fb_adr + (con->csr_y * _vc_width + con->csr_x); *where = (c | att); con->csr_x++; } if(con->csr_x >= _vc_width) { con->csr_x = 0; con->csr_y++; } scroll(con); /* move cursor only if the VC we're writing is the current VC */ if(_curr_vc == con) move_csr(); }