Skip to content

Commit

Permalink
Bring back shortcuts help
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Dec 22, 2019
1 parent e0ac3da commit 2d20530
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,14 @@ extension SpaceController {
}

public override var keyCommands: [UIKeyCommand]? {
let input = SmarterTermInput.shared
guard foregroundActive else {
return []
return input.noOpKeyCommands
}
return SmarterTermInput.shared.blinkKeyCommands
return input.blinkKeyCommands
}

@objc func _onNoOpCommand(_ cmd: BlinkCommand) {
}

@objc func _onBlinkCommand(_ cmd: BlinkCommand) {
Expand Down
14 changes: 14 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 noOpKeyCommands: [BlinkCommand] = []

func configure(_ cfg: KBConfig) {
_buildCommands(cfg)
Expand All @@ -66,6 +67,19 @@ class KBWebView: KBWebViewBase {
cmd.bindingAction = shortcut.action
return cmd
}

noOpKeyCommands = 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._onNoOpCommand(_:)),
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 2d20530

Please sign in to comment.