Editor: add GotoLine action

This commit is contained in:
Jeremy Soller 2023-11-07 15:56:31 -07:00
parent e62fea5efd
commit db0883b525
2 changed files with 8 additions and 0 deletions

View file

@ -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 {

View file

@ -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`