Skip to content

Commit

Permalink
expore some more things (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 authored Jan 24, 2025
1 parent 39c5c70 commit ea7cefb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions editor-core/src/buffer/rope_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions editor-core/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ impl Selection {
self.regions.iter().all(|region| region.is_caret())
}

pub fn current_caret(&self) -> Option<usize> {
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
Expand Down
4 changes: 4 additions & 0 deletions renderer/src/text/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
4 changes: 2 additions & 2 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit ea7cefb

Please sign in to comment.