mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
959f5889a1
This commit adds support for the idea of a text "Truncator", a string that is shown at the end of truncated text to indicate that it has been shortened because it would not fit within the requested number of lines. When specifying a maximum number of lines, a truncator symbol is always used. If the user does not provide one, the rune `…` is used. This requirement results in a better user experience and significantly simpler code, as we can rely upon the presence of one or more truncator glyphs in the output glyph stream when truncation has occurred. When interacting with truncated text, the truncator glyphs all act as a single, indivisible unit. They can be selected or not, and if selected they act as the entire contents of the truncated portion of the text. This means that copying all of a truncated label will copy the entire label text content, with the truncator symbol not appearing at all. Concretely, the exposed text API now accepts a Truncator string in text.Parameters, and there is a new glyph flag FlagTruncator which indicates that the glyph is part of the truncator run. The truncator run will only have a single FlagClusterBreak (even if the run would usually have many), and the glyph with both FlagClusterBreak and FlagTruncator will have the quantity of truncated runes in its Runes field. This necessitated increasing the size of the Runes field from a byte to an int, as it's theoretically possible for quite a lot of text to be truncated. This commit necessarily bumps our go-text/typesetting dependency to the version exposing truncation in the exported API. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>