| @@ -80,11 +80,11 @@ public: | |||||
| { | { | ||||
| int i = 0; | int i = 0; | ||||
| if (TextAtom* const lastAtom = atoms.getLast()) | |||||
| if (auto* lastAtom = atoms.getLast()) | |||||
| { | { | ||||
| if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) | if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) | ||||
| { | { | ||||
| TextAtom* const first = other.atoms.getUnchecked(0); | |||||
| auto* first = other.atoms.getUnchecked(0); | |||||
| if (! CharacterFunctions::isWhitespace (first->atomText[0])) | if (! CharacterFunctions::isWhitespace (first->atomText[0])) | ||||
| { | { | ||||
| @@ -116,9 +116,8 @@ public: | |||||
| for (int i = 0; i < atoms.size(); ++i) | for (int i = 0; i < atoms.size(); ++i) | ||||
| { | { | ||||
| TextAtom* const atom = atoms.getUnchecked(i); | |||||
| const int nextIndex = index + atom->numChars; | |||||
| auto* atom = atoms.getUnchecked(i); | |||||
| auto nextIndex = index + atom->numChars; | |||||
| if (index == indexToBreakAt) | if (index == indexToBreakAt) | ||||
| { | { | ||||
| @@ -130,7 +129,7 @@ public: | |||||
| } | } | ||||
| else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) | else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) | ||||
| { | { | ||||
| TextAtom* const secondAtom = new TextAtom(); | |||||
| auto* secondAtom = new TextAtom(); | |||||
| secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); | secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); | ||||
| secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); | secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); | ||||
| @@ -164,17 +163,17 @@ public: | |||||
| void appendSubstring (MemoryOutputStream& mo, const Range<int> range) const | void appendSubstring (MemoryOutputStream& mo, const Range<int> range) const | ||||
| { | { | ||||
| int index = 0; | int index = 0; | ||||
| for (int i = 0; i < atoms.size(); ++i) | |||||
| for (auto* atom : atoms) | |||||
| { | { | ||||
| const TextAtom* const atom = atoms.getUnchecked (i); | |||||
| const int nextIndex = index + atom->numChars; | |||||
| auto nextIndex = index + atom->numChars; | |||||
| if (range.getStart() < nextIndex) | if (range.getStart() < nextIndex) | ||||
| { | { | ||||
| if (range.getEnd() <= index) | if (range.getEnd() <= index) | ||||
| break; | break; | ||||
| const Range<int> r ((range - index).getIntersectionWith (Range<int> (0, (int) atom->numChars))); | |||||
| auto r = (range - index).getIntersectionWith (Range<int> (0, (int) atom->numChars)); | |||||
| if (! r.isEmpty()) | if (! r.isEmpty()) | ||||
| mo << atom->atomText.substring (r.getStart(), r.getEnd()); | mo << atom->atomText.substring (r.getStart(), r.getEnd()); | ||||
| @@ -188,8 +187,8 @@ public: | |||||
| { | { | ||||
| int total = 0; | int total = 0; | ||||
| for (int i = atoms.size(); --i >= 0;) | |||||
| total += atoms.getUnchecked(i)->numChars; | |||||
| for (auto* atom : atoms) | |||||
| total += atom->numChars; | |||||
| return total; | return total; | ||||
| } | } | ||||
| @@ -200,11 +199,8 @@ public: | |||||
| { | { | ||||
| font = newFont; | font = newFont; | ||||
| for (int i = atoms.size(); --i >= 0;) | |||||
| { | |||||
| TextAtom* const atom = atoms.getUnchecked(i); | |||||
| for (auto* atom : atoms) | |||||
| atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); | atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -216,12 +212,12 @@ public: | |||||
| private: | private: | ||||
| void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) | void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) | ||||
| { | { | ||||
| String::CharPointerType text (textToParse.getCharPointer()); | |||||
| auto text = textToParse.getCharPointer(); | |||||
| while (! text.isEmpty()) | while (! text.isEmpty()) | ||||
| { | { | ||||
| size_t numChars = 0; | size_t numChars = 0; | ||||
| String::CharPointerType start (text); | |||||
| auto start = text; | |||||
| // create a whitespace atom unless it starts with non-ws | // create a whitespace atom unless it starts with non-ws | ||||
| if (text.isWhitespace() && *text != '\r' && *text != '\n') | if (text.isWhitespace() && *text != '\r' && *text != '\n') | ||||
| @@ -261,7 +257,7 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| TextAtom* const atom = atoms.add (new TextAtom()); | |||||
| auto* atom = atoms.add (new TextAtom()); | |||||
| atom->atomText = String (start, numChars); | atom->atomText = String (start, numChars); | ||||
| atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); | atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); | ||||
| @@ -350,14 +346,15 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| bool forceNewLine = false; | |||||
| if (sectionIndex >= sections.size()) | if (sectionIndex >= sections.size()) | ||||
| { | { | ||||
| moveToEndOfLastAtom(); | moveToEndOfLastAtom(); | ||||
| return false; | return false; | ||||
| } | } | ||||
| else if (atomIndex >= currentSection->atoms.size() - 1) | |||||
| bool forceNewLine = false; | |||||
| if (atomIndex >= currentSection->atoms.size() - 1) | |||||
| { | { | ||||
| if (atomIndex >= currentSection->atoms.size()) | if (atomIndex >= currentSection->atoms.size()) | ||||
| { | { | ||||
| @@ -372,7 +369,7 @@ public: | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const TextAtom* const lastAtom = currentSection->atoms.getUnchecked (atomIndex); | |||||
| auto* lastAtom = currentSection->atoms.getUnchecked (atomIndex); | |||||
| if (! lastAtom->isWhitespace()) | if (! lastAtom->isWhitespace()) | ||||
| { | { | ||||
| @@ -384,12 +381,12 @@ public: | |||||
| for (int section = sectionIndex + 1; section < sections.size(); ++section) | for (int section = sectionIndex + 1; section < sections.size(); ++section) | ||||
| { | { | ||||
| const UniformTextSection* const s = sections.getUnchecked (section); | |||||
| auto* s = sections.getUnchecked (section); | |||||
| if (s->atoms.size() == 0) | if (s->atoms.size() == 0) | ||||
| break; | break; | ||||
| const TextAtom* const nextAtom = s->atoms.getUnchecked (0); | |||||
| auto* nextAtom = s->atoms.getUnchecked (0); | |||||
| if (nextAtom->isWhitespace()) | if (nextAtom->isWhitespace()) | ||||
| break; | break; | ||||
| @@ -467,7 +464,7 @@ public: | |||||
| int tempSectionIndex = sectionIndex; | int tempSectionIndex = sectionIndex; | ||||
| int tempAtomIndex = atomIndex; | int tempAtomIndex = atomIndex; | ||||
| const UniformTextSection* section = sections.getUnchecked (tempSectionIndex); | |||||
| auto* section = sections.getUnchecked (tempSectionIndex); | |||||
| lineHeight = section->font.getHeight(); | lineHeight = section->font.getHeight(); | ||||
| maxDescent = section->font.getDescent(); | maxDescent = section->font.getDescent(); | ||||
| @@ -491,7 +488,7 @@ public: | |||||
| checkSize = true; | checkSize = true; | ||||
| } | } | ||||
| const TextAtom* const nextAtom = section->atoms.getUnchecked (tempAtomIndex); | |||||
| auto* nextAtom = section->atoms.getUnchecked (tempAtomIndex); | |||||
| if (nextAtom == nullptr) | if (nextAtom == nullptr) | ||||
| break; | break; | ||||
| @@ -626,7 +623,8 @@ public: | |||||
| int j; | int j; | ||||
| for (j = 0; j < numGlyphs; ++j) | for (j = 0; j < numGlyphs; ++j) | ||||
| { | { | ||||
| const PositionedGlyph& pg = g.getGlyph(j); | |||||
| auto& pg = g.getGlyph(j); | |||||
| if ((pg.getLeft() + pg.getRight()) / 2 > xToFind) | if ((pg.getLeft() + pg.getRight()) / 2 > xToFind) | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -775,8 +773,9 @@ public: | |||||
| int getSizeInUnits() override | int getSizeInUnits() override | ||||
| { | { | ||||
| int n = 16; | int n = 16; | ||||
| for (int i = removedSections.size(); --i >= 0;) | |||||
| n += removedSections.getUnchecked (i)->getTotalLength(); | |||||
| for (auto* s : removedSections) | |||||
| n += s->getTotalLength(); | |||||
| return n; | return n; | ||||
| } | } | ||||
| @@ -840,10 +839,7 @@ private: | |||||
| class TextEditorViewport : public Viewport | class TextEditorViewport : public Viewport | ||||
| { | { | ||||
| public: | public: | ||||
| TextEditorViewport (TextEditor& ed) | |||||
| : owner (ed), lastWordWrapWidth (0), rentrant (false) | |||||
| { | |||||
| } | |||||
| TextEditorViewport (TextEditor& ed) : owner (ed) {} | |||||
| void visibleAreaChanged (const Rectangle<int>&) override | void visibleAreaChanged (const Rectangle<int>&) override | ||||
| { | { | ||||
| @@ -865,8 +861,8 @@ public: | |||||
| private: | private: | ||||
| TextEditor& owner; | TextEditor& owner; | ||||
| float lastWordWrapWidth; | |||||
| bool rentrant; | |||||
| float lastWordWrapWidth = 0; | |||||
| bool rentrant = false; | |||||
| JUCE_DECLARE_NON_COPYABLE (TextEditorViewport) | JUCE_DECLARE_NON_COPYABLE (TextEditorViewport) | ||||
| }; | }; | ||||
| @@ -911,7 +907,7 @@ TextEditor::TextEditor (const String& name, | |||||
| TextEditor::~TextEditor() | TextEditor::~TextEditor() | ||||
| { | { | ||||
| if (wasFocused) | if (wasFocused) | ||||
| if (ComponentPeer* const peer = getPeer()) | |||||
| if (auto* peer = getPeer()) | |||||
| peer->dismissPendingTextInput(); | peer->dismissPendingTextInput(); | ||||
| textValue.removeListener (textHolder); | textValue.removeListener (textHolder); | ||||
| @@ -1032,11 +1028,11 @@ void TextEditor::setFont (const Font& newFont) | |||||
| void TextEditor::applyFontToAllText (const Font& newFont) | void TextEditor::applyFontToAllText (const Font& newFont) | ||||
| { | { | ||||
| currentFont = newFont; | currentFont = newFont; | ||||
| const Colour overallColour (findColour (textColourId)); | |||||
| auto overallColour = findColour (textColourId); | |||||
| for (int i = sections.size(); --i >= 0;) | for (int i = sections.size(); --i >= 0;) | ||||
| { | { | ||||
| UniformTextSection* const uts = sections.getUnchecked (i); | |||||
| auto* uts = sections.getUnchecked (i); | |||||
| uts->setFont (newFont, passwordCharacter); | uts->setFont (newFont, passwordCharacter); | ||||
| uts->colour = overallColour; | uts->colour = overallColour; | ||||
| } | } | ||||
| @@ -1167,9 +1163,12 @@ void TextEditor::setText (const String& newText, | |||||
| if (newLength != getTotalNumChars() || getText() != newText || styleChanged) | if (newLength != getTotalNumChars() || getText() != newText || styleChanged) | ||||
| { | { | ||||
| if (! sendTextChangeMessage) | |||||
| textValue.removeListener (textHolder); | |||||
| textValue = newText; | textValue = newText; | ||||
| int oldCursorPos = caretPosition; | |||||
| auto oldCursorPos = caretPosition; | |||||
| const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); | const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); | ||||
| clearInternal (nullptr); | clearInternal (nullptr); | ||||
| @@ -1186,6 +1185,8 @@ void TextEditor::setText (const String& newText, | |||||
| if (sendTextChangeMessage) | if (sendTextChangeMessage) | ||||
| textChanged(); | textChanged(); | ||||
| else | |||||
| textValue.addListener (textHolder); | |||||
| updateTextHolderSize(); | updateTextHolderSize(); | ||||
| scrollToMakeSureCursorIsVisible(); | scrollToMakeSureCursorIsVisible(); | ||||
| @@ -1246,7 +1247,7 @@ void TextEditor::timerCallbackInt() | |||||
| if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent()) | if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent()) | ||||
| wasFocused = true; | wasFocused = true; | ||||
| const unsigned int now = Time::getApproximateMillisecondCounter(); | |||||
| auto now = Time::getApproximateMillisecondCounter(); | |||||
| if (now > lastTransactionTime + 200) | if (now > lastTransactionTime + 200) | ||||
| newTransaction(); | newTransaction(); | ||||
| @@ -1266,7 +1267,7 @@ void TextEditor::repaintText (const Range<int> range) | |||||
| i.getCharPosition (range.getStart(), x, y, lh); | i.getCharPosition (range.getStart(), x, y, lh); | ||||
| const int y1 = (int) y; | |||||
| auto y1 = (int) y; | |||||
| int y2; | int y2; | ||||
| if (range.getEnd() >= getTotalNumChars()) | if (range.getEnd() >= getTotalNumChars()) | ||||
| @@ -1321,8 +1322,7 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, | |||||
| { | { | ||||
| updateCaretPosition(); | updateCaretPosition(); | ||||
| const Rectangle<int> caretPos (getCaretRectangle()); | |||||
| auto caretPos = getCaretRectangle(); | |||||
| int vx = caretPos.getX() - desiredCaretX; | int vx = caretPos.getX() - desiredCaretX; | ||||
| int vy = caretPos.getY() - desiredCaretY; | int vy = caretPos.getY() - desiredCaretY; | ||||
| @@ -1357,7 +1357,7 @@ Rectangle<int> TextEditor::getCaretRectangle() | |||||
| float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) | float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) | ||||
| getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); | getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); | ||||
| return Rectangle<int> (roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight)); | |||||
| return { roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight) }; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -1421,10 +1421,9 @@ void TextEditor::scrollToMakeSureCursorIsVisible() | |||||
| if (keepCaretOnScreen) | if (keepCaretOnScreen) | ||||
| { | { | ||||
| Point<int> viewPos (viewport->getViewPosition()); | |||||
| const Rectangle<int> caretRect (getCaretRectangle()); | |||||
| const Point<int> relativeCursor = caretRect.getPosition() - viewPos; | |||||
| auto viewPos = viewport->getViewPosition(); | |||||
| auto caretRect = getCaretRectangle(); | |||||
| auto relativeCursor = caretRect.getPosition() - viewPos; | |||||
| if (relativeCursor.x < jmax (1, proportionOfWidth (0.05f))) | if (relativeCursor.x < jmax (1, proportionOfWidth (0.05f))) | ||||
| { | { | ||||
| @@ -1460,11 +1459,11 @@ void TextEditor::moveCaretTo (const int newPosition, const bool isSelecting) | |||||
| { | { | ||||
| moveCaret (newPosition); | moveCaret (newPosition); | ||||
| const Range<int> oldSelection (selection); | |||||
| auto oldSelection = selection; | |||||
| if (dragType == notDragging) | if (dragType == notDragging) | ||||
| { | { | ||||
| if (abs (getCaretPosition() - selection.getStart()) < abs (getCaretPosition() - selection.getEnd())) | |||||
| if (std::abs (getCaretPosition() - selection.getStart()) < std::abs (getCaretPosition() - selection.getEnd())) | |||||
| dragType = draggingSelectionStart; | dragType = draggingSelectionStart; | ||||
| else | else | ||||
| dragType = draggingSelectionEnd; | dragType = draggingSelectionEnd; | ||||
| @@ -1536,7 +1535,7 @@ void TextEditor::copy() | |||||
| { | { | ||||
| if (passwordCharacter == 0) | if (passwordCharacter == 0) | ||||
| { | { | ||||
| const String selectedText (getHighlightedText()); | |||||
| auto selectedText = getHighlightedText(); | |||||
| if (selectedText.isNotEmpty()) | if (selectedText.isNotEmpty()) | ||||
| SystemClipboard::copyTextToClipboard (selectedText); | SystemClipboard::copyTextToClipboard (selectedText); | ||||
| @@ -1547,7 +1546,7 @@ void TextEditor::paste() | |||||
| { | { | ||||
| if (! isReadOnly()) | if (! isReadOnly()) | ||||
| { | { | ||||
| const String clip (SystemClipboard::getTextFromClipboard()); | |||||
| auto clip = SystemClipboard::getTextFromClipboard(); | |||||
| if (clip.isNotEmpty()) | if (clip.isNotEmpty()) | ||||
| insertTextAtCaret (clip); | insertTextAtCaret (clip); | ||||
| @@ -1571,7 +1570,7 @@ void TextEditor::drawContent (Graphics& g) | |||||
| if (wordWrapWidth > 0) | if (wordWrapWidth > 0) | ||||
| { | { | ||||
| g.setOrigin (leftIndent, topIndent); | g.setOrigin (leftIndent, topIndent); | ||||
| const Rectangle<int> clip (g.getClipBounds()); | |||||
| auto clip = g.getClipBounds(); | |||||
| Colour selectedTextColour; | Colour selectedTextColour; | ||||
| Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); | Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); | ||||
| @@ -1758,8 +1757,8 @@ void TextEditor::mouseDoubleClick (const MouseEvent& e) | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const String t (getText()); | |||||
| const int totalLength = getTotalNumChars(); | |||||
| auto t = getText(); | |||||
| auto totalLength = getTotalNumChars(); | |||||
| while (tokenEnd < totalLength) | while (tokenEnd < totalLength) | ||||
| { | { | ||||
| @@ -1852,7 +1851,7 @@ bool TextEditor::moveCaretUp (bool selecting) | |||||
| if (! isMultiLine()) | if (! isMultiLine()) | ||||
| return moveCaretToStartOfLine (selecting); | return moveCaretToStartOfLine (selecting); | ||||
| const Rectangle<float> caretPos (getCaretRectangle().toFloat()); | |||||
| auto caretPos = getCaretRectangle().toFloat(); | |||||
| return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting); | return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting); | ||||
| } | } | ||||
| @@ -1861,7 +1860,7 @@ bool TextEditor::moveCaretDown (bool selecting) | |||||
| if (! isMultiLine()) | if (! isMultiLine()) | ||||
| return moveCaretToEndOfLine (selecting); | return moveCaretToEndOfLine (selecting); | ||||
| const Rectangle<float> caretPos (getCaretRectangle().toFloat()); | |||||
| auto caretPos = getCaretRectangle().toFloat(); | |||||
| return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f), selecting); | return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f), selecting); | ||||
| } | } | ||||
| @@ -1870,7 +1869,7 @@ bool TextEditor::pageUp (bool selecting) | |||||
| if (! isMultiLine()) | if (! isMultiLine()) | ||||
| return moveCaretToStartOfLine (selecting); | return moveCaretToStartOfLine (selecting); | ||||
| const Rectangle<float> caretPos (getCaretRectangle().toFloat()); | |||||
| auto caretPos = getCaretRectangle().toFloat(); | |||||
| return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting); | return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting); | ||||
| } | } | ||||
| @@ -1879,13 +1878,13 @@ bool TextEditor::pageDown (bool selecting) | |||||
| if (! isMultiLine()) | if (! isMultiLine()) | ||||
| return moveCaretToEndOfLine (selecting); | return moveCaretToEndOfLine (selecting); | ||||
| const Rectangle<float> caretPos (getCaretRectangle().toFloat()); | |||||
| auto caretPos = getCaretRectangle().toFloat(); | |||||
| return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting); | return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting); | ||||
| } | } | ||||
| void TextEditor::scrollByLines (int deltaLines) | void TextEditor::scrollByLines (int deltaLines) | ||||
| { | { | ||||
| if (ScrollBar* scrollbar = viewport->getVerticalScrollBar()) | |||||
| if (auto* scrollbar = viewport->getVerticalScrollBar()) | |||||
| scrollbar->moveScrollbarInSteps (deltaLines); | scrollbar->moveScrollbarInSteps (deltaLines); | ||||
| } | } | ||||
| @@ -1908,7 +1907,7 @@ bool TextEditor::moveCaretToTop (bool selecting) | |||||
| bool TextEditor::moveCaretToStartOfLine (bool selecting) | bool TextEditor::moveCaretToStartOfLine (bool selecting) | ||||
| { | { | ||||
| const Rectangle<float> caretPos (getCaretRectangle().toFloat()); | |||||
| auto caretPos = getCaretRectangle().toFloat(); | |||||
| return moveCaretWithTransaction (indexAtPosition (0.0f, caretPos.getY()), selecting); | return moveCaretWithTransaction (indexAtPosition (0.0f, caretPos.getY()), selecting); | ||||
| } | } | ||||
| @@ -1919,7 +1918,7 @@ bool TextEditor::moveCaretToEnd (bool selecting) | |||||
| bool TextEditor::moveCaretToEndOfLine (bool selecting) | bool TextEditor::moveCaretToEndOfLine (bool selecting) | ||||
| { | { | ||||
| const Rectangle<float> caretPos (getCaretRectangle().toFloat()); | |||||
| auto caretPos = getCaretRectangle().toFloat(); | |||||
| return moveCaretWithTransaction (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()), selecting); | return moveCaretWithTransaction (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()), selecting); | ||||
| } | } | ||||
| @@ -2054,7 +2053,7 @@ void TextEditor::focusGained (FocusChangeType) | |||||
| repaint(); | repaint(); | ||||
| updateCaretPosition(); | updateCaretPosition(); | ||||
| if (ComponentPeer* const peer = getPeer()) | |||||
| if (auto* peer = getPeer()) | |||||
| if (! isReadOnly()) | if (! isReadOnly()) | ||||
| peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this); | peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this); | ||||
| } | } | ||||
| @@ -2068,7 +2067,7 @@ void TextEditor::focusLost (FocusChangeType) | |||||
| underlinedSections.clear(); | underlinedSections.clear(); | ||||
| if (ComponentPeer* const peer = getPeer()) | |||||
| if (auto* peer = getPeer()) | |||||
| peer->dismissPendingTextInput(); | peer->dismissPendingTextInput(); | ||||
| updateCaretPosition(); | updateCaretPosition(); | ||||
| @@ -2276,9 +2275,8 @@ void TextEditor::remove (Range<int> range, UndoManager* const um, const int care | |||||
| if (range.getEnd() <= range.getStart()) | if (range.getEnd() <= range.getStart()) | ||||
| break; | break; | ||||
| UniformTextSection* const section = sections.getUnchecked (i); | |||||
| const int nextIndex = index + section->getTotalLength(); | |||||
| auto* section = sections.getUnchecked (i); | |||||
| auto nextIndex = index + section->getTotalLength(); | |||||
| if (range.getStart() <= index && range.getEnd() >= nextIndex) | if (range.getStart() <= index && range.getEnd() >= nextIndex) | ||||
| removedSections.add (new UniformTextSection (*section)); | removedSections.add (new UniformTextSection (*section)); | ||||
| @@ -2294,19 +2292,19 @@ void TextEditor::remove (Range<int> range, UndoManager* const um, const int care | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| Range<int> remainingRange (range); | |||||
| auto remainingRange = range; | |||||
| for (int i = 0; i < sections.size(); ++i) | for (int i = 0; i < sections.size(); ++i) | ||||
| { | { | ||||
| UniformTextSection* const section = sections.getUnchecked (i); | |||||
| auto* section = sections.getUnchecked (i); | |||||
| const int nextIndex = index + section->getTotalLength(); | const int nextIndex = index + section->getTotalLength(); | ||||
| if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) | if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) | ||||
| { | { | ||||
| sections.remove (i); | sections.remove (i); | ||||
| remainingRange.setEnd (remainingRange.getEnd() - (nextIndex - index)); | remainingRange.setEnd (remainingRange.getEnd() - (nextIndex - index)); | ||||
| if (remainingRange.isEmpty()) | if (remainingRange.isEmpty()) | ||||
| break; | break; | ||||
| @@ -2354,7 +2352,7 @@ String TextEditor::getTextInRange (const Range<int>& range) const | |||||
| for (int i = 0; i < sections.size(); ++i) | for (int i = 0; i < sections.size(); ++i) | ||||
| { | { | ||||
| auto* s = sections.getUnchecked (i); | auto* s = sections.getUnchecked (i); | ||||
| const int nextIndex = index + s->getTotalLength(); | |||||
| auto nextIndex = index + s->getTotalLength(); | |||||
| if (range.getStart() < nextIndex) | if (range.getStart() < nextIndex) | ||||
| { | { | ||||
| @@ -2440,8 +2438,8 @@ int TextEditor::indexAtPosition (const float x, const float y) | |||||
| //============================================================================== | //============================================================================== | ||||
| int TextEditor::findWordBreakAfter (const int position) const | int TextEditor::findWordBreakAfter (const int position) const | ||||
| { | { | ||||
| const String t (getTextInRange (Range<int> (position, position + 512))); | |||||
| const int totalLength = t.length(); | |||||
| auto t = getTextInRange (Range<int> (position, position + 512)); | |||||
| auto totalLength = t.length(); | |||||
| int i = 0; | int i = 0; | ||||
| while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) | while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) | ||||
| @@ -2463,8 +2461,8 @@ int TextEditor::findWordBreakBefore (const int position) const | |||||
| if (position <= 0) | if (position <= 0) | ||||
| return 0; | return 0; | ||||
| const int startOfBuffer = jmax (0, position - 512); | |||||
| const String t (getTextInRange (Range<int> (startOfBuffer, position))); | |||||
| auto startOfBuffer = jmax (0, position - 512); | |||||
| auto t = getTextInRange (Range<int> (startOfBuffer, position)); | |||||
| int i = position - startOfBuffer; | int i = position - startOfBuffer; | ||||
| @@ -2473,7 +2471,7 @@ int TextEditor::findWordBreakBefore (const int position) const | |||||
| if (i > 0) | if (i > 0) | ||||
| { | { | ||||
| const int type = TextEditorDefs::getCharacterCategory (t [i - 1]); | |||||
| auto type = TextEditorDefs::getCharacterCategory (t [i - 1]); | |||||
| while (i > 0 && type == TextEditorDefs::getCharacterCategory (t [i - 1])) | while (i > 0 && type == TextEditorDefs::getCharacterCategory (t [i - 1])) | ||||
| --i; | --i; | ||||
| @@ -2497,8 +2495,8 @@ void TextEditor::coalesceSimilarSections() | |||||
| { | { | ||||
| for (int i = 0; i < sections.size() - 1; ++i) | for (int i = 0; i < sections.size() - 1; ++i) | ||||
| { | { | ||||
| UniformTextSection* const s1 = sections.getUnchecked (i); | |||||
| UniformTextSection* const s2 = sections.getUnchecked (i + 1); | |||||
| auto* s1 = sections.getUnchecked (i); | |||||
| auto* s2 = sections.getUnchecked (i + 1); | |||||
| if (s1->font == s2->font | if (s1->font == s2->font | ||||
| && s1->colour == s2->colour) | && s1->colour == s2->colour) | ||||