修复shell无法正确获取输入问题

This commit is contained in:
XIAOYI12 2024-09-08 10:37:13 +08:00
parent 0d5299a94f
commit 33f618631a
5 changed files with 23 additions and 8 deletions

View File

@ -5,12 +5,21 @@
extern void print_info();
int shell_getc(){
char c;
do{
c = syscall_getch();
if(c == '\b' || c == '\n') break;
} while (!isprint(c));
return c;
}
static int gets(char *buf) {
int index = 0;
char c;
while ((c = syscall_getch()) != '\n') {
while ((c = shell_getc()) != '\n') {
if (c == '\b') {
if (index > 0) {
index--;

View File

@ -163,9 +163,9 @@ void kernel_main(multiboot_t *multiboot) {
clock_sleep(25);
vfs_change_path("apps");
klogf(user_process("init.bin","InitService") != -1,"Init service process init.\n");
// int pid = user_process("shell.bin","UserShell");
//kernel_thread(check_task_usershell,&pid,"CTU");
// klogf(user_process("init.bin","InitService") != -1,"Init service process init.\n");
int pid = user_process("shell.bin","UserShell");
kernel_thread(check_task_usershell,&pid,"CTU");
// int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
// klogf(pid != -1,"Launch kernel shell.\n");

View File

@ -394,7 +394,7 @@ void init_default_tty(struct task_struct *task){
task->tty->is_using = true;
task->tty->print = tty_print;
task->tty->clear = clear_TextMode;
task->tty->putchar = putchar_TextMode;
task->tty->putchar = vbe_putchar;
task->tty->gotoxy = tty_gotoxy;
task->tty->screen_ne = screen_ne_TextMode;
task->tty->vram = screen;

View File

@ -14,8 +14,16 @@ extern Queue *key_char_queue;
extern vdisk vdisk_ctl[10];
extern bool hasFS;
static inline int isprint_syshell(int c) {
return (c > 0x1F && c < 0x7F);
}
char getc() {
char c = kernel_getch();
char c;
do{
c = kernel_getch();
if(c == '\b' || c == '\n') break;
} while (!isprint_syshell(c));
return c;
}

View File

@ -338,8 +338,6 @@ void print(char *message) {
return;
}
logk(message);
if(vbe_status){
vbe_writestring(message);
} else vga_writestring(message);