Feat: SCANF WORKING!
This commit is contained in:
@@ -178,6 +178,17 @@ static inline int __put_char_VGA_POS(_VGA _c, _VGA_screen_space _position, int _
|
||||
return written;
|
||||
}
|
||||
|
||||
if (_c.codepoint == '\b') {
|
||||
if (_position.column > 0) {
|
||||
_position.column--;
|
||||
vga[(_position.line * VGA_WIDTH) + _position.column].codepoint = ' ';
|
||||
vga[(_position.line * VGA_WIDTH) + _position.column].color = _c.color;
|
||||
}
|
||||
text_pos.line = _position.line;
|
||||
text_pos.column = _position.column;
|
||||
return 1;
|
||||
}
|
||||
|
||||
vga[(_position.line * VGA_WIDTH) + _position.column].codepoint = _c.codepoint;
|
||||
vga[(_position.line * VGA_WIDTH) + _position.column].color = _c.color;
|
||||
|
||||
@@ -435,36 +446,14 @@ static inline char __convert_ascii(uint8_t __scancode) {
|
||||
return __char;
|
||||
}
|
||||
|
||||
uint8_t __scancode_h[128] = {0};
|
||||
static uint32_t __total_isr_calls = 0;
|
||||
|
||||
void __keyboard_handle_scancode(uint8_t __scancode) {
|
||||
__total_isr_calls++;
|
||||
|
||||
char __temp = __convert_ascii(__scancode);
|
||||
static uint8_t __index = 0;
|
||||
|
||||
if (__index < sizeof(__scancode_h)) {
|
||||
__scancode_h[__index++] = __scancode;
|
||||
}
|
||||
|
||||
if (__temp == '\0') {
|
||||
return;
|
||||
}
|
||||
__keyboard_buffer_push(__temp);
|
||||
}
|
||||
|
||||
void __dump_scancode_history() {
|
||||
printf("Scancode History: \n");
|
||||
printf("Total ISR Calls: %u\n", __total_isr_calls);
|
||||
for (size_t i = 0; i < sizeof(__scancode_h); i++) {
|
||||
if (__scancode_h[i] != 0) {
|
||||
printf("[%x] = %c\n", __scancode_h[i], __convert_ascii(__scancode_h[i]));
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static inline char __gets_internal(char *buffer, size_t max_length) {
|
||||
size_t index = 0;
|
||||
char __c;
|
||||
@@ -477,10 +466,22 @@ static inline char __gets_internal(char *buffer, size_t max_length) {
|
||||
}
|
||||
|
||||
if (__c == '\n' || __c == '\r') {
|
||||
printf("\n");
|
||||
buffer[index] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (__c == '\b') {
|
||||
if (index > 0) {
|
||||
index--;
|
||||
printf("\b \b");
|
||||
scursor(text_pos.column, text_pos.line);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%c", __c);
|
||||
scursor(text_pos.column, text_pos.line);
|
||||
buffer[index++] = __c;
|
||||
}
|
||||
|
||||
@@ -492,9 +493,8 @@ void gets(char *buffer, size_t max_length) {
|
||||
__gets_internal(buffer, max_length);
|
||||
}
|
||||
|
||||
/*
|
||||
static inline int __scanf_internal(const char *fmt, va_list args) {
|
||||
|
||||
scursor(text_pos.column, text_pos.line);
|
||||
char buffer[256];
|
||||
__gets_internal(buffer, sizeof(buffer));
|
||||
|
||||
@@ -559,6 +559,5 @@ int scanf(const char *fmt, ...) {
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user