From 378677b3caeb9e347b9b384104736b3695b36b83 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 1 Dec 2006 01:40:16 +0000 Subject: [PATCH] added con_closeontoggleconsole cvar based on Dresk's patch, but reduced to a minimal set of changes to one file rather than two git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6629 d7cf8633-e32d-0410-b094-e92efae38249 --- keys.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/keys.c b/keys.c index eefb0e68..7ef45f1d 100644 --- a/keys.c +++ b/keys.c @@ -23,6 +23,8 @@ #include "quakedef.h" #include "cl_video.h" +cvar_t con_closeontoggleconsole = {CVAR_SAVE, "con_closeontoggleconsole","0", "allows toggleconsole binds to close the console as well"}; + /* key up events are sent even if in console mode */ @@ -302,7 +304,7 @@ Key_Console (int key, char ascii) Cbuf_AddText (key_lines[edit_line]+1); // skip the ] Cbuf_AddText ("\n"); Con_Printf("%s\n",key_lines[edit_line]); - if(key_lines[edit_line][1] == 0) // empty line (just a [)? + if(key_lines[edit_line][1] == 0) // empty line (just a ])? return; // no, no, you can't submit empty lines to the history... // LordHavoc: redesigned edit_line/history_line edit_line = 31; @@ -826,6 +828,8 @@ Key_Init (void) Cmd_AddCommand ("bind", Key_Bind_f, "binds a command to the specified key in bindmap 0"); Cmd_AddCommand ("unbind", Key_Unbind_f, "removes a command on the specified key in bindmap 0"); Cmd_AddCommand ("unbindall", Key_Unbindall_f, "removes all commands from all keys in all bindmaps (leaving only shift-escape and escape)"); + + Cvar_RegisterVariable (&con_closeontoggleconsole); } const char *Key_GetBind (int key) @@ -959,13 +963,13 @@ Key_Event (int key, char ascii, qboolean down) return; } -#if 1 +#if 0 // ignore binds (other than the above escape/F1-F12 keys) while in console if (key_consoleactive && down) #else // respond to toggleconsole binds while in console unless the pressed key // happens to be the color prefix character (such as on German keyboards) - if (key_consoleactive && down && (strncmp(bind, "toggleconsole", strlen("toggleconsole")) || ascii == STRING_COLOR_TAG)) + if (key_consoleactive && down && (!con_closeontoggleconsole.integer || !bind || strncmp(bind, "toggleconsole", strlen("toggleconsole")) || ascii == STRING_COLOR_TAG)) #endif { Key_Console (key, ascii); -- 2.39.2