]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4694 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 16 Oct 2012 23:03:29 +0000 (19:03 -0400)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 16 Oct 2012 23:03:29 +0000 (19:03 -0400)
libs/esl/fs_cli.c
src/switch_console.c

index 80388db3a4c1d1c829c133a6ecd15daa86fa95b1..d85f176d6f2b26f174987c791a1b3a9383fb398f 100644 (file)
@@ -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') {
index c84b823695d8df49b8486e121ec81931381d1060..3958cf98fc7ec175fd67877529badf5011f62a7a 100644 (file)
@@ -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') {