Editor: add GotoLine action
This commit is contained in:
parent
e62fea5efd
commit
db0883b525
2 changed files with 8 additions and 0 deletions
|
|
@ -91,6 +91,7 @@ impl Edit for Editor {
|
|||
if self.cursor != cursor {
|
||||
self.cursor = cursor;
|
||||
self.cursor_moved = true;
|
||||
self.cursor_x_opt = None;
|
||||
self.buffer.set_redraw(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -854,6 +855,11 @@ impl Edit for Editor {
|
|||
self.cursor.index = self.buffer.lines[self.cursor.line].text().len();
|
||||
self.cursor_x_opt = None;
|
||||
}
|
||||
Action::GotoLine(line) => {
|
||||
let mut cursor = self.buffer.layout_cursor(&self.cursor);
|
||||
cursor.line = line;
|
||||
self.set_layout_cursor(font_system, cursor);
|
||||
}
|
||||
}
|
||||
|
||||
if old_cursor != self.cursor {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ pub enum Action {
|
|||
BufferStart,
|
||||
/// Move cursor to the end of the document
|
||||
BufferEnd,
|
||||
/// Move cursor to specific line
|
||||
GotoLine(usize),
|
||||
}
|
||||
|
||||
/// A trait to allow easy replacements of [`Editor`], like `SyntaxEditor`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue