1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 23:36:08 +03:00

Refactor slightly

This commit is contained in:
Tae Won Ha 2020-02-07 18:51:36 +01:00
parent c1e8e04d67
commit 7a75be0d00
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 34 additions and 169 deletions

View File

@ -35,176 +35,41 @@ let defaultShortcuts: [String: Shortcut?] = [
"com.qvacua.vimr.menuitems.view.font.bigger": Shortcut(keyEquivalent: "⌘+"),
"com.qvacua.vimr.menuitems.view.font.reset-to-default-size": Shortcut(keyEquivalent: "⌘0"),
"com.qvacua.vimr.menuitems.view.font.smaller": Shortcut(keyEquivalent: "⌘-"),
"com.qvacua.vimr.menuitems.window.bring-all-to-front": Shortcut(keyEquivalent: ""),
"com.qvacua.vimr.menuitems.window.bring-all-to-front": Shortcut(keyEquivalent: ""),
"com.qvacua.vimr.menuitems.window.minimize": Shortcut(keyEquivalent: "⌘M"),
"com.qvacua.vimr.menuitems.window.zoom": Shortcut(keyEquivalent: ""),
]
let legacyDefaultShortcuts: [String: [String: Any]] = [
"com.qvacua.vimr.menuitems.edit.copy": [
SRShortcutCharacters: "c",
SRShortcutCharactersIgnoringModifiers: "c",
SRShortcutKeyCode: 8,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.edit.cut": [
SRShortcutCharacters: "x",
SRShortcutCharactersIgnoringModifiers: "x",
SRShortcutKeyCode: 7,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.edit.delete": [String: Any](),
"com.qvacua.vimr.menuitems.edit.paste": [
SRShortcutCharacters: "v",
SRShortcutCharactersIgnoringModifiers: "v",
SRShortcutKeyCode: 9,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.edit.redo": [
SRShortcutCharacters: "z",
SRShortcutCharactersIgnoringModifiers: "Z",
SRShortcutKeyCode: 6,
SRShortcutModifierFlagsKey: 1179914,
],
"com.qvacua.vimr.menuitems.edit.select-all": [
SRShortcutCharacters: "a",
SRShortcutCharactersIgnoringModifiers: "a",
SRShortcutKeyCode: 0,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.edit.undo": [
SRShortcutCharacters: "z",
SRShortcutCharactersIgnoringModifiers: "z",
SRShortcutKeyCode: 6,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.file.close": [
SRShortcutCharacters: "w",
SRShortcutCharactersIgnoringModifiers: "w",
SRShortcutKeyCode: 13,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.file.close-window": [
SRShortcutCharacters: "w",
SRShortcutCharactersIgnoringModifiers: "W",
SRShortcutKeyCode: 13,
SRShortcutModifierFlagsKey: 1179914,
],
"com.qvacua.vimr.menuitems.file.new": [
SRShortcutCharacters: "n",
SRShortcutCharactersIgnoringModifiers: "n",
SRShortcutKeyCode: 45,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.file.new-tab": [
SRShortcutCharacters: "t",
SRShortcutCharactersIgnoringModifiers: "t",
SRShortcutKeyCode: 17,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.file.open-in-new-window": [
SRShortcutCharacters: "ø",
SRShortcutCharactersIgnoringModifiers: "o",
SRShortcutKeyCode: 31,
SRShortcutModifierFlagsKey: 1573160,
],
"com.qvacua.vimr.menuitems.file.open-quickly": [
SRShortcutCharacters: "o",
SRShortcutCharactersIgnoringModifiers: "O",
SRShortcutKeyCode: 31,
SRShortcutModifierFlagsKey: 1179914,
],
"com.qvacua.vimr.menuitems.file.open": [
SRShortcutCharacters: "o",
SRShortcutCharactersIgnoringModifiers: "o",
SRShortcutKeyCode: 31,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.file.save-as": [
SRShortcutCharacters: "s",
SRShortcutCharactersIgnoringModifiers: "S",
SRShortcutKeyCode: 1,
SRShortcutModifierFlagsKey: 1179914,
],
"com.qvacua.vimr.menuitems.file.save": [
SRShortcutCharacters: "s",
SRShortcutCharactersIgnoringModifiers: "s",
SRShortcutKeyCode: 1,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.help.vimr-help": [String: Any](),
"com.qvacua.vimr.menuitems.tools.focus-neovim-view": [
SRShortcutCharacters: ".",
SRShortcutCharactersIgnoringModifiers: ".",
SRShortcutKeyCode: 47,
SRShortcutModifierFlagsKey: 1048576,
],
"com.qvacua.vimr.menuitems.tools.toggle-all-tools": [
SRShortcutCharacters: "\\",
SRShortcutCharactersIgnoringModifiers: "\\",
SRShortcutKeyCode: 42,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-file-browser": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "1",
SRShortcutKeyCode: 18,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-buffer-list": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "2",
SRShortcutKeyCode: 19,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-markdown-preview": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "3",
SRShortcutKeyCode: 20,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-html-preview": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "4",
SRShortcutKeyCode: 21,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-tool-buttons": [
SRShortcutCharacters: "\\",
SRShortcutCharactersIgnoringModifiers: "|",
SRShortcutKeyCode: 42,
SRShortcutModifierFlagsKey: 1179914,
],
"com.qvacua.vimr.menuitems.view.enter-full-screen": [
SRShortcutCharacters: "\006",
SRShortcutCharactersIgnoringModifiers: "f",
SRShortcutKeyCode: 3,
SRShortcutModifierFlagsKey: 1319176,
],
"com.qvacua.vimr.menuitems.view.font.bigger": [
SRShortcutCharacters: "=",
SRShortcutCharactersIgnoringModifiers: "=",
SRShortcutKeyCode: 24,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.view.font.reset-to-default-size": [
SRShortcutCharacters: "0",
SRShortcutCharactersIgnoringModifiers: "0",
SRShortcutKeyCode: 29,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.view.font.smaller": [
SRShortcutCharacters: "-",
SRShortcutCharactersIgnoringModifiers: "-",
SRShortcutKeyCode: 27,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.window.bring-all-to-front": [String: Any](),
"com.qvacua.vimr.menuitems.window.minimize": [
SRShortcutCharacters: "m",
SRShortcutCharactersIgnoringModifiers: "m",
SRShortcutKeyCode: 46,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.window.zoom": [String: Any](),
let legacyDefaultShortcuts: [String] = [
"com.qvacua.vimr.menuitems.edit.copy",
"com.qvacua.vimr.menuitems.edit.cut",
"com.qvacua.vimr.menuitems.edit.delete",
"com.qvacua.vimr.menuitems.edit.paste",
"com.qvacua.vimr.menuitems.edit.redo",
"com.qvacua.vimr.menuitems.edit.select-all",
"com.qvacua.vimr.menuitems.edit.undo",
"com.qvacua.vimr.menuitems.file.close",
"com.qvacua.vimr.menuitems.file.close-window",
"com.qvacua.vimr.menuitems.file.new",
"com.qvacua.vimr.menuitems.file.new-tab",
"com.qvacua.vimr.menuitems.file.open-in-new-window",
"com.qvacua.vimr.menuitems.file.open-quickly",
"com.qvacua.vimr.menuitems.file.open",
"com.qvacua.vimr.menuitems.file.save-as",
"com.qvacua.vimr.menuitems.file.save",
"com.qvacua.vimr.menuitems.help.vimr-help",
"com.qvacua.vimr.menuitems.tools.focus-neovim-view",
"com.qvacua.vimr.menuitems.tools.toggle-all-tools",
"com.qvacua.vimr.menuitems.tools.toggle-file-browser",
"com.qvacua.vimr.menuitems.tools.toggle-buffer-list",
"com.qvacua.vimr.menuitems.tools.toggle-markdown-preview",
"com.qvacua.vimr.menuitems.tools.toggle-html-preview",
"com.qvacua.vimr.menuitems.tools.toggle-tool-buttons",
"com.qvacua.vimr.menuitems.view.enter-full-screen",
"com.qvacua.vimr.menuitems.view.font.bigger",
"com.qvacua.vimr.menuitems.view.font.reset-to-default-size",
"com.qvacua.vimr.menuitems.view.font.smaller",
"com.qvacua.vimr.menuitems.window.bring-all-to-front",
"com.qvacua.vimr.menuitems.window.minimize",
"com.qvacua.vimr.menuitems.window.zoom",
]

View File

@ -76,7 +76,7 @@ class ShortcutsPref: PrefPane,
return
}
legacyDefaultShortcuts.keys.forEach { id in
legacyDefaultShortcuts.forEach { id in
let shortcut: Shortcut?
if let dict = self.shortcutsUserDefaults?.value(forKey: id) as? [String: Any] {
shortcut = Shortcut(dictionary: dict)