summaryrefslogtreecommitdiff
path: root/indra/llui/lllineeditor.cpp
diff options
context:
space:
mode:
authorAdam Moss <moss@lindenlab.com>2009-04-16 23:45:35 +0000
committerAdam Moss <moss@lindenlab.com>2009-04-16 23:45:35 +0000
commitb01c75cb423f07a3d3354f8bd62f265f80062b3b (patch)
treedec1b220c24a60cc220d1cb07fd3545610644f0a /indra/llui/lllineeditor.cpp
parent868250bdd74f348557102c0d8408d9bec30331f6 (diff)
svn merge -r117314:117337
svn+ssh://svn.lindenlab.com/svn/linden/branches/moss/mv13a-merge-1 QAR-1343 maint-viewer-13a+libcurlexploitfix-3-3 combo merge
Diffstat (limited to 'indra/llui/lllineeditor.cpp')
-rw-r--r--indra/llui/lllineeditor.cpp97
1 files changed, 86 insertions, 11 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 6aa2aac48c..964254d93f 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -489,6 +489,9 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
// delay cursor flashing
mKeystrokeTimer.reset();
+ // take selection to 'primary' clipboard
+ updatePrimary();
+
return TRUE;
}
@@ -571,6 +574,17 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
return TRUE;
}
+BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+ // llinfos << "MiddleMouseDown" << llendl;
+ setFocus( TRUE );
+ if( canPastePrimary() )
+ {
+ setCursorAtLocalPos(x);
+ pastePrimary();
+ }
+ return TRUE;
+}
BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask)
{
@@ -665,6 +679,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask)
{
// delay cursor flashing
mKeystrokeTimer.reset();
+
+ // take selection to 'primary' clipboard
+ updatePrimary();
}
return handled;
@@ -868,7 +885,12 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask)
}
}
-
+ if(handled)
+ {
+ // take selection to 'primary' clipboard
+ updatePrimary();
+ }
+
return handled;
}
@@ -877,7 +899,7 @@ void LLLineEditor::deleteSelection()
if( !mReadOnly && hasSelection() )
{
S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
- S32 selection_length = abs( mSelectionStart - mSelectionEnd );
+ S32 selection_length = llabs( mSelectionStart - mSelectionEnd );
mText.erase(left_pos, selection_length);
deselect();
@@ -900,7 +922,7 @@ void LLLineEditor::cut()
S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
- S32 length = abs( mSelectionStart - mSelectionEnd );
+ S32 length = llabs( mSelectionStart - mSelectionEnd );
gClipboard.copyFromSubstring( mText.getWString(), left_pos, length );
deleteSelection();
@@ -931,7 +953,7 @@ void LLLineEditor::copy()
if( canCopy() )
{
S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
- S32 length = abs( mSelectionStart - mSelectionEnd );
+ S32 length = llabs( mSelectionStart - mSelectionEnd );
gClipboard.copyFromSubstring( mText.getWString(), left_pos, length );
}
}
@@ -941,20 +963,50 @@ BOOL LLLineEditor::canPaste() const
return !mReadOnly && gClipboard.canPasteString();
}
-
-// paste from clipboard
void LLLineEditor::paste()
{
- if (canPaste())
+ bool is_primary = false;
+ pasteHelper(is_primary);
+}
+
+void LLLineEditor::pastePrimary()
+{
+ bool is_primary = true;
+ pasteHelper(is_primary);
+}
+
+// paste from primary (is_primary==true) or clipboard (is_primary==false)
+void LLLineEditor::pasteHelper(bool is_primary)
+{
+ bool can_paste_it;
+ if (is_primary)
+ {
+ can_paste_it = canPastePrimary();
+ }
+ else
+ {
+ can_paste_it = canPaste();
+ }
+
+ if (can_paste_it)
{
- LLWString paste = gClipboard.getPasteWString();
+ LLWString paste;
+ if (is_primary)
+ {
+ paste = gClipboard.getPastePrimaryWString();
+ }
+ else
+ {
+ paste = gClipboard.getPasteWString();
+ }
+
if (!paste.empty())
{
// Prepare for possible rollback
LLLineEditorRollback rollback(this);
// Delete any selected characters
- if (hasSelection())
+ if ((!is_primary) && hasSelection())
{
deleteSelection();
}
@@ -990,7 +1042,7 @@ void LLLineEditor::paste()
clean_string = clean_string.substr(0, wchars_that_fit);
reportBadKeystroke();
}
-
+
mText.insert(getCursor(), clean_string);
setCursor( getCursor() + (S32)clean_string.length() );
deselect();
@@ -1011,7 +1063,30 @@ void LLLineEditor::paste()
}
}
-
+// copy selection to primary
+void LLLineEditor::copyPrimary()
+{
+ if( canCopy() )
+ {
+ S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
+ S32 length = llabs( mSelectionStart - mSelectionEnd );
+ gClipboard.copyFromPrimarySubstring( mText.getWString(), left_pos, length );
+ }
+}
+
+BOOL LLLineEditor::canPastePrimary() const
+{
+ return !mReadOnly && gClipboard.canPastePrimaryString();
+}
+
+void LLLineEditor::updatePrimary()
+{
+ if(canCopy() )
+ {
+ copyPrimary();
+ }
+}
+
BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
{
BOOL handled = FALSE;