Changeset 1436 for code/branches/console/src/core
- Timestamp:
- May 27, 2008, 3:01:49 AM (16 years ago)
- Location:
- code/branches/console/src/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/ArgumentCompleter.h
r1430 r1436 64 64 return (*this->function_5_)(param1, param2, param3, param4, param5); 65 65 default: 66 return (*this->function_0_)();66 return std::list<std::pair<std::string, std::string> >(); 67 67 } 68 68 } -
code/branches/console/src/core/ArgumentCompletionFunctions.cc
r1434 r1436 30 30 #include <map> 31 31 32 //#include <stdio.h> 33 //#include <stdlib.h> 34 //#include <errno.h> 35 //#include <sys/types.h> 36 //#include <sys/stat.h> 37 #include <dirent.h> 38 32 39 #include "ArgumentCompletionFunctions.h" 33 40 #include "CoreIncludes.h" … … 36 43 #include "TclThreadManager.h" 37 44 #include "util/String.h" 45 #include "util/SubString.h" 38 46 39 47 namespace orxonox … … 44 52 { 45 53 return std::list<std::pair<std::string, std::string> >(); 54 } 55 56 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment) 57 { 58 std::list<std::pair<std::string, std::string> > dirlist; 59 std::list<std::pair<std::string, std::string> > filelist; 60 61 SubString tokens(fragment, "/", "", false, '\0', false, '\0', false, '\0', '\0', false, '\0'); 62 63 std::string startdirectory = "."; 64 if (fragment.size() > 0 && fragment[fragment.size() - 1] == '/' && tokens.size() > 0) 65 startdirectory = tokens.subSet(0, tokens.size()).join("/"); 66 else if (tokens.size() > 1) 67 startdirectory = tokens.subSet(0, tokens.size() - 1).join("/"); 68 69 std::cout << "startdir: " << startdirectory << std::endl; 70 71 struct stat fileInfo; 72 struct dirent *currentFile; 73 DIR *handler = 0; 74 75 handler = opendir(startdirectory.c_str()); 76 if (handler) 77 { 78 while ((currentFile = readdir(handler)) != 0) 79 { 80 if (strcmp(currentFile->d_name, ".") && strcmp(currentFile->d_name, "..")) 81 { 82 std::string path = startdirectory + "/" + currentFile->d_name; 83 if (stat(path.c_str(), &fileInfo) == -1) 84 { 85 closedir(handler); 86 break; 87 } 88 89 if (S_ISREG(fileInfo.st_mode)) // normal file 90 filelist.push_back(std::pair<std::string, std::string>(getLowercase(path), path)); 91 else if (S_ISDIR(fileInfo.st_mode)) // directory 92 dirlist.push_back(std::pair<std::string, std::string>(getLowercase(path) + "/", path + "/")); 93 else // special file 94 filelist.push_back(std::pair<std::string, std::string>(getLowercase(path), path)); 95 } 96 } 97 98 closedir(handler); 99 } 100 101 filelist.insert(filelist.begin(), dirlist.begin(), dirlist.end()); 102 return filelist; 46 103 } 47 104 … … 57 114 } 58 115 59 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& classname)116 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname) 60 117 { 61 118 std::list<std::pair<std::string, std::string> > configvalues; … … 71 128 } 72 129 73 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& varname, const std::string& classname)130 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname) 74 131 { 75 132 std::list<std::pair<std::string, std::string> > oldvalue; -
code/branches/console/src/core/ArgumentCompletionFunctions.h
r1434 r1436 56 56 { 57 57 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)(); 58 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment); 58 59 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalueclasses)(); 59 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalues)(const std::string& classname);60 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalue)(const std::string& varname, const std::string& classname);60 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalues)(const std::string& fragment, const std::string& classname); 61 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname); 61 62 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(tclthreads)(); 62 63 } -
code/branches/console/src/core/CommandExecutor.cc
r1435 r1436 557 557 unsigned int lowestIndex = 1 + (CommandExecutor::getEvaluation().functionclass_ != 0); 558 558 559 for (unsigned int i = CommandExecutor::argumentsGiven() - 2; i >= lowestIndex; --i)559 for (unsigned int i = CommandExecutor::argumentsGiven() - 1; i >= lowestIndex; --i) 560 560 { 561 561 params[index] = CommandExecutor::getArgument(i); -
code/branches/console/src/core/ConfigFileManager.cc
r1435 r1436 42 42 SetConsoleCommandShortcutExtern(reloadConfig); 43 43 SetConsoleCommandShortcutExtern(cleanConfig); 44 SetConsoleCommandShortcutExtern(loadSettings) ;45 SetConsoleCommandShortcutExtern(loadKeybindings) ;44 SetConsoleCommandShortcutExtern(loadSettings).setArgumentCompleter(0, autocompletion::files()); 45 SetConsoleCommandShortcutExtern(loadKeybindings).setArgumentCompleter(0, autocompletion::files()); 46 46 47 47 bool config(const std::string& classname, const std::string& varname, const std::string& value) -
code/branches/console/src/core/ConsoleCommandCompilation.cc
r1341 r1436 34 34 namespace orxonox 35 35 { 36 SetConsoleCommandShortcutExtern(source) ;36 SetConsoleCommandShortcutExtern(source).setArgumentCompleter(0, autocompletion::files()); 37 37 SetConsoleCommandShortcutExtern(echo); 38 38 SetConsoleCommandShortcutExtern(puts); 39 39 40 SetConsoleCommandShortcutExtern(read) ;41 SetConsoleCommandShortcutExtern(append) ;42 SetConsoleCommandShortcutExtern(write) ;40 SetConsoleCommandShortcutExtern(read).setArgumentCompleter(0, autocompletion::files()); 41 SetConsoleCommandShortcutExtern(append).setArgumentCompleter(0, autocompletion::files()); 42 SetConsoleCommandShortcutExtern(write).setArgumentCompleter(0, autocompletion::files()); 43 43 44 44 SetConsoleCommandShortcutExtern(calculate);
Note: See TracChangeset
for help on using the changeset viewer.