Add move_to method to Editor

This commit is contained in:
Héctor Ramón Jiménez 2025-12-01 20:11:42 +01:00
parent 63e9eeffb5
commit 4428f31b4f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 295 additions and 258 deletions

View file

@ -390,7 +390,6 @@ where
R: text::Renderer,
{
editor: R::Editor,
is_dirty: bool,
}
impl<R> Content<R>
@ -406,7 +405,6 @@ where
pub fn with_text(text: &str) -> Self {
Self(RefCell::new(Internal {
editor: R::Editor::with_text(text),
is_dirty: true,
}))
}
@ -415,7 +413,13 @@ where
let internal = self.0.get_mut();
internal.editor.perform(action);
internal.is_dirty = true;
}
/// Moves the current cursor to reflect the given one.
pub fn move_to(&mut self, cursor: Cursor) {
let internal = self.0.get_mut();
internal.editor.move_to(cursor);
}
/// Returns the current cursor position of the [`Content`].
@ -511,7 +515,6 @@ where
f.debug_struct("Content")
.field("editor", &internal.editor)
.field("is_dirty", &internal.is_dirty)
.finish()
}
}