[4744] | 1 | /* |
---|
[1853] | 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. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[5254] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[7374] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL |
---|
[1853] | 17 | |
---|
[7374] | 18 | #include "shell_completion_plugin.h" |
---|
[5639] | 19 | #include "shell_command_class.h" |
---|
[1853] | 20 | |
---|
[5194] | 21 | #include "shell_command.h" |
---|
[5181] | 22 | |
---|
[5183] | 23 | #include "substring.h" |
---|
[5178] | 24 | #include "class_list.h" |
---|
| 25 | #include "debug.h" |
---|
| 26 | |
---|
[7374] | 27 | namespace OrxShell |
---|
[5178] | 28 | { |
---|
[7407] | 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 |
---|
[5184] | 34 | { |
---|
[7409] | 35 | PRINT(0)("Requires '%s'\n", MultiType::MultiTypeToString(this->_value->getType()).c_str()); |
---|
[7407] | 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 | { |
---|
[7412] | 49 | printf("TEST\n"); |
---|
[7374] | 50 | unsigned int inputLen = completionBegin.size(); |
---|
| 51 | for (unsigned int i = 0; i < this->_size; ++i) |
---|
[7412] | 52 | { |
---|
| 53 | printf("%s\n", this->_stringArray[i].c_str()); |
---|
[7374] | 54 | if (!nocaseCmp(this->_stringArray[i], completionBegin, inputLen)) |
---|
| 55 | completionList.push_back(this->_stringArray[i]); |
---|
[7412] | 56 | } |
---|
[5184] | 57 | } |
---|
| 58 | |
---|
[7407] | 59 | CompletorPlugin* CompletorStringArray::clone() const |
---|
| 60 | { |
---|
| 61 | return new CompletorStringArray(this->_stringArray, this->_size); |
---|
| 62 | } |
---|
[7387] | 63 | |
---|
| 64 | |
---|
| 65 | CompletorList::CompletorList(const std::list<std::string>* list) |
---|
| 66 | { |
---|
| 67 | this->_list = list; |
---|
| 68 | } |
---|
| 69 | |
---|
[7407] | 70 | void CompletorList::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const |
---|
[7387] | 71 | { |
---|
| 72 | unsigned int inputLen = completionBegin.size(); |
---|
| 73 | std::list<std::string>::const_iterator it; |
---|
| 74 | for (it = this->_list->begin(); it != this->_list->end(); ++it) |
---|
| 75 | if (!nocaseCmp((*it), completionBegin, inputLen)) |
---|
| 76 | completionList.push_back(*it); |
---|
| 77 | } |
---|
| 78 | |
---|
[7407] | 79 | CompletorPlugin* CompletorList::clone() const |
---|
| 80 | { |
---|
| 81 | return new CompletorList(this->_list); |
---|
| 82 | } |
---|
[7387] | 83 | |
---|
| 84 | |
---|
[7377] | 85 | CompletorFileSystem::CompletorFileSystem(const std::string& fileExtension, |
---|
| 86 | StartDirectory startDir, |
---|
| 87 | const std::string& subDir) |
---|
| 88 | : _fileExtension(fileExtension), _startDir(startDir), _subDir(subDir) |
---|
| 89 | { } |
---|
| 90 | |
---|
[7387] | 91 | |
---|
[7407] | 92 | void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const |
---|
[7377] | 93 | { |
---|
| 94 | if (completionBegin.empty()) // if we do not yet have the beginning of the line, start with the chosen startDir. |
---|
| 95 | { |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | } |
---|
| 99 | } |
---|
[7407] | 100 | CompletorPlugin* CompletorFileSystem::clone() const |
---|
| 101 | { |
---|
| 102 | return new CompletorFileSystem(this->_fileExtension, this->_startDir, this->_subDir); |
---|
| 103 | } |
---|
[7377] | 104 | |
---|
[7407] | 105 | |
---|
[7377] | 106 | } |
---|
| 107 | |
---|