Compare commits
No commits in common. "bdfac39bc94376d1fa47cc5d1f687938062f9693" and "08f7352a314d69eb11ea8138ec46e0368196a8a0" have entirely different histories.
bdfac39bc9
...
08f7352a31
@ -9,4 +9,3 @@ size_t strlen(const char *str);
|
|||||||
char *strstr(const char *haystack, const char *needle);
|
char *strstr(const char *haystack, const char *needle);
|
||||||
void *memcpy(void *dest, const void *src, size_t n);
|
void *memcpy(void *dest, const void *src, size_t n);
|
||||||
int memcmp(const void *s1, const void *s2, size_t n);
|
int memcmp(const void *s1, const void *s2, size_t n);
|
||||||
void *memset(void *str, int c, size_t n);
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
void *memset(void *str, int c, size_t n)
|
|
||||||
{
|
|
||||||
uint8_t *c1 = (uint8_t *)str;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < n; i++)
|
|
||||||
c1[i] = c;
|
|
||||||
return c1;
|
|
||||||
}
|
|
@ -40,7 +40,7 @@ static CMD_TOK find_command(char *line)
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_line(void)
|
static void read_line(char *buf, size_t size)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
struct key_event ev;
|
struct key_event ev;
|
||||||
@ -50,9 +50,6 @@ static void read_line(void)
|
|||||||
ev = terminal_getkey();
|
ev = terminal_getkey();
|
||||||
if (ev.c == '\n')
|
if (ev.c == '\n')
|
||||||
break;
|
break;
|
||||||
char *buf = screen->line;
|
|
||||||
i = strlen(screen->line);
|
|
||||||
const size_t size = sizeof(screen->line);
|
|
||||||
if (prev_scan_code != ev.scan_code && ev.scan_code) {
|
if (prev_scan_code != ev.scan_code && ev.scan_code) {
|
||||||
if (ev.scan_code == KEY_BACKSPACE && i) {
|
if (ev.scan_code == KEY_BACKSPACE && i) {
|
||||||
buf[--i] = '\0';
|
buf[--i] = '\0';
|
||||||
@ -70,14 +67,14 @@ static void read_line(void)
|
|||||||
prev_scan_code = ev.scan_code;
|
prev_scan_code = ev.scan_code;
|
||||||
}
|
}
|
||||||
kprintf(0, "\n");
|
kprintf(0, "\n");
|
||||||
screen->line[i] = '\0';
|
buf[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void shell_init(void)
|
void shell_init(void)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
kprintf(0, PROMPT);
|
kprintf(0, PROMPT);
|
||||||
read_line();
|
read_line(screen->line, sizeof(screen->line));
|
||||||
switch (find_command(screen->line)) {
|
switch (find_command(screen->line)) {
|
||||||
case HELP:
|
case HELP:
|
||||||
kprintf(0, "Welcome to bozOShell, the shell of "
|
kprintf(0, "Welcome to bozOShell, the shell of "
|
||||||
@ -110,6 +107,5 @@ void shell_init(void)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(screen->line, '\0', sizeof(screen->line));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "ctype.h"
|
#include "ctype.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
#include "shell.h"
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "sys/io.h"
|
#include "sys/io.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
@ -45,8 +44,6 @@ void terminal_set_screen(int pos)
|
|||||||
screen = &screens[pos];
|
screen = &screens[pos];
|
||||||
memcpy(TERM_BUF, screen->buffer, sizeof(screen->buffer));
|
memcpy(TERM_BUF, screen->buffer, sizeof(screen->buffer));
|
||||||
update_cursor();
|
update_cursor();
|
||||||
if (TERM_BUF[0] == vga_entry(' ', VGA_COLOR_WHITE))
|
|
||||||
kprintf(0, PROMPT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void terminal_setcolor(uint8_t color)
|
void terminal_setcolor(uint8_t color)
|
||||||
|
Loading…
Reference in New Issue
Block a user