v1.2.9: fix enter key send, remove all local $ symbols
This commit is contained in:
@@ -523,9 +523,14 @@ fun SshTerminalScreen(
|
||||
setHintTextColor(android.graphics.Color.parseColor("#6E7681"))
|
||||
imeOptions = EditorInfo.IME_ACTION_SEND
|
||||
setSingleLine()
|
||||
setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
val cmd = text.toString().trim()
|
||||
addTextChangedListener(object : android.text.TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
override fun afterTextChanged(s: android.text.Editable?) {}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
val text = s?.toString() ?: ""
|
||||
// 检测回车字符:输入法按回车时会在文本末尾插入 \n
|
||||
if (text.endsWith('\n')) {
|
||||
val cmd = text.dropLast(1).trim()
|
||||
if (cmd.isNotEmpty()) {
|
||||
coroutineScope.launch {
|
||||
manager.sendCommand(cmd)
|
||||
@@ -533,17 +538,10 @@ fun SshTerminalScreen(
|
||||
}
|
||||
setText("")
|
||||
currentInput = ""
|
||||
true
|
||||
} else {
|
||||
false
|
||||
currentInput = text
|
||||
}
|
||||
}
|
||||
addTextChangedListener(object : android.text.TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
override fun afterTextChanged(s: android.text.Editable?) {}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
currentInput = s?.toString() ?: ""
|
||||
}
|
||||
})
|
||||
setOnKeyListener { _, keyCode, event ->
|
||||
if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) {
|
||||
|
||||
Reference in New Issue
Block a user