From c51aebf621ad884b197e15bd30e81afe6ca1c0a0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 16 Oct 2012 19:03:29 -0400 Subject: [PATCH] FS-4694 --resolve --- libs/esl/fs_cli.c | 20 ++++++++++++++++++++ src/switch_console.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 80388db3a4..d85f176d6f 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -39,6 +39,7 @@ #define KEY_RIGHT 7 #define KEY_INSERT 8 #define PROMPT_OP 9 +#define KEY_DELETE 10 static int console_bufferInput (char *buf, int len, char *cmd, int key); static unsigned char esl_console_complete(const char *buffer, const char *cursor, const char *lastchar); #endif @@ -318,6 +319,22 @@ static int console_bufferInput (char *addchars, int len, char *cmd, int key) if (key == KEY_INSERT) { insertMode = !insertMode; } + if (key == KEY_DELETE) { + if (iCmdCursor < iCmdBuffer) { + int pos; + for (pos = iCmdCursor; pos < iCmdBuffer; pos++) { + cmd[pos] = cmd[pos + 1]; + } + cmd[pos] = 0; + iCmdBuffer--; + + for (pos = iCmdCursor; pos < iCmdBuffer; pos++) { + printf("%c", cmd[pos]); + } + printf(" "); + SetConsoleCursorPosition(hOut, position); + } + } for (iBuf = 0; iBuf < len; iBuf++) { switch (addchars[iBuf]) { case '\r': @@ -510,6 +527,9 @@ static BOOL console_readConsole(HANDLE conIn, char *buf, int len, int *pRed, int if (keyEvent.wVirtualKeyCode == 45 && keyEvent.wVirtualScanCode == 82) { *key = KEY_INSERT; } + if (keyEvent.wVirtualKeyCode == 46 && keyEvent.wVirtualScanCode == 83) { + *key = KEY_DELETE; + } while (keyEvent.wRepeatCount && keyEvent.uChar.AsciiChar) { buf[bufferIndex] = keyEvent.uChar.AsciiChar; if (buf[bufferIndex] == '\r') { diff --git a/src/switch_console.c b/src/switch_console.c index c84b823695..3958cf98fc 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -67,6 +67,7 @@ static char *hfile = NULL; #define KEY_RIGHT 7 #define KEY_INSERT 8 #define PROMPT_OP 9 +#define KEY_DELETE 10 static int console_bufferInput(char *buf, int len, char *cmd, int key); #endif @@ -1285,6 +1286,22 @@ static int console_bufferInput(char *addchars, int len, char *cmd, int key) if (key == KEY_INSERT) { insertMode = !insertMode; } + if (key == KEY_DELETE) { + if (iCmdCursor < iCmdBuffer) { + int pos; + for (pos = iCmdCursor; pos < iCmdBuffer; pos++) { + cmd[pos] = cmd[pos + 1]; + } + cmd[pos] = 0; + iCmdBuffer--; + + for (pos = iCmdCursor; pos < iCmdBuffer; pos++) { + printf("%c", cmd[pos]); + } + printf(" "); + SetConsoleCursorPosition(hOut, position); + } + } for (iBuf = 0; iBuf < len; iBuf++) { switch (addchars[iBuf]) { case '\r': @@ -1476,6 +1493,9 @@ static BOOL console_readConsole(HANDLE conIn, char *buf, int len, int *pRed, int if (keyEvent.wVirtualKeyCode == 45 && keyEvent.wVirtualScanCode == 82) { *key = KEY_INSERT; } + if (keyEvent.wVirtualKeyCode == 46 && keyEvent.wVirtualScanCode == 83) { + *key = KEY_DELETE; + } while (keyEvent.wRepeatCount && keyEvent.uChar.AsciiChar) { buf[bufferIndex] = keyEvent.uChar.AsciiChar; if (buf[bufferIndex] == '\r') {