From: Wouter V. <m97...@us...> - 2004-02-26 18:18:36
|
Update of /cvsroot/openmsx/openMSX/src/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20330/src/commands Modified Files: CommandController.cc Interpreter.hh TCLInterp.cc TCLInterp.hh Log Message: tab-completion for all TCL commands Index: CommandController.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/commands/CommandController.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- CommandController.cc 23 Feb 2004 18:19:13 -0000 1.19 +++ CommandController.cc 26 Feb 2004 18:10:29 -0000 1.20 @@ -318,10 +318,7 @@ if (tokens.size() == 1) { // build a list of all command strings set<string> cmds; - for (CompleterMap::const_iterator it = commandCompleters.begin(); - it != commandCompleters.end(); it++) { - cmds.insert(it->first); - } + interpreter.getCommandNames(cmds); completeString(tokens, cmds); } else { CompleterMap::const_iterator it = commandCompleters.find(tokens.front()); Index: Interpreter.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/commands/Interpreter.hh,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Interpreter.hh 23 Feb 2004 18:19:13 -0000 1.1 +++ Interpreter.hh 26 Feb 2004 18:10:30 -0000 1.2 @@ -3,7 +3,12 @@ #ifndef __INTERPRETER_HH__ #define __INTERPRETER_HH__ -#include <Command.hh> +#include <set> +#include <string> +#include "Command.hh" + +using std::set; +using std::string; namespace openmsx { @@ -17,6 +22,7 @@ virtual void init(const char* programName) = 0; virtual void registerCommand(const string& name, Command& command) = 0; virtual void unregisterCommand(const string& name, Command& command) = 0; + virtual void getCommandNames(set<string>& result) = 0; virtual bool isComplete(const string& command) const = 0; virtual string execute(const string& command) throw(CommandException) = 0; virtual string executeFile(const string& filename) throw(CommandException) = 0; Index: TCLInterp.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/commands/TCLInterp.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TCLInterp.cc 25 Feb 2004 17:05:11 -0000 1.3 +++ TCLInterp.cc 26 Feb 2004 18:10:30 -0000 1.4 @@ -70,6 +70,25 @@ } } +// Returns +// - build-in TCL commands +// - openmsx commands +// - user-defined procs +void TCLInterp::getCommandNames(set<string>& result) +{ + string list = execute("info commands"); + + int argc; + const char** argv; + if (Tcl_SplitList(interp, list.c_str(), &argc, &argv) != TCL_OK) { + return; + } + for (int i = 0; i < argc; ++i) { + result.insert(argv[i]); + } + Tcl_Free((char*)argv); +} + bool TCLInterp::isComplete(const string& command) const { return Tcl_CommandComplete(command.c_str()); Index: TCLInterp.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/commands/TCLInterp.hh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TCLInterp.hh 23 Feb 2004 18:19:13 -0000 1.3 +++ TCLInterp.hh 26 Feb 2004 18:10:30 -0000 1.4 @@ -25,6 +25,7 @@ virtual void init(const char* programName); virtual void registerCommand(const string& name, Command& command); virtual void unregisterCommand(const string& name, Command& command); + virtual void getCommandNames(set<string>& result); virtual bool isComplete(const string& command) const; virtual string execute(const string& command) throw(CommandException); virtual string executeFile(const string& filename) throw(CommandException); |