Commit 9c21ea236fd3cb5391fcf53335ae6895fc98640d

antirez 2010-03-22T19:54:24

ctrl-t implemented

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/linenoise.c b/linenoise.c
index 8267ce5..5950d49 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -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 */