]> git.lizzy.rs Git - linenoise.git/commitdiff
ctrl-t implemented
authorantirez <antirez@gmail.com>
Mon, 22 Mar 2010 18:54:24 +0000 (19:54 +0100)
committerantirez <antirez@gmail.com>
Mon, 22 Mar 2010 18:54:24 +0000 (19:54 +0100)
linenoise.c

index 8267ce55ce2527088082db160922063139ffc31a..5950d493b4af80bc1ccc695cc04133b851bac46b 100644 (file)
@@ -225,6 +225,15 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
                 refreshLine(fd,prompt,buf,len,pos,cols);
             }
             break;
+        case 20:    /* ctrl-t */
+            if (pos > 0 && pos < len) {
+                int aux = buf[pos-1];
+                buf[pos-1] = buf[pos];
+                buf[pos] = aux;
+                if (pos != len-1) pos++;
+                refreshLine(fd,prompt,buf,len,pos,cols);
+            }
+            break;
         case 2:     /* ctrl-b */
             goto left_arrow;
         case 6:     /* ctrl-f */