Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the project more flexible. #714

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading