summaryrefslogtreecommitdiffstats
path: root/widget/src/text_editor.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-13 16:31:56 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-13 16:31:56 +0200
commitf14ef7a6069cf45ae11261d7d20df6a5d7870dde (patch)
tree019e4c9fdc25e4095e134585577e355b9b0a33e5 /widget/src/text_editor.rs
parentf4c51a96d50953d5fb6e9eb62194f226e2cbfd3c (diff)
downloadiced-f14ef7a6069cf45ae11261d7d20df6a5d7870dde.tar.gz
iced-f14ef7a6069cf45ae11261d7d20df6a5d7870dde.tar.bz2
iced-f14ef7a6069cf45ae11261d7d20df6a5d7870dde.zip
Fix `clippy` lints
Diffstat (limited to 'widget/src/text_editor.rs')
-rw-r--r--widget/src/text_editor.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 38c243bd..48de6409 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -7,8 +7,8 @@ use crate::core::text::editor::{Cursor, Editor as _};
use crate::core::text::{self, LineHeight};
use crate::core::widget::{self, Widget};
use crate::core::{
- Clipboard, Color, Element, Length, Padding, Pixels, Point, Rectangle,
- Shell, Vector,
+ Clipboard, Color, Element, Length, Padding, Pixels, Rectangle, Shell,
+ Vector,
};
use std::cell::RefCell;
@@ -205,8 +205,12 @@ where
Update::Edit(action) => {
shell.publish(on_edit(action));
}
- Update::Copy => {}
- Update::Paste => if let Some(_contents) = clipboard.read() {},
+ Update::Copy => todo!(),
+ Update::Paste => {
+ if let Some(_contents) = clipboard.read() {
+ todo!()
+ }
+ }
}
event::Status::Captured
@@ -353,7 +357,6 @@ impl Update {
cursor: mouse::Cursor,
) -> Option<Self> {
let edit = |action| Some(Update::Edit(action));
- let move_ = |motion| Some(Update::Edit(Action::Move(motion)));
match event {
Event::Mouse(event) => match event {
@@ -399,11 +402,12 @@ impl Update {
modifiers,
} if state.is_focused => {
if let Some(motion) = motion(key_code) {
- let motion = if modifiers.control() {
- motion.widen()
- } else {
- motion
- };
+ let motion =
+ if platform::is_jump_modifier_pressed(modifiers) {
+ motion.widen()
+ } else {
+ motion
+ };
return edit(if modifiers.shift() {
Action::Select(motion)
@@ -417,6 +421,12 @@ impl Update {
keyboard::KeyCode::Backspace => edit(Action::Backspace),
keyboard::KeyCode::Delete => edit(Action::Delete),
keyboard::KeyCode::Escape => Some(Self::Unfocus),
+ keyboard::KeyCode::C => Some(Self::Copy),
+ keyboard::KeyCode::V
+ if modifiers.command() && !modifiers.alt() =>
+ {
+ Some(Self::Paste)
+ }
_ => None,
}
}