Some history browsing fixes (partly from uhexen2)

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@734 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
svdijk 2012-09-26 17:08:37 +00:00
parent 52d203e252
commit 1b58beef6d
1 changed files with 21 additions and 7 deletions

View File

@ -183,6 +183,7 @@ Interactive line editing and console scrollback
void Key_Console (int key)
{
static char current[MAXCMDLINE] = "";
int history_line_last;
extern int con_vislines;
extern char key_tabpartial[MAXCMDLINE];
@ -307,25 +308,38 @@ void Key_Console (int key)
return;
case K_UPARROW:
// Needs rewriting as we have persistent history
// if (history_line == 0) return;
if (history_line == edit_line)
Q_strcpy(current,key_lines[edit_line]);
history_line_last = history_line;
do
{
history_line = (history_line - 1) & 31;
}
while (history_line != edit_line && !key_lines[history_line][1]);
if (history_line == edit_line)
{
history_line = history_line_last;
return;
}
key_tabpartial[0] = 0;
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;
case K_DOWNARROW:
key_tabpartial[0] = 0;
if (history_line == edit_line)
return;
key_tabpartial[0] = 0;
history_line = (history_line + 1) & 31;
do
{
history_line = (history_line + 1) & 31;
}
while (history_line != edit_line && !key_lines[history_line][1]);
if (history_line == edit_line)
Q_strcpy(key_lines[edit_line], current);