Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell_completion.h @ 7447

Last change on this file since 7447 was 7415, checked in by bensch, 19 years ago

orxonox/trunk: Super-good completion :), and extremely tired bensch

File size: 2.6 KB
RevLine 
[4838]1/*!
[5170]2 * @file shell_completion.h
3 * @brief The Shell Completion Tasks
[5371]4 *
5 * @todo if the second string is a Command, the third should not be completed!
6 * @todo also make some completion for registered (or special) Types
[3245]7*/
[1853]8
[5170]9#ifndef _SHELL_COMPLETION_H
10#define _SHELL_COMPLETION_H
[1853]11
[7373]12#include <vector>
[5779]13#include <list>
[7225]14#include <string>
[5779]15
[4838]16// FORWARD DECLARATION
[5178]17class BaseObject;
[3543]18
[7374]19namespace OrxShell
[7373]20{
[7413]21  class ShellCommand;
22
[7374]23  //! A class for Completing the an InputString.
24  class ShellCompletion
25  {
[7403]26      //! an enumerator for different types the Shell can complete.
27      typedef enum {
28        NullCompletion         = 0,
29        ClassCompletion        = 1,
30        ObjectCompletion       = 2,
31        FunctionCompletion     = 4,
32        AliasCompletion        = 8,
[7412]33        ParamCompletion        = 16,
[7374]34    } CompletionType;
[1853]35
[7403]36      //! A struct for ShellElements (these are used as containers to identify an Input for what it is)
37      struct CompletionElement
38      {
[7412]39        CompletionElement(std::string name, CompletionType type) : name(name), type(type) {}
[7403]40        std::string     name;     //!< the Name of the Element to be completed.
41        CompletionType  type;     //!< the type of the Element
42      };
[7371]43
[7403]44    public:
45      ShellCompletion();
46      virtual ~ShellCompletion();
[7371]47
[1853]48
[7403]49      // Functions to produce the Complete Lists.
50      bool autoComplete(std::string& input);
[7373]51
[7403]52      static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type);
[3245]53
[7403]54    private:
55      bool objectComplete(const std::string& objectBegin, long classID);
56      bool commandComplete(const std::string& commandBegin, const std::string& className);
57      bool aliasComplete(const std::string& aliasBegin);
[7415]58      bool paramComplete(const std::string& paramBegin, const ShellCommand* command, unsigned int paramNumber);
[5178]59
[7403]60      // Generally Completes.
61      bool generalComplete(std::string& input,
62                           const std::string& begin, const std::string& displayAs = "%s",
63                           const std::string& addBack = "", const std::string& addFront = "");
[7388]64
[5178]65
[7403]66      bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
67      bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
[7373]68
[7403]69      // Helpers.
70      void clearCompletionList();
[5245]71
[7403]72    private:
73      std::vector<CompletionElement>  completionList;          //!< A list of completions, that are io.
74
75      static const std::string        typeNames[];             //!< A list of Completion-Type-Names.
[7374]76  };
[7372]77
[7374]78}
[1853]79
[5170]80#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.