| @@ -217,6 +217,7 @@ public: | |||||
| const String getAllText() const throw() | const String getAllText() const throw() | ||||
| { | { | ||||
| String s; | String s; | ||||
| s.preallocateStorage (getTotalLength()); | |||||
| for (int i = 0; i < atoms.size(); ++i) | for (int i = 0; i < atoms.size(); ++i) | ||||
| s += getAtom(i)->atomText; | s += getAtom(i)->atomText; | ||||
| @@ -294,8 +295,7 @@ private: | |||||
| while (i < len) | while (i < len) | ||||
| { | { | ||||
| const int start = i; | |||||
| int end = i; | |||||
| int start = i; | |||||
| // create a whitespace atom unless it starts with non-ws | // create a whitespace atom unless it starts with non-ws | ||||
| if (CharacterFunctions::isWhitespace (text[i]) | if (CharacterFunctions::isWhitespace (text[i]) | ||||
| @@ -309,41 +309,34 @@ private: | |||||
| { | { | ||||
| ++i; | ++i; | ||||
| } | } | ||||
| end = i; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if (text[i] == T('\r')) | if (text[i] == T('\r')) | ||||
| { | { | ||||
| ++i; | ++i; | ||||
| end = i; | |||||
| if ((i < len) && (text[i] == T('\n'))) | if ((i < len) && (text[i] == T('\n'))) | ||||
| { | |||||
| ++start; | |||||
| ++i; | ++i; | ||||
| } | |||||
| } | } | ||||
| else if (text[i] == T('\n')) | else if (text[i] == T('\n')) | ||||
| { | { | ||||
| ++i; | ++i; | ||||
| end = i; | |||||
| if ((i < len) && (text[i] == T('\r'))) | |||||
| ++i; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| while ((i < len) && ! CharacterFunctions::isWhitespace (text[i])) | while ((i < len) && ! CharacterFunctions::isWhitespace (text[i])) | ||||
| ++i; | ++i; | ||||
| end = i; | |||||
| } | } | ||||
| } | } | ||||
| TextAtom* const atom = new TextAtom(); | TextAtom* const atom = new TextAtom(); | ||||
| atom->atomText = textToParse.substring (start, end); | |||||
| atom->atomText = textToParse.substring (start, i); | |||||
| atom->width = font.getStringWidthFloat (atom->getText (passwordCharacter)); | atom->width = font.getStringWidthFloat (atom->getText (passwordCharacter)); | ||||
| atom->numChars = (uint16) (end - start); | |||||
| atom->numChars = (uint16) (i - start); | |||||
| atoms.add (atom); | atoms.add (atom); | ||||
| } | } | ||||
| @@ -1483,6 +1476,8 @@ void TextEditor::insertTextAtCursor (String newText) | |||||
| if (! isMultiLine()) | if (! isMultiLine()) | ||||
| newText = newText.replaceCharacters (T("\r\n"), T(" ")); | newText = newText.replaceCharacters (T("\r\n"), T(" ")); | ||||
| else | |||||
| newText = newText.replace (T("\r\n"), T("\n")); | |||||
| const int newCaretPos = selectionStart + newText.length(); | const int newCaretPos = selectionStart + newText.length(); | ||||
| const int insertIndex = selectionStart; | const int insertIndex = selectionStart; | ||||