|
|
@@ -927,24 +927,20 @@ String UITextInput::getSelectionText() {
|
|
|
return L"";
|
|
|
|
|
|
String totalText = L"";
|
|
|
- if(selectionTop == selectionBottom) {
|
|
|
- totalText = lines[selectionTop].substr(selectionL, selectionR-selectionL);
|
|
|
- return totalText;
|
|
|
- } else {
|
|
|
- totalText += lines[selectionTop].substr(selectionL, lines[selectionTop].length()-selectionL);
|
|
|
- totalText += L"\n";
|
|
|
- }
|
|
|
-
|
|
|
- if(selectionBottom > selectionTop+1) {
|
|
|
- for(int i=selectionTop+1; i < selectionBottom; i++) {
|
|
|
- totalText += lines[i];
|
|
|
- if(i != selectionBottom-1)
|
|
|
- totalText += L"\n";
|
|
|
- }
|
|
|
+
|
|
|
+ // Set up iteration cursors
|
|
|
+ int currentLine = selectionTop;
|
|
|
+ int currentLeft = selectionL;
|
|
|
+
|
|
|
+ // Iterate over the inner lines(we'll be appending \n to these)
|
|
|
+ while(currentLine < selectionBottom) {
|
|
|
+ totalText += lines[currentLine].substr(currentLeft, lines[currentLine].length()-currentLeft) + '\n';
|
|
|
+ currentLine++;
|
|
|
+ currentLeft = 0;
|
|
|
}
|
|
|
-
|
|
|
- totalText += lines[selectionBottom].substr(0, selectionL);
|
|
|
-
|
|
|
+ // Add the selection in the last line(no \n needed)
|
|
|
+ totalText += lines[currentLine].substr(currentLeft, selectionR-currentLeft);
|
|
|
+
|
|
|
return totalText;
|
|
|
}
|
|
|
|