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