Struct unicode_bidi::utf16::ParagraphBidiInfo

source ·
pub struct ParagraphBidiInfo<'text> {
    pub text: &'text [u16],
    pub original_classes: Vec<BidiClass>,
    pub levels: Vec<Level>,
    pub paragraph_level: Level,
    pub is_pure_ltr: bool,
}
Expand description

Bidi information of text treated as a single paragraph.

The original_classes and levels vectors are indexed by code unit offsets into the text. If a character is multiple code units wide, then its class and level will appear multiple times in these vectors.

Fields§

§text: &'text [u16]

The text

§original_classes: Vec<BidiClass>

The BidiClass of the character at each byte in the text.

§levels: Vec<Level>

The directional embedding level of each byte in the text.

§paragraph_level: Level

The paragraph embedding level.

§is_pure_ltr: bool

Whether the paragraph is purely LTR.

Implementations§

source§

impl<'text> ParagraphBidiInfo<'text>

source

pub fn new( text: &[u16], default_para_level: Option<Level>, ) -> ParagraphBidiInfo<'_>

Determine the bidi embedding level.

The hardcoded-data Cargo feature (enabled by default) must be enabled to use this.

TODO: In early steps, check for special cases that allow later steps to be skipped. like text that is entirely LTR. See the nsBidi class from Gecko for comparison.

TODO: Support auto-RTL base direction

source

pub fn new_with_data_source<'a, D: BidiDataSource>( data_source: &D, text: &'a [u16], default_para_level: Option<Level>, ) -> ParagraphBidiInfo<'a>

Determine the bidi embedding level, with a custom BidiDataSource for Bidi data. If you just wish to use the hardcoded Bidi data, please use BidiInfo::new() instead (enabled with tbe default hardcoded-data Cargo feature).

(This is the single-paragraph equivalent of BidiInfo::new_with_data_source, and should be kept in sync with it.

source

pub fn reordered_levels(&self, line: Range<usize>) -> Vec<Level>

Produce the levels for this paragraph as needed for reordering, one level per code unit in the paragraph. The returned vector includes code units that are not included in the line, but will not adjust them.

See BidiInfo::reordered_levels for details.

(This should be kept in sync with BidiInfo::reordered_levels.)

source

pub fn reordered_levels_per_char(&self, line: Range<usize>) -> Vec<Level>

Produce the levels for this paragraph as needed for reordering, one level per character in the paragraph. The returned vector includes characters that are not included in the line, but will not adjust them.

See BidiInfo::reordered_levels_per_char for details.

(This should be kept in sync with BidiInfo::reordered_levels_per_char.)

source

pub fn reorder_line(&self, line: Range<usize>) -> Cow<'text, [u16]>

Re-order a line based on resolved levels and return the line in display order.

See BidiInfo::reorder_line for details.

(This should be kept in sync with BidiInfo::reorder_line.)

source

pub fn reorder_visual(levels: &[Level]) -> Vec<usize>

Reorders pre-calculated levels of a sequence of characters.

See BidiInfo::reorder_visual for details.

source

pub fn visual_runs(&self, line: Range<usize>) -> (Vec<Level>, Vec<LevelRun>)

Find the level runs within a line and return them in visual order.

line is a range of code-unit indices within levels.

See BidiInfo::visual_runs for details.

(This should be kept in sync with BidiInfo::visual_runs.)

source

pub fn has_rtl(&self) -> bool

If processed text has any computed RTL levels

This information is usually used to skip re-ordering of text when no RTL level is present

source

pub fn direction(&self) -> Direction

Return the paragraph’s Direction (Ltr, Rtl, or Mixed) based on its levels.

Trait Implementations§

source§

impl<'text> Debug for ParagraphBidiInfo<'text>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'text> PartialEq for ParagraphBidiInfo<'text>

source§

fn eq(&self, other: &ParagraphBidiInfo<'text>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'text> StructuralPartialEq for ParagraphBidiInfo<'text>

Auto Trait Implementations§

§

impl<'text> Freeze for ParagraphBidiInfo<'text>

§

impl<'text> RefUnwindSafe for ParagraphBidiInfo<'text>

§

impl<'text> Send for ParagraphBidiInfo<'text>

§

impl<'text> Sync for ParagraphBidiInfo<'text>

§

impl<'text> Unpin for ParagraphBidiInfo<'text>

§

impl<'text> UnwindSafe for ParagraphBidiInfo<'text>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.