forked from joejulian/gio
go.*,text,widget{,/material}: enable configurable line wrapping within words
This commit enables consumers of the text shaper to select a policy for how line breaking candidates will be chosen. The new default policy can break lines within "words" (UAX#14 segments) when words do not fit by themselves on a line. This ensures that text does not horizontally overflow its bounding box unless the available width is insufficient to display a single UAX#29 grapheme cluster. Fixes: https://todo.sr.ht/~eliasnaur/gio/467 Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -57,6 +57,8 @@ type Editor struct {
|
||||
// Filter is the list of characters allowed in the Editor. If Filter is empty,
|
||||
// all characters are allowed.
|
||||
Filter string
|
||||
// WrapPolicy configures how displayed text will be broken into lines.
|
||||
WrapPolicy text.WrapPolicy
|
||||
|
||||
buffer *editBuffer
|
||||
// scratch is a byte buffer that is reused to efficiently read portions of text
|
||||
@@ -504,6 +506,7 @@ func (e *Editor) initBuffer() {
|
||||
e.text.Alignment = e.Alignment
|
||||
e.text.SingleLine = e.SingleLine
|
||||
e.text.Mask = e.Mask
|
||||
e.text.WrapPolicy = e.WrapPolicy
|
||||
}
|
||||
|
||||
// Layout lays out the editor using the provided textMaterial as the paint material
|
||||
|
||||
Reference in New Issue
Block a user