Compare commits

...

1 Commits

Author SHA1 Message Date
Jakub Panek aba2b4d5ef fix: make modifiers configurable 2023-08-13 13:43:25 +02:00
2 changed files with 72 additions and 4 deletions
+40
View File
@@ -153,6 +153,46 @@ pub struct EditorConfig {
desc = "Set the default number of visible lines above and below the diff block (-1 for infinite)"
)]
pub diff_context_lines: i32,
#[field_names(desc = "Multi-cursor key modifier.")]
pub multi_cursor_key_modifier: ModifierKeys,
#[field_names(desc = "Selection key modifier.")]
pub multi_select_key_modifier: ModifierKeys,
}
type MultiCursorKeyModifier = ModifierKeys;
impl Default for MultiCursorKeyModifier {
fn default() -> Self {
Self::Alt
}
}
type MultiSelectKeyModifier = ModifierKeys;
impl Default for MultiSelectKeyModifier {
fn default() -> Self {
Self::CtrlCmd
}
}
enum ModifierKeys {
/// Maps to Alt on Windows/Linux and Option on macOS
Alt,
/// Maps to Control on Windows/Linux and to Command on macOS
CtrlCmd,
}
impl Into<floem::glazier::keyboard_types::modifiers::Modifiers> for ModifierKeys {
fn into(self) -> keyboard_types::modifiers::Modifiers {
use floem::glazier::keyboard_types::modifiers::Modifiers;
match self {
ModifierKeys::Alt => Modifiers::ALT,
#[cfg(not(target_os = "macos"))]
ModifierKeys::CtrlCmd => Modifiers::CONTROL,
#[cfg(target_os = "macos")]
ModifierKeys::CtrlCmd => Modifiers::META,
}
}
}
impl EditorConfig {
+32 -4
View File
@@ -1882,8 +1882,22 @@ impl EditorData {
cursor.add_region(
start,
end,
pointer_event.modifiers.contains(Modifiers::SHIFT),
pointer_event.modifiers.contains(Modifiers::ALT),
pointer_event.modifiers.contains(
self.common
.config
.get_untracked()
.editor
.multi_select_key_modifier
.into(),
),
pointer_event.modifiers.contains(
self.common
.config
.get_untracked()
.editor
.multi_cursor_key_modifier
.into(),
),
)
});
}
@@ -1899,8 +1913,22 @@ impl EditorData {
cursor.add_region(
start,
end,
pointer_event.modifiers.contains(Modifiers::SHIFT),
pointer_event.modifiers.contains(Modifiers::ALT),
pointer_event.modifiers.contains(
self.common
.config
.get_untracked()
.editor
.multi_select_key_modifier
.into(),
),
pointer_event.modifiers.contains(
self.common
.config
.get_untracked()
.editor
.multi_cursor_key_modifier
.into(),
),
)
});
}