[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src playturn.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src playturn.cpp |
Date: |
Sat, 04 Jun 2005 19:21:06 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/06/04 23:21:06
Modified files:
src : playturn.cpp
Log message:
made tab-completion case insensitive and can tab-complete on observers
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.380&tr2=1.381&r1=text&r2=text
Patches:
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.380 wesnoth/src/playturn.cpp:1.381
--- wesnoth/src/playturn.cpp:1.380 Sat Jun 4 19:16:05 2005
+++ wesnoth/src/playturn.cpp Sat Jun 4 23:21:06 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.380 2005/06/04 19:16:05 ott Exp $ */
+/* $Id: playturn.cpp,v 1.381 2005/06/04 23:21:06 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -2935,6 +2935,15 @@
}
close_textbox();
+}
+
+namespace {
+
+bool tab_complete(const std::string& partword, const std::string& name)
+{
+ return name.size() >= partword.size() &&
std::equal(partword.begin(),partword.end(),name.begin(),chars_equal_insensitive);
+}
+
}
void turn_info::tab_textbox()
@@ -2973,24 +2982,24 @@
}
const unit_map::const_iterator leader =
team_leader(n+1,units_);
if(leader != units_.end()) {
- const std::string name =
leader->second.description();
- if(name.find(semiword) == 0) {
- if(guess.size() == 0) {
- guess = name;
- }else{
- size_t i;
- for(i=0; (i < guess.size()) ||
(i < name.size()); i++) {
- if(guess[i] != name[i])
{
- break;
- }
- }
- guess.assign(guess,0,i);
- }
+ const std::string& name =
leader->second.description();
+ if(tab_complete(semiword,name)) {
+ guess = name;
}
}
+ }
+
+ if(guess.empty()) {
+ const std::set<std::string>& observers =
gui_.observers();
+ for(std::set<std::string>::const_iterator i =
observers.begin(); i != observers.end(); ++i) {
+ if(tab_complete(semiword,*i)) {
+ guess = *i;
+ break;
+ }
+ }
}
- if(guess.size() != 0) {
+ if(guess.empty() == false) {
std::string add = beginning ? ": " : " ";
text.replace(last_space+1, semiword.size(), guess +
add);
textbox_.box->set_text(text);
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, Jon Daniel, 2005/06/03
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, Jon Daniel, 2005/06/03
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, Jon Daniel, 2005/06/03
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, Jon Daniel, 2005/06/03
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, Jon Daniel, 2005/06/03
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, David White, 2005/06/03
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp,
David White <=
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, David White, 2005/06/19
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp, Yann Dirson, 2005/06/21