Documentation
¶
Overview ¶
Package textdir resolves the base direction of a paragraph of text: bellui.TextDirectionFirstStrong from the text's own letters (UAX #9 rules P2 and P3), the other directions as the UI resolves them.
Index ¶
- func Align(a bellui.TextAlign, rtl bool) bellui.TextAlign
- func Effective(dir bellui.TextDirection) bellui.TextDirection
- func FirstStrong(text string) (rtl, ok bool)
- func FirstStrongRunes(text []rune) (rtl, ok bool)
- func RTL(dir bellui.TextDirection, text string) bool
- func RTLRunes(dir bellui.TextDirection, text []rune) bool
- func ResolveAlign(a bellui.TextAlign, dir bellui.TextDirection, text string) bellui.TextAlign
- type Scanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Effective ¶
func Effective(dir bellui.TextDirection) bellui.TextDirection
Effective is the base direction text with dir is laid out in: dir, or for TextDirectionAuto inside a direction scope that makes text take its direction from its letters, bellui.TextDirectionFirstStrong (#1733).
func FirstStrong ¶
FirstStrong reports whether the first strong letter of the paragraph text starts is right-to-left; ok is false when it has none.
func FirstStrongRunes ¶
FirstStrongRunes is FirstStrong for runes.
func RTL ¶
func RTL(dir bellui.TextDirection, text string) bool
RTL reports whether a paragraph of text with base direction dir is right-to-left: by its first strong letter for bellui.TextDirectionFirstStrong, falling back to the UI direction.
func RTLRunes ¶
func RTLRunes(dir bellui.TextDirection, text []rune) bool
RTLRunes is RTL for runes.
func ResolveAlign ¶
ResolveAlign is lang.ResolveAlign for text with base direction dir: text that takes its direction from its letters has leading and trailing at the edges its own direction gives, whatever the UI's.
Types ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner finds the first strong letter of a paragraph whose text comes in pieces, as a RichText's segments and rows hold it.
func (*Scanner) Direction ¶
func (s *Scanner) Direction() bellui.TextDirection
Direction returns the paragraph's direction from what Scan found: bellui.TextDirectionLTR or bellui.TextDirectionRTL, or bellui.TextDirectionAuto (the ambient direction, rule P3) when no strong letter was found.