Fixed backspace in new printing

This commit is contained in:
2024-04-19 13:56:15 +02:00
parent 12c0fafa1f
commit 889f283fcd
3 changed files with 17 additions and 5 deletions
+3
View File
@@ -51,6 +51,7 @@ char buffer[MAX_BUFFER_SIZE + 1] = { 0 };
bool echo = false; bool echo = false;
bool canBackspace = false; bool canBackspace = false;
// TODO: Refactor this
void keyboardHandler() { void keyboardHandler() {
uint8_t scancode; uint8_t scancode;
scancode = inb(0x60); scancode = inb(0x60);
@@ -75,6 +76,8 @@ void keyboardHandler() {
} }
} }
// TODO: Add a 'char readc();' function that returns a single read character and use it for read()
// Also this should be refactored to not use so many flag variables
char* read(char terminator) { char* read(char terminator) {
bufferLen = 0; bufferLen = 0;
echo = true; echo = true;
+13 -4
View File
@@ -6,8 +6,8 @@
#define MODE_INFO_BLOCK 0x5000 #define MODE_INFO_BLOCK 0x5000
#define WIDTH 1920 #define WIDTH 1920
#define HEIGHT 1080 #define HEIGHT 1080
#define BG_COLOR 0xff1f2937 #define BG_COLOR 0xff010b17
#define FG_COLOR 0xffd1d5db #define FG_COLOR 0xffebddf4
struct cursor_s { struct cursor_s {
uint32_t x; uint32_t x;
@@ -39,13 +39,22 @@ void putcAt(char c, uint32_t x, uint32_t y) {
} }
} }
void putc(char c) { void printAt(const char* str, uint32_t x, uint32_t y) {
putcAt(c, cursor.x, cursor.y); while (*str != '\0') {
putcAt(*str++, x, y);
x++;
}
}
void putc(char c) {
if (c == '\n') { if (c == '\n') {
cursor.y++; cursor.y++;
cursor.x = 0; cursor.x = 0;
} else if (c == '\b') {
cursor.x--;
putcAt(' ', cursor.x, cursor.y);
} else { } else {
putcAt(c, cursor.x, cursor.y);
cursor.x++; cursor.x++;
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
=== Todo === === Todo ===
- [*] Multistage Bootloader - [*] Multistage Bootloader
- [ ] Write down where stuff is in memory (0x1000 - kernel, 0x2000 - filetable, 0x5000 - VBE Mode Info, 0x6000 - Font) - [ ] Write down where stuff is in memory (0x1000 - kernel, 0x4000? - filetable, 0x5000 - VBE Mode Info, 0x6000 - Font)
- [ ] Screen - [ ] Screen
- [ ] Scrolling - [ ] Scrolling
- [ ] Scroll-back - [ ] Scroll-back