summaryrefslogtreecommitdiff
path: root/src/qcommon
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-03 11:59:51 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:35 +0000
commit8e412322448053080c00a67f92fda4de183df7fa (patch)
tree007c8e8ba9c6bc39869bd2a3c433bc53e0f7e6d1 /src/qcommon
parente28bdd7b296c0028aaa63ee1feb027c2f0ebde51 (diff)
* Merge ioq3-r1464
* Use WM cursor when running windowed and UI module has input
Diffstat (limited to 'src/qcommon')
-rw-r--r--src/qcommon/common.c103
1 files changed, 46 insertions, 57 deletions
diff --git a/src/qcommon/common.c b/src/qcommon/common.c
index f16234c2..7c98d45e 100644
--- a/src/qcommon/common.c
+++ b/src/qcommon/common.c
@@ -2983,37 +2983,52 @@ static char *Field_FindFirstSeparator( char *s )
return NULL;
}
-#ifndef DEDICATED
/*
===============
-Field_CompleteKeyname
+Field_Complete
===============
*/
-static void Field_CompleteKeyname( void )
+static qboolean Field_Complete( void )
{
- matchCount = 0;
- shortestMatch[ 0 ] = 0;
-
- Key_KeynameCompletion( FindMatches );
+ int completionOffset;
if( matchCount == 0 )
- return;
+ return qfalse;
+
+ completionOffset = strlen( completionField->buffer ) - strlen( completionString );
+
+ Q_strncpyz( &completionField->buffer[ completionOffset ], shortestMatch,
+ sizeof( completionField->buffer ) - completionOffset );
- Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) -
- strlen( completionString ) ], shortestMatch,
- sizeof( completionField->buffer ) );
completionField->cursor = strlen( completionField->buffer );
if( matchCount == 1 )
{
Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " );
completionField->cursor++;
- return;
+ return qtrue;
}
Com_Printf( "]%s\n", completionField->buffer );
-
- Key_KeynameCompletion( PrintMatches );
+
+ return qfalse;
+}
+
+#ifndef DEDICATED
+/*
+===============
+Field_CompleteKeyname
+===============
+*/
+static void Field_CompleteKeyname( void )
+{
+ matchCount = 0;
+ shortestMatch[ 0 ] = 0;
+
+ Key_KeynameCompletion( FindMatches );
+
+ if( !Field_Complete( ) )
+ Key_KeynameCompletion( PrintMatches );
}
#endif
@@ -3030,24 +3045,8 @@ static void Field_CompleteFilename( const char *dir,
FS_FilenameCompletion( dir, ext, stripExt, FindMatches );
- if( matchCount == 0 )
- return;
-
- Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) -
- strlen( completionString ) ], shortestMatch,
- sizeof( completionField->buffer ) );
- completionField->cursor = strlen( completionField->buffer );
-
- if( matchCount == 1 )
- {
- Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " );
- completionField->cursor++;
- return;
- }
-
- Com_Printf( "]%s\n", completionField->buffer );
-
- FS_FilenameCompletion( dir, ext, stripExt, PrintMatches );
+ if( !Field_Complete( ) )
+ FS_FilenameCompletion( dir, ext, stripExt, PrintMatches );
}
/*
@@ -3185,13 +3184,19 @@ static void Field_CompleteCommand( char *cmd,
Field_CompleteCommand( p, qtrue, qtrue );
}
}
+ else if( !Q_stricmp( baseCmd, "unbind" ) && completionArgument == 2 )
+ {
+ // Skip "unbind "
+ p = Com_SkipTokens( cmd, 1, " " );
+
+ if( p > cmd )
+ Field_CompleteKeyname( );
+ }
#endif
}
}
else
{
- int completionOffset;
-
if( completionString[0] == '\\' || completionString[0] == '/' )
completionString++;
@@ -3207,31 +3212,15 @@ static void Field_CompleteCommand( char *cmd,
if( doCvars )
Cvar_CommandCompletion( FindMatches );
- if( matchCount == 0 )
- return; // no matches
-
- completionOffset = strlen( completionField->buffer ) - strlen( completionString );
-
- Q_strncpyz( &completionField->buffer[ completionOffset ], shortestMatch,
- sizeof( completionField->buffer ) - completionOffset );
-
- completionField->cursor = strlen( completionField->buffer );
-
- if( matchCount == 1 )
+ if( !Field_Complete( ) )
{
- Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " );
- completionField->cursor++;
- return;
- }
+ // run through again, printing matches
+ if( doCommands )
+ Cmd_CommandCompletion( PrintMatches );
- Com_Printf( "]%s\n", completionField->buffer );
-
- // run through again, printing matches
- if( doCommands )
- Cmd_CommandCompletion( PrintMatches );
-
- if( doCvars )
- Cvar_CommandCompletion( PrintCvarMatches );
+ if( doCvars )
+ Cvar_CommandCompletion( PrintCvarMatches );
+ }
}
}