Struct cosmic_text::Buffer
source · pub struct Buffer<'a> {
pub lines: Vec<BufferLine>,
/* private fields */
}
Expand description
A buffer of text that is shaped and laid out
Fields
lines: Vec<BufferLine>
BufferLines (or paragraphs) of text in the buffer
Implementations
sourceimpl<'a> Buffer<'a>
impl<'a> Buffer<'a>
sourcepub fn new(font_system: &'a FontSystem, metrics: Metrics) -> Self
pub fn new(font_system: &'a FontSystem, 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 font_system(&self) -> &'a FontSystem
pub fn font_system(&self) -> &'a FontSystem
Get FontSystem
used by this Buffer
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 set_redraw(&mut self, redraw: bool)
pub fn set_redraw(&mut self, redraw: bool)
Set redraw needed flag
sourcepub fn layout_runs<'b>(&'b self) -> LayoutRunIter<'a, 'b> ⓘ
pub fn layout_runs<'b>(&'b self) -> LayoutRunIter<'a, '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