diff options
Diffstat (limited to 'src/text.rs')
| -rw-r--r-- | src/text.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/text.rs b/src/text.rs index ad5c350..ff5d5a4 100644 --- a/src/text.rs +++ b/src/text.rs @@ -388,7 +388,7 @@ where let click_position = cursor.position_in(bounds); if viewport.intersection(&bounds).is_none() - && state.selection == Selection::default() + && state.selection.is_empty() && state.dragging.is_none() { return; @@ -466,7 +466,14 @@ where state.selection.change_selection(new_end); } - Dragging::Word => {} + Dragging::Word => { + let new_end = SelectionEnd { line, index }; + + state.selection.change_selection_by_word( + new_end, + &state.paragraph, + ); + } Dragging::Line => { state.selection.change_selection_by_line( line, @@ -491,7 +498,7 @@ where } keyboard::Key::Character("a") if state.keyboard_modifiers.command() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { state.selection.select_all(&state.paragraph); @@ -499,7 +506,7 @@ where } keyboard::Key::Named(key::Named::Home) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.jump() { state.selection.select_beginning(); @@ -511,7 +518,7 @@ where } keyboard::Key::Named(key::Named::End) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.jump() { state.selection.select_end(&state.paragraph); @@ -523,7 +530,7 @@ where } keyboard::Key::Named(key::Named::ArrowLeft) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_line_beginning(); @@ -539,7 +546,7 @@ where } keyboard::Key::Named(key::Named::ArrowRight) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_line_end(&state.paragraph); @@ -555,7 +562,7 @@ where } keyboard::Key::Named(key::Named::ArrowUp) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_beginning(); @@ -569,7 +576,7 @@ where } keyboard::Key::Named(key::Named::ArrowDown) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_end(&state.paragraph); |
