textdir

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Align

func Align(a bellui.TextAlign, rtl bool) bellui.TextAlign

Align returns a as an edge: leading and trailing swapped when rtl.

func Effective

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

func FirstStrong(text string) (rtl, ok bool)

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

func FirstStrongRunes(text []rune) (rtl, ok bool)

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

func ResolveAlign(a bellui.TextAlign, dir bellui.TextDirection, text string) bellui.TextAlign

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.

func (*Scanner) Scan

func (s *Scanner) Scan(text string) bool

Scan takes the next piece of the paragraph and reports whether its direction is known: from a strong letter, or as the paragraph ended without one.

func (*Scanner) ScanRunes

func (s *Scanner) ScanRunes(text []rune) bool

ScanRunes is Scan for runes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL