Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-09 12:19:25 +0000
committerStijn Buys <ingar@osirion.org>2008-02-09 12:19:25 +0000
commit23aee34002facf39b56d209320817375db3b6189 (patch)
treeb94a4b8164ef28a56fc9e1cb71e50dc2f0abb0ca /src/core
parent2b6208917e92d93f94ad6620c5135d1bcd237ea8 (diff)
load/save console input history
Diffstat (limited to 'src/core')
-rw-r--r--src/core/commandbuffer.cc28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index a46863c..965f428 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -102,16 +102,30 @@ void complete(std::string &input, size_t &pos)
if (!match.size())
return;
+
+ std::string maxmatch(*match.begin());
- if (match.size() == 1) {
+ if (match.size() > 1) {
std::list<std::string>::iterator l;
- l = match.begin();
- input.replace(0, pos, (*l));
- pos = (*l).size();
- } else {
- std::list<std::string>::iterator l;
- for (l = match.begin(); l !=match.end(); l++)
+ for (l = match.begin(); l !=match.end(); l++) {
+ if (maxmatch.size()) {
+ size_t i =0;
+ while ((i < maxmatch.size() && i < (*l).size()) && (maxmatch[i] == (*l)[i])) {
+ i++;
+ }
+ if (i < maxmatch.size())
+ maxmatch.erase(i);
+ }
con_print << " " << (*l) << std::endl;
+ }
+ 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();
}
}