TextBaseDirection
The base direction of a text a user types: the direction its paragraph reads in, which decides where the text starts, where an empty field puts its caret, and which way a screen reader is told it runs.
Public functions
TextBaseDirection
| Returns | Function |
|---|---|
| Methods | |
LayoutDirection | resolve(text: &str, language: Option<&LanguageTag>, window: LayoutDirection) |
Detailed description
A text input resolves it, every time it lays out, in this order:
- an explicit
TextBaseDirection::LeftToRightorTextBaseDirection::RightToLeft, used as given; - with
TextBaseDirection::Auto(the default), the first strongly directional character of the text (UAX #9, rules P2 and P3): Arabic text reads right to left, Latin text left to right, whatever the window's direction; - when the text has none (it is empty, or only digits and punctuation),
the
content_languagedeclared on or above the field, throughLanguageTag::likely_direction; - with no language declared, the window's layout direction.
So an empty field declared Arabic opens with its caret on the right, and a
field declared Japanese that holds Arabic text still reads right to left:
the language never decides against the text. This is HTML's dir="auto",
falling back on the language before the surrounding direction.
API reference
📖 Full rustdoc API for this module
pub enum TextBaseDirection
Import: use teksilo::widgets::TextBaseDirection;
Which way a typed text's paragraph reads. See the module for how
a text input resolves it.
#![allow(unused)] fn main() { pub enum TextBaseDirection { /* variants */ } }
Variants
Auto— The text decides: its first strongly directional character, else the declared language's usual direction, else the window's.LeftToRight— Left to right, whatever the text.RightToLeft— Right to left, whatever the text.
Methods
pub fn resolve( self, text: &str, language: Option<&LanguageTag>, window: LayoutDirection, ) -> LayoutDirection
The direction a paragraph of text reads in: see the module.
language is the content language declared on or above the field,
window the window's layout direction.