chore: update libcosmic
This commit is contained in:
parent
1a7b210b70
commit
0a5325ba05
6 changed files with 491 additions and 504 deletions
|
|
@ -1,4 +1,7 @@
|
|||
use cosmic::iced::keyboard::{KeyCode, Modifiers};
|
||||
use cosmic::{
|
||||
iced::keyboard::{Key, Modifiers},
|
||||
iced_core::keyboard::key::Named,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
|
|
@ -15,12 +18,12 @@ pub enum Modifier {
|
|||
#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct KeyBind {
|
||||
pub modifiers: Vec<Modifier>,
|
||||
pub key_code: KeyCode,
|
||||
pub key: Key,
|
||||
}
|
||||
|
||||
impl KeyBind {
|
||||
pub fn matches(&self, modifiers: Modifiers, key_code: KeyCode) -> bool {
|
||||
self.key_code == key_code
|
||||
pub fn matches(&self, modifiers: Modifiers, key: Key) -> bool {
|
||||
self.key == key
|
||||
&& modifiers.logo() == self.modifiers.contains(&Modifier::Super)
|
||||
&& modifiers.control() == self.modifiers.contains(&Modifier::Ctrl)
|
||||
&& modifiers.alt() == self.modifiers.contains(&Modifier::Alt)
|
||||
|
|
@ -33,7 +36,7 @@ impl fmt::Display for KeyBind {
|
|||
for modifier in self.modifiers.iter() {
|
||||
write!(f, "{:?} + ", modifier)?;
|
||||
}
|
||||
write!(f, "{:?}", self.key_code)
|
||||
write!(f, "{:?}", self.key)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,47 +45,55 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
|
|||
let mut key_binds = HashMap::new();
|
||||
|
||||
macro_rules! bind {
|
||||
([$($modifier:ident),+ $(,)?], $key_code:ident, $action:ident) => {{
|
||||
([$($modifier:ident),+ $(,)?], $key:expr, $action:ident) => {{
|
||||
key_binds.insert(
|
||||
KeyBind {
|
||||
modifiers: vec![$(Modifier::$modifier),+],
|
||||
key_code: KeyCode::$key_code,
|
||||
key: $key,
|
||||
},
|
||||
Action::$action,
|
||||
);
|
||||
}};
|
||||
}
|
||||
|
||||
bind!([Ctrl], W, CloseFile);
|
||||
bind!([Ctrl], X, Cut);
|
||||
bind!([Ctrl], C, Copy);
|
||||
bind!([Ctrl], F, Find);
|
||||
bind!([Ctrl], H, FindAndReplace);
|
||||
bind!([Ctrl], V, Paste);
|
||||
bind!([Ctrl], T, NewFile);
|
||||
bind!([Ctrl], N, NewWindow);
|
||||
bind!([Ctrl], O, OpenFileDialog);
|
||||
bind!([Ctrl, Shift], O, OpenProjectDialog);
|
||||
bind!([Ctrl], Q, Quit);
|
||||
bind!([Ctrl, Shift], Z, Redo);
|
||||
bind!([Ctrl], S, Save);
|
||||
bind!([Ctrl], A, SelectAll);
|
||||
bind!([Ctrl], Key1, TabActivate0);
|
||||
bind!([Ctrl], Key2, TabActivate1);
|
||||
bind!([Ctrl], Key3, TabActivate2);
|
||||
bind!([Ctrl], Key4, TabActivate3);
|
||||
bind!([Ctrl], Key5, TabActivate4);
|
||||
bind!([Ctrl], Key6, TabActivate5);
|
||||
bind!([Ctrl], Key7, TabActivate6);
|
||||
bind!([Ctrl], Key8, TabActivate7);
|
||||
bind!([Ctrl], Key9, TabActivate8);
|
||||
bind!([Ctrl], Tab, TabNext);
|
||||
bind!([Ctrl, Shift], Tab, TabPrev);
|
||||
bind!([Ctrl, Shift], G, ToggleGitManagement);
|
||||
bind!([Ctrl, Shift], F, ToggleProjectSearch);
|
||||
bind!([Ctrl], Comma, ToggleSettingsPage);
|
||||
bind!([Alt], Z, ToggleWordWrap);
|
||||
bind!([Ctrl], Z, Undo);
|
||||
bind!([Ctrl], Key::Character("w".into()), CloseFile);
|
||||
bind!([Ctrl], Key::Character("x".into()), Cut);
|
||||
bind!([Ctrl], Key::Character("c".into()), Copy);
|
||||
bind!([Ctrl], Key::Character("f".into()), Find);
|
||||
bind!([Ctrl], Key::Character("h".into()), FindAndReplace);
|
||||
bind!([Ctrl], Key::Character("v".into()), Paste);
|
||||
bind!([Ctrl], Key::Character("t".into()), NewFile);
|
||||
bind!([Ctrl], Key::Character("n".into()), NewWindow);
|
||||
bind!([Ctrl], Key::Character("o".into()), OpenFileDialog);
|
||||
bind!([Ctrl, Shift], Key::Character("O".into()), OpenProjectDialog);
|
||||
bind!([Ctrl], Key::Character("q".into()), Quit);
|
||||
bind!([Ctrl, Shift], Key::Character("z".into()), Redo);
|
||||
bind!([Ctrl], Key::Character("s".into()), Save);
|
||||
bind!([Ctrl], Key::Character("a".into()), SelectAll);
|
||||
bind!([Ctrl], Key::Character("1".into()), TabActivate0);
|
||||
bind!([Ctrl], Key::Character("2".into()), TabActivate1);
|
||||
bind!([Ctrl], Key::Character("3".into()), TabActivate2);
|
||||
bind!([Ctrl], Key::Character("4".into()), TabActivate3);
|
||||
bind!([Ctrl], Key::Character("5".into()), TabActivate4);
|
||||
bind!([Ctrl], Key::Character("6".into()), TabActivate5);
|
||||
bind!([Ctrl], Key::Character("7".into()), TabActivate6);
|
||||
bind!([Ctrl], Key::Character("8".into()), TabActivate7);
|
||||
bind!([Ctrl], Key::Character("9".into()), TabActivate8);
|
||||
bind!([Ctrl], Key::Named(Named::Tab), TabNext);
|
||||
bind!([Ctrl, Shift], Key::Named(Named::Tab), TabPrev);
|
||||
bind!(
|
||||
[Ctrl, Shift],
|
||||
Key::Character("G".into()),
|
||||
ToggleGitManagement
|
||||
);
|
||||
bind!(
|
||||
[Ctrl, Shift],
|
||||
Key::Character("F".into()),
|
||||
ToggleProjectSearch
|
||||
);
|
||||
bind!([Ctrl], Key::Character(",".into()), ToggleSettingsPage);
|
||||
bind!([Alt], Key::Character("z".into()), ToggleWordWrap);
|
||||
bind!([Ctrl], Key::Character("z".into()), Undo);
|
||||
|
||||
key_binds
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue