修复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(); 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) { static int gets(char *buf) {
int index = 0; int index = 0;
char c; char c;
while ((c = syscall_getch()) != '\n') { while ((c = shell_getc()) != '\n') {
if (c == '\b') { if (c == '\b') {
if (index > 0) { if (index > 0) {
index--; index--;

View File

@ -163,9 +163,9 @@ void kernel_main(multiboot_t *multiboot) {
clock_sleep(25); clock_sleep(25);
vfs_change_path("apps"); vfs_change_path("apps");
klogf(user_process("init.bin","InitService") != -1,"Init service process init.\n"); // klogf(user_process("init.bin","InitService") != -1,"Init service process init.\n");
// int pid = user_process("shell.bin","UserShell"); int pid = user_process("shell.bin","UserShell");
//kernel_thread(check_task_usershell,&pid,"CTU"); kernel_thread(check_task_usershell,&pid,"CTU");
// int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell"); // int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
// klogf(pid != -1,"Launch kernel shell.\n"); // 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->is_using = true;
task->tty->print = tty_print; task->tty->print = tty_print;
task->tty->clear = clear_TextMode; task->tty->clear = clear_TextMode;
task->tty->putchar = putchar_TextMode; task->tty->putchar = vbe_putchar;
task->tty->gotoxy = tty_gotoxy; task->tty->gotoxy = tty_gotoxy;
task->tty->screen_ne = screen_ne_TextMode; task->tty->screen_ne = screen_ne_TextMode;
task->tty->vram = screen; task->tty->vram = screen;

View File

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

View File

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