mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 12:41:21 +00:00
Moved input line indicator ] out of line buffer
This commit is contained in:
parent
a18ea4b11d
commit
98d33fad06
3 changed files with 65 additions and 65 deletions
|
@ -60,10 +60,8 @@ DrawAltStringScaled(int x, int y, char *s, float factor)
|
||||||
void
|
void
|
||||||
Key_ClearTyping(void)
|
Key_ClearTyping(void)
|
||||||
{
|
{
|
||||||
key_lines[edit_line][0] = ']';
|
key_lines[edit_line][0] = '\0';
|
||||||
key_lines[edit_line][1] = '\0';
|
key_linepos = 0;
|
||||||
|
|
||||||
key_linepos = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -476,6 +474,7 @@ Con_DrawInput(void)
|
||||||
char ch;
|
char ch;
|
||||||
int txtlen;
|
int txtlen;
|
||||||
int linepos;
|
int linepos;
|
||||||
|
int draw_icon;
|
||||||
|
|
||||||
if (cls.key_dest == key_menu)
|
if (cls.key_dest == key_menu)
|
||||||
{
|
{
|
||||||
|
@ -493,23 +492,30 @@ Con_DrawInput(void)
|
||||||
linepos = key_linepos;
|
linepos = key_linepos;
|
||||||
|
|
||||||
/* prestep if horizontally scrolling */
|
/* prestep if horizontally scrolling */
|
||||||
if (linepos >= con.linewidth)
|
if (linepos >= (con.linewidth - 1))
|
||||||
{
|
{
|
||||||
int ofs = 1 + linepos - con.linewidth;
|
int ofs = 1 + linepos - con.linewidth;
|
||||||
|
|
||||||
text += ofs;
|
text += ofs;
|
||||||
linepos -= ofs;
|
linepos -= ofs;
|
||||||
|
|
||||||
|
draw_icon = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Draw_CharScaled(8 * scale, con.vislines - 22 * scale, CON_INPUT_INDICATOR, scale);
|
||||||
|
draw_icon = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
txtlen = strlen(text);
|
txtlen = strlen(text);
|
||||||
|
|
||||||
for (i = 0; i < con.linewidth; i++)
|
for (i = 0; i < (con.linewidth - draw_icon); i++)
|
||||||
{
|
{
|
||||||
if (i == linepos)
|
if (i == linepos)
|
||||||
{
|
{
|
||||||
if (cls.realtime & 8)
|
if (cls.realtime & 8)
|
||||||
{
|
{
|
||||||
ch = 11;
|
ch = CON_INPUT_CURSOR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -525,7 +531,7 @@ Con_DrawInput(void)
|
||||||
ch = text[i];
|
ch = text[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw_CharScaled(((i + 1) << 3) * scale, con.vislines - 22 * scale, ch, scale);
|
Draw_CharScaled(((i + 1 + draw_icon) << 3) * scale, con.vislines - 22 * scale, ch, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,9 +272,10 @@ keyname_t keynames[] = {
|
||||||
void
|
void
|
||||||
CompleteCommand(void)
|
CompleteCommand(void)
|
||||||
{
|
{
|
||||||
char *cmd, *s;
|
char *cmd;
|
||||||
|
char *s;
|
||||||
|
|
||||||
s = key_lines[edit_line] + 1;
|
s = key_lines[edit_line];
|
||||||
|
|
||||||
if ((*s == '\\') || (*s == '/'))
|
if ((*s == '\\') || (*s == '/'))
|
||||||
{
|
{
|
||||||
|
@ -282,65 +283,48 @@ CompleteCommand(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = Cmd_CompleteCommand(s);
|
cmd = Cmd_CompleteCommand(s);
|
||||||
|
if (!cmd)
|
||||||
if (cmd)
|
|
||||||
{
|
{
|
||||||
key_lines[edit_line][1] = '/';
|
return;
|
||||||
strcpy(key_lines[edit_line] + 2, cmd);
|
|
||||||
key_linepos = strlen(cmd) + 2;
|
|
||||||
|
|
||||||
if (Cmd_IsComplete(cmd))
|
|
||||||
{
|
|
||||||
key_lines[edit_line][key_linepos] = ' ';
|
|
||||||
key_linepos++;
|
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
*key_lines[edit_line] = '/';
|
||||||
|
strcpy(key_lines[edit_line] + 1, cmd);
|
||||||
|
key_linepos = strlen(cmd) + 1;
|
||||||
|
|
||||||
|
if (Cmd_IsComplete(cmd))
|
||||||
|
{
|
||||||
|
key_lines[edit_line][key_linepos] = ' ';
|
||||||
|
key_linepos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
key_lines[edit_line][key_linepos] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CompleteMapNameCommand(void)
|
CompleteMapNameCommand(void)
|
||||||
{
|
{
|
||||||
int i;
|
char *s, *cmdArg;
|
||||||
char *s, *t, *cmdArg;
|
|
||||||
const char *mapCmdString = "map ";
|
const char *mapCmdString = "map ";
|
||||||
|
|
||||||
s = key_lines[edit_line] + 1;
|
s = key_lines[edit_line];
|
||||||
|
|
||||||
if ((*s == '\\') || (*s == '/'))
|
if ((*s == '\\') || (*s == '/'))
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = s;
|
if (strncmp(mapCmdString, s, strlen(mapCmdString)) != 0)
|
||||||
|
|
||||||
for (i = 0; i < strlen(mapCmdString); i++)
|
|
||||||
{
|
{
|
||||||
if (t[i] == mapCmdString[i])
|
return;
|
||||||
{
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArg = Cmd_CompleteMapCommand(s);
|
cmdArg = Cmd_CompleteMapCommand(s + strlen(mapCmdString));
|
||||||
|
|
||||||
if (cmdArg)
|
if (cmdArg)
|
||||||
{
|
{
|
||||||
key_lines[edit_line][1] = '/';
|
snprintf(key_lines[edit_line], MAXCMDLINE, "/%s%s", mapCmdString, cmdArg);
|
||||||
strcpy(key_lines[edit_line] + 2, mapCmdString);
|
|
||||||
key_linepos = strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
strcpy(key_lines[edit_line] + key_linepos, cmdArg);
|
|
||||||
key_linepos = key_linepos + strlen(cmdArg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,9 +384,9 @@ Key_Console(int key)
|
||||||
|
|
||||||
if (key == 'c' || key == 'x')
|
if (key == 'c' || key == 'x')
|
||||||
{
|
{
|
||||||
if (key_lines[edit_line][1] != '\0')
|
if (*key_lines[edit_line] != '\0')
|
||||||
{
|
{
|
||||||
if (IN_SetClipboardText(key_lines[edit_line] + 1))
|
if (IN_SetClipboardText(key_lines[edit_line]))
|
||||||
{
|
{
|
||||||
Com_Printf("Copy to clipboard failed.\n");
|
Com_Printf("Copy to clipboard failed.\n");
|
||||||
}
|
}
|
||||||
|
@ -431,18 +415,18 @@ Key_Console(int key)
|
||||||
if ((key == K_ENTER) || (key == K_KP_ENTER))
|
if ((key == K_ENTER) || (key == K_KP_ENTER))
|
||||||
{
|
{
|
||||||
/* slash text are commands, else chat */
|
/* slash text are commands, else chat */
|
||||||
if ((key_lines[edit_line][1] == '\\') ||
|
if ((*key_lines[edit_line] == '\\') || (*key_lines[edit_line] == '/'))
|
||||||
(key_lines[edit_line][1] == '/'))
|
|
||||||
{
|
{
|
||||||
Cbuf_AddText(key_lines[edit_line] + 2); /* skip the > */
|
Cbuf_AddText(key_lines[edit_line] + 1); /* skip the > */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Cbuf_AddText(key_lines[edit_line] + 1); /* valid command */
|
Cbuf_AddText(key_lines[edit_line]); /* valid command */
|
||||||
}
|
}
|
||||||
|
|
||||||
Cbuf_AddText("\n");
|
Cbuf_AddText("\n");
|
||||||
Com_Printf("%s\n", key_lines[edit_line]);
|
Com_Printf("%c%s\n", CON_INPUT_INDICATOR, key_lines[edit_line]);
|
||||||
|
|
||||||
edit_line = (edit_line + 1) & (NUM_KEY_LINES - 1);
|
edit_line = (edit_line + 1) & (NUM_KEY_LINES - 1);
|
||||||
history_line = edit_line;
|
history_line = edit_line;
|
||||||
|
|
||||||
|
@ -468,7 +452,7 @@ Key_Console(int key)
|
||||||
|
|
||||||
if (key == K_LEFTARROW)
|
if (key == K_LEFTARROW)
|
||||||
{
|
{
|
||||||
if (key_linepos > 1)
|
if (key_linepos > 0)
|
||||||
{
|
{
|
||||||
key_linepos--;
|
key_linepos--;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +473,7 @@ Key_Console(int key)
|
||||||
if ((key == K_BACKSPACE) ||
|
if ((key == K_BACKSPACE) ||
|
||||||
((key == 'h') && (keydown[K_CTRL])))
|
((key == 'h') && (keydown[K_CTRL])))
|
||||||
{
|
{
|
||||||
if (key_linepos > 1)
|
if (key_linepos > 0)
|
||||||
{
|
{
|
||||||
Q_strdel(key_lines[edit_line], key_linepos - 1, 1);
|
Q_strdel(key_lines[edit_line], key_linepos - 1, 1);
|
||||||
key_linepos--;
|
key_linepos--;
|
||||||
|
@ -516,7 +500,7 @@ Key_Console(int key)
|
||||||
history_line = (history_line - 1) & (NUM_KEY_LINES-1);
|
history_line = (history_line - 1) & (NUM_KEY_LINES-1);
|
||||||
}
|
}
|
||||||
while (history_line != edit_line &&
|
while (history_line != edit_line &&
|
||||||
!key_lines[history_line][1]);
|
key_lines[history_line][0] == '\0');
|
||||||
|
|
||||||
if (history_line == edit_line)
|
if (history_line == edit_line)
|
||||||
{
|
{
|
||||||
|
@ -524,7 +508,8 @@ Key_Console(int key)
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
||||||
key_linepos = (int)strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +526,7 @@ Key_Console(int key)
|
||||||
history_line = (history_line + 1) & (NUM_KEY_LINES-1);
|
history_line = (history_line + 1) & (NUM_KEY_LINES-1);
|
||||||
}
|
}
|
||||||
while (history_line != edit_line &&
|
while (history_line != edit_line &&
|
||||||
!key_lines[history_line][1]);
|
key_lines[history_line][0] == '\0');
|
||||||
|
|
||||||
if (history_line == edit_line)
|
if (history_line == edit_line)
|
||||||
{
|
{
|
||||||
|
@ -550,7 +535,7 @@ Key_Console(int key)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
||||||
key_linepos = (int)strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -585,7 +570,7 @@ Key_Console(int key)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key_linepos = 1;
|
key_linepos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -600,7 +585,7 @@ Key_Console(int key)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key_linepos = (int)strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -995,7 +980,7 @@ Key_WriteConsoleHistory()
|
||||||
int lineIdx = (edit_line+i) & (NUM_KEY_LINES-1);
|
int lineIdx = (edit_line+i) & (NUM_KEY_LINES-1);
|
||||||
const char* line = key_lines[lineIdx];
|
const char* line = key_lines[lineIdx];
|
||||||
|
|
||||||
if(line[1] != '\0' && strcmp(lastWrittenLine, line ) != 0)
|
if(*line != '\0' && strcmp(lastWrittenLine, line) != 0)
|
||||||
{
|
{
|
||||||
// if the line actually contains something besides the ] prompt,
|
// if the line actually contains something besides the ] prompt,
|
||||||
// and is not identical to the last written line, write it to the file
|
// and is not identical to the last written line, write it to the file
|
||||||
|
@ -1042,6 +1027,7 @@ Key_ReadConsoleHistory()
|
||||||
history_line = i;
|
history_line = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing newlines
|
// remove trailing newlines
|
||||||
int lastCharIdx = strlen(key_lines[i])-1;
|
int lastCharIdx = strlen(key_lines[i])-1;
|
||||||
while((key_lines[i][lastCharIdx] == '\n' || key_lines[i][lastCharIdx] == '\r') && lastCharIdx >= 0)
|
while((key_lines[i][lastCharIdx] == '\n' || key_lines[i][lastCharIdx] == '\r') && lastCharIdx >= 0)
|
||||||
|
@ -1049,6 +1035,12 @@ Key_ReadConsoleHistory()
|
||||||
key_lines[i][lastCharIdx] = '\0';
|
key_lines[i][lastCharIdx] = '\0';
|
||||||
--lastCharIdx;
|
--lastCharIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* backwards compatibility with old history files */
|
||||||
|
if(key_lines[i][0] == ']')
|
||||||
|
{
|
||||||
|
memmove(key_lines[i], key_lines[i] + 1, MAXCMDLINE - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't remember the input line */
|
/* don't remember the input line */
|
||||||
|
@ -1077,12 +1069,11 @@ Key_Init(void)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < NUM_KEY_LINES; i++)
|
for (i = 0; i < NUM_KEY_LINES; i++)
|
||||||
{
|
{
|
||||||
key_lines[i][0] = ']';
|
key_lines[i][0] = '\0';
|
||||||
key_lines[i][1] = 0;
|
|
||||||
}
|
}
|
||||||
// can't call Key_ReadConsoleHistory() here because FS_Gamedir() isn't set yet
|
// can't call Key_ReadConsoleHistory() here because FS_Gamedir() isn't set yet
|
||||||
|
|
||||||
key_linepos = 1;
|
key_linepos = 0;
|
||||||
|
|
||||||
/* init 128 bit ascii characters in console mode */
|
/* init 128 bit ascii characters in console mode */
|
||||||
for (i = 32; i < 128; i++)
|
for (i = 32; i < 128; i++)
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#ifndef CL_HEADER_CONSOLE_H
|
#ifndef CL_HEADER_CONSOLE_H
|
||||||
#define CL_HEADER_CONSOLE_H
|
#define CL_HEADER_CONSOLE_H
|
||||||
|
|
||||||
|
#define CON_INPUT_INDICATOR ']'
|
||||||
|
#define CON_INPUT_CURSOR 11
|
||||||
|
|
||||||
#define NUM_CON_TIMES 4
|
#define NUM_CON_TIMES 4
|
||||||
#define CON_TEXTSIZE 32768
|
#define CON_TEXTSIZE 32768
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue