Trait kas::text::TextApiExt [−]
pub trait TextApiExt: TextApi {
Show 15 methods
fn update_env<F>(&mut self, f: F) -> Vec2
where
F: FnOnce(&mut UpdateEnv<'_>),
{ ... }
fn required_action(&self) -> Action { ... }
fn num_lines(&self) -> usize { ... }
fn find_line(&self, index: usize) -> Option<(usize, Range<usize>)> { ... }
fn line_range(&self, line: usize) -> Option<Range<usize>> { ... }
fn line_is_ltr(&self, line: usize) -> bool { ... }
fn line_is_rtl(&self, line: usize) -> bool { ... }
fn text_index_nearest(&self, pos: Vec2) -> usize { ... }
fn line_index_nearest(&self, line: usize, x: f32) -> Option<usize> { ... }
fn text_glyph_pos(&self, index: usize) -> MarkerPosIterⓘNotable traits for MarkerPosIterimpl Iterator for MarkerPosIter type Item = MarkerPos;
{ ... }
fn num_glyphs(&self) -> usize { ... }
fn glyphs<F>(&self, f: F)
where
F: FnMut(FaceId, f32, Glyph),
{ ... }
fn glyphs_with_effects<X, F, G>(
&self,
effects: &[Effect<X>],
default_aux: X,
f: F,
g: G
)
where
X: Copy,
G: FnMut(f32, f32, f32, f32, usize, X),
F: FnMut(FaceId, f32, Glyph, usize, X),
{ ... }
fn highlight_lines(&self, range: Range<usize>) -> Vec<(Vec2, Vec2), Global> { ... }
fn highlight_runs(&self, range: Range<usize>) -> Vec<(Vec2, Vec2), Global> { ... }
}
Expand description
Extension trait over TextApi
Provided methods
fn update_env<F>(&mut self, f: F) -> Vec2 where
F: FnOnce(&mut UpdateEnv<'_>),
fn update_env<F>(&mut self, f: F) -> Vec2 where
F: FnOnce(&mut UpdateEnv<'_>),
Update the environment and prepare, returning required size
This prepares text as necessary. It always performs line-wrapping.
fn required_action(&self) -> Action
fn required_action(&self) -> Action
Get required action
Get the number of lines
Wraps TextDisplay::num_lines
.
Find the line containing text index
Wraps TextDisplay::find_line
.
fn line_range(&self, line: usize) -> Option<Range<usize>>
fn line_range(&self, line: usize) -> Option<Range<usize>>
Get the range of a line, by line number
Wraps TextDisplay::line_range
.
fn line_is_ltr(&self, line: usize) -> bool
fn line_is_ltr(&self, line: usize) -> bool
Get the directionality of the current line
Wraps TextDisplay::line_is_ltr
.
fn line_is_rtl(&self, line: usize) -> bool
fn line_is_rtl(&self, line: usize) -> bool
Get the directionality of the current line
Wraps TextDisplay::line_is_rtl
.
fn text_index_nearest(&self, pos: Vec2) -> usize
fn text_index_nearest(&self, pos: Vec2) -> usize
Find the text index for the glyph nearest the given pos
fn line_index_nearest(&self, line: usize, x: f32) -> Option<usize>
fn line_index_nearest(&self, line: usize, x: f32) -> Option<usize>
Find the text index nearest horizontal-coordinate x
on line
fn text_glyph_pos(&self, index: usize) -> MarkerPosIterⓘNotable traits for MarkerPosIterimpl Iterator for MarkerPosIter type Item = MarkerPos;
fn text_glyph_pos(&self, index: usize) -> MarkerPosIterⓘNotable traits for MarkerPosIterimpl Iterator for MarkerPosIter type Item = MarkerPos;
impl Iterator for MarkerPosIter type Item = MarkerPos;
Find the starting position (top-left) of the glyph at the given index
Wraps TextDisplay::text_glyph_pos
.
fn num_glyphs(&self) -> usize
fn num_glyphs(&self) -> usize
Get the number of glyphs
Wraps TextDisplay::num_glyphs
.
Yield a sequence of positioned glyphs
Wraps TextDisplay::glyphs
.
Like TextDisplay::glyphs
but with added effects
Yield a sequence of rectangles to highlight a given range, by lines
Wraps TextDisplay::highlight_lines
.
Yield a sequence of rectangles to highlight a given range, by runs
Wraps TextDisplay::highlight_runs
.