feature (shell): started work on a basic shell
This commit is contained in:
parent
99cd492570
commit
ddc47b3ea3
|
@ -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);
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue