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

Function Field_CompleteCommand

codemp/qcommon/common.cpp:1904–1961  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1902===============
1903*/
1904void Field_CompleteCommand( char *cmd, qboolean doCommands, qboolean doCvars )
1905{
1906 int completionArgument = 0;
1907
1908 // Skip leading whitespace and quotes
1909 cmd = Com_SkipCharset( cmd, " \"" );
1910
1911 Cmd_TokenizeStringIgnoreQuotes( cmd );
1912 completionArgument = Cmd_Argc();
1913
1914 // If there is trailing whitespace on the cmd
1915 if ( *(cmd + strlen( cmd )-1) == ' ' ) {
1916 completionString = "";
1917 completionArgument++;
1918 }
1919 else
1920 completionString = Cmd_Argv( completionArgument - 1 );
1921
1922 if ( completionArgument > 1 ) {
1923 const char *baseCmd = Cmd_Argv( 0 );
1924 char *p;
1925
1926#ifndef DEDICATED
1927 if ( baseCmd[0] == '\\' || baseCmd[0] == '/' )
1928 baseCmd++;
1929#endif
1930
1931 if( ( p = Field_FindFirstSeparator( cmd ) ) )
1932 Field_CompleteCommand( p + 1, qtrue, qtrue ); // Compound command
1933 else
1934 Cmd_CompleteArgument( baseCmd, cmd, completionArgument );
1935 }
1936 else {
1937 if ( completionString[0] == '\\' || completionString[0] == '/' )
1938 completionString++;
1939
1940 matchCount = 0;
1941 shortestMatch[ 0 ] = 0;
1942
1943 if ( strlen( completionString ) == 0 )
1944 return;
1945
1946 if ( doCommands )
1947 Cmd_CommandCompletion( FindMatches );
1948
1949 if ( doCvars )
1950 Cvar_CommandCompletion( FindMatches );
1951
1952 if ( !Field_Complete() ) {
1953 // run through again, printing matches
1954 if ( doCommands )
1955 Cmd_CommandCompletion( PrintMatches );
1956
1957 if ( doCvars )
1958 Cvar_CommandCompletion( PrintCvarMatches );
1959 }
1960 }
1961}

Callers 5

Field_AutoCompleteFunction · 0.70
Cmd_CompleteCmdNameFunction · 0.70
Cvar_CompleteCvarNameFunction · 0.70
Key_CompleteBindFunction · 0.50
CL_CompleteRconFunction · 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