feature: functional shell with help and merdella commands
TOOD: reboot, poweroff, echo, color
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const char *keymap[128] = {
|
||||
[2] = "1!", [3] = "2@", [4] = "3#", [5] = "4$", [6] = "5%",
|
||||
[7] = "6^", [8] = "7&", [9] = "8*", [10] = "9(", [11] = "0)",
|
||||
@ -93,6 +95,11 @@ static const char *keymap[128] = {
|
||||
#define KEY_RIGHT 0x4D
|
||||
#define KEY_SPACE 0x39
|
||||
#define KEY_UP 0x48
|
||||
#define KET_LEFT_SHIFT 0x2A
|
||||
#define KEY_LEFT_SHIFT 0x2A
|
||||
#define KEY_RIGHT_SHIFT 0x36
|
||||
#define KEY_CAPSLOCK 0x3A
|
||||
#define KEY_CAPSLOCK 0x3A
|
||||
|
||||
struct key_event {
|
||||
uint8_t c;
|
||||
uint8_t scan_code;
|
||||
};
|
||||
|
49
headers/shell.h
Normal file
49
headers/shell.h
Normal file
@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#define PROMPT "> "
|
||||
|
||||
static const char *POOP =
|
||||
" / ____/ / _ \\\n"
|
||||
" _/ ___/_ / / \\___ \\_\n"
|
||||
" / _/'-, `---._ / / \\_ \\\n"
|
||||
" / ______/(0} `, , ` , ) / / \\_ \\\n"
|
||||
" / V ; ` , ` ( / / ,'~~~~~~`, \\\n"
|
||||
" | `.____,- ' (, ` , ) / / :`,-'\"\"`. \"; "
|
||||
"|\n"
|
||||
" | `-------._); , ` `, / / \\;: )``: |\n"
|
||||
" / / ) ) ; ` ,, : / / `` : '; "
|
||||
"\\\n"
|
||||
"/ / ( (`;: ; ` ;:\\ / / ;;;, "
|
||||
"\\\n"
|
||||
"| / (: )``;:;;)`'`'`--./ / ____ _,-';;` "
|
||||
"|\n"
|
||||
"| | :` )`;)`)`' : / / ~~~~~ ~~~`--',.;;;| "
|
||||
"|\n"
|
||||
"| | `--;~~~~~ ` / /, \" \" \"` \",, \\ ;`` | "
|
||||
" |\n"
|
||||
"| | ( ; , / / ; `; ; | "
|
||||
"|\n"
|
||||
"| | (; ; ; ` / / ,` ` : | "
|
||||
"><\n"
|
||||
"| | (; / / / ` ; ; : |\n"
|
||||
"| \\ ;(_; ; : / /` ; ; ,,,\"\"\";} `; / "
|
||||
"><\n"
|
||||
"\\ \\ : `; `; ` / /,;,'''' );;`); ; / >< "
|
||||
" ><\n"
|
||||
" \\ | ;' :; ;/ / (;` :( ; , ; | "
|
||||
"><\n"
|
||||
" | | |, `;; ,/ / `)`; `(; ` `; | "
|
||||
"(`\\\n"
|
||||
" | \\ ; ;; ``: / `).:` \\;, `. / _> "
|
||||
")_\n"
|
||||
" \\ \\_ ,-' ;`;;:;` / ;;'`;; `) )/ ,-' "
|
||||
",-. `;\n"
|
||||
" \\ \\_ ~~~,-`;`;,\" / ~~~~~ ,-' ; "
|
||||
"`\"\"/ /\"\"\n"
|
||||
" \\_ \\___\"\"\"/\"\" / `\"\"/\"\" "
|
||||
"\n";
|
||||
|
||||
typedef enum { HELP, REBOOT, POWEROFF, ECHO, COLOR, MERDELLA, ERROR } CMD_TOK;
|
||||
|
||||
void reboot(void);
|
||||
void shell_init(void);
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "keyboard.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -14,6 +15,7 @@ struct screen {
|
||||
size_t column;
|
||||
uint8_t color;
|
||||
uint16_t buffer[VGA_WIDTH * VGA_HEIGHT];
|
||||
char line[256];
|
||||
};
|
||||
|
||||
enum vga_color {
|
||||
@ -35,13 +37,16 @@ enum vga_color {
|
||||
VGA_COLOR_WHITE = 15,
|
||||
};
|
||||
|
||||
enum cursor_direction { LEFT, RIGHT, UP, DOWN };
|
||||
|
||||
void terminal_initialize(void);
|
||||
void terminal_setcolor(uint8_t color);
|
||||
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y);
|
||||
int terminal_putchar(char c);
|
||||
int terminal_write(const char *data, size_t size);
|
||||
int terminal_writestring(const char *data);
|
||||
int terminal_writelong(long number);
|
||||
void terminal_set_screen(int pos);
|
||||
uint8_t terminal_getkey(void);
|
||||
struct key_event terminal_getkey(void);
|
||||
void update_cursor(void);
|
||||
void move_cursor(int direction);
|
||||
struct screen *get_screen(void);
|
||||
|
Reference in New Issue
Block a user