You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/02/17 18:39:51 UTC
svn commit: r1783448 - in /pivot/branches/2.0.x: ./
wtk/src/org/apache/pivot/wtk/TextPane.java
Author: rwhitcomb
Date: Fri Feb 17 18:39:51 2017
New Revision: 1783448
URL: http://svn.apache.org/viewvc?rev=1783448&view=rev
Log:
PIVOT-992: Change the "getSelectedText" method of TextPane to just use the equivalent
call to "getText(start, finish)" instead of doing a "getSelectedRange()" and serializing
that. The results will be different in that if the selection doesn't actually encompass
an end of line, then the result will not contain a spurious newline.
The difference affects find/replace operations (for instance) that would be calling
"getSelectedText" and doing a find operation on a piece of text that doesn't actually
appear in the document (like "abc\n").
I suspect that this new method is actually a bit faster than the old way, although
that probably makes little to no difference in actual use.
This is a merge of revision 1783447 from "trunk" to "branches/2.0.x".
Modified:
pivot/branches/2.0.x/ (props changed)
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TextPane.java
Propchange: pivot/branches/2.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 17 18:39:51 2017
@@ -1 +1 @@
-/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175,1717360,1727931,1728247,1729480,1729493,1730100,1730108,1735181,1735282,1740570,1747445,1750549,1756534
+/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175,1717360,1727931,1728247,1729480,1729493,1730100,1730108,1735181,1735282,1740570,1747445,1750549,1756534,1783447
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TextPane.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TextPane.java?rev=1783448&r1=1783447&r2=1783448&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TextPane.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TextPane.java Fri Feb 17 18:39:51 2017
@@ -859,22 +859,7 @@ public class TextPane extends Container
* <tt>null</tt> if nothing is selected.
*/
public String getSelectedText() {
- String selectedText = null;
-
- if (selectionLength > 0) {
- Document selection = (Document)document.getRange(selectionStart, selectionLength);
-
- try {
- PlainTextSerializer serializer = new PlainTextSerializer();
- StringWriter writer = new StringWriter();
- serializer.writeObject(selection, writer);
- selectedText = writer.toString();
- } catch(IOException exception) {
- throw new RuntimeException(exception);
- }
- }
-
- return selectedText;
+ return selectionLength > 0 ? getText(selectionStart, selectionStart + selectionLength) : null;
}
/**