FACT++  1.0
char * Readline::Complete ( const char *  text,
int  state 
)
protectedvirtual

Functions dealing with auto completion.

If fCompletion==0 the default is to call readline's rl_filename_completion_function. Otherwise the contents of fCompletion are returned. To change fCompletion either initialize it via SetCompletion() (in this case you must ensure the life time of the object) or call Complete(const vector<string>&, const char*) from Completion(const char * int, int)

This is the so called generator function, the readline manual says about this function:

The generator function is called repeatedly from rl_completion_matches(), returning a string each time. The arguments to the generator function are text and state. text is the partial word to be completed. state is zero the first time the function is called, allowing the generator to perform any necessary initialization, and a positive non-zero integer for each subsequent call. The generator function returns (char *)NULL to inform rl_completion_matches() that there are no more possibilities left. Usually the generator function computes the list of possible completions when state is zero, and returns them one at a time on subsequent calls. Each string the generator function returns as a match must be allocated with malloc(); Readline frees the strings when it has finished with them.

Definition at line 477 of file Readline.cc.

References Compare(), and fCompletion.

Referenced by CompleteImp(), and SetCompletion().

478 {
479  if (fCompletion==0)
480  return rl_filename_completion_function(text, state);
481 
482  static vector<string>::const_iterator pos;
483  if (state==0)
484  pos = fCompletion->begin();
485 
486  while (pos!=fCompletion->end())
487  {
488  char *rc = Compare(*pos++, text);
489  if (rc)
490  return rc;
491  }
492 
493  return 0;
494 }
static char * Compare(const std::string &str, const std::string &txt)
Definition: Readline.cc:409
const std::vector< std::string > * fCompletion
Pointer to a list of possible matched for auto-completion.
Definition: Readline.h:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function: