feature: a lot of stuff and got to a working command line ish

This commit is contained in:
2021-02-01 22:31:21 +01:00
parent 468d5968a9
commit 9986d95dbb
22 changed files with 1511 additions and 76 deletions

30
kernel/libc/readline.c Normal file
View File

@@ -0,0 +1,30 @@
//
// Created by rick on 01-02-21.
//
#include "readline.h"
#include <libc/libc.h>
#include <types.h>
#include <kprint.h>
#include <mem/mem.h>
#include <drivers/keyboard.h>
#define RESULT_SIZE 256
const char* default_msg = "> ";
char* readline(const char *prompt) {
kprint(prompt == NULL ? default_msg : prompt);
char* result = malloc(RESULT_SIZE);
memset(result, 0, RESULT_SIZE);
for (int i = 0; i < RESULT_SIZE; ++i) {
result[i] = getc();
kprint(&result[i]);
if (result[i] == '\n') {
result[i] = 0;
break;
}
}
return result;
}