diff --git a/editor-core/src/buffer/rope_text.rs b/editor-core/src/buffer/rope_text.rs index e1be745c..748f45a1 100644 --- a/editor-core/src/buffer/rope_text.rs +++ b/editor-core/src/buffer/rope_text.rs @@ -405,6 +405,12 @@ impl<'a> From<&'a Rope> for RopeTextRef<'a> { } } +impl RopeText for Rope { + fn text(&self) -> &Rope { + self + } +} + /// Joins an iterator of iterators over char indices `(usize, char)` into one /// as if they were from a single long string /// Assumes the iterators end after the first `None` value diff --git a/editor-core/src/selection.rs b/editor-core/src/selection.rs index a8a9a147..f6312c97 100644 --- a/editor-core/src/selection.rs +++ b/editor-core/src/selection.rs @@ -258,6 +258,18 @@ impl Selection { self.regions.iter().all(|region| region.is_caret()) } + pub fn current_caret(&self) -> Option { + if self.regions.len() == 1 { + if self.regions[0].is_caret() { + Some(self.regions[0].start) + } else { + None + } + } else { + None + } + } + /// Returns `true` if `self` has zero [`SelRegion`] pub fn is_empty(&self) -> bool { self.len() == 0 diff --git a/renderer/src/text/layout.rs b/renderer/src/text/layout.rs index 4b98e962..3f0d3c72 100644 --- a/renderer/src/text/layout.rs +++ b/renderer/src/text/layout.rs @@ -278,6 +278,10 @@ impl TextLayout { .set_size(&mut font_system, Some(width), Some(height)); } + pub fn metrics(&self) -> Metrics { + self.buffer.metrics() + } + pub fn lines(&self) -> &[BufferLine] { &self.buffer.lines } diff --git a/renderer/src/text/mod.rs b/renderer/src/text/mod.rs index 73a83079..75790607 100644 --- a/renderer/src/text/mod.rs +++ b/renderer/src/text/mod.rs @@ -3,7 +3,7 @@ mod layout; pub use attrs::{Attrs, AttrsList, AttrsOwned, FamilyOwned, LineHeightValue}; pub use cosmic_text::{ - fontdb, CacheKey, Cursor, Family, LayoutGlyph, LayoutLine, Stretch, Style, SubpixelBin, - SwashCache, SwashContent, Weight, Wrap, + fontdb, CacheKey, Cursor, Family, LayoutGlyph, LayoutLine, LineEnding, Stretch, Style, + SubpixelBin, SwashCache, SwashContent, Weight, Wrap, }; pub use layout::{HitPoint, HitPosition, LayoutRun, TextLayout, FONT_SYSTEM}; diff --git a/src/style.rs b/src/style.rs index f48c949e..f4518805 100644 --- a/src/style.rs +++ b/src/style.rs @@ -1682,12 +1682,12 @@ define_builtin_props!( prop!( /// How children overflowing their container in Y axis should affect layout - pub(crate) OverflowX: Overflow {} = Overflow::default() + pub OverflowX: Overflow {} = Overflow::default() ); prop!( /// How children overflowing their container in X axis should affect layout - pub(crate) OverflowY: Overflow {} = Overflow::default() + pub OverflowY: Overflow {} = Overflow::default() ); prop_extractor! {