|
|
|
@ -4,6 +4,253 @@ use indoc::indoc;
|
|
|
|
|
extern crate serde_yaml;
|
|
|
|
|
extern crate toml;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_basic() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- name: Global
|
|
|
|
|
remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_application() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not:
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_application_regex() {
|
|
|
|
|
yaml_assert_parse(indoc! {r"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not:
|
|
|
|
|
- /^Minecraft/
|
|
|
|
|
- /^Minecraft\//
|
|
|
|
|
- /^Minecraft\d/
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: /^Miencraft\\/
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_multi_purpose_key() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Space:
|
|
|
|
|
held: Shift_L
|
|
|
|
|
alone: Space
|
|
|
|
|
- remap:
|
|
|
|
|
Muhenkan:
|
|
|
|
|
held: Alt_L
|
|
|
|
|
alone: Muhenkan
|
|
|
|
|
alone_timeout_millis: 500
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_multi_purpose_key_multi_key() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Space:
|
|
|
|
|
held: [Shift_L]
|
|
|
|
|
alone: [Shift_L,A]
|
|
|
|
|
- remap:
|
|
|
|
|
Muhenkan:
|
|
|
|
|
held: [Alt_L,Shift_L]
|
|
|
|
|
alone: [Muhenkan]
|
|
|
|
|
alone_timeout_millis: 500
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_virtual_modifiers() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
virtual_modifiers:
|
|
|
|
|
- CapsLock
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_press_release_key() {
|
|
|
|
|
yaml_assert_parse(indoc! {r#"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Space:
|
|
|
|
|
press: { launch: ["wmctrl", "-x", "-a", "code.Code"] }
|
|
|
|
|
release: { launch: ["wmctrl", "-x", "-a", "nocturn.Nocturn"] }
|
|
|
|
|
"#})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_basic() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- name: Global
|
|
|
|
|
remap:
|
|
|
|
|
Alt-Enter: Ctrl-Enter
|
|
|
|
|
- remap:
|
|
|
|
|
M-S: C-S
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_lr_modifiers() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- name: Global
|
|
|
|
|
remap:
|
|
|
|
|
Alt_L-Enter: Ctrl_L-Enter
|
|
|
|
|
- remap:
|
|
|
|
|
M_R-S: C_L-S
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_application() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt-Enter: Ctrl-Enter
|
|
|
|
|
application:
|
|
|
|
|
not: Gnome-terminal
|
|
|
|
|
- remap:
|
|
|
|
|
Alt-S: Ctrl-S
|
|
|
|
|
application:
|
|
|
|
|
only:
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_array() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
C-w:
|
|
|
|
|
- Shift-C-w
|
|
|
|
|
- C-x
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_remap() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
C-x:
|
|
|
|
|
remap:
|
|
|
|
|
s: C-w
|
|
|
|
|
C-s:
|
|
|
|
|
remap:
|
|
|
|
|
x: C-z
|
|
|
|
|
timeout_key: Down
|
|
|
|
|
timeout_millis: 1000
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_launch() {
|
|
|
|
|
yaml_assert_parse(indoc! {r#"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
KEY_GRAVE:
|
|
|
|
|
launch:
|
|
|
|
|
- "/bin/sh"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "date > /tmp/hotkey_test"
|
|
|
|
|
"#})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_mode() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
default_mode: insert
|
|
|
|
|
keymap:
|
|
|
|
|
- mode: insert
|
|
|
|
|
remap:
|
|
|
|
|
Esc: { set_mode: normal }
|
|
|
|
|
- mode: normal
|
|
|
|
|
remap:
|
|
|
|
|
i: { set_mode: insert }
|
|
|
|
|
h: Left
|
|
|
|
|
j: Down
|
|
|
|
|
k: Up
|
|
|
|
|
l: Right
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_mark() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
C-space: { set_mark: true }
|
|
|
|
|
C-g: [esc, { set_mark: false }]
|
|
|
|
|
C-b: { with_mark: left }
|
|
|
|
|
M-b: { with_mark: C-left }
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_shared_data_anchor() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
shared:
|
|
|
|
|
terminals: &terminals
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
- Kitty
|
|
|
|
|
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not: *terminals
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
#[should_panic]
|
|
|
|
|
fn test_yaml_fail_on_data_outside_of_config_model() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
terminals: &terminals
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
- Kitty
|
|
|
|
|
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not: *terminals
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_toml_modmap_basic() {
|
|
|
|
|
toml_assert_parse(indoc! {"
|
|
|
|
@ -276,252 +523,7 @@ fn test_toml_fail_on_data_outside_of_config_model() {
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_basic() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- name: Global
|
|
|
|
|
remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_application() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not:
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_application_regex() {
|
|
|
|
|
yaml_assert_parse(indoc! {r"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not:
|
|
|
|
|
- /^Minecraft/
|
|
|
|
|
- /^Minecraft\//
|
|
|
|
|
- /^Minecraft\d/
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: /^Miencraft\\/
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_multi_purpose_key() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Space:
|
|
|
|
|
held: Shift_L
|
|
|
|
|
alone: Space
|
|
|
|
|
- remap:
|
|
|
|
|
Muhenkan:
|
|
|
|
|
held: Alt_L
|
|
|
|
|
alone: Muhenkan
|
|
|
|
|
alone_timeout_millis: 500
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_multi_purpose_key_multi_key() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Space:
|
|
|
|
|
held: [Shift_L]
|
|
|
|
|
alone: [Shift_L,A]
|
|
|
|
|
- remap:
|
|
|
|
|
Muhenkan:
|
|
|
|
|
held: [Alt_L,Shift_L]
|
|
|
|
|
alone: [Muhenkan]
|
|
|
|
|
alone_timeout_millis: 500
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_virtual_modifiers() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
virtual_modifiers:
|
|
|
|
|
- CapsLock
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_modmap_press_release_key() {
|
|
|
|
|
yaml_assert_parse(indoc! {r#"
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Space:
|
|
|
|
|
press: { launch: ["wmctrl", "-x", "-a", "code.Code"] }
|
|
|
|
|
release: { launch: ["wmctrl", "-x", "-a", "nocturn.Nocturn"] }
|
|
|
|
|
"#})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_basic() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- name: Global
|
|
|
|
|
remap:
|
|
|
|
|
Alt-Enter: Ctrl-Enter
|
|
|
|
|
- remap:
|
|
|
|
|
M-S: C-S
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_lr_modifiers() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- name: Global
|
|
|
|
|
remap:
|
|
|
|
|
Alt_L-Enter: Ctrl_L-Enter
|
|
|
|
|
- remap:
|
|
|
|
|
M_R-S: C_L-S
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_application() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt-Enter: Ctrl-Enter
|
|
|
|
|
application:
|
|
|
|
|
not: Gnome-terminal
|
|
|
|
|
- remap:
|
|
|
|
|
Alt-S: Ctrl-S
|
|
|
|
|
application:
|
|
|
|
|
only:
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_array() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
C-w:
|
|
|
|
|
- Shift-C-w
|
|
|
|
|
- C-x
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_remap() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
C-x:
|
|
|
|
|
remap:
|
|
|
|
|
s: C-w
|
|
|
|
|
C-s:
|
|
|
|
|
remap:
|
|
|
|
|
x: C-z
|
|
|
|
|
timeout_key: Down
|
|
|
|
|
timeout_millis: 1000
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_launch() {
|
|
|
|
|
yaml_assert_parse(indoc! {r#"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
KEY_GRAVE:
|
|
|
|
|
launch:
|
|
|
|
|
- "/bin/sh"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "date > /tmp/hotkey_test"
|
|
|
|
|
"#})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_mode() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
default_mode: insert
|
|
|
|
|
keymap:
|
|
|
|
|
- mode: insert
|
|
|
|
|
remap:
|
|
|
|
|
Esc: { set_mode: normal }
|
|
|
|
|
- mode: normal
|
|
|
|
|
remap:
|
|
|
|
|
i: { set_mode: insert }
|
|
|
|
|
h: Left
|
|
|
|
|
j: Down
|
|
|
|
|
k: Up
|
|
|
|
|
l: Right
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_keymap_mark() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
keymap:
|
|
|
|
|
- remap:
|
|
|
|
|
C-space: { set_mark: true }
|
|
|
|
|
C-g: [esc, { set_mark: false }]
|
|
|
|
|
C-b: { with_mark: left }
|
|
|
|
|
M-b: { with_mark: C-left }
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_yaml_shared_data_anchor() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
shared:
|
|
|
|
|
terminals: &terminals
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
- Kitty
|
|
|
|
|
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not: *terminals
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
#[should_panic]
|
|
|
|
|
fn test_yaml_fail_on_data_outside_of_config_model() {
|
|
|
|
|
yaml_assert_parse(indoc! {"
|
|
|
|
|
terminals: &terminals
|
|
|
|
|
- Gnome-terminal
|
|
|
|
|
- Kitty
|
|
|
|
|
|
|
|
|
|
modmap:
|
|
|
|
|
- remap:
|
|
|
|
|
Alt_L: Ctrl_L
|
|
|
|
|
application:
|
|
|
|
|
not: *terminals
|
|
|
|
|
- remap:
|
|
|
|
|
Shift_R: Win_R
|
|
|
|
|
application:
|
|
|
|
|
only: Google-chrome
|
|
|
|
|
"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn toml_assert_parse(toml: &str) {
|
|
|
|
|
let result: Result<Config, toml::de::Error> = toml::from_str(toml);
|
|
|
|
@ -530,8 +532,6 @@ fn toml_assert_parse(toml: &str) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn yaml_assert_parse(yaml: &str) {
|
|
|
|
|
let result: Result<Config, serde_yaml::Error> = serde_yaml::from_str(yaml);
|
|
|
|
|
if let Err(e) = result {
|
|
|
|
|