mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Make some fixes for command line history now that history is persistent
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@244 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
66cafbd197
commit
f303df4d82
2 changed files with 20 additions and 31 deletions
|
@ -921,7 +921,7 @@ void Con_TabComplete (void)
|
|||
c = key_lines[edit_line] + key_linepos - 1; //start one space left of cursor
|
||||
while (*c!=' ' && *c!='\"' && *c!=';' && c!=key_lines[edit_line])
|
||||
c--;
|
||||
c++; //start 1 char after the seperator we just found
|
||||
c++; //start 1 char after the separator we just found
|
||||
}
|
||||
for (i = 0; c + i < key_lines[edit_line] + key_linepos; i++)
|
||||
partial[i] = c[i];
|
||||
|
@ -1003,7 +1003,7 @@ void Con_TabComplete (void)
|
|||
//use prev or next to find next match
|
||||
match = keydown[K_SHIFT] ? t->prev->name : t->next->name;
|
||||
}
|
||||
Hunk_FreeToLowMark(mark); //it's okay to free it here becuase match is a pointer to persistent data
|
||||
Hunk_FreeToLowMark(mark); //it's okay to free it here because match is a pointer to persistent data
|
||||
|
||||
// insert new match into edit line
|
||||
Q_strcpy (partial, match); //first copy match string
|
||||
|
|
47
Quake/keys.c
47
Quake/keys.c
|
@ -187,6 +187,7 @@ void Key_Console (int key)
|
|||
{
|
||||
extern int con_vislines;
|
||||
extern char key_tabpartial[MAXCMDLINE];
|
||||
static char current[MAXCMDLINE]="";
|
||||
|
||||
switch (key)
|
||||
{
|
||||
|
@ -197,8 +198,9 @@ void Key_Console (int key)
|
|||
Cbuf_AddText ("\n");
|
||||
Con_Printf ("%s\n",key_lines[edit_line]);
|
||||
|
||||
// If the last two lines are identical, only store one (in history)
|
||||
if (edit_line==0 || strcmp(key_lines[edit_line],key_lines[edit_line-1]))
|
||||
// If the last two lines are identical, skip storing this line in history
|
||||
// by not incrementing edit_line
|
||||
if (strcmp(key_lines[edit_line],key_lines[(edit_line-1)&31]))
|
||||
edit_line = (edit_line + 1) & 31;
|
||||
|
||||
history_line = edit_line;
|
||||
|
@ -307,16 +309,15 @@ void Key_Console (int key)
|
|||
return;
|
||||
|
||||
case K_UPARROW:
|
||||
if (history_line == 0)
|
||||
return;
|
||||
// Needs rewriting as we have persistent history
|
||||
|
||||
// if (history_line == 0) return;
|
||||
if (history_line == edit_line) {
|
||||
Q_strcpy(current,key_lines[edit_line]);
|
||||
};
|
||||
key_tabpartial[0] = 0;
|
||||
do
|
||||
{
|
||||
history_line = (history_line - 1) & 31;
|
||||
} while (history_line != edit_line
|
||||
&& !key_lines[history_line][1]);
|
||||
if (history_line == edit_line)
|
||||
history_line = (edit_line+1)&31;
|
||||
history_line = (history_line - 1) & 31;
|
||||
|
||||
Q_strcpy(key_lines[edit_line], key_lines[history_line]);
|
||||
key_linepos = Q_strlen(key_lines[edit_line]);
|
||||
return;
|
||||
|
@ -324,30 +325,18 @@ void Key_Console (int key)
|
|||
case K_DOWNARROW:
|
||||
key_tabpartial[0] = 0;
|
||||
|
||||
if (history_line == edit_line)
|
||||
{
|
||||
//clear editline
|
||||
key_lines[edit_line][1] = 0;
|
||||
key_linepos = 1;
|
||||
if (history_line == edit_line)
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
history_line = (history_line + 1) & 31;
|
||||
} while (history_line != edit_line
|
||||
&& !key_lines[history_line][1]);
|
||||
history_line = (history_line + 1) & 31;
|
||||
|
||||
if (history_line == edit_line)
|
||||
{
|
||||
key_lines[edit_line][0] = ']';
|
||||
key_lines[edit_line][1] = 0;
|
||||
key_linepos = 1;
|
||||
}
|
||||
Q_strcpy(key_lines[edit_line], current);
|
||||
else
|
||||
{
|
||||
Q_strcpy(key_lines[edit_line], key_lines[history_line]);
|
||||
key_linepos = Q_strlen(key_lines[edit_line]);
|
||||
}
|
||||
key_linepos = Q_strlen(key_lines[edit_line]);
|
||||
return;
|
||||
|
||||
case 'c':
|
||||
if (keydown[K_CTRL]) {
|
||||
// Control+C (S.A)
|
||||
|
|
Loading…
Reference in a new issue