Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-09 23:06:00 +0000
committerStijn Buys <ingar@osirion.org>2008-02-09 23:06:00 +0000
commit31959bc355c471c573828bf63932850e46c4b5bc (patch)
treecc473901e88926e36c89775a7fc97a51da948498 /src/core/commandbuffer.cc
parentd281384f727583b39b8e97ffea58b278ecc8dd47 (diff)
more entities
Diffstat (limited to 'src/core/commandbuffer.cc')
-rw-r--r--src/core/commandbuffer.cc37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index 965f428..c381d38 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -17,16 +17,17 @@ namespace core
std::stringstream cmd(std::stringstream::in | std::stringstream::out);
-namespace commandbuffer {
+namespace commandbuffer
+{
void exec(const char *text)
{
std::stringstream cmdstream(text);
std::string cmdname;
-
+
if (!(cmdstream >> cmdname))
return;
-
+
// is it a function
Func f = func::find(cmdname);
if (f) {
@@ -34,7 +35,7 @@ void exec(const char *text)
f(cmdstream);
return;
}
-
+
// is it a cvar
Cvar cv = cvar::find(cmdname);
if (cv) {
@@ -43,15 +44,15 @@ void exec(const char *text)
if (cmdstream >> args) {
// we're setting a new value
char c;
- while(cmdstream >> c)
+ while (cmdstream >> c)
args += c;
(*cv) = args;
}
-
+
con_print << cmdname << " " << cv->text() << std::endl;
return;
}
-
+
con_print << "Unknown command '" << cmdname << "'" << std::endl;
}
@@ -59,12 +60,12 @@ void execute()
{
if (core::cmd.eof())
return;
-
+
char line[MAXCMDSIZE];
while (core::cmd.getline(line, MAXCMDSIZE-1)) {
exec(line);
}
-
+
cmd.clear();
}
@@ -74,14 +75,14 @@ void clear()
while (core::cmd.getline(line, MAXCMDSIZE-1));
}
-void complete(std::string &input, size_t &pos)
+void complete(std::string &input, size_t &pos)
{
std::list<std::string> match;
-
+
std::string partial = input.substr(0, pos);
if (!partial.size())
return;
-
+
// search function registry for matches
std::map<std::string, Func>::iterator f;
for (f = func::registry.begin(); f != func::registry.end(); f++) {
@@ -90,7 +91,7 @@ void complete(std::string &input, size_t &pos)
//con_print << " " << (*f).first << std::endl;
}
}
-
+
// search cvar registry for matches
std::map<std::string, Cvar>::iterator c;
for (c = cvar::registry.begin(); c != cvar::registry.end(); c++) {
@@ -99,12 +100,12 @@ void complete(std::string &input, size_t &pos)
//con_print << " " << (*c).first << std::endl;
}
}
-
+
if (!match.size())
return;
-
+
std::string maxmatch(*match.begin());
-
+
if (match.size() > 1) {
std::list<std::string>::iterator l;
for (l = match.begin(); l !=match.end(); l++) {
@@ -121,13 +122,13 @@ void complete(std::string &input, size_t &pos)
con_print << match.size() << " matches" << std::endl;
}
-
+
if (maxmatch.size() > partial.size()) {
if (match.size()==1) maxmatch += ' ';
input.replace(0, pos, maxmatch);
pos = maxmatch.size();
}
-
+
}
} // namespace commandbuffer