Added cl_constyle cvar.

This commit is contained in:
Anton E. Gavrilov 2000-03-13 01:35:17 +00:00
parent 3f48c050be
commit 1dfc12ebf5

View file

@ -41,6 +41,7 @@ key up events are sent even if in console mode
*/ */
cvar_t *cl_constyle;
#define MAXCMDLINE 256 #define MAXCMDLINE 256
char key_lines[32][MAXCMDLINE]; char key_lines[32][MAXCMDLINE];
@ -257,18 +258,27 @@ void Key_Console (int key)
switch (key) { switch (key) {
case KP_ENTER: case KP_ENTER:
case K_ENTER: case K_ENTER:
// backslash text are commands, else chat // backslash text are commands
if (key_lines[edit_line][1] == '\\' || key_lines[edit_line][1] == '/') if (key_lines[edit_line][1] == '/' && key_lines[edit_line][2] == '/')
Cbuf_AddText (key_lines[edit_line]+2); // skip the > goto no_lf;
else if (CheckForCommand()) else if (key_lines[edit_line][1] == '\\' || key_lines[edit_line][1] == '/')
Cbuf_AddText (key_lines[edit_line]+2); // skip the ]/
else if (cl_constyle->value != 2 && CheckForCommand())
Cbuf_AddText (key_lines[edit_line]+1); // valid command Cbuf_AddText (key_lines[edit_line]+1); // valid command
else { // convert to a chat message else if ((cls.state >= ca_connected && cl_constyle->value == 1) || cl_constyle->value == 2)
if (cls.state >= ca_connected) {
Cbuf_AddText ("say "); if (cls.state < ca_connected) // can happen if cl_constyle == 2
Cbuf_AddText (key_lines[edit_line]+1); // skip the > goto no_lf; // drop the whole line
// convert to a chat message
Cbuf_AddText ("say ");
Cbuf_AddText (key_lines[edit_line]+1);
} }
else
Cbuf_AddText (key_lines[edit_line]+1); // skip the ]
Cbuf_AddText ("\n"); Cbuf_AddText ("\n");
no_lf:
Con_Printf ("%s\n",key_lines[edit_line]); Con_Printf ("%s\n",key_lines[edit_line]);
edit_line = (edit_line + 1) & 31; edit_line = (edit_line + 1) & 31;
history_line = edit_line; history_line = edit_line;
@ -382,13 +392,14 @@ void Key_Console (int key)
strcpy(textCopied, clipText); strcpy(textCopied, clipText);
/* Substitutes a NULL for every token */strtok(textCopied, "\n\r\b"); /* Substitutes a NULL for every token */strtok(textCopied, "\n\r\b");
i = strlen(textCopied); i = strlen(textCopied);
if (i + strlen(key_lines[edit_line]) >= MAXCMDLINE) if (i + strlen(key_lines[edit_line]) >= MAXCMDLINE-1)
i = MAXCMDLINE - strlen(key_lines[edit_line]); i = MAXCMDLINE-1 - strlen(key_lines[edit_line]);
if (i>0) { if (i > 0)
textCopied[i]=0; { // insert the string
// FIXME: actually INSERT the string, not append! memcpy (key_lines[edit_line] + key_linepos + i,
strcat(key_lines[edit_line], textCopied); key_lines[edit_line] + key_linepos, strlen(key_lines[edit_line]) - key_linepos + 1);
key_linepos = strlen(key_lines[edit_line]);; memcpy (key_lines[edit_line] + key_linepos, textCopied, i);
key_linepos += i;
} }
free(textCopied); free(textCopied);
} }
@ -750,7 +761,8 @@ void Key_Init (void)
Cmd_AddCommand ("unbind",Key_Unbind_f); Cmd_AddCommand ("unbind",Key_Unbind_f);
Cmd_AddCommand ("unbindall",Key_Unbindall_f); Cmd_AddCommand ("unbindall",Key_Unbindall_f);
cl_constyle = Cvar_Get ("cl_constyle", "1", 0,
"0 - NQ, 1 - QW, 2 - Q3");
} }
/* /*