From 85d67626475bb101a027faaa94a1b79760acfc74 Mon Sep 17 00:00:00 2001 From: myT Date: Thu, 18 May 2017 23:23:50 +0200 Subject: [PATCH] added auto-completion to the Windows dedicated server fixed Linux dedicated servers inserting a leading backslash when running auto-completion fixed tty handling of the leading "]" --- changelog.txt | 6 ++++++ code/client/cl_keys.cpp | 2 +- code/qcommon/common.cpp | 14 +++++--------- code/qcommon/qcommon.h | 2 +- code/unix/unix_main.cpp | 9 ++++++++- code/win32/win_syscon.cpp | 21 ++++++++++++++++++--- 6 files changed, 39 insertions(+), 15 deletions(-) diff --git a/changelog.txt b/changelog.txt index 18d15a8..6ed9ee9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -55,6 +55,8 @@ chg: remove the byzantine r_mode usage added in 1.47 Windows: +add: auto-completion in the dedicated server console window + add: new bindable key: BACKSLASH (the key to the right of the left shift button) fix: the crash handler will reset the system timer resolution @@ -68,6 +70,10 @@ chg: reduced raw mouse input latency and added cl_drawMouseLag Linux: +fix: tty handling of the leading "]" character + +fix: dedicated servers no longer insert a leading backslash when running auto-completion + fix: the crash handler will reset tty input mode correctly chg: tty input behavior matches in-game behavior when cgame is running and fixed the truncated tty input diff --git a/code/client/cl_keys.cpp b/code/client/cl_keys.cpp index 5253581..d163813 100644 --- a/code/client/cl_keys.cpp +++ b/code/client/cl_keys.cpp @@ -494,7 +494,7 @@ static void Console_Key( int key ) // command completion if (key == K_TAB) { - Field_AutoComplete(&g_consoleField); + Field_AutoComplete( &g_consoleField, qtrue ); return; } diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp index 1f31ccc..cc7295a 100644 --- a/code/qcommon/common.cpp +++ b/code/qcommon/common.cpp @@ -2804,20 +2804,14 @@ void Field_AutoCompleteFrom( int startArg, int compArg, qbool searchCmds, qbool } -// returns qtrue if there already was a leading slash -static qbool Field_EnsureLeadingSlash( field_t *field ) +static void Field_AddLeadingSlash( field_t *field ) { - if ( String_HasLeadingSlash( field->buffer ) ) - return qtrue; - const size_t length = strlen( field->buffer ); if ( length + 1 < sizeof( field->buffer ) ) { memmove( field->buffer + 1, field->buffer, length + 1 ); *field->buffer = '\\'; field->cursor++; } - - return qfalse; } @@ -2855,10 +2849,12 @@ static qbool Field_AutoCompleteNoLeadingSlash( field_t *field ) } -void Field_AutoComplete( field_t *field ) +void Field_AutoComplete( field_t *field, qbool insertBackslash ) { const qbool ranComp = Field_AutoCompleteNoLeadingSlash( field ); - const qbool hadSlash = Field_EnsureLeadingSlash( field ); + const qbool hadSlash = String_HasLeadingSlash( field->buffer ); + if ( !hadSlash && insertBackslash ) + Field_AddLeadingSlash( field ); if ( ranComp ) return; diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index e08e7fe..90530f2 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -657,7 +657,7 @@ typedef struct { } field_t; void Field_Clear( field_t *edit ); -void Field_AutoComplete( field_t *edit ); // should only be called by Console_Key +void Field_AutoComplete( field_t *edit, qbool insertBackslash ); // should only be called by Console_Key // these are the functions you can use from your own command argument auto-completion callbacks void Field_AutoCompleteFrom( int startArg, int compArg, qbool searchCmds, qbool searchVars ); diff --git a/code/unix/unix_main.cpp b/code/unix/unix_main.cpp index cecf582..ab25e07 100644 --- a/code/unix/unix_main.cpp +++ b/code/unix/unix_main.cpp @@ -135,6 +135,7 @@ static void tty_Hide() tty_Back(); } } + tty_Back(); // delete the leading "]" ttycon_hide++; } @@ -148,6 +149,7 @@ static void tty_Show() ttycon_hide--; if (ttycon_hide == 0) { + write(STDOUT_FILENO, "]", 1); if (tty_con.cursor) { for (i=0; i