Skip to content

Commit

Permalink
make the project more flexible. (#714)
Browse files Browse the repository at this point in the history
* make the project more flexible.

* fmt
  • Loading branch information
jm-observer authored Jan 2, 2025
1 parent 3052a51 commit d91c0d4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion renderer/src/text/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'a> Attrs<'a> {
}

#[derive(PartialEq, Clone)]
pub struct AttrsList(pub(crate) cosmic_text::AttrsList);
pub struct AttrsList(pub cosmic_text::AttrsList);

impl AttrsList {
/// Create a new attributes list with a set of default [Attrs]
Expand Down
8 changes: 7 additions & 1 deletion renderer/src/text/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl LayoutRun<'_> {
}
}

fn cursor_from_glyph_right(&self, glyph: &LayoutGlyph) -> Cursor {
pub fn cursor_from_glyph_right(&self, glyph: &LayoutGlyph) -> Cursor {
if self.rtl {
Cursor::new_with_affinity(self.line_i, glyph.start, Affinity::After)
} else {
Expand Down Expand Up @@ -221,6 +221,12 @@ impl TextLayout {
}
}

pub fn new_with_text(text: &str, attrs_list: AttrsList) -> Self {
let mut layout = Self::new();
layout.set_text(text, attrs_list);
layout
}

pub fn set_text(&mut self, text: &str, attrs_list: AttrsList) {
self.buffer.lines.clear();
self.lines_range.clear();
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pub use cosmic_text::{
fontdb, CacheKey, Cursor, Family, LayoutGlyph, LayoutLine, Stretch, Style, SubpixelBin,
SwashCache, SwashContent, Weight, Wrap,
};
pub use layout::{HitPoint, HitPosition, TextLayout, FONT_SYSTEM};
pub use layout::{HitPoint, HitPosition, LayoutRun, TextLayout, FONT_SYSTEM};
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub use app_state::AppState;
pub use clipboard::{Clipboard, ClipboardError};
pub use floem_reactive as reactive;
pub use floem_renderer::text;
use floem_renderer::Renderer;
pub use floem_renderer::Renderer;
pub use id::ViewId;
pub use peniko;
pub use peniko::kurbo;
Expand Down
2 changes: 1 addition & 1 deletion src/views/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ prop_extractor! {
}
}
impl EditorStyle {
fn ed_text_color(&self) -> Color {
pub fn ed_text_color(&self) -> Color {
self.text_color().unwrap_or(Color::BLACK)
}
}
Expand Down

0 comments on commit d91c0d4

Please sign in to comment.