X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=keys.c;h=deeb06674d67033b57a344e6ebdba320dc3025aa;hb=5e5a0dc6a799dea2883254396414e6c3817f862f;hp=45d2daf85fdab1581b224cacd6c85eb0aac981d6;hpb=9a69ea042cd1455e635febc7f4af634ac2a90730;p=xonotic%2Fdarkplaces.git diff --git a/keys.c b/keys.c index 45d2daf8..deeb0667 100644 --- a/keys.c +++ b/keys.c @@ -743,7 +743,8 @@ Key_Console (int key, int unicode) } else if (*p == '\n' || *p == '\r' || *p == '\b') *p++ = ';'; - p++; + else + p++; } #else strtok(cbd, "\n\r\b"); @@ -753,21 +754,6 @@ Key_Console (int key, int unicode) i= MAX_INPUTLINE - key_linepos - 1; if (i > 0) { - // terencehill: insert the clipboard text between the characters of the line - /* - char *temp = (char *) Z_Malloc(MAX_INPUTLINE); - cbd[i]=0; - temp[0]=0; - if ( key_linepos < (int)strlen(key_line) ) - strlcpy(temp, key_line + key_linepos, (int)strlen(key_line) - key_linepos +1); - key_line[key_linepos] = 0; - strlcat(key_line, cbd, sizeof(key_line)); - if (temp[0]) - strlcat(key_line, temp, sizeof(key_line)); - Z_Free(temp); - key_linepos += i; - */ - // blub: I'm changing this to use memmove() like the rest of the code does. cbd[i] = 0; memmove(key_line + key_linepos + i, key_line + key_linepos, sizeof(key_line) - key_linepos - i); memcpy(key_line + key_linepos, cbd, i); @@ -1050,7 +1036,6 @@ Key_Console (int key, int unicode) Key_History_Down(); return; } - // ~1.0795 = 82/76 using con_textsize 64 76 is height of the char, 6 is the distance between 2 lines if (keydown[K_CTRL]) { @@ -1186,16 +1171,21 @@ Key_Console (int key, int unicode) // check insert mode, or always insert if at end of line if (key_insert || len == 0) { + if (key_linepos + len + blen >= MAX_INPUTLINE) + return; // can't use strcpy to move string to right len++; - //memmove(&key_line[key_linepos + u8_bytelen(key_line + key_linepos, 1)], &key_line[key_linepos], len); + if (key_linepos + blen + len >= MAX_INPUTLINE) + return; memmove(&key_line[key_linepos + blen], &key_line[key_linepos], len); } + else if (key_linepos + len + blen - u8_bytelen(key_line + key_linepos, 1) >= MAX_INPUTLINE) + return; memcpy(key_line + key_linepos, buf, blen); + if (blen > len) + key_line[key_linepos + blen] = 0; + // END OF FIXME key_linepos += blen; - //key_linepos += u8_fromchar(unicode, key_line + key_linepos, sizeof(key_line) - key_linepos - 1); - //key_line[key_linepos] = ascii; - //key_linepos++; } } @@ -1209,7 +1199,7 @@ static void Key_Message (int key, int ascii) { char vabuf[1024]; - if (key == K_ENTER || ascii == 10 || ascii == 13) + if (key == K_ENTER || key == K_KP_ENTER || ascii == 10 || ascii == 13) { if(chat_mode < 0) Cmd_ExecuteString(chat_buffer, src_command, true); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases! @@ -1637,6 +1627,7 @@ Key_Init (void) Cmd_AddCommand ("in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap"); Cmd_AddCommand ("in_bindlist", Key_In_BindList_f, "bindlist: displays bound keys for all bindmaps, or the given 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 ("in_releaseall", Key_ReleaseAll, "releases all currently pressed keys (debug command)"); 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"); @@ -1766,11 +1757,6 @@ Key_Event (int key, int ascii, qboolean down) return; } - if (ascii == 0x80 && utf8_enable.integer) // pressing AltGr-5 (or AltGr-e) and for some reason we get windows-1252 encoding? - ascii = 0x20AC; // we want the Euro currency sign - // TODO find out which vid_ drivers do it and fix it there - // but catching U+0080 here is no loss as that char is not useful anyway - // get key binding bind = keybindings[key_bmap][key]; if (!bind) @@ -1781,7 +1767,7 @@ Key_Event (int key, int ascii, qboolean down) if(key_consoleactive) keydest = key_console; - + if (down) { // increment key repeat count each time a down is received so that things @@ -1805,7 +1791,7 @@ Key_Event (int key, int ascii, qboolean down) if(keydest == key_void) return; - + // key_consoleactive is a flag not a key_dest because the console is a // high priority overlay ontop of the normal screen (designed as a safety // feature so that developers and users can rescue themselves from a bad @@ -1933,7 +1919,7 @@ Key_Event (int key, int ascii, qboolean down) { if (down && con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && ascii != STRING_COLOR_TAG) { - Con_ToggleConsole_f (); + Cbuf_AddText("toggleconsole\n"); // Deferred to next frame so we're not sending the text event to the console. tbl_keydest[key] = key_void; // key release should go nowhere (especially not to key_menu or key_game) return; } @@ -2005,14 +1991,3 @@ Key_ReleaseAll (void) // now all keys are guaranteed down (once the event queue is unblocked) // and only future events count } - -/* -=================== -Key_ClearStates -=================== -*/ -void -Key_ClearStates (void) -{ - memset(keydown, 0, sizeof(keydown)); -}