allow setting cursor
This commit is contained in:
parent
b5f45f81f6
commit
6dba04df08
4 changed files with 16 additions and 12 deletions
|
|
@ -36,17 +36,6 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new [`Editor`] with the provided [`Buffer`] and [`Cursor`]
|
||||
pub fn new_with_cursor(buffer: Buffer, cursor: Cursor) -> Self {
|
||||
Self {
|
||||
buffer,
|
||||
cursor,
|
||||
cursor_x_opt: None,
|
||||
select_opt: None,
|
||||
cursor_moved: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn set_layout_cursor(&mut self, font_system: &mut FontSystem, cursor: LayoutCursor) {
|
||||
let layout = self
|
||||
.buffer
|
||||
|
|
@ -95,6 +84,10 @@ impl Edit for Editor {
|
|||
self.cursor
|
||||
}
|
||||
|
||||
fn set_cursor(&mut self, cursor: Cursor) {
|
||||
self.cursor = cursor;
|
||||
}
|
||||
|
||||
fn select_opt(&self) -> Option<Cursor> {
|
||||
self.select_opt
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,9 +99,12 @@ pub trait Edit {
|
|||
/// Get the internal [`Buffer`], mutably
|
||||
fn buffer_mut(&mut self) -> &mut Buffer;
|
||||
|
||||
/// Get the current cursor position
|
||||
/// Get the current cursor
|
||||
fn cursor(&self) -> Cursor;
|
||||
|
||||
/// Set the current cursor
|
||||
fn set_cursor(&mut self, cursor: Cursor);
|
||||
|
||||
/// Get the current selection position
|
||||
fn select_opt(&self) -> Option<Cursor>;
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,10 @@ impl<'a> Edit for SyntaxEditor<'a> {
|
|||
self.editor.cursor()
|
||||
}
|
||||
|
||||
fn set_cursor(&mut self, cursor: Cursor) {
|
||||
self.editor.set_cursor(cursor);
|
||||
}
|
||||
|
||||
fn select_opt(&self) -> Option<Cursor> {
|
||||
self.editor.select_opt()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ impl<'a> Edit for ViEditor<'a> {
|
|||
self.editor.cursor()
|
||||
}
|
||||
|
||||
fn set_cursor(&mut self, cursor: Cursor) {
|
||||
self.editor.set_cursor(cursor);
|
||||
}
|
||||
|
||||
fn select_opt(&self) -> Option<Cursor> {
|
||||
self.editor.select_opt()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue