diff --git a/ramdisk/shell.c b/ramdisk/shell.c new file mode 100644 index 0000000..b1cd05c --- /dev/null +++ b/ramdisk/shell.c @@ -0,0 +1,39 @@ +#include "nox/stdio.h" + +#define COMMAND_BUFFER_SIZE 512 + +int read_command(char* command_buffer) { + char chr = 0; + int pos = 0; + while (chr != '\n') { + chr = getc(); + switch (chr) { + case '\b': { + if (pos > 0) pos--; + break; + } + default: { + if (pos < COMMAND_BUFFER_SIZE) { + command_buffer[pos] = chr; + pos++; + } + break; + } + } + } + + command_buffer[pos] = '\0'; + return pos; +} + +void _start() { + printf("Welcome to the nox shell.\ntype 'help' for a list of commands\n"); + + bool running = true; + + while(running) { + printf("\n>>> "); + char command_buffer[COMMAND_BUFFER_SIZE]; + read_command(command_buffer); + } +} \ No newline at end of file diff --git a/ramdisk/shell.elf b/ramdisk/shell.elf new file mode 100755 index 0000000..5599c10 Binary files /dev/null and b/ramdisk/shell.elf differ