Commit 0f3b8134c666d86bad6847e00fed1f439fffbf24

antirez 2013-02-06T12:41:15

Escapes dispatching better documented.

diff --git a/linenoise.c b/linenoise.c
index 8bd610e..29555b0 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -539,19 +539,25 @@ static int linenoiseEdit(int fd, char *buf, size_t buflen, const char *prompt)
             linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_NEXT);
             break;
         case 27:    /* escape sequence */
+            /* Read the next two bytes representing the escape sequence. */
             if (read(fd,seq,2) == -1) break;
+
             if (seq[0] == 91 && seq[1] == 68) {
+                /* Left arrow */
                 linenoiseEditMoveLeft(&l);
             } else if (seq[0] == 91 && seq[1] == 67) {
+                /* Right arrow */
                 linenoiseEditMoveRight(&l);
             } else if (seq[0] == 91 && (seq[1] == 65 || seq[1] == 66)) {
+                /* Up and Down arrows */
                 linenoiseEditHistoryNext(&l,
                     (seq[1] == 65) ? LINENOISE_HISTORY_PREV :
                                      LINENOISE_HISTORY_NEXT);
             } else if (seq[0] == 91 && seq[1] > 48 && seq[1] < 55) {
-                /* extended escape */
+                /* extended escape, read additional two bytes. */
                 if (read(fd,seq2,2) == -1) break;
                 if (seq[1] == 51 && seq2[0] == 126) {
+                    /* Delete key. */
                     linenoiseEditDelete(&l);
                 }
             }