feature: character escape (you can now write text)
fix: cursor when changing screens
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
#include "keyboard.h"
|
||||
#include "kprintf.h"
|
||||
#include "sys/io.h"
|
||||
#include "terminal.h"
|
||||
@ -9,7 +10,8 @@ uint8_t terminal_getkey(void)
|
||||
|
||||
scan_code = inb(KEYBOARD_PORT);
|
||||
if (scan_code != prev_scan_code && prev_scan_code != 0) {
|
||||
kprintf(0, "%d", scan_code);
|
||||
if (scan_code < 128 && keymap[scan_code])
|
||||
kprintf(0, "%c", keymap[scan_code][0]);
|
||||
if (scan_code >= KEY_F1 && scan_code <= KEY_F10)
|
||||
terminal_set_screen(scan_code - KEY_F1);
|
||||
}
|
||||
|
@ -26,14 +26,14 @@ void terminal_initialize(void)
|
||||
for (size_t y = 0; y < VGA_HEIGHT; y++) {
|
||||
for (size_t x = 0; x < VGA_WIDTH; x++) {
|
||||
const size_t index = y * VGA_WIDTH + x;
|
||||
TERM_BUF[index] = vga_entry(' ', screen->color);
|
||||
TERM_BUF[index] = vga_entry(' ', VGA_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < TERM_COUNT; i++) {
|
||||
screens[i].row = 0;
|
||||
screens[i].column = 0;
|
||||
screens[i].color =
|
||||
vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
|
||||
screens[i].color = vga_entry_color(VGA_COLOR_LIGHT_MAGENTA - i,
|
||||
VGA_COLOR_BLACK);
|
||||
memcpy(screens[i].buffer, TERM_BUF, sizeof(screen->buffer));
|
||||
}
|
||||
}
|
||||
@ -43,6 +43,7 @@ void terminal_set_screen(int pos)
|
||||
memcpy(screen->buffer, TERM_BUF, sizeof(screen->buffer));
|
||||
screen = &screens[pos];
|
||||
memcpy(TERM_BUF, screen->buffer, sizeof(screen->buffer));
|
||||
update_cursor();
|
||||
}
|
||||
|
||||
void terminal_setcolor(uint8_t color)
|
||||
@ -62,7 +63,7 @@ static void terminal_scroll(void)
|
||||
for (size_t i = 0; i < VGA_WIDTH * (VGA_HEIGHT - 1); i++)
|
||||
TERM_BUF[i] = TERM_BUF[i + VGA_WIDTH];
|
||||
for (size_t i = 0; i < VGA_WIDTH; i++)
|
||||
terminal_putentryat(' ', screen->color, i, VGA_HEIGHT - 1);
|
||||
terminal_putentryat(' ', VGA_COLOR_WHITE, i, VGA_HEIGHT - 1);
|
||||
}
|
||||
|
||||
static void terminal_new_line(void)
|
||||
|
Reference in New Issue
Block a user