summaryrefslogtreecommitdiff
path: root/indra/newview/llgesturemgr.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2014-05-19 18:10:45 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2014-05-19 18:10:45 -0400
commit67051b26ba41a0d0cde2c2b96bccb0972d8ffe23 (patch)
tree4856017a193dd7a559bb3021670877f2eab5d155 /indra/newview/llgesturemgr.cpp
parenta5bb8839fa24fa0b7da331f14eedccea1b44bc84 (diff)
parent644ca6a0f8a7759119814f88df93b8e838321a12 (diff)
merge
Diffstat (limited to 'indra/newview/llgesturemgr.cpp')
-rwxr-xr-xindra/newview/llgesturemgr.cpp62
1 files changed, 59 insertions, 3 deletions
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index e1c81068bf..b15556d73d 100755
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -1344,6 +1344,7 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
{
S32 in_len = in_str.length();
+ //return whole trigger, if received text equals to it
item_map_t::iterator it;
for (it = mActive.begin(); it != mActive.end(); ++it)
{
@@ -1351,7 +1352,24 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
if (gesture)
{
const std::string& trigger = gesture->getTrigger();
-
+ if (!LLStringUtil::compareInsensitive(in_str, trigger))
+ {
+ *out_str = trigger;
+ return TRUE;
+ }
+ }
+ }
+
+ //return common chars, if more than one trigger matches the prefix
+ std::string rest_of_match = "";
+ std::string buf = "";
+ for (it = mActive.begin(); it != mActive.end(); ++it)
+ {
+ LLMultiGesture* gesture = (*it).second;
+ if (gesture)
+ {
+ const std::string& trigger = gesture->getTrigger();
+
if (in_len > (S32)trigger.length())
{
// too short, bail out
@@ -1362,11 +1380,49 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
LLStringUtil::truncate(trigger_trunc, in_len);
if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc))
{
- *out_str = trigger;
- return TRUE;
+ if (rest_of_match.compare("") == 0)
+ {
+ rest_of_match = trigger.substr(in_str.size());
+ }
+ std::string cur_rest_of_match = trigger.substr(in_str.size());
+ buf = "";
+ S32 i=0;
+
+ while (i<rest_of_match.length() && i<cur_rest_of_match.length())
+ {
+ if (rest_of_match[i]==cur_rest_of_match[i])
+ {
+ buf.push_back(rest_of_match[i]);
+ }
+ else
+ {
+ if(i==0)
+ {
+ rest_of_match = "";
+ }
+ break;
+ }
+ i++;
+ }
+ if (rest_of_match.compare("") == 0)
+ {
+ return FALSE;
+ }
+ if (buf.compare("") != 0)
+ {
+ rest_of_match = buf;
+ }
+
}
}
}
+
+ if (rest_of_match.compare("") != 0)
+ {
+ *out_str = in_str+rest_of_match;
+ return TRUE;
+ }
+
return FALSE;
}