diff --git a/Blink/SpaceController.swift b/Blink/SpaceController.swift index c27bca238..abab40a0b 100644 --- a/Blink/SpaceController.swift +++ b/Blink/SpaceController.swift @@ -56,6 +56,7 @@ public class SpaceController: UIViewController { private var _overlay = UIView() private var _spaceControllerAnimating: Bool = false + private var _noOpKeyCommands: [UIKeyCommand] = [] public override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() @@ -91,7 +92,7 @@ public class SpaceController: UIViewController { super.viewDidLoad() view.isOpaque = true - + _viewportsController.view.isOpaque = true _viewportsController.dataSource = self _viewportsController.delegate = self @@ -225,6 +226,9 @@ public class SpaceController: UIViewController { } } + @objc func noOp(_ cmd: UIKeyCommand) { + } + func _closeCurrentSpace() { currentTerm()?.terminate() _removeCurrentSpace() @@ -455,13 +459,19 @@ extension SpaceController { guard view.window?.windowScene?.activationState == UIScene.ActivationState.foregroundActive else { - return [] + return SmarterTermInput.shared.noOpBlinkKeyCommands } return SmarterTermInput.shared.blinkKeyCommands } @objc func _onBlinkCommand(_ cmd: BlinkCommand) { + guard + view.window?.windowScene?.activationState == UIScene.ActivationState.foregroundActive + else { + return + } + SmarterTermInput.shared.reportStateReset() switch cmd.bindingAction { case .press(let keyCode, mods: let mods): diff --git a/KB/Native/Views/KBWebView.swift b/KB/Native/Views/KBWebView.swift index dbab67091..383fb5561 100644 --- a/KB/Native/Views/KBWebView.swift +++ b/KB/Native/Views/KBWebView.swift @@ -41,6 +41,7 @@ class KBWebView: KBWebViewBase { private var _loaded = false private(set) var webViewReady = false private(set) var blinkKeyCommands: [BlinkCommand] = [] + private(set) var noOpBlinkKeyCommands: [BlinkCommand] = [] func configure(_ cfg: KBConfig) { _buildCommands(cfg) @@ -66,6 +67,18 @@ class KBWebView: KBWebViewBase { cmd.bindingAction = shortcut.action return cmd } + noOpBlinkKeyCommands = cfg.shortcuts.map { shortcut in + let cmd = BlinkCommand( + title: shortcut.action.isCommand ? shortcut.title : "", // Show only commands in cmd help view + image: nil, + action: #selector(SpaceController.noOp(_:)), + input: shortcut.input, + modifierFlags: shortcut.modifiers, + propertyList: nil + ) + cmd.bindingAction = shortcut.action + return cmd + } } func matchCommand(input: String, flags: UIKeyModifierFlags) -> (UIKeyCommand, UIResponder)? {