mirror of
https://github.com/ioquake/ioq3.git
synced 2025-05-31 17:11:40 +00:00
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.
This commit is contained in:
parent
d9485b696e
commit
43ea1aebb3
1 changed files with 10 additions and 1 deletions
|
@ -37,6 +37,7 @@ static CONSOLE_CURSOR_INFO qconsole_orig_cursorinfo;
|
||||||
// cmd history
|
// cmd history
|
||||||
static char qconsole_history[ QCONSOLE_HISTORY ][ MAX_EDIT_LINE ];
|
static char qconsole_history[ QCONSOLE_HISTORY ][ MAX_EDIT_LINE ];
|
||||||
static int qconsole_history_pos = -1;
|
static int qconsole_history_pos = -1;
|
||||||
|
static int qconsole_history_lines = 0;
|
||||||
static int qconsole_history_oldest = 0;
|
static int qconsole_history_oldest = 0;
|
||||||
|
|
||||||
// current edit buffer
|
// current edit buffer
|
||||||
|
@ -107,6 +108,9 @@ static void CON_HistAdd( void )
|
||||||
Q_strncpyz( qconsole_history[ qconsole_history_oldest ], qconsole_line,
|
Q_strncpyz( qconsole_history[ qconsole_history_oldest ], qconsole_line,
|
||||||
sizeof( qconsole_history[ qconsole_history_oldest ] ) );
|
sizeof( qconsole_history[ qconsole_history_oldest ] ) );
|
||||||
|
|
||||||
|
if( qconsole_history_lines < QCONSOLE_HISTORY )
|
||||||
|
qconsole_history_lines++;
|
||||||
|
|
||||||
if( qconsole_history_oldest >= QCONSOLE_HISTORY - 1 )
|
if( qconsole_history_oldest >= QCONSOLE_HISTORY - 1 )
|
||||||
qconsole_history_oldest = 0;
|
qconsole_history_oldest = 0;
|
||||||
else
|
else
|
||||||
|
@ -128,7 +132,7 @@ static void CON_HistPrev( void )
|
||||||
( QCONSOLE_HISTORY - 1 ) : ( qconsole_history_pos - 1 );
|
( QCONSOLE_HISTORY - 1 ) : ( qconsole_history_pos - 1 );
|
||||||
|
|
||||||
// don' t allow looping through history
|
// don' t allow looping through history
|
||||||
if( pos == qconsole_history_oldest )
|
if( pos == qconsole_history_oldest || pos >= qconsole_history_lines )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qconsole_history_pos = pos;
|
qconsole_history_pos = pos;
|
||||||
|
@ -146,12 +150,17 @@ static void CON_HistNext( void )
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
// don' t allow looping through history
|
||||||
|
if( qconsole_history_pos == qconsole_history_oldest )
|
||||||
|
return;
|
||||||
|
|
||||||
pos = ( qconsole_history_pos >= QCONSOLE_HISTORY - 1 ) ?
|
pos = ( qconsole_history_pos >= QCONSOLE_HISTORY - 1 ) ?
|
||||||
0 : ( qconsole_history_pos + 1 );
|
0 : ( qconsole_history_pos + 1 );
|
||||||
|
|
||||||
// clear the edit buffer if they try to advance to a future command
|
// clear the edit buffer if they try to advance to a future command
|
||||||
if( pos == qconsole_history_oldest )
|
if( pos == qconsole_history_oldest )
|
||||||
{
|
{
|
||||||
|
qconsole_history_pos = pos;
|
||||||
qconsole_line[ 0 ] = '\0';
|
qconsole_line[ 0 ] = '\0';
|
||||||
qconsole_linelen = 0;
|
qconsole_linelen = 0;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue