aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lllineeditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/lllineeditor.cpp')
-rw-r--r--linden/indra/llui/lllineeditor.cpp83
1 files changed, 75 insertions, 8 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp
index 498ef26..f905774 100644
--- a/linden/indra/llui/lllineeditor.cpp
+++ b/linden/indra/llui/lllineeditor.cpp
@@ -493,6 +493,9 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
493 // delay cursor flashing 493 // delay cursor flashing
494 mKeystrokeTimer.reset(); 494 mKeystrokeTimer.reset();
495 495
496 // take selection to 'primary' clipboard
497 updatePrimary();
498
496 return TRUE; 499 return TRUE;
497} 500}
498 501
@@ -575,6 +578,17 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
575 return TRUE; 578 return TRUE;
576} 579}
577 580
581BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
582{
583 // llinfos << "MiddleMouseDown" << llendl;
584 setFocus( TRUE );
585 if( canPastePrimary() )
586 {
587 setCursorAtLocalPos(x);
588 pastePrimary();
589 }
590 return TRUE;
591}
578 592
579BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) 593BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask)
580{ 594{
@@ -669,6 +683,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask)
669 { 683 {
670 // delay cursor flashing 684 // delay cursor flashing
671 mKeystrokeTimer.reset(); 685 mKeystrokeTimer.reset();
686
687 // take selection to 'primary' clipboard
688 updatePrimary();
672 } 689 }
673 690
674 return handled; 691 return handled;
@@ -872,7 +889,12 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask)
872 } 889 }
873 } 890 }
874 891
875 892 if(handled)
893 {
894 // take selection to 'primary' clipboard
895 updatePrimary();
896 }
897
876 return handled; 898 return handled;
877} 899}
878 900
@@ -945,20 +967,42 @@ BOOL LLLineEditor::canPaste() const
945 return !mReadOnly && gClipboard.canPasteString(); 967 return !mReadOnly && gClipboard.canPasteString();
946} 968}
947 969
948
949// paste from clipboard
950void LLLineEditor::paste() 970void LLLineEditor::paste()
951{ 971{
952 if (canPaste()) 972 bool is_primary = false;
973 pasteHelper(is_primary);
974}
975
976void LLLineEditor::pastePrimary()
977{
978 bool is_primary = true;
979 pasteHelper(is_primary);
980}
981
982// paste from primary (is_primary==true) or clipboard (is_primary==false)
983void LLLineEditor::pasteHelper(bool is_primary)
984{
985 bool can_paste_it;
986 if (is_primary)
987 can_paste_it = canPastePrimary();
988 else
989 can_paste_it = canPaste();
990
991 if (can_paste_it)
953 { 992 {
954 LLWString paste = gClipboard.getPasteWString(); 993 LLWString paste;
994 if (is_primary)
995 paste = gClipboard.getPastePrimaryWString();
996 else
997 paste = gClipboard.getPasteWString();
998
955 if (!paste.empty()) 999 if (!paste.empty())
956 { 1000 {
957 // Prepare for possible rollback 1001 // Prepare for possible rollback
958 LLLineEditorRollback rollback(this); 1002 LLLineEditorRollback rollback(this);
959 1003
960 // Delete any selected characters 1004 // Delete any selected characters
961 if (hasSelection()) 1005 if ((!is_primary) && hasSelection())
962 { 1006 {
963 deleteSelection(); 1007 deleteSelection();
964 } 1008 }
@@ -994,7 +1038,7 @@ void LLLineEditor::paste()
994 clean_string = clean_string.substr(0, wchars_that_fit); 1038 clean_string = clean_string.substr(0, wchars_that_fit);
995 reportBadKeystroke(); 1039 reportBadKeystroke();
996 } 1040 }
997 1041
998 mText.insert(getCursor(), clean_string); 1042 mText.insert(getCursor(), clean_string);
999 setCursor( getCursor() + (S32)clean_string.length() ); 1043 setCursor( getCursor() + (S32)clean_string.length() );
1000 deselect(); 1044 deselect();
@@ -1015,7 +1059,30 @@ void LLLineEditor::paste()
1015 } 1059 }
1016} 1060}
1017 1061
1018 1062// copy selection to primary
1063void LLLineEditor::copyPrimary()
1064{
1065 if( canCopy() )
1066 {
1067 S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
1068 S32 length = abs( mSelectionStart - mSelectionEnd );
1069 gClipboard.copyFromPrimarySubstring( mText.getWString(), left_pos, length );
1070 }
1071}
1072
1073BOOL LLLineEditor::canPastePrimary() const
1074{
1075 return !mReadOnly && gClipboard.canPastePrimaryString();
1076}
1077
1078void LLLineEditor::updatePrimary()
1079{
1080 if(canCopy() )
1081 {
1082 copyPrimary();
1083 }
1084}
1085
1019BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) 1086BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
1020{ 1087{
1021 BOOL handled = FALSE; 1088 BOOL handled = FALSE;