diff options
author | McCabe Maxsted | 2010-09-12 22:43:47 -0700 |
---|---|---|
committer | McCabe Maxsted | 2010-09-12 22:43:47 -0700 |
commit | c7f47c01e0af0f60871ae6f90c52597337b754c2 (patch) | |
tree | 47acf1921acfab32d3a2226ee6fb20f9e817a1db | |
parent | Applied patch by Makomk Makosen for #515: Uninitialized pointer mNextAudioSes... (diff) | |
parent | Added ' support for punctuation matching (diff) | |
download | meta-impy-c7f47c01e0af0f60871ae6f90c52597337b754c2.zip meta-impy-c7f47c01e0af0f60871ae6f90c52597337b754c2.tar.gz meta-impy-c7f47c01e0af0f60871ae6f90c52597337b754c2.tar.bz2 meta-impy-c7f47c01e0af0f60871ae6f90c52597337b754c2.tar.xz |
Merge remote branch 'elektra/weekly' into weekly
-rw-r--r-- | linden/indra/newview/llchatbar.cpp | 81 | ||||
-rw-r--r-- | linden/indra/newview/llfloaterchat.cpp | 2 |
2 files changed, 77 insertions, 6 deletions
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index dc67448..88ef2b5 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp | |||
@@ -71,6 +71,8 @@ | |||
71 | 71 | ||
72 | #include "chatbar_as_cmdline.h" | 72 | #include "chatbar_as_cmdline.h" |
73 | 73 | ||
74 | #include "boost/regex.hpp" | ||
75 | |||
74 | // | 76 | // |
75 | // Globals | 77 | // Globals |
76 | // | 78 | // |
@@ -199,12 +201,83 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) | |||
199 | } | 201 | } |
200 | } | 202 | } |
201 | // only do this in main chatbar | 203 | // only do this in main chatbar |
202 | else if ( KEY_ESCAPE == key && gChatBar == this) | 204 | else if (KEY_ESCAPE == key && mask == MASK_NONE && gChatBar == this) |
203 | { | 205 | { |
204 | stopChat(); | 206 | stopChat(); |
205 | |||
206 | handled = TRUE; | 207 | handled = TRUE; |
207 | } | 208 | } |
209 | else if (key == KEY_ESCAPE && mask == MASK_CONTROL && gChatBar == this) | ||
210 | { | ||
211 | if (mInputEditor) | ||
212 | { | ||
213 | std::vector<LLUUID> avatar_ids; | ||
214 | std::vector<LLVector3d> positions; | ||
215 | LLWorld::getInstance()->getAvatars(&avatar_ids, &positions); | ||
216 | |||
217 | if (!avatar_ids.empty()) | ||
218 | { | ||
219 | std::string txt(mInputEditor->getText()); | ||
220 | |||
221 | std::string to_match(txt); | ||
222 | std::string left_part = ""; | ||
223 | std::string right_part = ""; | ||
224 | S32 cursorPos = mInputEditor->getCursor(); | ||
225 | |||
226 | if (cursorPos < txt.length()) | ||
227 | { | ||
228 | right_part = txt.substr(cursorPos); | ||
229 | left_part = txt.substr(0, cursorPos); | ||
230 | to_match = std::string(left_part); | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | to_match = std::string(txt); | ||
235 | left_part = txt; | ||
236 | } | ||
237 | |||
238 | std::string pattern_s = "(^|.*[\\.\\?!:;,\\*\\(\\s]+)([a-z0-9]+)$"; | ||
239 | boost::match_results<std::string::const_iterator> what; | ||
240 | boost::regex expression(pattern_s, boost::regex::icase); | ||
241 | if (boost::regex_search(to_match, what, expression, boost::match_extra)) | ||
242 | { | ||
243 | to_match = what[2]; | ||
244 | if (to_match.length() < 3) | ||
245 | return handled; | ||
246 | } | ||
247 | else | ||
248 | return handled; | ||
249 | |||
250 | for (U32 i=0; i<avatar_ids.size(); i++) | ||
251 | { | ||
252 | if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) | ||
253 | continue; | ||
254 | /* | ||
255 | // Commented out for now... doesn't work above 1024 meters as usual | ||
256 | F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); | ||
257 | if (dist > CHAT_NORMAL_RADIUS) | ||
258 | continue; | ||
259 | */ | ||
260 | |||
261 | std::string agent_name = " "; | ||
262 | std::string agent_surname = " "; | ||
263 | |||
264 | if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) | ||
265 | continue; | ||
266 | |||
267 | std::string test_name(agent_name); | ||
268 | std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); | ||
269 | |||
270 | if (test_name.find(to_match) == 0) | ||
271 | { | ||
272 | std::string rest_of_match = agent_name.substr(to_match.length(), agent_name.length()); | ||
273 | mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + agent_name + right_part); | ||
274 | mInputEditor->setSelection(cursorPos, cursorPos + rest_of_match.length()); | ||
275 | return TRUE; | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | } | ||
208 | 281 | ||
209 | return handled; | 282 | return handled; |
210 | } | 283 | } |
@@ -598,9 +671,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) | |||
598 | KEY key = gKeyboard->currentKey(); | 671 | KEY key = gKeyboard->currentKey(); |
599 | 672 | ||
600 | // Ignore "special" keys, like backspace, arrows, etc. | 673 | // Ignore "special" keys, like backspace, arrows, etc. |
601 | if (length > 1 | 674 | if (length > 1 && raw_text[0] == '/' && key < KEY_SPECIAL) |
602 | && raw_text[0] == '/' | ||
603 | && key < KEY_SPECIAL) | ||
604 | { | 675 | { |
605 | // we're starting a gesture, attempt to autocomplete | 676 | // we're starting a gesture, attempt to autocomplete |
606 | 677 | ||
diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index 1cf85de..b1c1356 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp | |||
@@ -456,7 +456,7 @@ void LLFloaterChat::updateSettings() | |||
456 | BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) | 456 | BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) |
457 | { | 457 | { |
458 | std::string my_name = gSavedSettings.getString("FirstName"); | 458 | std::string my_name = gSavedSettings.getString("FirstName"); |
459 | std::string pattern_s = "(^|.*[\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([,\\.\\?!:;\\*\\)\\s]+.*|$)"; | 459 | std::string pattern_s = "(^|.*[',\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([',\\.\\?!:;\\*\\)\\s]+.*|$)"; |
460 | boost::smatch what; | 460 | boost::smatch what; |
461 | boost::regex e1(pattern_s, boost::regex::icase); | 461 | boost::regex e1(pattern_s, boost::regex::icase); |
462 | 462 | ||