diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index d122c62c34..2b9076ab49 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -281,7 +281,8 @@ struct TextEditor::Iterator bottomRight (ed.getMaximumWidth(), ed.getMaximumHeight()), wordWrapWidth (ed.getWordWrapWidth()), passwordCharacter (ed.passwordCharacter), - lineSpacing (ed.lineSpacing) + lineSpacing (ed.lineSpacing), + underlineWhitespace (ed.underlineWhitespace) { jassert (wordWrapWidth > 0); @@ -511,7 +512,7 @@ struct TextEditor::Iterator //============================================================================== void draw (Graphics& g, const UniformTextSection*& lastSection, AffineTransform transform) const { - if (passwordCharacter != 0 || ! atom->isWhitespace()) + if (passwordCharacter != 0 || (underlineWhitespace || ! atom->isWhitespace())) { if (lastSection != currentSection) { @@ -684,6 +685,7 @@ private: const float wordWrapWidth; const juce_wchar passwordCharacter; const float lineSpacing; + const bool underlineWhitespace; TextAtom tempAtom; void moveToEndOfLastAtom() diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index aa57e5766d..1ce56c66bd 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -249,7 +249,7 @@ public: @see setFont */ - const Font& getFont() const noexcept { return currentFont; } + const Font& getFont() const noexcept { return currentFont; } /** Applies a colour to all the text in the editor. @@ -258,6 +258,18 @@ public: */ void applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour = true); + /** Sets whether whitespace should be underlined when the editor font is underlined. + + @see isWhitespaceUnderlined + */ + void setWhitespaceUnderlined (bool shouldUnderlineWhitespace) noexcept { underlineWhitespace = shouldUnderlineWhitespace; } + + /** Returns true if whitespace is underlined for underlined fonts. + + @see setWhitespaceIsUnderlined + */ + bool isWhitespaceUnderlined() const noexcept { return underlineWhitespace; } + //============================================================================== /** If set to true, focusing on the editor will highlight all its text. @@ -729,6 +741,7 @@ private: bool menuActive = false; bool valueTextNeedsUpdating = false; bool consumeEscAndReturnKeys = true; + bool underlineWhitespace = true; UndoManager undoManager; std::unique_ptr caret;