Use bitflags for keyboard::Modifiers
This commit is contained in:
parent
735cfb7908
commit
b57d567981
6 changed files with 78 additions and 72 deletions
|
|
@ -362,7 +362,7 @@ where
|
|||
Event::Keyboard(keyboard::Event::CharacterReceived(c))
|
||||
if self.state.is_focused
|
||||
&& self.state.is_pasting.is_none()
|
||||
&& !self.state.keyboard_modifiers.is_command_pressed()
|
||||
&& !self.state.keyboard_modifiers.command()
|
||||
&& !c.is_control() =>
|
||||
{
|
||||
let mut editor =
|
||||
|
|
@ -450,7 +450,7 @@ where
|
|||
if platform::is_jump_modifier_pressed(modifiers)
|
||||
&& !self.is_secure
|
||||
{
|
||||
if modifiers.shift {
|
||||
if modifiers.shift() {
|
||||
self.state
|
||||
.cursor
|
||||
.select_left_by_words(&self.value);
|
||||
|
|
@ -459,7 +459,7 @@ where
|
|||
.cursor
|
||||
.move_left_by_words(&self.value);
|
||||
}
|
||||
} else if modifiers.shift {
|
||||
} else if modifiers.shift() {
|
||||
self.state.cursor.select_left(&self.value)
|
||||
} else {
|
||||
self.state.cursor.move_left(&self.value);
|
||||
|
|
@ -469,7 +469,7 @@ where
|
|||
if platform::is_jump_modifier_pressed(modifiers)
|
||||
&& !self.is_secure
|
||||
{
|
||||
if modifiers.shift {
|
||||
if modifiers.shift() {
|
||||
self.state
|
||||
.cursor
|
||||
.select_right_by_words(&self.value);
|
||||
|
|
@ -478,14 +478,14 @@ where
|
|||
.cursor
|
||||
.move_right_by_words(&self.value);
|
||||
}
|
||||
} else if modifiers.shift {
|
||||
} else if modifiers.shift() {
|
||||
self.state.cursor.select_right(&self.value)
|
||||
} else {
|
||||
self.state.cursor.move_right(&self.value);
|
||||
}
|
||||
}
|
||||
keyboard::KeyCode::Home => {
|
||||
if modifiers.shift {
|
||||
if modifiers.shift() {
|
||||
self.state.cursor.select_range(
|
||||
self.state.cursor.start(&self.value),
|
||||
0,
|
||||
|
|
@ -495,7 +495,7 @@ where
|
|||
}
|
||||
}
|
||||
keyboard::KeyCode::End => {
|
||||
if modifiers.shift {
|
||||
if modifiers.shift() {
|
||||
self.state.cursor.select_range(
|
||||
self.state.cursor.start(&self.value),
|
||||
self.value.len(),
|
||||
|
|
@ -505,10 +505,7 @@ where
|
|||
}
|
||||
}
|
||||
keyboard::KeyCode::C
|
||||
if self
|
||||
.state
|
||||
.keyboard_modifiers
|
||||
.is_command_pressed() =>
|
||||
if self.state.keyboard_modifiers.command() =>
|
||||
{
|
||||
match self.state.cursor.selection(&self.value) {
|
||||
Some((start, end)) => {
|
||||
|
|
@ -520,10 +517,7 @@ where
|
|||
}
|
||||
}
|
||||
keyboard::KeyCode::X
|
||||
if self
|
||||
.state
|
||||
.keyboard_modifiers
|
||||
.is_command_pressed() =>
|
||||
if self.state.keyboard_modifiers.command() =>
|
||||
{
|
||||
match self.state.cursor.selection(&self.value) {
|
||||
Some((start, end)) => {
|
||||
|
|
@ -545,7 +539,7 @@ where
|
|||
messages.push(message);
|
||||
}
|
||||
keyboard::KeyCode::V => {
|
||||
if self.state.keyboard_modifiers.is_command_pressed() {
|
||||
if self.state.keyboard_modifiers.command() {
|
||||
let content = match self.state.is_pasting.take() {
|
||||
Some(content) => content,
|
||||
None => {
|
||||
|
|
@ -576,10 +570,7 @@ where
|
|||
}
|
||||
}
|
||||
keyboard::KeyCode::A
|
||||
if self
|
||||
.state
|
||||
.keyboard_modifiers
|
||||
.is_command_pressed() =>
|
||||
if self.state.keyboard_modifiers.command() =>
|
||||
{
|
||||
self.state.cursor.select_all(&self.value);
|
||||
}
|
||||
|
|
@ -858,9 +849,9 @@ mod platform {
|
|||
|
||||
pub fn is_jump_modifier_pressed(modifiers: keyboard::Modifiers) -> bool {
|
||||
if cfg!(target_os = "macos") {
|
||||
modifiers.alt
|
||||
modifiers.alt()
|
||||
} else {
|
||||
modifiers.control
|
||||
modifiers.control()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue