MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Field_CompleteCommand

Function Field_CompleteCommand

code/qcommon/common.cpp:1795–1850  ·  view source on GitHub ↗

=============== Field_CompleteCommand =============== */

Source from the content-addressed store, hash-verified

1793===============
1794*/
1795void Field_CompleteCommand( char *cmd, qboolean doCommands, qboolean doCvars )
1796{
1797 int completionArgument = 0;
1798
1799 // Skip leading whitespace and quotes
1800 cmd = Com_SkipCharset( cmd, " \"" );
1801
1802 Cmd_TokenizeStringIgnoreQuotes( cmd );
1803 completionArgument = Cmd_Argc();
1804
1805 // If there is trailing whitespace on the cmd
1806 if ( *(cmd + strlen( cmd )-1) == ' ' ) {
1807 completionString = "";
1808 completionArgument++;
1809 }
1810 else
1811 completionString = Cmd_Argv( completionArgument - 1 );
1812
1813 if ( completionArgument > 1 ) {
1814 const char *baseCmd = Cmd_Argv( 0 );
1815 char *p;
1816
1817 if ( baseCmd[0] == '\\' || baseCmd[0] == '/' )
1818 baseCmd++;
1819
1820 if( ( p = Field_FindFirstSeparator( cmd ) ) )
1821 Field_CompleteCommand( p + 1, qtrue, qtrue ); // Compound command
1822 else
1823 Cmd_CompleteArgument( baseCmd, cmd, completionArgument );
1824 }
1825 else {
1826 if ( completionString[0] == '\\' || completionString[0] == '/' )
1827 completionString++;
1828
1829 matchCount = 0;
1830 shortestMatch[ 0 ] = 0;
1831
1832 if ( strlen( completionString ) == 0 )
1833 return;
1834
1835 if ( doCommands )
1836 Cmd_CommandCompletion( FindMatches );
1837
1838 if ( doCvars )
1839 Cvar_CommandCompletion( FindMatches );
1840
1841 if ( !Field_Complete() ) {
1842 // run through again, printing matches
1843 if ( doCommands )
1844 Cmd_CommandCompletion( PrintMatches );
1845
1846 if ( doCvars )
1847 Cvar_CommandCompletion( PrintCvarMatches );
1848 }
1849 }
1850}
1851
1852/*

Callers 3

Field_AutoCompleteFunction · 0.70
Cvar_CompleteCvarNameFunction · 0.70
Key_CompleteBindFunction · 0.50

Calls 9

Com_SkipCharsetFunction · 0.70
Cmd_ArgcFunction · 0.70
Cmd_ArgvFunction · 0.70
Field_FindFirstSeparatorFunction · 0.70
Cmd_CompleteArgumentFunction · 0.70
Cmd_CommandCompletionFunction · 0.70
Cvar_CommandCompletionFunction · 0.70
Field_CompleteFunction · 0.70

Tested by

no test coverage detected