| 1 | /* |
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
|---|
| 3 | |
|---|
| 4 | Copyright (C) 2004 orx |
|---|
| 5 | |
|---|
| 6 | This program is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU General Public License as published by |
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
|---|
| 9 | any later version. |
|---|
| 10 | |
|---|
| 11 | ### File Specific: |
|---|
| 12 | main-programmer: Benjamin Grauer |
|---|
| 13 | co-programmer: ... |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL |
|---|
| 17 | |
|---|
| 18 | #include "shell_completion_plugin.h" |
|---|
| 19 | #include "shell_command_class.h" |
|---|
| 20 | |
|---|
| 21 | #include "shell_command.h" |
|---|
| 22 | |
|---|
| 23 | #include "substring.h" |
|---|
| 24 | #include "class_list.h" |
|---|
| 25 | #include "debug.h" |
|---|
| 26 | |
|---|
| 27 | namespace OrxShell |
|---|
| 28 | { |
|---|
| 29 | CompletorDefault::CompletorDefault(const MultiType* value) |
|---|
| 30 | :_value(value) |
|---|
| 31 | { } |
|---|
| 32 | |
|---|
| 33 | void CompletorDefault::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const |
|---|
| 34 | { |
|---|
| 35 | PRINT(0)("Requires '%s'\n", MultiType::MultiTypeToString(this->_value->getType()).c_str()); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | CompletorPlugin* CompletorDefault::clone() const |
|---|
| 39 | { |
|---|
| 40 | return new CompletorDefault(this->_value); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const |
|---|
| 48 | { |
|---|
| 49 | unsigned int inputLen = completionBegin.size(); |
|---|
| 50 | for (unsigned int i = 0; i < this->_size; ++i) |
|---|
| 51 | if (!nocaseCmp(this->_stringArray[i], completionBegin, inputLen)) |
|---|
| 52 | completionList.push_back(this->_stringArray[i]); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | CompletorPlugin* CompletorStringArray::clone() const |
|---|
| 56 | { |
|---|
| 57 | return new CompletorStringArray(this->_stringArray, this->_size); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | CompletorList::CompletorList(const std::list<std::string>* list) |
|---|
| 62 | { |
|---|
| 63 | this->_list = list; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | void CompletorList::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const |
|---|
| 67 | { |
|---|
| 68 | unsigned int inputLen = completionBegin.size(); |
|---|
| 69 | std::list<std::string>::const_iterator it; |
|---|
| 70 | for (it = this->_list->begin(); it != this->_list->end(); ++it) |
|---|
| 71 | if (!nocaseCmp((*it), completionBegin, inputLen)) |
|---|
| 72 | completionList.push_back(*it); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | CompletorPlugin* CompletorList::clone() const |
|---|
| 76 | { |
|---|
| 77 | return new CompletorList(this->_list); |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | CompletorFileSystem::CompletorFileSystem(const std::string& fileExtension, |
|---|
| 82 | StartDirectory startDir, |
|---|
| 83 | const std::string& subDir) |
|---|
| 84 | : _fileExtension(fileExtension), _startDir(startDir), _subDir(subDir) |
|---|
| 85 | { } |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const |
|---|
| 89 | { |
|---|
| 90 | if (completionBegin.empty()) // if we do not yet have the beginning of the line, start with the chosen startDir. |
|---|
| 91 | { |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | CompletorPlugin* CompletorFileSystem::clone() const |
|---|
| 97 | { |
|---|
| 98 | return new CompletorFileSystem(this->_fileExtension, this->_startDir, this->_subDir); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | } |
|---|
| 103 | |
|---|