Struct cosmic_text::BorrowedWithFontSystem
source · pub struct BorrowedWithFontSystem<'a, T> { /* private fields */ }
Expand description
A value borrowed together with an FontSystem
Implementations§
source§impl<'a> BorrowedWithFontSystem<'a, Buffer>
impl<'a> BorrowedWithFontSystem<'a, Buffer>
sourcepub fn shape_until(&mut self, lines: i32) -> i32
pub fn shape_until(&mut self, lines: i32) -> i32
Pre-shape lines in the buffer, up to lines
, return actual number of layout lines
sourcepub fn shape_until_cursor(&mut self, cursor: Cursor)
pub fn shape_until_cursor(&mut self, cursor: Cursor)
Shape lines until cursor, also scrolling to include cursor in view
sourcepub fn shape_until_scroll(&mut self)
pub fn shape_until_scroll(&mut self)
Shape lines until scroll
sourcepub fn line_shape(&mut self, line_i: usize) -> Option<&ShapeLine>
pub fn line_shape(&mut self, line_i: usize) -> Option<&ShapeLine>
Shape the provided line index and return the result
sourcepub fn line_layout(&mut self, line_i: usize) -> Option<&[LayoutLine]>
pub fn line_layout(&mut self, line_i: usize) -> Option<&[LayoutLine]>
Lay out the provided line index and return the result
sourcepub fn set_metrics(&mut self, metrics: Metrics)
pub fn set_metrics(&mut self, metrics: Metrics)
sourcepub fn set_text(&mut self, text: &str, attrs: Attrs<'_>, shaping: Shaping)
pub fn set_text(&mut self, text: &str, attrs: Attrs<'_>, shaping: Shaping)
Set text of buffer, using provided attributes for each line by default
sourcepub fn set_rich_text<'r, 's, I>(&mut self, spans: I, shaping: Shaping)where
I: IntoIterator<Item = (&'s str, Attrs<'r>)>,
pub fn set_rich_text<'r, 's, I>(&mut self, spans: I, shaping: Shaping)where I: IntoIterator<Item = (&'s str, Attrs<'r>)>,
Set text of buffer, using an iterator of styled spans (pairs of text and attributes)
let mut buffer = Buffer::new_empty(Metrics::new(32.0, 44.0));
let mut buffer = buffer.borrow_with(&mut font_system);
let attrs = Attrs::new().family(Family::Serif);
buffer.set_rich_text(
[
("hello, ", attrs),
("cosmic\ntext", attrs.family(Family::Monospace)),
],
Shaping::Advanced,
);
source§impl<'a, T: Edit> BorrowedWithFontSystem<'a, T>
impl<'a, T: Edit> BorrowedWithFontSystem<'a, T>
sourcepub fn buffer_mut(&mut self) -> BorrowedWithFontSystem<'_, Buffer>
pub fn buffer_mut(&mut self) -> BorrowedWithFontSystem<'_, Buffer>
Get the internal Buffer
, mutably
sourcepub fn shape_as_needed(&mut self)
pub fn shape_as_needed(&mut self)
Shape lines until scroll, after adjusting scroll if the cursor moved
Trait Implementations§
source§impl<'a, T: Debug> Debug for BorrowedWithFontSystem<'a, T>
impl<'a, T: Debug> Debug for BorrowedWithFontSystem<'a, T>
source§impl<'a, T> Deref for BorrowedWithFontSystem<'a, T>
impl<'a, T> Deref for BorrowedWithFontSystem<'a, T>
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for BorrowedWithFontSystem<'a, T>
impl<'a, T> Send for BorrowedWithFontSystem<'a, T>where T: Send,
impl<'a, T> Sync for BorrowedWithFontSystem<'a, T>where T: Sync,
impl<'a, T> Unpin for BorrowedWithFontSystem<'a, T>
impl<'a, T> !UnwindSafe for BorrowedWithFontSystem<'a, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more