Struct cosmic_text::TextBuffer
source · [−]pub struct TextBuffer<'a> {
pub lines: Vec<TextBufferLine<'a>>,
pub cursor_moved: bool,
pub redraw: bool,
/* private fields */
}Expand description
A buffer of text that is shaped and laid out
Fields
lines: Vec<TextBufferLine<'a>>cursor_moved: boolredraw: boolImplementations
sourceimpl<'a> TextBuffer<'a>
impl<'a> TextBuffer<'a>
pub fn new(
font_system: &'a FontSystem<'a>,
attrs: Attrs<'a>,
metrics: TextMetrics
) -> Self
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)
pub fn shape_until_cursor(&mut self)
Shape lines until cursor, also scrolling to include cursor in view
pub fn shape_until_scroll(&mut self)
sourcepub fn cursor(&self) -> TextCursor
pub fn cursor(&self) -> TextCursor
Get the current cursor position
sourcepub fn metrics(&self) -> TextMetrics
pub fn metrics(&self) -> TextMetrics
Get the current TextMetrics
sourcepub fn set_metrics(&mut self, metrics: TextMetrics)
pub fn set_metrics(&mut self, metrics: TextMetrics)
Set the current TextMetrics
pub fn attrs(&self) -> &Attrs<'a>
sourcepub fn text_lines(&self) -> &[TextBufferLine<'_>]
pub fn text_lines(&self) -> &[TextBufferLine<'_>]
Get the lines of the original text
sourcepub fn action(&mut self, action: TextAction)
pub fn action(&mut self, action: TextAction)
Perform a TextAction on the buffer
sourcepub fn hit(&self, x: i32, y: i32) -> Option<TextCursor>
pub fn hit(&self, x: i32, y: i32) -> Option<TextCursor>
Convert x, y position to TextCursor (hit detection)
sourcepub fn layout_runs<'b>(&'b self) -> TextLayoutRunIter<'a, 'b>ⓘNotable traits for TextLayoutRunIter<'a, 'b>impl<'a, 'b> Iterator for TextLayoutRunIter<'a, 'b> type Item = TextLayoutRun<'b>;
pub fn layout_runs<'b>(&'b self) -> TextLayoutRunIter<'a, 'b>ⓘNotable traits for TextLayoutRunIter<'a, 'b>impl<'a, 'b> Iterator for TextLayoutRunIter<'a, 'b> type Item = TextLayoutRun<'b>;
Get the visible layout runs for rendering and other tasks
Auto Trait Implementations
impl<'a> !RefUnwindSafe for TextBuffer<'a>
impl<'a> Send for TextBuffer<'a>
impl<'a> Sync for TextBuffer<'a>
impl<'a> Unpin for TextBuffer<'a>
impl<'a> !UnwindSafe for TextBuffer<'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