From: havoc Date: Mon, 14 Aug 2006 22:51:43 +0000 (+0000) Subject: patch from div0: X-Git-Tag: xonotic-v0.1.0preview~3834 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=c6d75888024a184badb49fb12261c47db35cc4b7;p=xonotic%2Fdarkplaces.git patch from div0: fix console weirdnesses: * empty lines kill command history (instead don't add empty lines to the history) * cursor position and history line length were done the wrong way, positioning the cursor outside of the line or only recalling part of a line NOTE: maybe it is better to move the Con_Printf BELOW the return so an empty prompt isn't even displayed? bash does not do it like that, IRC clients do it like that, and personally I don't care git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6552 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/keys.c b/keys.c index 0f40462a..eefb0e68 100644 --- a/keys.c +++ b/keys.c @@ -302,6 +302,8 @@ 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 [)? + return; // no, no, you can't submit empty lines to the history... // LordHavoc: redesigned edit_line/history_line edit_line = 31; history_line = edit_line; @@ -414,7 +416,7 @@ Key_Console (int key, char ascii) { size_t linelen; history_line--; - linelen = strlen(key_lines[edit_line]); + linelen = strlen(key_lines[history_line]); memcpy(key_lines[edit_line], key_lines[history_line], linelen + 1); key_linepos = (int)linelen; } @@ -434,7 +436,7 @@ Key_Console (int key, char ascii) else { size_t linelen; - linelen = strlen(key_lines[edit_line]); + linelen = strlen(key_lines[history_line]); memcpy(key_lines[edit_line], key_lines[history_line], linelen + 1); key_linepos = (int)linelen; }