From 0526a5ca6efb68152f88d9a258ef957b808cd831 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 14 Feb 2025 12:24:58 +1100 Subject: For wrapping, try to break lines without separating letters from modifiers. There are still problems for languages like Javanese but it will improve most cases. Unicode proposal to improve line breaking: https://www.unicode.org/L2/L2022/22080r2-line-break-ortho-bnd.pdf --- doc/ScintillaHistory.html | 1 + src/PositionCache.cxx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index c9f423488..8e50097a4 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -612,6 +612,7 @@
  • Fix segmentation of long lexemes to avoid breaking before modifiers like accents that must be drawn with their base letters. + For wrapping, try to break lines without separating letters from modifiers.
  • For GTK on Windows, replace reverse arrow cursor with hand as reverse arrow was small in scaled modes. diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 5cc8f8fe8..07f0c9541 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -355,6 +355,13 @@ void LineLayout::WrapLine(const Document *pdoc, Sci::Position posLineStart, Wrap Sci::Position lastGoodBreak = p; if (p > 0) { lastGoodBreak = CharacterBoundary(p, -1); + if (CpUtf8 == pdoc->dbcsCodePage) { + // Go back before a base character, commonly a letter as modifiers are after the letter they modify + std::string_view svWithoutLast(&chars[lastLineStart], CharacterBoundary(p+1, 1) - lastLineStart); + if (DiscardLastCombinedCharacter(svWithoutLast) && !svWithoutLast.empty()) { + lastGoodBreak = lastLineStart + static_cast(svWithoutLast.length()); + } + } } if (wrapState != Wrap::Char) { Sci::Position pos = lastGoodBreak; -- cgit v1.2.3