Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/ArgumentCompleter


Ignore:
Timestamp:
Oct 7, 2008, 1:58:32 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/ArgumentCompleter

    v1 v1  
     1= !ArgumentCompleter =
     2[[TracNav(TracNav/TOC_Development)]]
     3
     4
     5== Description ==
     6The !ArgumentCompleter returns a list of possible arguments for a [wiki:ConsoleCommand]. This is achieved by calling a function which returns an [wiki:ArgumentCompletionList]. These functions are defined in [wiki:ArgumentCompletionFunctions].
     7
     8An !ArgumentCompleter can be assigned to every argument of a !ConsoleCommand:
     9{{{
     10SetConsoleCommand(ClassName, functionname, bShortcut)
     11  .argumentCompleter(param-nr (0-4), autocompletion::ac_function());
     12}}}
     13''ac_function'' is one of the defined functions in [wiki:ArgumentCompletionFunctions]. If the given !ConsoleCommand is typed into the [wiki:Shell] and '''complete()''' is called in the [wiki:CommandExecutor], a list of the possible arguments is displayed in the Shell.
     14
     15The returned list may depend on the already given set of arguments (including the currently typed argument). This allows to return, for example, all [wiki:HowTo/ConfigValue config-values] of a given class, where the classname is the first argument and the name of the config-value the second argument.
     16
     17== Examples ==
     18 * Classnames:
     19{{{
     20SCC(...).argumentCompleter(0, autocompletion::classnames());
     21
     22> command-name a
     23}}}
     24    In this example the !ArgumentCompleter returns a list of all classnames starting with "a".
     25
     26 * Config-values:
     27{{{
     28SCC(...).argumentCompleter(0, autocompletion::configvalueclasses())
     29        .argumentCompleter(1, autocompletion::configvalues());
     30
     31> command-name classname b
     32}}}
     33    Now the ArgumentCompleter gets called with "classname" and "b" and returns a list of all config-values of "classname" starting with "b".
     34
     35 * Filesystem:
     36{{{
     37SCC(...).argumentCompleter(0, autocompletion::files());
     38
     39> command-name ./directory/c
     40}}}
     41    In this example, the !ArgumentCompleter gets called with "./directory/c" and returns a list of files in the directory "./directory" starting with "c"