Code

wreadln: adding additional line editing binds
authorJ. Alexander Treuman <jat@spatialrift.net>
Sun, 21 Sep 2008 19:37:42 +0000 (21:37 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 21 Sep 2008 19:37:42 +0000 (21:37 +0200)
Adding some GNU readline-style binds.  These are ^B/^F to move the cursor
back/forward, and ^N/^P to go to the next/previous line.

src/wreadln.c

index ed8ad9a390230bd861ba8597296c7ba5bd83f557..dc1dfe86708f629d8eeb80bff240e03df6c20b86 100644 (file)
 #endif
 
 #define KEY_CTRL_A   1
+#define KEY_CTRL_B   2
 #define KEY_CTRL_C   3
-#define KEY_CTRL_D   4 
+#define KEY_CTRL_D   4
 #define KEY_CTRL_E   5
+#define KEY_CTRL_F   6
 #define KEY_CTRL_G   7
 #define KEY_CTRL_K   11
+#define KEY_CTRL_N   14
+#define KEY_CTRL_P   16
 #define KEY_CTRL_U   21
 #define KEY_CTRL_Z   26
 #define KEY_BCKSPC   8
@@ -251,9 +255,11 @@ _wreadln(WINDOW *w,
                        return NULL;
 
                case KEY_LEFT:
+               case KEY_CTRL_B:
                        cursor_move_left(&cursor, &start);
                        break;
                case KEY_RIGHT:
+               case KEY_CTRL_F:
                        cursor_move_right(&cursor, &start, width, x0, x1, line);
                        break;
                case KEY_HOME:
@@ -291,6 +297,7 @@ _wreadln(WINDOW *w,
                        }
                        break;
                case KEY_UP:
+               case KEY_CTRL_P:
                        /* get previous history entry */
                        if( history && hlist->prev ) {
                                if( hlist==hcurrent )
@@ -305,6 +312,7 @@ _wreadln(WINDOW *w,
                        cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
                        break;
                case KEY_DOWN:
+               case KEY_CTRL_N:
                        /* get next history entry */
                        if( history && hlist->next ) {
                                /* get next line */