Remove Mutex from FontSystem
This commit is contained in:
parent
46e9ef0246
commit
384c5c1fdc
16 changed files with 109 additions and 96 deletions
|
|
@ -35,7 +35,7 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_layout_cursor(&mut self, font_system: &FontSystem, cursor: LayoutCursor) {
|
||||
pub(crate) fn set_layout_cursor(&mut self, font_system: &mut FontSystem, cursor: LayoutCursor) {
|
||||
let layout = self
|
||||
.buffer
|
||||
.line_layout(font_system, cursor.line)
|
||||
|
|
@ -94,7 +94,7 @@ impl Edit for Editor {
|
|||
}
|
||||
}
|
||||
|
||||
fn shape_as_needed(&mut self, font_system: &FontSystem) {
|
||||
fn shape_as_needed(&mut self, font_system: &mut FontSystem) {
|
||||
if self.cursor_moved {
|
||||
self.buffer.shape_until_cursor(font_system, self.cursor);
|
||||
self.cursor_moved = false;
|
||||
|
|
@ -281,7 +281,7 @@ impl Edit for Editor {
|
|||
self.cursor.index = self.buffer.lines[self.cursor.line].text().len() - after_len;
|
||||
}
|
||||
|
||||
fn action(&mut self, font_system: &FontSystem, action: Action) {
|
||||
fn action(&mut self, font_system: &mut FontSystem, action: Action) {
|
||||
let old_cursor = self.cursor;
|
||||
|
||||
match action {
|
||||
|
|
@ -677,7 +677,7 @@ impl Edit for Editor {
|
|||
#[cfg(feature = "swash")]
|
||||
fn draw<F>(
|
||||
&self,
|
||||
font_system: &FontSystem,
|
||||
font_system: &mut FontSystem,
|
||||
cache: &mut crate::SwashCache,
|
||||
color: Color,
|
||||
mut f: F,
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ pub trait Edit {
|
|||
fn set_select_opt(&mut self, select_opt: Option<Cursor>);
|
||||
|
||||
/// Shape lines until scroll, after adjusting scroll if the cursor moved
|
||||
fn shape_as_needed(&mut self, font_system: &FontSystem);
|
||||
fn shape_as_needed(&mut self, font_system: &mut FontSystem);
|
||||
|
||||
/// Copy selection
|
||||
fn copy_selection(&mut self) -> Option<String>;
|
||||
|
|
@ -122,12 +122,17 @@ pub trait Edit {
|
|||
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>);
|
||||
|
||||
/// Perform an [Action] on the editor
|
||||
fn action(&mut self, font_system: &FontSystem, action: Action);
|
||||
fn action(&mut self, font_system: &mut FontSystem, action: Action);
|
||||
|
||||
/// Draw the editor
|
||||
#[cfg(feature = "swash")]
|
||||
fn draw<F>(&self, font_system: &FontSystem, cache: &mut crate::SwashCache, color: Color, f: F)
|
||||
where
|
||||
fn draw<F>(
|
||||
&self,
|
||||
font_system: &mut FontSystem,
|
||||
cache: &mut crate::SwashCache,
|
||||
color: Color,
|
||||
f: F,
|
||||
) where
|
||||
F: FnMut(i32, i32, u32, u32, Color);
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +157,7 @@ impl<'a, T: Edit> BorrowedWithFontSystem<'a, T> {
|
|||
|
||||
/// Draw the editor
|
||||
#[cfg(feature = "swash")]
|
||||
pub fn draw<F>(&self, cache: &mut crate::SwashCache, color: Color, f: F)
|
||||
pub fn draw<F>(&mut self, cache: &mut crate::SwashCache, color: Color, f: F)
|
||||
where
|
||||
F: FnMut(i32, i32, u32, u32, Color),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl<'a> SyntaxEditor<'a> {
|
|||
#[cfg(feature = "std")]
|
||||
pub(crate) fn load_text<P: AsRef<Path>>(
|
||||
&mut self,
|
||||
font_system: &FontSystem,
|
||||
font_system: &mut FontSystem,
|
||||
path: P,
|
||||
attrs: crate::Attrs,
|
||||
) -> io::Result<()> {
|
||||
|
|
@ -131,7 +131,7 @@ impl<'a> Edit for SyntaxEditor<'a> {
|
|||
self.editor.set_select_opt(select_opt);
|
||||
}
|
||||
|
||||
fn shape_as_needed(&mut self, font_system: &FontSystem) {
|
||||
fn shape_as_needed(&mut self, font_system: &mut FontSystem) {
|
||||
#[cfg(feature = "std")]
|
||||
let now = std::time::Instant::now();
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ impl<'a> Edit for SyntaxEditor<'a> {
|
|||
self.editor.insert_string(data, attrs_list);
|
||||
}
|
||||
|
||||
fn action(&mut self, font_system: &FontSystem, action: Action) {
|
||||
fn action(&mut self, font_system: &mut FontSystem, action: Action) {
|
||||
self.editor.action(font_system, action);
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ impl<'a> Edit for SyntaxEditor<'a> {
|
|||
#[cfg(feature = "swash")]
|
||||
fn draw<F>(
|
||||
&self,
|
||||
font_system: &FontSystem,
|
||||
font_system: &mut FontSystem,
|
||||
cache: &mut crate::SwashCache,
|
||||
_color: Color,
|
||||
mut f: F,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ impl<'a> ViEditor<'a> {
|
|||
#[cfg(feature = "std")]
|
||||
pub(crate) fn load_text<P: AsRef<std::path::Path>>(
|
||||
&mut self,
|
||||
font_system: &FontSystem,
|
||||
font_system: &mut FontSystem,
|
||||
path: P,
|
||||
attrs: crate::Attrs,
|
||||
) -> std::io::Result<()> {
|
||||
|
|
@ -71,7 +71,7 @@ impl<'a> Edit for ViEditor<'a> {
|
|||
self.editor.set_select_opt(select_opt);
|
||||
}
|
||||
|
||||
fn shape_as_needed(&mut self, font_system: &FontSystem) {
|
||||
fn shape_as_needed(&mut self, font_system: &mut FontSystem) {
|
||||
self.editor.shape_as_needed(font_system);
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ impl<'a> Edit for ViEditor<'a> {
|
|||
self.editor.insert_string(data, attrs_list);
|
||||
}
|
||||
|
||||
fn action(&mut self, font_system: &FontSystem, action: Action) {
|
||||
fn action(&mut self, font_system: &mut FontSystem, action: Action) {
|
||||
let old_mode = self.mode;
|
||||
|
||||
match self.mode {
|
||||
|
|
@ -229,7 +229,7 @@ impl<'a> Edit for ViEditor<'a> {
|
|||
#[cfg(feature = "swash")]
|
||||
fn draw<F>(
|
||||
&self,
|
||||
font_system: &FontSystem,
|
||||
font_system: &mut FontSystem,
|
||||
cache: &mut crate::SwashCache,
|
||||
color: Color,
|
||||
mut f: F,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue