From 403c86b9fefc5299ddefb82e749bb8a5d17a394f Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 24 May 2009 19:32:10 +0000 Subject: [PATCH] line editing: new binds ctrl-q (push line to history) and ctrl-u (delete line), similar to zsh git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8985 d7cf8633-e32d-0410-b094-e92efae38249 --- keys.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/keys.c b/keys.c index bfe77d26..a4f4abe9 100644 --- a/keys.c +++ b/keys.c @@ -392,7 +392,7 @@ Key_Console (int key, int ascii) break; } - if ((toupper(key) == 'V' && keydown[K_CTRL]) || ((key == K_INS || key == K_KP_INS) && keydown[K_SHIFT])) + if (key == 'v' && keydown[K_CTRL]) || ((key == K_INS || key == K_KP_INS) && keydown[K_SHIFT])) { char *cbd, *p; if ((cbd = Sys_GetClipboardData()) != 0) @@ -435,13 +435,29 @@ Key_Console (int key, int ascii) return; } - if (key == 'l') + if (key == 'l' && keydown[K_CTRL]) { - if (keydown[K_CTRL]) - { - Cbuf_AddText ("clear\n"); - return; - } + Cbuf_AddText ("clear\n"); + return; + } + + if (key == 'u' && keydown[K_CTRL]) // like vi/readline ^u: delete currently edited line + { + // clear line + key_line[0] = ']'; + key_line[1] = 0; + key_linepos = 1; + return; + } + + if (key == 'q' && keydown[K_CTRL]) // like zsh ^q: push line to history, don't execute, and clear + { + // clear line + Key_History_Push(); + key_line[0] = ']'; + key_line[1] = 0; + key_linepos = 1; + return; } if (key == K_ENTER || key == K_KP_ENTER) -- 2.39.2