[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] | 17 | class BaseObject; |
---|
[3543] | 18 | |
---|
[7374] | 19 | namespace OrxShell |
---|
[7373] | 20 | { |
---|
[7374] | 21 | //! A class for Completing the an InputString. |
---|
| 22 | class ShellCompletion |
---|
| 23 | { |
---|
| 24 | //! an enumerator for different types the Shell can complete. |
---|
| 25 | typedef enum { |
---|
| 26 | NullCompletion = 0, |
---|
| 27 | ClassCompletion = 1, |
---|
| 28 | ObjectCompletion = 2, |
---|
| 29 | FunctionCompletion = 4, |
---|
| 30 | AliasCompletion = 8, |
---|
| 31 | } CompletionType; |
---|
[1853] | 32 | |
---|
[7374] | 33 | //! A struct for ShellElements (these are used as containers to identify an Input for what it is) |
---|
| 34 | struct CompletionElement |
---|
| 35 | { |
---|
| 36 | std::string name; //!< the Name of the Element to be completed. |
---|
| 37 | CompletionType type; //!< the type of the Element |
---|
| 38 | }; |
---|
[7371] | 39 | |
---|
[7374] | 40 | public: |
---|
| 41 | ShellCompletion(); |
---|
| 42 | virtual ~ShellCompletion(); |
---|
[7371] | 43 | |
---|
[1853] | 44 | |
---|
[7374] | 45 | // Functions to produce the Complete Lists. |
---|
| 46 | bool autoComplete(std::string& input); |
---|
| 47 | bool classComplete(const std::string& classBegin); |
---|
| 48 | // long classMatch(const char* input, unsigned int* length); |
---|
| 49 | bool objectComplete(const std::string& objectBegin, long classID); |
---|
| 50 | // bool objectMatch(const char* objectBegin, long classID, unsigned int* length); |
---|
| 51 | bool functionComplete(const std::string& functionBegin, const std::string& className); |
---|
| 52 | // bool functionMatch(const char* functionBegin, long classID, unsigned int* length); |
---|
| 53 | bool aliasComplete(const std::string& aliasBegin); |
---|
[7373] | 54 | |
---|
[7374] | 55 | bool generalComplete(std::string& input, |
---|
| 56 | const std::string& begin, const std::string& displayAs = "%s", |
---|
| 57 | const std::string& addBack = "", const std::string& addFront = ""); |
---|
[3245] | 58 | |
---|
[5178] | 59 | |
---|
[7374] | 60 | bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); |
---|
| 61 | bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); |
---|
| 62 | void clearCompletionList(); |
---|
[5178] | 63 | |
---|
[7371] | 64 | |
---|
[7374] | 65 | // Helpers. |
---|
| 66 | static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type); |
---|
[7373] | 67 | |
---|
[7374] | 68 | private: |
---|
| 69 | std::vector<CompletionElement> completionList; //!< A list of completions, that are io. |
---|
[5245] | 70 | |
---|
[7374] | 71 | static const std::string typeNames[]; //!< A list of Completion-Type-Names. |
---|
| 72 | }; |
---|
[7372] | 73 | |
---|
[7374] | 74 | } |
---|
[1853] | 75 | |
---|
[5170] | 76 | #endif /* _SHELL_COMPLETION_H */ |
---|