From 73bbf0d63853d87e00c95df9e9293eb8dad15c5b Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Thu, 19 Mar 2009 19:01:43 +0100 Subject: [PATCH] hdt: ctrl+a or HOME key return to the beginning of line Impact: Users can now uses ctrl+a or HOME to return at the beginning of a line Ctrl+a or home key is now implemented --- com32/hdt/hdt-cli.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 5f25b4c..9527476 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -352,6 +352,7 @@ void start_cli_mode(struct s_hardware *hardware) { struct s_cli cli; int current_key = 0; + char ansi_command[MAX_LINE_SIZE]; set_mode(&cli, HDT_MODE, hardware); printf("Entering CLI mode\n"); @@ -362,12 +363,21 @@ void start_cli_mode(struct s_hardware *hardware) //fgets(cli_line, sizeof cli_line, stdin); current_key = get_key(stdin, 0); switch (current_key) { + /* quit current line */ case KEY_CTRL('c'): more_printf("\n"); reset_prompt(&cli); break; case KEY_TAB: break; + /* Returning at the begining of the line*/ + case KEY_CTRL('a'): + case KEY_HOME: + sprintf(ansi_command,"\033[%dD",cli.cursor_pos); + /* Return to the begining of line */ + fputs(ansi_command, stdout); + cli.cursor_pos=0; + break; case KEY_ENTER: more_printf("\n"); exec_command(skipspace(cli.input), &cli, hardware); @@ -378,7 +388,7 @@ void start_cli_mode(struct s_hardware *hardware) if (cli.cursor_pos == 0) break; - /* Return to the begining of line */ + /* Return one char back */ fputs("\033[1D", stdout); /* Erase that char */ -- 2.7.4