Skip to content

Commit

Permalink
Show shortcuts menu on stuck cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Dec 15, 2019
1 parent 54fff6e commit 9de21dc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -91,7 +92,7 @@ public class SpaceController: UIViewController {
super.viewDidLoad()

view.isOpaque = true

_viewportsController.view.isOpaque = true
_viewportsController.dataSource = self
_viewportsController.delegate = self
Expand Down Expand Up @@ -225,6 +226,9 @@ public class SpaceController: UIViewController {
}
}

@objc func noOp(_ cmd: UIKeyCommand) {
}

func _closeCurrentSpace() {
currentTerm()?.terminate()
_removeCurrentSpace()
Expand Down Expand Up @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions KB/Native/Views/KBWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)? {
Expand Down

0 comments on commit 9de21dc

Please sign in to comment.