From 4d67fcc433be184429a6c70621d3368386bc01e2 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Sun, 12 Sep 2010 18:18:21 +0200 Subject: Fixed the regexp to match commas before the name --- linden/indra/newview/llfloaterchat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linden') diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index 1cf85de..c956aba 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp @@ -456,7 +456,7 @@ void LLFloaterChat::updateSettings() BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) { std::string my_name = gSavedSettings.getString("FirstName"); - std::string pattern_s = "(^|.*[\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([,\\.\\?!:;\\*\\)\\s]+.*|$)"; + std::string pattern_s = "(^|.*[,\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([,\\.\\?!:;\\*\\)\\s]+.*|$)"; boost::smatch what; boost::regex e1(pattern_s, boost::regex::icase); -- cgit v1.1 From 37aa6de0889eb864bbeba61341304b120a184eb0 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Mon, 13 Sep 2010 04:59:36 +0200 Subject: Initial support for names autocompletion in chat using ctrl-esc --- linden/indra/newview/llchatbar.cpp | 81 +++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 5 deletions(-) (limited to 'linden') 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 @@ #include "chatbar_as_cmdline.h" +#include "boost/regex.hpp" + // // Globals // @@ -199,12 +201,83 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) } } // only do this in main chatbar - else if ( KEY_ESCAPE == key && gChatBar == this) + else if (KEY_ESCAPE == key && mask == MASK_NONE && gChatBar == this) { stopChat(); - handled = TRUE; } + else if (key == KEY_ESCAPE && mask == MASK_CONTROL && gChatBar == this) + { + if (mInputEditor) + { + std::vector avatar_ids; + std::vector positions; + LLWorld::getInstance()->getAvatars(&avatar_ids, &positions); + + if (!avatar_ids.empty()) + { + std::string txt(mInputEditor->getText()); + + std::string to_match(txt); + std::string left_part = ""; + std::string right_part = ""; + S32 cursorPos = mInputEditor->getCursor(); + + if (cursorPos < txt.length()) + { + right_part = txt.substr(cursorPos); + left_part = txt.substr(0, cursorPos); + to_match = std::string(left_part); + } + else + { + to_match = std::string(txt); + left_part = txt; + } + + std::string pattern_s = "(^|.*[\\.\\?!:;,\\*\\(\\s]+)([a-z0-9]+)$"; + boost::match_results what; + boost::regex expression(pattern_s, boost::regex::icase); + if (boost::regex_search(to_match, what, expression, boost::match_extra)) + { + to_match = what[2]; + if (to_match.length() < 3) + return handled; + } + else + return handled; + + for (U32 i=0; i CHAT_NORMAL_RADIUS) + continue; +*/ + + std::string agent_name = " "; + std::string agent_surname = " "; + + if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) + continue; + + std::string test_name(agent_name); + std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); + + if (test_name.find(to_match) == 0) + { + std::string rest_of_match = agent_name.substr(to_match.length(), agent_name.length()); + mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + agent_name + right_part); + mInputEditor->setSelection(cursorPos, cursorPos + rest_of_match.length()); + return TRUE; + } + } + } + } + } return handled; } @@ -598,9 +671,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) KEY key = gKeyboard->currentKey(); // Ignore "special" keys, like backspace, arrows, etc. - if (length > 1 - && raw_text[0] == '/' - && key < KEY_SPECIAL) + if (length > 1 && raw_text[0] == '/' && key < KEY_SPECIAL) { // we're starting a gesture, attempt to autocomplete -- cgit v1.1 From 72faf5ba993d5540efda363ce935c46e9ff762d0 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Mon, 13 Sep 2010 05:00:58 +0200 Subject: Added ' support for punctuation matching --- linden/indra/newview/llfloaterchat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linden') diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index c956aba..b1c1356 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp @@ -456,7 +456,7 @@ void LLFloaterChat::updateSettings() BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) { std::string my_name = gSavedSettings.getString("FirstName"); - std::string pattern_s = "(^|.*[,\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([,\\.\\?!:;\\*\\)\\s]+.*|$)"; + std::string pattern_s = "(^|.*[',\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([',\\.\\?!:;\\*\\)\\s]+.*|$)"; boost::smatch what; boost::regex e1(pattern_s, boost::regex::icase); -- cgit v1.1