Feature: Combined sequence

This commit is contained in:
zt515 2017-08-24 23:56:45 +08:00
parent bffb7f1dd4
commit 465b6dcf8e
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package io.neoterm.component.eks.combine
/**
* <Ctrl> <Alt> <Delete>
* <Ctrl> C
* <Esc> :q <Enter>
*
* @author kiva
*/
class CombinedSequence private constructor() {
val keys = mutableListOf<String>()
companion object {
fun solveString(keyString: String): CombinedSequence {
val seq = CombinedSequence()
keyString.split(' ').forEach {
val key = if (it.startsWith('<') && it.endsWith('>')) {
// is a sequence
it.substring(1, it.length - 1).toUpperCase()
} else {
// is a normal string
it
}
seq.keys.add(key)
}
return seq
}
}
}

View File

@ -0,0 +1,15 @@
package io.neoterm
import io.neoterm.component.eks.combine.CombinedSequence
import org.junit.Test
/**
* @author kiva
*/
class CombinedKeyTest {
@Test
fun testCombinedKey() {
val key = CombinedSequence.solveString("<Ctrl> <Alt> <F1> q")
println(key.keys)
}
}