Implement motion selection in text::Editor
This commit is contained in:
parent
b24b94d827
commit
edd5918475
1 changed files with 20 additions and 1 deletions
|
|
@ -254,7 +254,26 @@ impl editor::Editor for Editor {
|
|||
}
|
||||
|
||||
// Selection events
|
||||
Action::Select(_motion) => todo!(),
|
||||
Action::Select(motion) => {
|
||||
let cursor = editor.cursor();
|
||||
|
||||
if editor.select_opt().is_none() {
|
||||
editor.set_select_opt(Some(cursor));
|
||||
}
|
||||
|
||||
editor.action(font_system.raw(), motion_to_action(motion));
|
||||
|
||||
// Deselect if selection matches cursor position
|
||||
if let Some(selection) = editor.select_opt() {
|
||||
let cursor = editor.cursor();
|
||||
|
||||
if cursor.line == selection.line
|
||||
&& cursor.index == selection.index
|
||||
{
|
||||
editor.set_select_opt(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::SelectWord => todo!(),
|
||||
Action::SelectLine => todo!(),
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue