1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

TextEditor: Fix lines being invisible beyond the word wrap width

This commit is contained in:
attila 2025-05-21 13:19:56 +02:00 committed by Attila Szarvas
parent 0e4287df52
commit a272b35261
3 changed files with 17 additions and 0 deletions

View file

@ -327,6 +327,9 @@ JustifiedText::JustifiedText (const SimpleShapedText* t, const ShapedTextOptions
rangesToDraw.set ({ 0, (int64) shapedText.getGlyphs().size() }, DrawType::normal, ops);
if (options.getDrawLinesInFull())
return;
//==============================================================================
// Everything above this line should work well given none of the lines were too
// long. When Options::getMaxNumLines() == 0 this is guaranteed by SimpleShapedText.

View file

@ -179,6 +179,17 @@ public:
return withMember (*this, &ShapedTextOptions::ellipsis, std::move (x));
}
/* Draw each line in its entirety even if it goes beyond wordWrapWidth. This means that even
if configured, an ellipsis will never be inserted.
This is used by the TextEditor where the Viewport guarantees that all text will be viewable
even beyond the word wrap width.
*/
[[nodiscard]] ShapedTextOptions withDrawLinesInFull (bool x = true) const
{
return withMember (*this, &ShapedTextOptions::drawLinesInFull, std::move (x));
}
[[nodiscard]] ShapedTextOptions withReadingDirection (std::optional<TextDirection> x) const
{
return withMember (*this, &ShapedTextOptions::readingDir, x);
@ -203,6 +214,7 @@ public:
const auto& getTrailingWhitespacesShouldFit() const { return trailingWhitespacesShouldFit; }
const auto& getMaxNumLines() const { return maxNumLines; }
const auto& getEllipsis() const { return ellipsis; }
const auto& getDrawLinesInFull() const { return drawLinesInFull; }
const auto& getAllowBreakingInsideWord() const { return allowBreakingInsideWord; }
private:
@ -227,6 +239,7 @@ private:
bool baselineAtZero = false;
bool allowBreakingInsideWord = false;
bool trailingWhitespacesShouldFit = true;
bool drawLinesInFull = false;
int64 maxNumLines = std::numeric_limits<int64>::max();
String ellipsis;
};

View file

@ -947,6 +947,7 @@ void TextEditor::updateBaseShapedTextOptions()
{
auto options = detail::ShapedText::Options{}.withTrailingWhitespacesShouldFit (true)
.withJustification (getJustificationType().getOnlyHorizontalFlags())
.withDrawLinesInFull()
.withLeading (lineSpacing);
if (wordWrap)