Skip to content

Commit

Permalink
Fix config
Browse files Browse the repository at this point in the history
yury committed Dec 9, 2019
1 parent bdcc15f commit bb2d8b4
Showing 5 changed files with 13 additions and 106 deletions.
90 changes: 4 additions & 86 deletions Blink/SmarterKeys/SmarterTermInput.swift
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ class SmarterTermInput: KBWebView {
private var _hideSmartKeysWithHKB = !BKUserConfigurationManager.userSettingsValue(
forKey: BKUserConfigShowSmartKeysWithXKeyBoard)
private var _inputAccessoryView: UIView? = nil
private var _keyCommands: [BlinkCommand] = []
var blinkKeyCommands: [BlinkCommand] = []

var device: TermDevice? = nil

@@ -116,68 +116,20 @@ class SmarterTermInput: KBWebView {
}

override func configure(_ cfg: KBConfig, data: Data) {
_keyCommands = cfg.shortcuts.map { shortcut in
blinkKeyCommands = cfg.shortcuts.map { shortcut in
let cmd = BlinkCommand(
title: shortcut.title,
image: nil,
action: _canHandleAction(shortcut.action) ? #selector(_onBlinkInputCommand(_:)) : #selector(_onBlinkCommand(_:)),
action: #selector(SpaceController._onBlinkCommand(_:)),
input: shortcut.input,
modifierFlags: shortcut.modifiers,
propertyList: nil
)
cmd.bindingAction = shortcut.action
return cmd
}
super.configure(cfg, data: data)
}

func _canHandleAction(_ action: KeyBindingAction) -> Bool {
switch action {
case .command(let cmd):
switch cmd {
case .clipboardPaste, .clipboardCopy, .zoomReset, .zoomIn, .zoomOut: return true
default: return false
}
case .hex: return true
case .none: return true
case .press: return true
}
}

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

@objc func _onBlinkInputCommand(_ cmd: BlinkCommand) {
SmarterTermInput.shared.reportStateReset()
switch cmd.bindingAction {
case .command(let cmd):
_onCommand(cmd)
default:
break
}
}

override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(_onBlinkCommand(_:)) {
return false
}
return super.canPerformAction(action, withSender: sender)
}

func _onCommand(_ cmd: Command) {
switch cmd {
case .clipboardCopy: copy(self)
case .clipboardPaste: paste(self)
case .zoomIn:
device?.view?.increaseFontSize()
case .zoomOut:
device?.view?.decreaseFontSize()
case .zoomReset:
device?.view?.resetFontSize()
default: break
}
}

override var keyCommands: [UIKeyCommand]? { _keyCommands }

@objc func _updateSettings() {
KBSound.isMutted = BKUserConfigurationManager.userSettingsValue(
@@ -421,11 +373,6 @@ class SmarterTermInput: KBWebView {
// }
// }

func deviceWrite(_ input: String!) {
// super.deviceWrite(input)
// _kbView.turnOffUntracked()
}

func _removeSmartKeys() {
_inputAccessoryView = UIView(frame: .zero)
self.removeAssistantsFromView()
@@ -627,33 +574,4 @@ extension SmarterTermInput: TermInput {
}
}

func insertText(_ text: String!) {

}

func fkeySeq(_ cmd: UIKeyCommand!) {

}

func arrowSeq(_ cmd: UIKeyCommand!) {

}

func cursorSeq(_ cmd: UIKeyCommand!) {

}

func escCtrlSeq(withInput input: String!) {

}

func escSeq(withInput input: String!) {

}

func ctrlSeq(withInput input: String!) {

}


}
11 changes: 6 additions & 5 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
@@ -460,9 +460,7 @@ extension SpaceController {
// MARK: Commands

extension SpaceController {
public override var keyCommands: [UIKeyCommand]? {
return SmarterTermInput.shared.keyCommands
}
public override var keyCommands: [UIKeyCommand]? { SmarterTermInput.shared.blinkKeyCommands }

// simple helper
private func _cmd(_ title: String, _ action: Selector, _ input: String, _ flags: UIKeyModifierFlags) -> UIKeyCommand {
@@ -546,8 +544,11 @@ extension SpaceController {
case .windowClose: _closeWindowAction()
case .windowFocusOther: _focusOtherWindowAction()
case .windowNew: _newWindowAction()
default:
break;
case .clipboardCopy: SmarterTermInput.shared.copy(self)
case .clipboardPaste: SmarterTermInput.shared.paste(self)
case .zoomIn: currentTerm()?.termDevice.view?.increaseFontSize()
case .zoomOut: currentTerm()?.termDevice.view?.decreaseFontSize()
case .zoomReset: currentTerm()?.termDevice.view?.resetFontSize()
}
}

12 changes: 0 additions & 12 deletions Blink/TermInput.h
Original file line number Diff line number Diff line change
@@ -62,22 +62,10 @@
@property (weak) TermDevice *device;
@property BOOL secureTextEntry;

- (void)deviceWrite:(NSString *)input;
- (void)insertText:(NSString *)text;

- (void)fkeySeq:(UIKeyCommand *)cmd;
- (void)arrowSeq:(UIKeyCommand *)cmd;
- (void)cursorSeq:(UIKeyCommand *)cmd;
- (void)setHasSelection:(BOOL)value;

- (void)reset;

- (void)escCtrlSeqWithInput:(NSString *)input;
- (void)escSeqWithInput:(NSString *)input;
- (void)ctrlSeqWithInput:(NSString *)input;



@end

@interface TermInputOld : UITextView<TermInput>
4 changes: 2 additions & 2 deletions KB/JS/dist/kb.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion KB/JS/src/Keyboard.ts
Original file line number Diff line number Diff line change
@@ -735,7 +735,7 @@ export default class Keyboard implements IKeyboard {
let code = key.code;
let down = _action(key.down);
if (down) {
this._upMap[code.id] = down;
this._downMap[code.id] = down;
}
let mod = this._mod(key.mod);
if (mod) {

0 comments on commit bb2d8b4

Please sign in to comment.