aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lltexteditor.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-10-18 17:58:27 -0700
committerMcCabe Maxsted2009-10-18 17:58:27 -0700
commite4b0e7c82d670081c071d8a3da31b5ec407b8e07 (patch)
tree9410962bbb582eedbec448139e217f2714050777 /linden/indra/llui/lltexteditor.cpp
parentStarted 1.3.0 branch (diff)
parentUpdated and added some Linux libs. (diff)
downloadmeta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.zip
meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.gz
meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.bz2
meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.xz
Merged working branch of 1.2 into LL 1.23 merge
Diffstat (limited to 'linden/indra/llui/lltexteditor.cpp')
-rw-r--r--linden/indra/llui/lltexteditor.cpp97
1 files changed, 90 insertions, 7 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp
index ccdf44b..32106f1 100644
--- a/linden/indra/llui/lltexteditor.cpp
+++ b/linden/indra/llui/lltexteditor.cpp
@@ -1205,6 +1205,18 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
1205} 1205}
1206 1206
1207 1207
1208BOOL LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
1209{
1210 setFocus( TRUE );
1211 if( canPastePrimary() )
1212 {
1213 setCursorAtLocalPos( x, y, TRUE );
1214 pastePrimary();
1215 }
1216 return TRUE;
1217}
1218
1219
1208BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) 1220BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask)
1209{ 1221{
1210 BOOL handled = FALSE; 1222 BOOL handled = FALSE;
@@ -1327,6 +1339,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
1327 endSelection(); 1339 endSelection();
1328 1340
1329 updateScrollFromCursor(); 1341 updateScrollFromCursor();
1342
1343 // take selection to primary clipboard
1344 updatePrimary();
1330 } 1345 }
1331 1346
1332 if( !hasSelection() ) 1347 if( !hasSelection() )
@@ -1334,6 +1349,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
1334 handleMouseUpOverSegment( x, y, mask ); 1349 handleMouseUpOverSegment( x, y, mask );
1335 } 1350 }
1336 1351
1352 // take selection to 'primary' clipboard
1353 updatePrimary();
1354
1337 handled = TRUE; 1355 handled = TRUE;
1338 } 1356 }
1339 1357
@@ -1396,8 +1414,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
1396 // delay cursor flashing 1414 // delay cursor flashing
1397 resetKeystrokeTimer(); 1415 resetKeystrokeTimer();
1398 1416
1417 // take selection to 'primary' clipboard
1418 updatePrimary();
1419
1399 handled = TRUE; 1420 handled = TRUE;
1400 } 1421 }
1422
1401 return handled; 1423 return handled;
1402} 1424}
1403 1425
@@ -1693,6 +1715,12 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask)
1693 } 1715 }
1694 } 1716 }
1695 1717
1718 if( handled )
1719 {
1720 // take selection to 'primary' clipboard
1721 updatePrimary();
1722 }
1723
1696 return handled; 1724 return handled;
1697} 1725}
1698 1726
@@ -1872,22 +1900,46 @@ BOOL LLTextEditor::canPaste() const
1872 return !mReadOnly && gClipboard.canPasteString(); 1900 return !mReadOnly && gClipboard.canPasteString();
1873} 1901}
1874 1902
1875
1876// paste from clipboard 1903// paste from clipboard
1877void LLTextEditor::paste() 1904void LLTextEditor::paste()
1878{ 1905{
1879 if (!canPaste()) 1906 bool is_primary = false;
1907 pasteHelper(is_primary);
1908}
1909
1910// paste from primary
1911void LLTextEditor::pastePrimary()
1912{
1913 bool is_primary = true;
1914 pasteHelper(is_primary);
1915}
1916
1917// paste from primary (itsprimary==true) or clipboard (itsprimary==false)
1918void LLTextEditor::pasteHelper(bool is_primary)
1919{
1920 bool can_paste_it;
1921 if (is_primary)
1922 can_paste_it = canPastePrimary();
1923 else
1924 can_paste_it = canPaste();
1925
1926 if (!can_paste_it)
1880 { 1927 {
1881 return; 1928 return;
1882 } 1929 }
1883 LLUUID source_id; 1930 LLUUID source_id;
1884 LLWString paste = gClipboard.getPasteWString(&source_id); 1931 LLWString paste;
1932 if (is_primary)
1933 paste = gClipboard.getPastePrimaryWString(&source_id);
1934 else
1935 paste = gClipboard.getPasteWString(&source_id);
1936
1885 if (paste.empty()) 1937 if (paste.empty())
1886 { 1938 {
1887 return; 1939 return;
1888 } 1940 }
1889 // Delete any selected characters (the paste replaces them) 1941 // Delete any selected characters (the paste replaces them)
1890 if( hasSelection() ) 1942 if( (!is_primary) && hasSelection() )
1891 { 1943 {
1892 deleteSelection(TRUE); 1944 deleteSelection(TRUE);
1893 } 1945 }
@@ -1921,6 +1973,32 @@ void LLTextEditor::paste()
1921} 1973}
1922 1974
1923 1975
1976
1977// copy selection to primary
1978void LLTextEditor::copyPrimary()
1979{
1980 if( !canCopy() )
1981 {
1982 return;
1983 }
1984 S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
1985 S32 length = abs( mSelectionStart - mSelectionEnd );
1986 gClipboard.copyFromPrimarySubstring(mWText, left_pos, length, mSourceID);
1987}
1988
1989BOOL LLTextEditor::canPastePrimary() const
1990{
1991 return !mReadOnly && gClipboard.canPastePrimaryString();
1992}
1993
1994void LLTextEditor::updatePrimary()
1995{
1996 if (canCopy())
1997 {
1998 copyPrimary();
1999 }
2000}
2001
1924BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) 2002BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask)
1925{ 2003{
1926 BOOL handled = FALSE; 2004 BOOL handled = FALSE;
@@ -1996,6 +2074,11 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask)
1996 } 2074 }
1997 } 2075 }
1998 2076
2077 if (handled)
2078 {
2079 updatePrimary();
2080 }
2081
1999 return handled; 2082 return handled;
2000} 2083}
2001 2084
@@ -3537,9 +3620,9 @@ void LLTextEditor::appendColoredText(const std::string &new_text,
3537} 3620}
3538 3621
3539void LLTextEditor::appendStyledText(const std::string &new_text, 3622void LLTextEditor::appendStyledText(const std::string &new_text,
3540 bool allow_undo, 3623 bool allow_undo,
3541 bool prepend_newline, 3624 bool prepend_newline,
3542 LLStyleSP stylep) 3625 const LLStyleSP stylep)
3543{ 3626{
3544 S32 part = (S32)LLTextParser::WHOLE; 3627 S32 part = (S32)LLTextParser::WHOLE;
3545 if(mParseHTML) 3628 if(mParseHTML)
@@ -3576,7 +3659,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text,
3576 3659
3577 html->setLinkHREF(text.substr(start,end-start)); 3660 html->setLinkHREF(text.substr(start,end-start));
3578 appendText(text.substr(start, end-start),allow_undo, prepend_newline, html); 3661 appendText(text.substr(start, end-start),allow_undo, prepend_newline, html);
3579 if (end < (S32)text.length()) 3662 if (end < (S32)text.length())
3580 { 3663 {
3581 text = text.substr(end,text.length() - end); 3664 text = text.substr(end,text.length() - end);
3582 end=0; 3665 end=0;