diff --git a/examples/editor-libcosmic/src/text_box.rs b/examples/editor-libcosmic/src/text_box.rs index 5774e4c..00ea9b2 100644 --- a/examples/editor-libcosmic/src/text_box.rs +++ b/examples/editor-libcosmic/src/text_box.rs @@ -13,7 +13,6 @@ use cosmic::iced_native::{ }; use cosmic_text::{ Action, - Buffer, Editor, SwashCache, }; diff --git a/src/buffer.rs b/src/buffer.rs index fef7efb..d030bc6 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -151,6 +151,7 @@ pub struct Buffer<'a> { } impl<'a> Buffer<'a> { + /// Create a new [Buffer] with the provided [FontSystem] and [Metrics] pub fn new( font_system: &'a FontSystem<'a>, metrics: Metrics, @@ -322,11 +323,13 @@ impl<'a> Buffer<'a> { ) } + /// Shape the provided line index and return the result pub fn line_shape(&mut self, line_i: usize) -> Option<&ShapeLine> { let line = self.lines.get_mut(line_i)?; Some(line.shape(&self.font_system)) } + /// Lay out the provided line index and return the result pub fn line_layout(&mut self, line_i: usize) -> Option<&[LayoutLine]> { let line = self.lines.get_mut(line_i)?; Some(line.layout(&self.font_system, self.metrics.font_size, self.width)) @@ -370,6 +373,7 @@ impl<'a> Buffer<'a> { self.scroll } + /// Set the current scroll location pub fn set_scroll(&mut self, scroll: i32) { if scroll != self.scroll { self.scroll = scroll; diff --git a/src/editor.rs b/src/editor.rs index 147adf1..a17c4e4 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -54,6 +54,7 @@ pub struct Editor<'a> { } impl<'a> Editor<'a> { + /// Create a new [Editor] with the provided [Buffer] pub fn new(buffer: Buffer<'a>) -> Self { Self { buffer, @@ -64,6 +65,7 @@ impl<'a> Editor<'a> { } } + /// Shape lines until scroll, after adjusting scroll if the cursor moved pub fn shape_as_needed(&mut self) { if self.cursor_moved { self.buffer.shape_until_cursor(self.cursor);