Struct cosmic_text::Buffer
source · [−]pub struct Buffer<'a> {
pub lines: Vec<BufferLine<'a>>,
pub redraw: bool,
/* private fields */
}Expand description
A buffer of text that is shaped and laid out
Fields
lines: Vec<BufferLine<'a>>Lines (or paragraphs) of text in the buffer
redraw: boolTrue if a redraw is requires. Set to false after processing
Implementations
sourceimpl<'a> Buffer<'a>
impl<'a> Buffer<'a>
sourcepub fn new(font_system: &'a FontSystem<'a>, metrics: Metrics) -> Self
pub fn new(font_system: &'a FontSystem<'a>, metrics: Metrics) -> Self
Create a new Buffer with the provided FontSystem and Metrics
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
pub fn layout_cursor(&self, cursor: &Cursor) -> LayoutCursor
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)
Set the current Metrics
sourcepub fn set_scroll(&mut self, scroll: i32)
pub fn set_scroll(&mut self, scroll: i32)
Set the current scroll location
sourcepub fn visible_lines(&self) -> i32
pub fn visible_lines(&self) -> i32
Get the number of lines that can be viewed in the buffer
sourcepub fn set_text(&mut self, text: &str, attrs: Attrs<'a>)
pub fn set_text(&mut self, text: &str, attrs: Attrs<'a>)
Set text of buffer, using provided attributes for each line by default
sourcepub fn layout_runs<'b>(&'b self) -> LayoutRunIter<'a, 'b>ⓘNotable traits for LayoutRunIter<'a, 'b>impl<'a, 'b> Iterator for LayoutRunIter<'a, 'b> type Item = LayoutRun<'b>;
pub fn layout_runs<'b>(&'b self) -> LayoutRunIter<'a, 'b>ⓘNotable traits for LayoutRunIter<'a, 'b>impl<'a, 'b> Iterator for LayoutRunIter<'a, 'b> type Item = LayoutRun<'b>;
Get the visible layout runs for rendering and other tasks
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Buffer<'a>
impl<'a> Send for Buffer<'a>
impl<'a> Sync for Buffer<'a>
impl<'a> Unpin for Buffer<'a>
impl<'a> !UnwindSafe for Buffer<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more