diff --git a/apps/sh/shell.c b/apps/sh/shell.c index 8a2904d..ea793fd 100644 --- a/apps/sh/shell.c +++ b/apps/sh/shell.c @@ -58,7 +58,8 @@ volatile uint32_t cmd_active_index = 0; volatile uint32_t shell_instance_cnt = 0; volatile struct typed_cmd cmd_active; -int virtual_cursor_pos = 0; +int virtual_cursor_pos = 0; +int virtual_index_scank = 0; rtc_t start_time; struct cmd_t *cmds[] = diff --git a/bin/boneshell/boneshell.c b/bin/boneshell/boneshell.c index 52ff9a5..ce97d0f 100644 --- a/bin/boneshell/boneshell.c +++ b/bin/boneshell/boneshell.c @@ -99,6 +99,7 @@ void loop_terminal() video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg = BG__; virtual_cursor_pos = 0; + virtual_index_scank = 0; scank(true,true, "%s" , cmd_active.value); diff --git a/bin/help/help.c b/bin/help/help.c index 94181c3..f719726 100644 --- a/bin/help/help.c +++ b/bin/help/help.c @@ -26,39 +26,67 @@ #include #include #include +#include #include #include struct cmd_opt_t* cmd_help_opts[] = { - &cmd_help_opt_cmd - ,0 + &cmd_help_opt_cmd + ,0 }; int cmd_help_handler(char* cmd) { - size_t num_opts = get_opt_count(cmd); - if(num_opts == 1) - { - printk("BoneOS Shell. Type in \" --help\" for more help on that command\n"); - printk("or \"help -cmd \"\n\n"); - printk("Commands\n"); - printk("--------\n"); - for(int i=0; cmds[i]; i+=3) - printk("%d : %s \t %d : %s \t %d : %s ]\n",i,cmds[i]->name,(i+1),cmds[i+1]->name,(i+2), cmds[i+2]->name); - return STATUS_OK; - } + size_t num_opts = get_opt_count(cmd); + if(num_opts == 1) + { + printk("BoneOS Shell. Type in \" --help\" for more help on that command\n"); + printk("or \"help -cmd \"\n\n"); + printk("Commands\n"); + printk("--------\n"); + /*for(int i=0; cmds[i]; i+=3) + printk("%d : %s \t %d : %s \t %d : %s ]\n",i,cmds[i]->name,(i+1),cmds[i+1]->name,(i+2), cmds[i+2]->name);*/ - main_help_opt_handler(cmd); + char to_print [128]; + to_print [0] = '\0'; + char main_print [512]; + int max_length = 20; + int len = 0; - return STATUS_OK; + for (int i = 0; cmds [i]; i+=3) + { + sprintk (to_print, "%d %s\n", i, cmds [i]->name); + printk ("%s\n", to_print); + len = strlen (to_print); + printk ("len = %d\n", len); + for (int j = 0; j < max_length; j ++) + { + if (j >= len) + { + sprintk (main_print, " "); + } + else if (j < len) + { + sprintk (main_print, "%c", to_print [j]); + } + } + printk ("%s\n", main_print); + } + + return STATUS_OK; + } + + main_help_opt_handler(cmd); + + return STATUS_OK; } struct cmd_t cmd_help = { - .name = "help", - .usage ="help [-cmd ] [--help]", - .help = "help(1) \t\t\t\t BoneOS Terminal Manual \n" + .name = "help", + .usage ="help [-cmd ] [--help]", + .help = "help(1) \t\t\t\t BoneOS Terminal Manual \n" "NAME : \n " "\thelp\n" "SYNOPSIS : \n " @@ -69,9 +97,9 @@ struct cmd_t cmd_help = "\tfor that command.\n" "MORE HELP : \n " "\t[help -cmd --help] for help on -cmd option\n", - .cmd_opts = cmd_help_opts, - .handler = &cmd_help_handler, - .invalid_use_msg = "Invalid use of help command.\n" + .cmd_opts = cmd_help_opts, + .handler = &cmd_help_handler, + .invalid_use_msg = "Invalid use of help command.\n" "Type in help --help for more help.\n", - .privilege = USER + .privilege = USER }; diff --git a/include/apps/sh/shell.h b/include/apps/sh/shell.h index 43ca6fa..37a7b7e 100644 --- a/include/apps/sh/shell.h +++ b/include/apps/sh/shell.h @@ -64,6 +64,7 @@ extern volatile bool tab_one_opt; extern volatile bool tab_zero_opt; volatile uint32_t shell_instance_cnt; extern int virtual_cursor_pos; +extern int virtual_index_scank; extern rtc_t start_time; #endif /*_APPS_TERM_TERMINAL_H_*/ diff --git a/platform/pc/drv/ps2/kbd/kbd.c b/platform/pc/drv/ps2/kbd/kbd.c index cab331d..86f844e 100644 --- a/platform/pc/drv/ps2/kbd/kbd.c +++ b/platform/pc/drv/ps2/kbd/kbd.c @@ -155,9 +155,20 @@ void kbd_early_init() * until enter is pressed */ void wait_until_enter(char key) -{ - buffer_scank[index_scank++] = key; - buffer_scank[index_scank] = 0; +{ + if (index_scank == (unsigned)virtual_index_scank) + { + buffer_scank[index_scank++] = key; + buffer_scank[index_scank] = 0; + virtual_index_scank ++; + } + else if ((unsigned)virtual_index_scank < index_scank) + { + buffer_scank [index_scank] = buffer_scank [index_scank - virtual_cursor_pos]; + buffer_scank [index_scank - virtual_cursor_pos] = key; + buffer_scank [++index_scank] = 0; + virtual_index_scank ++; + } } /* @@ -273,8 +284,11 @@ void key_handler_util_backspace() { if(!((LENGTH_INPUT-1) < 0)) { - if(active_scank) - buffer_scank[index_scank--] = 0; + if(active_scank) + { + buffer_scank[index_scank--] = 0; + virtual_index_scank --; + } if(print_scank == true) printk("\b"); @@ -362,7 +376,7 @@ void key_handler() video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor (video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column - virtual_cursor_pos ,__crsr_start,__crsr_end); - index_scank --; + virtual_index_scank --; } break; case KBD_UP_KEY_ID: