28cvar_t con_closeontoggleconsole = {
CF_CLIENT |
CF_ARCHIVE,
"con_closeontoggleconsole",
"1",
"allows toggleconsole binds to close the console as well; when set to 2, this even works when not at the start of the line in console input; when set to 3, this works even if the toggleconsole key is the color tag"};
68 if(c < 0 || c == 0 || c ==
'\r' || c ==
'\n')
97 qfile_t *historyfile =
FS_OpenRealFile(
"darkplaces_history.txt",
"w",
false);
102 Con_Print(
"Saving command history to darkplaces_history.txt ...\n");
119 if(strcmp(
key_line,
"]rcon_password"))
120 if(strncmp(
key_line,
"]rcon_password ", 15))
233 else if (!( strchr(partial,
'*') || strchr(partial,
'?') ))
234 partial =
va(vabuf,
sizeof(vabuf),
"*%s*", partial);
265 else if (!( strchr(partial,
'*') || strchr(partial,
'?') ))
266 partial =
va(vabuf,
sizeof(vabuf),
"*%s*", partial);
288 else if (!( strchr(partial,
'*') || strchr(partial,
'?') ))
289 partial =
va(vabuf,
sizeof(vabuf),
"*%s*", partial);
302 char *errchar =
NULL;
329typedef struct keyname_s
329typedef struct keyname_s {
…};
525 {
"APOSTROPHE",
'\''},
684#define KM_NONE (!keydown[K_CTRL] && !keydown[K_SHIFT] && !keydown[K_ALT])
685#define KM_CTRL_SHIFT_ALT ( keydown[K_CTRL] && keydown[K_SHIFT] && keydown[K_ALT])
686#define KM_CTRL_SHIFT ( keydown[K_CTRL] && keydown[K_SHIFT] && !keydown[K_ALT])
687#define KM_CTRL_ALT ( keydown[K_CTRL] && !keydown[K_SHIFT] && keydown[K_ALT])
688#define KM_SHIFT_ALT (!keydown[K_CTRL] && keydown[K_SHIFT] && keydown[K_ALT])
689#define KM_CTRL ( keydown[K_CTRL] && !keydown[K_SHIFT] && !keydown[K_ALT])
690#define KM_SHIFT (!keydown[K_CTRL] && keydown[K_SHIFT] && !keydown[K_ALT])
691#define KM_ALT (!keydown[K_CTRL] && !keydown[K_SHIFT] && keydown[K_ALT])
707 int len, blen, linepos;
736 memmove(&line[linepos + blen], &line[linepos], len);
740 memcpy(line + linepos,
buf, blen);
742 line[linepos + blen] = 0;
753 int linepos, linestart;
754 unsigned int linesize;
780 if (*p ==
'\r' && *(p+1) ==
'\n')
785 else if (*p ==
'\n' || *p ==
'\r' || *p ==
'\b')
791 strtok(cbd,
"\n\r\b");
799 memmove(line + linepos +
i, line + linepos, linesize - linepos -
i);
800 memcpy(line + linepos, cbd,
i);
817 int cvar_len, cvar_str_len, chars_to_move;
820 const char *cvar_str;
826 if(k ==
'\"' || k ==
';' || k ==
' ' || k ==
'\'')
832 for(cvar_len=0; (k = line[linepos + cvar_len]) != 0; cvar_len++)
834 if(k ==
'\"' || k ==
';' || k ==
' ' || k ==
'\'')
852 chars_to_move = (
int)
strlen(&line[linepos]);
853 if (linepos + 1 + cvar_str_len + chars_to_move <
MAX_INPUTLINE)
856 memmove(&line[linepos + 1 + cvar_str_len], &line[linepos], chars_to_move);
857 line[linepos++] =
' ';
858 memcpy(&line[linepos], cvar_str, cvar_str_len);
859 linepos += cvar_str_len;
860 line[linepos + chars_to_move] = 0;
863 Con_Printf(
"Couldn't append cvar value, edit line too long.\n");
883 if (linepos <= linestart + 1)
889 if (!(k ==
'\"' || k ==
';' || k ==
' ' || k ==
'\''))
891 }
while(pos > linestart);
893 if (pos == linestart)
898 if (k ==
'\"' || k ==
';' || k ==
' ' || k ==
'\'')
903 }
while(pos > linestart);
913 if (linepos <= linestart + 1)
915 pos = (
int)
u8_prevbyte(line + linestart, linepos - linestart) + linestart;
916 while (pos > linestart)
917 if(pos-1 >= linestart && line[pos-1] ==
STRING_COLOR_TAG && isdigit(line[pos]))
920 && isxdigit(line[pos-2]) && isxdigit(line[pos-1]) && isxdigit(line[pos]))
933 linepos = (
int)(pos + 1 - inchar);
939 if (linepos <= linestart + 1)
942 linepos = (
int)
u8_prevbyte(line + linestart, linepos - linestart) + linestart;
950 if (linepos > linestart)
953 int newpos = (
int)
u8_prevbyte(line + linestart, linepos - linestart) + linestart;
954 dp_strlcpy(line + newpos, line + linepos, linesize + 1 - linepos);
965 if (linepos < (
int)linelen)
966 memmove(line + linepos, line + linepos +
u8_bytelen(line + linepos, 1), linelen - linepos);
985 if(k ==
'\"' || k ==
';' || k ==
' ' || k ==
'\'')
993 if (!(k ==
'\"' || k ==
';' || k ==
' ' || k ==
'\''))
1012 if(isdigit(line[pos+1]))
1014 else if(line[pos+1] ==
STRING_COLOR_RGB_TAG_CHAR && isxdigit(line[pos+2]) && isxdigit(line[pos+3]) && isxdigit(line[pos+4]))
1029 if(isdigit(line[pos+1]))
1031 else if(line[pos+1] ==
STRING_COLOR_RGB_TAG_CHAR && isxdigit(line[pos+2]) && isxdigit(line[pos+3]) && isxdigit(line[pos+4]))
1042 if (linepos >= (
int)
strlen(line))
1074 return (
int)
strlen(line);
1335 ascii = 0xE000 + ascii;
1359 if (!str || !str[0])
1362 return tolower(str[0]);
1365 if (!strcasecmp (str, kn->
name))
1372 return (ch == 0 || *str != 0) ? -1 : (
int)ch;
1389 return "<KEY NOT FOUND>";
1393 if (keynum == kn->
keynum)
1404 return "<UNKNOWN KEYNUM>";
1414 if (keynum == -1 || keynum >=
MAX_KEYS)
1428 newbinding = (
char *)
Z_Malloc (l + 1);
1429 memcpy (newbinding, binding, l + 1);
1460 char *errchar =
NULL;
1463 Con_Print(
"in_unbind <bindmap> <key> : remove commands from a key\n");
1468 if ((m < 0) || (m >=
MAX_BINDMAPS) || (errchar && *errchar)) {
1480 Con_Printf(
"Key_SetBinding failed for unknown reason\n");
1488 char *errchar =
NULL;
1492 if (c != 3 && c != 4) {
1493 Con_Print(
"in_bind <bindmap> <key> [command] : attach a command to a key\n");
1498 if ((m < 0) || (m >=
MAX_BINDMAPS) || (errchar && *errchar)) {
1518 for (
i = 3;
i < c;
i++) {
1525 Con_Printf(
"Key_SetBinding failed for unknown reason\n");
1532 char *errchar =
NULL;
1537 Con_Print(
"in_bindmap <bindmap> <fallback>: set current bindmap and fallback\n");
1542 if ((m1 < 0) || (m1 >=
MAX_BINDMAPS) || (errchar && *errchar)) {
1548 if ((m2 < 0) || (m2 >=
MAX_BINDMAPS) || (errchar && *errchar)) {
1563 Con_Print(
"unbind <key> : remove commands from a key\n");
1574 Con_Printf(
"Key_SetBinding failed for unknown reason\n");
1614 char *errchar =
NULL;
1619 if ((m < 0) || (m >=
MAX_BINDMAPS) || (errchar && *errchar)) {
1646 if (c != 2 && c != 3) {
1647 Con_Print(
"bind <key> [command] : attach a command to a key\n");
1665 for (
i = 2;
i < c;
i++) {
1672 Con_Printf(
"Key_SetBinding failed for unknown reason\n");
1766 for (j = 0;j < numkeys;j++)
1779 if (!strcmp (
b, command) )
1782 if (
count == numkeys)
1797typedef struct eventqueueitem_s
1797typedef struct eventqueueitem_s {
…};
1859 Con_DPrintf(
"Key_Event(%i, '%c', %s) keydown %i bind \"%s\"\n", key, ascii ? ascii :
'?', down ?
"down" :
"up",
keydown[key], bind ? bind :
"");
1982 else if(bind[0] ==
'+' && !down &&
keydown[key] == 0)
2063 else if(bind[0] ==
'+' && !down &&
keydown[key] == 0)
2081 for(key = 0; key <
MAX_KEYS; ++key)
void CL_ForwardToServer(const char *s)
adds the string as a clc_stringcmd to the client message.
void CL_UpdateScreen(void)
void CL_Video_KeyEvent(int key, int ascii, qbool down)
void Cbuf_InsertText(cmd_state_t *cmd, const char *text)
void Cbuf_AddText(cmd_state_t *cmd, const char *text)
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
void Cmd_ExecuteString(cmd_state_t *cmd, const char *text, size_t textlen, cmd_source_t src, qbool lockmutex)
Parses a single line of text into arguments and tries to execute it.
qbool Cmd_QuoteString(char *out, size_t outlen, const char *in, const char *quoteset, qbool putquotes)
quotes a string so that it can be used as a command argument again; quoteset is a string that contain...
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
@ src_local
from the command buffer
#define CF_SERVER
cvar/command that only the server can change/execute
static int Cmd_Argc(cmd_state_t *cmd)
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
#define CF_CLIENT
cvar/command that only the client can change/execute
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
char * va(char *buf, size_t buflen, const char *format,...)
#define dp_strlcat(dst, src, dsize)
#define dp_strlcpy(dst, src, dsize)
const char * ConBuffer_GetLine(conbuffer_t *buf, int i)
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
void ConBuffer_Clear(conbuffer_t *buf)
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
void ConBuffer_Shutdown(conbuffer_t *buf)
int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console)
wrapper function to attempt to either complete the command line or to list possible matches grouped b...
void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, unsigned mask)
Appends a given string as a new line to the console.
void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool)
void Con_ToggleConsole_f(cmd_state_t *cmd)
#define CONBUFFER_LINES_COUNT(buf)
qbool CL_VM_InputEvent(int eventtype, float x, float y)
void Cvar_SetValueQuick(cvar_t *var, float value)
const char * Cvar_VariableDefString(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
const char * Cvar_VariableString(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
#define STRING_COLOR_RGB_TAG_CHAR
int matchpattern_with_separator(const char *in, const char *pattern, int caseinsensitive, const char *separators, qbool wildcard_least_one)
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
static int(ZEXPORT *qz_inflate)(z_stream *strm
int FS_Close(qfile_t *file)
int FS_Printf(qfile_t *file, const char *format,...)
int FS_Getc(qfile_t *file)
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
int Key_Parse_CommonKeys(cmd_state_t *cmd, qbool is_console, int key, int unicode)
void Key_FindKeysForCommand(const char *command, int *keys, int numkeys, int bindmap)
static void Key_History_First(void)
cvar_t con_closeontoggleconsole
static void Key_History_Init(void)
static int Key_Convert_NumPadKey(int key)
static void Key_History_f(cmd_state_t *cmd)
static void Key_In_Bind_f(cmd_state_t *cmd)
static void Key_History_Find_All(void)
void Key_WriteBindings(qfile_t *f)
qbool Key_SetBinding(int keynum, int bindmap, const char *binding)
qbool Key_SetBindMap(int fg, int bg)
char history_searchstring[MAX_INPUTLINE]
static void Key_PrintBindList(int j)
int Key_AddChar(int unicode, qbool is_console)
static const keyname_t keynames[]
static qbool Key_History_Get_foundCommand(void)
static void Key_EventQueue_Add(int key, int ascii, qbool down)
static void Key_History_Find_Backwards(void)
static void Key_History_Last(void)
static void Key_In_Unbind_f(cmd_state_t *cmd)
static void Key_Console(cmd_state_t *cmd, int key, int unicode)
static unsigned eventqueue_idx
static void Key_History_Down(void)
void Key_EventQueue_Block(void)
static void Key_History_Shutdown(void)
char * keybindings[MAX_BINDMAPS][MAX_KEYS]
static void Key_In_BindList_f(cmd_state_t *cmd)
char chat_buffer[MAX_INPUTLINE]
int Key_ClearEditLine(qbool is_console)
static void Key_In_Bindmap_f(cmd_state_t *cmd)
void Key_EventQueue_Unblock(void)
void Key_GetBindMap(int *fg, int *bg)
static int events_blocked
static void Key_History_Find_Forwards(void)
static void Key_Unbind_f(cmd_state_t *cmd)
static void Key_History_Up(void)
const char * Key_KeynumToString(int keynum, char *tinystr, size_t tinystrlength)
static keydest_t tbl_keydest[MAX_KEYS]
const char * Key_GetBind(int key, int bindmap)
static char tbl_keyascii[MAX_KEYS]
char key_line[MAX_INPUTLINE]
static void Key_Bind_f(cmd_state_t *cmd)
static unsigned char keydown[MAX_KEYS]
void Key_Event(int key, int ascii, qbool down)
static void Key_Message(cmd_state_t *cmd, int key, int ascii)
static void Key_BindList_f(cmd_state_t *cmd)
void Key_ReleaseAll_f(cmd_state_t *cmd)
static void Key_History_Push(void)
char history_savedline[MAX_INPUTLINE]
static void Key_Unbindall_f(cmd_state_t *cmd)
static eventqueueitem_t eventqueue[32]
void Key_ReleaseAll(void)
int Key_StringToKeynum(const char *str)
@ K_X360_LEFT_THUMB_RIGHT
@ K_X360_RIGHT_THUMB_DOWN
@ K_X360_RIGHT_THUMB_RIGHT
@ K_X360_RIGHT_THUMB_LEFT
#define KEY_CONSOLEACTIVE_USER
#define KEY_CONSOLEACTIVE_FORCED
#define HIST_MAXLINES
max command history buffer lines in console
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
#define CON_TEXTSIZE
max scrollback buffer characters in console
#define HIST_TEXTSIZE
max command history buffer characters in console
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
char * Sys_SDL_GetClipboardData(void)
int Sys_CheckParm(const char *parm)
int u8_charidx(const char *_s, size_t i, size_t *len)
Get the char-index for a byte-index.
size_t u8_bytelen(const char *_s, size_t n)
Get the number of bytes used in a string to represent an amount of characters.
int u8_fromchar(Uchar w, char *to, size_t maxlen)
Encode a wide-character into utf-8.
size_t u8_prevbyte(const char *_s, size_t i)
Get the byte offset of the previous byte.
#define u8_getnchar(c, e, n)