aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llchatbar.cpp42
-rw-r--r--linden/indra/newview/llchatbar.h2
2 files changed, 20 insertions, 24 deletions
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp
index 19ac2ab..e393342 100644
--- a/linden/indra/newview/llchatbar.cpp
+++ b/linden/indra/newview/llchatbar.cpp
@@ -122,6 +122,8 @@ LLChatBar::LLChatBar()
122 mCompletionHolder.current_index = 0; 122 mCompletionHolder.current_index = 0;
123 mCompletionHolder.last_match = ""; 123 mCompletionHolder.last_match = "";
124 mCompletionHolder.last_txt = ""; 124 mCompletionHolder.last_txt = "";
125 mCompletionHolder.cursorPos = -1;
126 mCompletionHolder.selected = false;
125 127
126 #if !LL_RELEASE_FOR_DOWNLOAD 128 #if !LL_RELEASE_FOR_DOWNLOAD
127 childDisplayNotFound(); 129 childDisplayNotFound();
@@ -227,16 +229,17 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
227 229
228 if (!avatar_ids.empty() && !txt.empty()) 230 if (!avatar_ids.empty() && !txt.empty())
229 { 231 {
230 S32 cursorPos = mInputEditor->getCursor(); 232 if (mCompletionHolder.cursorPos == -1) // Ele: cache cursor position
233 mCompletionHolder.cursorPos = mInputEditor->getCursor();
231 234
232 if (mCompletionHolder.last_txt != mInputEditor->getText()) 235 if (mCompletionHolder.last_txt != mInputEditor->getText())
233 { 236 {
234 mCompletionHolder.last_txt = std::string(mInputEditor->getText()); 237 mCompletionHolder.last_txt = std::string(mInputEditor->getText());
235 238
236 if (cursorPos < (S32)txt.length()) 239 if (mCompletionHolder.cursorPos < (S32)txt.length())
237 { 240 {
238 mCompletionHolder.right = txt.substr(cursorPos); 241 mCompletionHolder.right = txt.substr(mCompletionHolder.cursorPos);
239 mCompletionHolder.left = txt.substr(0, cursorPos); 242 mCompletionHolder.left = txt.substr(0, mCompletionHolder.cursorPos);
240 mCompletionHolder.match = std::string(mCompletionHolder.left); 243 mCompletionHolder.match = std::string(mCompletionHolder.left);
241 } 244 }
242 else 245 else
@@ -265,24 +268,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
265 { 268 {
266 if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) 269 if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull())
267 continue; 270 continue;
268/*
269 // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :(
270 LLVector3d real_pos = positions[i];
271 if (real_pos[2] == 0.0f)
272 {
273 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
274 if (av_obj != NULL && av_obj->isAvatar())
275 {
276 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
277 if (avatarp != NULL)
278 real_pos = avatarp->getPositionGlobal();
279 }
280 }
281 271
282 F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal()));
283 if (dist > CHAT_SHOUT_RADIUS)
284 continue;
285*/
286 std::string agent_name = " "; 272 std::string agent_name = " ";
287 std::string agent_surname = " "; 273 std::string agent_surname = " ";
288 274
@@ -308,15 +294,22 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
308 std::string current_name = mCompletionHolder.names[mCompletionHolder.current_index]; 294 std::string current_name = mCompletionHolder.names[mCompletionHolder.current_index];
309 295
310 mInputEditor->setText(mCompletionHolder.left.substr(0, mCompletionHolder.left.length() - mCompletionHolder.match.length()) + current_name + mCompletionHolder.right); 296 mInputEditor->setText(mCompletionHolder.left.substr(0, mCompletionHolder.left.length() - mCompletionHolder.match.length()) + current_name + mCompletionHolder.right);
311 mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - mCompletionHolder.match.length())); 297 mInputEditor->setCursor(mCompletionHolder.cursorPos + (current_name.length() - mCompletionHolder.match.length()));
298 mInputEditor->setSelection(mCompletionHolder.cursorPos, mCompletionHolder.cursorPos + (current_name.length() - mCompletionHolder.match.length()));
312 299
313 mCompletionHolder.current_index++; 300 mCompletionHolder.current_index++;
301 mCompletionHolder.selected = TRUE;
314 302
315 return TRUE; 303 return TRUE;
316 } 304 }
317 } 305 }
318 } 306 }
319 } 307 }
308 else
309 {
310 mCompletionHolder.cursorPos = -1;
311 mInputEditor->deselect();
312 }
320 313
321 return handled; 314 return handled;
322} 315}
@@ -663,6 +656,9 @@ void LLChatBar::stopChat()
663void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) 656void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
664{ 657{
665 LLChatBar* self = (LLChatBar *)userdata; 658 LLChatBar* self = (LLChatBar *)userdata;
659 KEY key = gKeyboard->currentKey();
660
661 self->mCompletionHolder.cursorPos = -1; // Ele: reset cached cursor pos for autocompletion
666 662
667 LLWString raw_text; 663 LLWString raw_text;
668 if (self->mInputEditor) raw_text = self->mInputEditor->getWText(); 664 if (self->mInputEditor) raw_text = self->mInputEditor->getWText();
@@ -707,8 +703,6 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
707 } 703 }
708 */ 704 */
709 705
710 KEY key = gKeyboard->currentKey();
711
712 // Ignore "special" keys, like backspace, arrows, etc. 706 // Ignore "special" keys, like backspace, arrows, etc.
713 if (length > 1 && raw_text[0] == '/' && key < KEY_SPECIAL) 707 if (length > 1 && raw_text[0] == '/' && key < KEY_SPECIAL)
714 { 708 {
diff --git a/linden/indra/newview/llchatbar.h b/linden/indra/newview/llchatbar.h
index 5542d8a..3e7ee03 100644
--- a/linden/indra/newview/llchatbar.h
+++ b/linden/indra/newview/llchatbar.h
@@ -54,6 +54,8 @@ struct CompletionHolder {
54 std::string last_txt; 54 std::string last_txt;
55 std::string last_match; 55 std::string last_match;
56 int current_index; 56 int current_index;
57 S32 cursorPos;
58 BOOL selected;
57}; 59};
58 60
59class LLChatBar 61class LLChatBar