]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
rewrote character insertion/replacement in console commandline, fixing all known...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 May 2005 10:31:05 +0000 (10:31 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 May 2005 10:31:05 +0000 (10:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5359 d7cf8633-e32d-0410-b094-e92efae38249

keys.c

diff --git a/keys.c b/keys.c
index 74ef648a291ef2ca284ed815a695f146e44a2572..ea86917733f75a11f129af4a9de4dce75a96f3ff 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -446,27 +446,17 @@ Key_Console (int key, char ascii)
 
        if (key_linepos < MAX_INPUTLINE-1)
        {
-               int i;
-
-               if (key_insert) // check insert mode
+               int len;
+               len = strlen(&key_lines[edit_line][key_linepos]);
+               // check insert mode, or always insert if at end of line
+               if (key_insert || len == 0)
                {
-                       // can't do strcpy to move string to right
-                       i = strlen(key_lines[edit_line]) - 1;
-
-                       if (i == 254)
-                               i--;
-
-                       for (; i >= key_linepos; i--)
-                               key_lines[edit_line][i + 1] = key_lines[edit_line][i];
+                       // can't use strcpy to move string to right
+                       len++;
+                       memmove(&key_lines[edit_line][key_linepos + 1], &key_lines[edit_line][key_linepos], len);
                }
-
-               // only null terminate if at the end
-               i = key_lines[edit_line][key_linepos];
                key_lines[edit_line][key_linepos] = ascii;
                key_linepos++;
-
-               if (!i)
-                       key_lines[edit_line][key_linepos] = 0;
        }
 }