Skip to content

Commit

Permalink
Some more work on #118
Browse files Browse the repository at this point in the history
  • Loading branch information
double-fault committed Jan 20, 2017
1 parent 5b7c16d commit 608af44
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 29 deletions.
3 changes: 2 additions & 1 deletion apps/sh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand Down
1 change: 1 addition & 0 deletions bin/boneshell/boneshell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
72 changes: 50 additions & 22 deletions bin/help/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,67 @@
#include <drv/video/video.h>
#include <unistd/unistd.h>
#include <stdio/stdio.h>
#include <string/string.h>
#include <help/opts/help_cmd_opt.h>
#include <help/opts/main_help.h>

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 \"<cmd_name> --help\" for more help on that command\n");
printk("or \"help -cmd <cmd_name>\"\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 \"<cmd_name> --help\" for more help on that command\n");
printk("or \"help -cmd <cmd_name>\"\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 <cmd_name>] [--help]",
.help = "help(1) \t\t\t\t BoneOS Terminal Manual \n"
.name = "help",
.usage ="help [-cmd <cmd_name>] [--help]",
.help = "help(1) \t\t\t\t BoneOS Terminal Manual \n"
"NAME : \n "
"\thelp\n"
"SYNOPSIS : \n "
Expand All @@ -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
};
1 change: 1 addition & 0 deletions include/apps/sh/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_*/
Expand Down
26 changes: 20 additions & 6 deletions platform/pc/drv/ps2/kbd/kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ++;
}
}

/*
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 608af44

Please sign in to comment.