diff options
author | Stijn Buys <ingar@osirion.org> | 2008-02-09 12:19:25 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-02-09 12:19:25 +0000 |
commit | 23aee34002facf39b56d209320817375db3b6189 (patch) | |
tree | b94a4b8164ef28a56fc9e1cb71e50dc2f0abb0ca /src/core | |
parent | 2b6208917e92d93f94ad6620c5135d1bcd237ea8 (diff) |
load/save console input history
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/commandbuffer.cc | 28 |
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(); } } |