]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added console editing enhancements patch from [515], except the part for special...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 12 Jan 2006 15:17:12 +0000 (15:17 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 12 Jan 2006 15:17:12 +0000 (15:17 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5901 d7cf8633-e32d-0410-b094-e92efae38249

keys.c

diff --git a/keys.c b/keys.c
index b908343918ffcc5929b5a49b86e4d0c1bbd4f98a..0be40b504eca3a2044d908a25b7f73147b6fbc9e 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -326,12 +326,29 @@ Key_Console (int key, char ascii)
 
        // Advanced Console Editing by Radix radix@planetquake.com
        // Added/Modified by EvilTypeGuy eviltypeguy@qeradiant.com
+       // Enhanced by [515]
 
        // left arrow will just move left one without erasing, backspace will
        // actually erase charcter
        if (key == K_LEFTARROW || key == K_KP_LEFTARROW)
        {
-               if (key_linepos > 1)
+               if (key_linepos < 2)
+                       return;
+               if(keydown[K_CTRL])
+               {
+                       int             pos;
+                       char    k;
+                       pos = key_linepos-1;
+                       if(pos)
+                               while(--pos)
+                               {
+                                       k = key_lines[edit_line][pos];
+                                       if(k == '\"' || k == ';' || k == ' ' || k == '\'')
+                                               break;
+                               }
+                       key_linepos = pos + 1;
+               }
+               else
                        key_linepos--;
                return;
        }
@@ -360,9 +377,24 @@ Key_Console (int key, char ascii)
        // otherwise just go right one
        if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW)
        {
-               if (key_linepos < (int)strlen(key_lines[edit_line]))
+               if (key_linepos >= (int)strlen(key_lines[edit_line]))
+                       return;
+               if(keydown[K_CTRL])
+               {
+                       int             pos, len;
+                       char    k;
+                       len = (int)strlen(key_lines[edit_line]);
+                       pos = key_linepos;
+                       while(++pos < len)
+                       {
+                               k = key_lines[edit_line][pos];
+                               if(k == '\"' || k == ';' || k == ' ' || k == '\'')
+                                       break;
+                       }
+                       key_linepos = pos;
+               }
+               else
                        key_linepos++;
-
                return;
        }
 
@@ -421,13 +453,19 @@ Key_Console (int key, char ascii)
 
        if (key == K_HOME || key == K_KP_HOME)
        {
-               con_backscroll = con_totallines - (vid_conheight.integer>>3) - 1;
+               if (keydown[K_CTRL])
+                       con_backscroll = con_totallines - (vid_conheight.integer>>3) - 1;
+               else
+                       key_linepos = 1;
                return;
        }
 
        if (key == K_END || key == K_KP_END)
        {
-               con_backscroll = 0;
+               if (keydown[K_CTRL])
+                       con_backscroll = 0;
+               else
+                       key_linepos = strlen(key_lines[edit_line]);
                return;
        }