Feature: Combined sequence
This commit is contained in:
parent
bffb7f1dd4
commit
465b6dcf8e
@ -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
|
||||
}
|
||||
}
|
||||
}
|
15
app/src/test/java/io/neoterm/CombinedKeyTest.kt
Normal file
15
app/src/test/java/io/neoterm/CombinedKeyTest.kt
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user