Project: Upgrade config file

This commit is contained in:
zt515 2017-08-26 22:58:27 +08:00
parent 4f6696ead6
commit 823ccc53d5
6 changed files with 22 additions and 12 deletions

View File

@ -1,5 +1,5 @@
extra-key: { extra-key: {
version: 19 version: 20
program: [ default ] program: [ default ]
key: [ key: [

View File

@ -1,23 +1,27 @@
extra-key: { extra-key: {
version: 19 version: 20
with-default: true with-default: true
program: [ vim, vi, neovim ] program: [ vim, vi, nvim ]
key: [ key: [
{ {
code: "dd" code: "<Esc> dd"
display: "dd"
with-enter: true with-enter: true
}, },
{ {
code: ":x" code: "<Esc> :x"
display: ":x"
with-enter: true with-enter: true
}, },
{ {
code: ":w" code: "<Esc> :w"
display: ":w"
with-enter: true with-enter: true
}, },
{ {
code: ":q" code: "<Esc> :q"
display: ":q"
with-enter: true with-enter: true
} }
] ]

View File

@ -9,7 +9,7 @@ import java.io.File
* @author kiva * @author kiva
*/ */
class ConfigureComponent : NeoComponent { class ConfigureComponent : NeoComponent {
val CONFIG_LOADER_VERSION = 19 val CONFIG_LOADER_VERSION = 20
override fun onServiceInit() { override fun onServiceInit() {
} }

View File

@ -46,7 +46,7 @@ class ExtraKeysComponent : NeoComponent {
extraKeysView.loadDefaultUserKeys() extraKeysView.loadDefaultUserKeys()
} }
fun registerShortcutKeys(extraKey: NeoExtraKey) { private fun registerShortcutKeys(extraKey: NeoExtraKey) {
extraKey.programNames.forEach { extraKey.programNames.forEach {
extraKeys[it] = extraKey extraKeys[it] = extraKey
} }

View File

@ -5,7 +5,6 @@ import android.util.AttributeSet
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.widget.Button import android.widget.Button
import io.neoterm.R import io.neoterm.R
import io.neoterm.frontend.terminal.TerminalView import io.neoterm.frontend.terminal.TerminalView
import io.neoterm.frontend.terminal.eks.combine.CombinedSequence import io.neoterm.frontend.terminal.eks.combine.CombinedSequence
@ -53,7 +52,7 @@ abstract class IExtraButton : View.OnClickListener {
fun sendKey(view: View, keyName: String) { fun sendKey(view: View, keyName: String) {
var keyCode = 0 var keyCode = 0
var chars: String? = null var chars = ""
when (keyName) { when (keyName) {
KEY_ESC -> keyCode = KeyEvent.KEYCODE_ESCAPE KEY_ESC -> keyCode = KeyEvent.KEYCODE_ESCAPE
KEY_TAB -> keyCode = KeyEvent.KEYCODE_TAB KEY_TAB -> keyCode = KeyEvent.KEYCODE_TAB
@ -76,7 +75,7 @@ abstract class IExtraButton : View.OnClickListener {
if (keyCode > 0) { if (keyCode > 0) {
view.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, keyCode)) view.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, keyCode))
view.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_UP, keyCode)) view.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_UP, keyCode))
} else { } else if (chars.isNotEmpty()) {
val terminalView = view.findViewById<TerminalView>(R.id.terminal_view) val terminalView = view.findViewById<TerminalView>(R.id.terminal_view)
val session = terminalView.currentSession val session = terminalView.currentSession
session?.write(chars) session?.write(chars)

View File

@ -1,5 +1,6 @@
package io.neoterm package io.neoterm
import io.neoterm.frontend.terminal.eks.button.IExtraButton
import io.neoterm.frontend.terminal.eks.combine.CombinedSequence import io.neoterm.frontend.terminal.eks.combine.CombinedSequence
import org.junit.Test import org.junit.Test
@ -11,5 +12,11 @@ class CombinedKeyTest {
fun testCombinedKey() { fun testCombinedKey() {
val key = CombinedSequence.solveString("<Ctrl> <Alt> <F1> q") val key = CombinedSequence.solveString("<Ctrl> <Alt> <F1> q")
println(key.keys) println(key.keys)
var chars = "Unchanged"
val XX = key.keys[0]
when (IExtraButton.KEY_CTRL) {
XX -> chars = "Detected ctrl"
}
println(chars)
} }
} }