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>
impl<'text> ParagraphBidiInfo<'text>
sourcepub fn new(
text: &[u16],
default_para_level: Option<Level>
) -> ParagraphBidiInfo<'_>
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
sourcepub fn new_with_data_source<'a, D: BidiDataSource>(
data_source: &D,
text: &'a [u16],
default_para_level: Option<Level>
) -> ParagraphBidiInfo<'a>
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.
sourcepub fn reordered_levels(&self, line: Range<usize>) -> Vec<Level>
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.)
sourcepub fn reordered_levels_per_char(&self, line: Range<usize>) -> Vec<Level>
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.)
sourcepub fn reorder_line(&self, line: Range<usize>) -> Cow<'text, [u16]>
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.)
sourcepub fn reorder_visual(levels: &[Level]) -> Vec<usize>
pub fn reorder_visual(levels: &[Level]) -> Vec<usize>
Reorders pre-calculated levels of a sequence of characters.
See BidiInfo::reorder_visual for details.
sourcepub fn visual_runs(&self, line: Range<usize>) -> (Vec<Level>, Vec<LevelRun>)
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.)
Trait Implementations§
source§impl<'text> Debug for ParagraphBidiInfo<'text>
impl<'text> Debug for ParagraphBidiInfo<'text>
source§impl<'text> PartialEq for ParagraphBidiInfo<'text>
impl<'text> PartialEq for ParagraphBidiInfo<'text>
source§fn eq(&self, other: &ParagraphBidiInfo<'text>) -> bool
fn eq(&self, other: &ParagraphBidiInfo<'text>) -> bool
self
and other
values to be equal, and is used
by ==
.