summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2013-07-21 17:29:29 -0500
committerTim Angus <tim@ngus.net>2014-06-17 17:43:33 +0100
commit99079643d058bc9dc839b6df032984cfc0d4406c (patch)
treec125eff93263846a2f49a3045817266dab586e9f /src/sys
parentc0b0fd714ed3c805a72d8f81b9b1ff1fbb51c872 (diff)
Fix Windows server history scrolling
Update history position when CON_HistNext goes to input line, otherwise when going to previous a line is skipped. Don't let CON_HistPrev go to unused lines.
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/con_win32.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sys/con_win32.c b/src/sys/con_win32.c
index e80885fe..d33afa54 100644
--- a/src/sys/con_win32.c
+++ b/src/sys/con_win32.c
@@ -38,6 +38,7 @@ static CONSOLE_CURSOR_INFO qconsole_orig_cursorinfo;
// cmd history
static char qconsole_history[ QCONSOLE_HISTORY ][ MAX_EDIT_LINE ];
static int qconsole_history_pos = -1;
+static int qconsole_history_lines = 0;
static int qconsole_history_oldest = 0;
// current edit buffer
@@ -108,6 +109,9 @@ static void CON_HistAdd( void )
Q_strncpyz( qconsole_history[ qconsole_history_oldest ], qconsole_line,
sizeof( qconsole_history[ qconsole_history_oldest ] ) );
+ if( qconsole_history_lines < QCONSOLE_HISTORY )
+ qconsole_history_lines++;
+
if( qconsole_history_oldest >= QCONSOLE_HISTORY - 1 )
qconsole_history_oldest = 0;
else
@@ -129,7 +133,7 @@ static void CON_HistPrev( void )
( QCONSOLE_HISTORY - 1 ) : ( qconsole_history_pos - 1 );
// don' t allow looping through history
- if( pos == qconsole_history_oldest )
+ if( pos == qconsole_history_oldest || pos >= qconsole_history_lines )
return;
qconsole_history_pos = pos;
@@ -147,12 +151,17 @@ static void CON_HistNext( void )
{
int pos;
+ // don' t allow looping through history
+ if( qconsole_history_pos == qconsole_history_oldest )
+ return;
+
pos = ( qconsole_history_pos >= QCONSOLE_HISTORY - 1 ) ?
0 : ( qconsole_history_pos + 1 );
// clear the edit buffer if they try to advance to a future command
if( pos == qconsole_history_oldest )
{
+ qconsole_history_pos = pos;
qconsole_line[ 0 ] = '\0';
qconsole_linelen = 0;
return;