Add an option to dynamic-break inside words

Authored by cullmann on Feb 12 2020, 8:04 AM.

Description

Add an option to dynamic-break inside words

Summary:
Add option to break lines longer than view width (or static boundary, when dynamic-wrapping at static boundary) anywhere. It merely sets QTextOption::WrapAnywhere for the view, plus exposes that as checkbox in the config and key for saving the configuration.

QTextOption::WrapAtWordBoundaryOrAnywhere is unfortunately very dumb, splitting at space only; while this might be ok for natural languages, it is not suitable for code: e.g. if(eng->option.wrapMode()==QTextOption::WrapAtWordBoundaryOrAnywhere){ has no "word boundary" according the the algorithm. FYI QTtextLayout internally uses QTextEngine::itemize() [https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/text/qtextengine.cpp?h=dev#n2057](link).

This patch makes a difference also for long lines "without word boundary" which should break anywhere as fallback (as per Qt's docs); in this fallback case, though ktextedit inserts zero-length line at the beginning (this is likely an existing but in ktextedit).

Without breaking anywhere (old behavior, the default):

breaking anywhere:

(My first contribution here.)

Reviewers: cullmann

Reviewed By: cullmann

Subscribers: dhaumann, cullmann, kwrite-devel, kde-frameworks-devel

Tags: KTextEditor, Kate, Frameworks

Differential Revision: https://phabricator.kde.org/D27238

Details

Committed
cullmannFeb 12 2020, 8:04 AM
Reviewer
cullmann
Differential Revision
D27238: Add an option to dynamic-break inside words
Parents
R39:f3f134f20b77: GIT_SILENT: qtcreator created .cmake/ repo.
Branches
Unknown
Tags
Unknown