Skip to content

Commit

Permalink
Route custom layout commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyh committed Oct 30, 2021
1 parent f8925f5 commit 38f844c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Amethyst/Events/HotKeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,42 @@ class HotKeyManager<Application: ApplicationType>: NSObject {
}
}

constructCommandWithCommandKey(CommandKey.command1.rawValue) {
let screenManager: ScreenManager<WindowManager<Application>>? = windowManager.focusedScreenManager()
screenManager?.updateCurrentLayout { layout in
if let customLayout = layout as? CustomLayout {
customLayout.command1()
}
}
}

constructCommandWithCommandKey(CommandKey.command2.rawValue) {
let screenManager: ScreenManager<WindowManager<Application>>? = windowManager.focusedScreenManager()
screenManager?.updateCurrentLayout { layout in
if let customLayout = layout as? CustomLayout {
customLayout.command2()
}
}
}

constructCommandWithCommandKey(CommandKey.command3.rawValue) {
let screenManager: ScreenManager<WindowManager<Application>>? = windowManager.focusedScreenManager()
screenManager?.updateCurrentLayout { layout in
if let customLayout = layout as? CustomLayout {
customLayout.command3()
}
}
}

constructCommandWithCommandKey(CommandKey.command4.rawValue) {
let screenManager: ScreenManager<WindowManager<Application>>? = windowManager.focusedScreenManager()
screenManager?.updateCurrentLayout { layout in
if let customLayout = layout as? CustomLayout {
customLayout.command4()
}
}
}

constructCommandWithCommandKey(CommandKey.focusCCW.rawValue) {
windowManager.focusTransitionCoordinator.moveFocusCounterClockwise()
}
Expand Down Expand Up @@ -331,6 +367,10 @@ class HotKeyManager<Application: ApplicationType>: NSObject {
hotKeyNameToDefaultsKey.append(["Expand main pane", CommandKey.expandMain.rawValue])
hotKeyNameToDefaultsKey.append(["Increase main pane count", CommandKey.increaseMain.rawValue])
hotKeyNameToDefaultsKey.append(["Decrease main pane count", CommandKey.decreaseMain.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 1", CommandKey.command1.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 2", CommandKey.command2.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 3", CommandKey.command3.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 4", CommandKey.command4.rawValue])
hotKeyNameToDefaultsKey.append(["Move focus counter clockwise", CommandKey.focusCCW.rawValue])
hotKeyNameToDefaultsKey.append(["Move focus clockwise", CommandKey.focusCW.rawValue])
hotKeyNameToDefaultsKey.append(["Move focus to main window", CommandKey.focusMain.rawValue])
Expand Down
4 changes: 4 additions & 0 deletions Amethyst/Preferences/UserConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ enum CommandKey: String {
case expandMain = "expand-main"
case increaseMain = "increase-main"
case decreaseMain = "decrease-main"
case command1 = "command1"
case command2 = "command2"
case command3 = "command3"
case command4 = "command4"
case focusCCW = "focus-ccw"
case focusCW = "focus-cw"
case focusMain = "focus-main"
Expand Down

0 comments on commit 38f844c

Please sign in to comment.