]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.c
removed detection of GL_NV_texture_shader extension which was previously used for...
[xonotic/darkplaces.git] / keys.c
diff --git a/keys.c b/keys.c
index 48d2da9904653e026bc1d4b87b6c2a8bc8ceda08..bec44c4c754e57eb15e3a075de325da4600b2746 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
+       // actually erase character
        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 = (int)strlen(key_lines[edit_line]);
                return;
        }
 
@@ -603,7 +641,7 @@ static void
 Key_In_Bind_f (void)
 {
        int         i, c, b, m;
-       char        cmd[1024];
+       char        cmd[MAX_INPUTLINE];
 
        c = Cmd_Argc ();
 
@@ -705,7 +743,7 @@ static void
 Key_Bind_f (void)
 {
        int         i, c, b;
-       char        cmd[1024];
+       char        cmd[MAX_INPUTLINE];
 
        c = Cmd_Argc ();
 
@@ -773,15 +811,25 @@ Key_Init (void)
 //
 // register our functions
 //
-       Cmd_AddCommand ("in_bind", Key_In_Bind_f);
-       Cmd_AddCommand ("in_unbind", Key_In_Unbind_f);
-       Cmd_AddCommand ("in_bindmap", Key_In_Bindmap_f);
+       Cmd_AddCommand ("in_bind", Key_In_Bind_f, "binds a command to the specified key in the selected bindmap");
+       Cmd_AddCommand ("in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap");
+       Cmd_AddCommand ("in_bindmap", Key_In_Bindmap_f, "selects active foreground and background (used only if a key is not bound in the foreground) bindmaps for typing");
 
-       Cmd_AddCommand ("bind", Key_Bind_f);
-       Cmd_AddCommand ("unbind", Key_Unbind_f);
-       Cmd_AddCommand ("unbindall", Key_Unbindall_f);
+       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)");
+}
+
+const char *Key_GetBind (int key)
+{
+       const char *bind;
+       bind = keybindings[key_bmap][key];
+       if (!bind)
+               bind = keybindings[key_bmap2][key];
+       return bind;
 }
 
+qboolean CL_VM_InputEvent (qboolean pressed, int key);
 
 /*
 ===================
@@ -793,12 +841,26 @@ void
 Key_Event (int key, char ascii, qboolean down)
 {
        const char *bind;
+       qboolean q;
 
        // get key binding
        bind = keybindings[key_bmap][key];
        if (!bind)
                bind = keybindings[key_bmap2][key];
 
+       if(key_dest == key_game)
+       {
+               q = CL_VM_InputEvent(!down, key);
+               if(q)
+               {
+                       if (down)
+                               keydown[key] = min(keydown[key] + 1, 2);
+                       else
+                               keydown[key] = 0;
+                       return;
+               }
+       }
+
        if (!down)
        {
                // clear repeat count now that the key is released
@@ -858,10 +920,7 @@ Key_Event (int key, char ascii, qboolean down)
                                MR_ToggleMenu_f ();
                                break;
                        default:
-                               if(UI_Callback_IsSlotUsed(key_dest - 3))
-                                       UI_Callback_KeyDown (key, ascii);
-                               else
-                                       Con_Printf ("Key_Event: Bad key_dest\n");
+                               Con_Printf ("Key_Event: Bad key_dest\n");
                }
                return;
        }
@@ -923,10 +982,7 @@ Key_Event (int key, char ascii, qboolean down)
                        }
                        break;
                default:
-                       if(UI_Callback_IsSlotUsed(key_dest - 3))
-                               UI_Callback_KeyDown (key, ascii);
-                       else
-                               Con_Printf ("Key_Event: Bad key_dest\n");
+                       Con_Printf ("Key_Event: Bad key_dest\n");
        }
 }