From 23aee34002facf39b56d209320817375db3b6189 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Feb 2008 12:19:25 +0000 Subject: load/save console input history --- src/core/commandbuffer.cc | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/core') 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::iterator l; - l = match.begin(); - input.replace(0, pos, (*l)); - pos = (*l).size(); - } else { - std::list::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(); } } -- cgit v1.2.3