aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/common.c
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-09-16 21:05:22 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-09-16 21:05:22 +0000
commit660be5cc7d3989740b4e6fbd8ed8b1d9c46ebd20 (patch)
treec609227c4de7d3ea10310714c3262d58665b3ffa /code/qcommon/common.c
parent134e4522a3a9eb3f3e2f8e3646eb3d3999d49694 (diff)
downloadioquake3-aero-660be5cc7d3989740b4e6fbd8ed8b1d9c46ebd20.tar.gz
ioquake3-aero-660be5cc7d3989740b4e6fbd8ed8b1d9c46ebd20.zip
* Move command argument completion from being hard coded to being associated
with the individual commands to be completed git-svn-id: svn://svn.icculus.org/quake3/trunk@1472 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon/common.c')
-rw-r--r--code/qcommon/common.c96
1 files changed, 7 insertions, 89 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index 5dda171..4436aea 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -2621,6 +2621,7 @@ void Com_Init( char *commandLine ) {
Cmd_AddCommand ("quit", Com_Quit_f);
Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
+ Cmd_SetCommandCompletionFunc( "writeconfig", Cmd_CompleteCfgName );
s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ );
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
@@ -3168,7 +3169,7 @@ static qboolean Field_Complete( void )
Field_CompleteKeyname
===============
*/
-static void Field_CompleteKeyname( void )
+void Field_CompleteKeyname( void )
{
matchCount = 0;
shortestMatch[ 0 ] = 0;
@@ -3185,7 +3186,7 @@ static void Field_CompleteKeyname( void )
Field_CompleteFilename
===============
*/
-static void Field_CompleteFilename( const char *dir,
+void Field_CompleteFilename( const char *dir,
const char *ext, qboolean stripExt )
{
matchCount = 0;
@@ -3202,11 +3203,10 @@ static void Field_CompleteFilename( const char *dir,
Field_CompleteCommand
===============
*/
-static void Field_CompleteCommand( char *cmd,
+void Field_CompleteCommand( char *cmd,
qboolean doCommands, qboolean doCvars )
{
int completionArgument = 0;
- char *p;
// Skip leading whitespace and quotes
cmd = Com_SkipCharset( cmd, " \"" );
@@ -3248,6 +3248,7 @@ static void Field_CompleteCommand( char *cmd,
if( completionArgument > 1 )
{
const char *baseCmd = Cmd_Argv( 0 );
+ char *p;
#ifndef DEDICATED
// This should always be true
@@ -3256,92 +3257,9 @@ static void Field_CompleteCommand( char *cmd,
#endif
if( ( p = Field_FindFirstSeparator( cmd ) ) )
- {
- // Compound command
- Field_CompleteCommand( p + 1, qtrue, qtrue );
- }
+ Field_CompleteCommand( p + 1, qtrue, qtrue ); // Compound command
else
- {
- // FIXME: all this junk should really be associated with the respective
- // commands, instead of being hard coded here
- if( ( !Q_stricmp( baseCmd, "map" ) ||
- !Q_stricmp( baseCmd, "devmap" ) ||
- !Q_stricmp( baseCmd, "spmap" ) ||
- !Q_stricmp( baseCmd, "spdevmap" ) ) &&
- completionArgument == 2 )
- {
- Field_CompleteFilename( "maps", "bsp", qtrue );
- }
- else if( ( !Q_stricmp( baseCmd, "exec" ) ||
- !Q_stricmp( baseCmd, "writeconfig" ) ) &&
- completionArgument == 2 )
- {
- Field_CompleteFilename( "", "cfg", qfalse );
- }
- else if( !Q_stricmp( baseCmd, "condump" ) &&
- completionArgument == 2 )
- {
- Field_CompleteFilename( "", "txt", qfalse );
- }
- else if( ( !Q_stricmp( baseCmd, "toggle" ) ||
- !Q_stricmp( baseCmd, "vstr" ) ||
- !Q_stricmp( baseCmd, "set" ) ||
- !Q_stricmp( baseCmd, "seta" ) ||
- !Q_stricmp( baseCmd, "setu" ) ||
- !Q_stricmp( baseCmd, "sets" ) ) &&
- completionArgument == 2 )
- {
- // Skip "<cmd> "
- p = Com_SkipTokens( cmd, 1, " " );
-
- if( p > cmd )
- Field_CompleteCommand( p, qfalse, qtrue );
- }
-#ifndef DEDICATED
- else if( !Q_stricmp( baseCmd, "demo" ) && completionArgument == 2 )
- {
- char demoExt[ 16 ];
-
- Com_sprintf( demoExt, sizeof( demoExt ), ".dm_%d", PROTOCOL_VERSION );
- Field_CompleteFilename( "demos", demoExt, qtrue );
- }
- else if( !Q_stricmp( baseCmd, "rcon" ) && completionArgument == 2 )
- {
- // Skip "rcon "
- p = Com_SkipTokens( cmd, 1, " " );
-
- if( p > cmd )
- Field_CompleteCommand( p, qtrue, qtrue );
- }
- else if( !Q_stricmp( baseCmd, "bind" ) )
- {
- if( completionArgument == 2 )
- {
- // Skip "bind "
- p = Com_SkipTokens( cmd, 1, " " );
-
- if( p > cmd )
- Field_CompleteKeyname( );
- }
- else if( completionArgument >= 3 )
- {
- // Skip "bind <key> "
- p = Com_SkipTokens( cmd, 2, " " );
-
- if( p > 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
- }
+ Cmd_CompleteArgument( baseCmd, cmd, completionArgument );
}
else
{