From 823ccc53d55430caaf2645fc5a850dab8c5b87da Mon Sep 17 00:00:00 2001 From: zt515 Date: Sat, 26 Aug 2017 22:58:27 +0800 Subject: [PATCH] Project: Upgrade config file --- app/src/main/assets/eks/default.nl | 2 +- app/src/main/assets/eks/vim.nl | 16 ++++++++++------ .../component/config/ConfigureComponent.kt | 2 +- .../neoterm/component/eks/ExtraKeysComponent.kt | 2 +- .../frontend/terminal/eks/button/IExtraButton.kt | 5 ++--- app/src/test/java/io/neoterm/CombinedKeyTest.kt | 7 +++++++ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/src/main/assets/eks/default.nl b/app/src/main/assets/eks/default.nl index 55e5737..bb89bee 100644 --- a/app/src/main/assets/eks/default.nl +++ b/app/src/main/assets/eks/default.nl @@ -1,5 +1,5 @@ extra-key: { - version: 19 + version: 20 program: [ default ] key: [ diff --git a/app/src/main/assets/eks/vim.nl b/app/src/main/assets/eks/vim.nl index e8a9bc5..23aacbe 100644 --- a/app/src/main/assets/eks/vim.nl +++ b/app/src/main/assets/eks/vim.nl @@ -1,23 +1,27 @@ extra-key: { - version: 19 + version: 20 with-default: true - program: [ vim, vi, neovim ] + program: [ vim, vi, nvim ] key: [ { - code: "dd" + code: " dd" + display: "dd" with-enter: true }, { - code: ":x" + code: " :x" + display: ":x" with-enter: true }, { - code: ":w" + code: " :w" + display: ":w" with-enter: true }, { - code: ":q" + code: " :q" + display: ":q" with-enter: true } ] diff --git a/app/src/main/java/io/neoterm/component/config/ConfigureComponent.kt b/app/src/main/java/io/neoterm/component/config/ConfigureComponent.kt index bde3f17..3082551 100644 --- a/app/src/main/java/io/neoterm/component/config/ConfigureComponent.kt +++ b/app/src/main/java/io/neoterm/component/config/ConfigureComponent.kt @@ -9,7 +9,7 @@ import java.io.File * @author kiva */ class ConfigureComponent : NeoComponent { - val CONFIG_LOADER_VERSION = 19 + val CONFIG_LOADER_VERSION = 20 override fun onServiceInit() { } diff --git a/app/src/main/java/io/neoterm/component/eks/ExtraKeysComponent.kt b/app/src/main/java/io/neoterm/component/eks/ExtraKeysComponent.kt index 0883c2d..46e83a0 100644 --- a/app/src/main/java/io/neoterm/component/eks/ExtraKeysComponent.kt +++ b/app/src/main/java/io/neoterm/component/eks/ExtraKeysComponent.kt @@ -46,7 +46,7 @@ class ExtraKeysComponent : NeoComponent { extraKeysView.loadDefaultUserKeys() } - fun registerShortcutKeys(extraKey: NeoExtraKey) { + private fun registerShortcutKeys(extraKey: NeoExtraKey) { extraKey.programNames.forEach { extraKeys[it] = extraKey } diff --git a/app/src/main/java/io/neoterm/frontend/terminal/eks/button/IExtraButton.kt b/app/src/main/java/io/neoterm/frontend/terminal/eks/button/IExtraButton.kt index 97c30ce..c0ca221 100644 --- a/app/src/main/java/io/neoterm/frontend/terminal/eks/button/IExtraButton.kt +++ b/app/src/main/java/io/neoterm/frontend/terminal/eks/button/IExtraButton.kt @@ -5,7 +5,6 @@ import android.util.AttributeSet import android.view.KeyEvent import android.view.View import android.widget.Button - import io.neoterm.R import io.neoterm.frontend.terminal.TerminalView import io.neoterm.frontend.terminal.eks.combine.CombinedSequence @@ -53,7 +52,7 @@ abstract class IExtraButton : View.OnClickListener { fun sendKey(view: View, keyName: String) { var keyCode = 0 - var chars: String? = null + var chars = "" when (keyName) { KEY_ESC -> keyCode = KeyEvent.KEYCODE_ESCAPE KEY_TAB -> keyCode = KeyEvent.KEYCODE_TAB @@ -76,7 +75,7 @@ abstract class IExtraButton : View.OnClickListener { if (keyCode > 0) { view.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, keyCode)) view.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_UP, keyCode)) - } else { + } else if (chars.isNotEmpty()) { val terminalView = view.findViewById(R.id.terminal_view) val session = terminalView.currentSession session?.write(chars) diff --git a/app/src/test/java/io/neoterm/CombinedKeyTest.kt b/app/src/test/java/io/neoterm/CombinedKeyTest.kt index 8f9ee3a..d7b5a50 100644 --- a/app/src/test/java/io/neoterm/CombinedKeyTest.kt +++ b/app/src/test/java/io/neoterm/CombinedKeyTest.kt @@ -1,5 +1,6 @@ package io.neoterm +import io.neoterm.frontend.terminal.eks.button.IExtraButton import io.neoterm.frontend.terminal.eks.combine.CombinedSequence import org.junit.Test @@ -11,5 +12,11 @@ class CombinedKeyTest { fun testCombinedKey() { val key = CombinedSequence.solveString(" q") println(key.keys) + var chars = "Unchanged" + val XX = key.keys[0] + when (IExtraButton.KEY_CTRL) { + XX -> chars = "Detected ctrl" + } + println(chars) } } \ No newline at end of file