v1.2.9: fix enter key send, remove all local $ symbols

This commit is contained in:
茂之钳
2026-05-25 03:55:44 +00:00
parent f12efdbb08
commit 708f1cb986
@@ -523,9 +523,14 @@ fun SshTerminalScreen(
setHintTextColor(android.graphics.Color.parseColor("#6E7681")) setHintTextColor(android.graphics.Color.parseColor("#6E7681"))
imeOptions = EditorInfo.IME_ACTION_SEND imeOptions = EditorInfo.IME_ACTION_SEND
setSingleLine() setSingleLine()
setOnEditorActionListener { _, actionId, _ -> addTextChangedListener(object : android.text.TextWatcher {
if (actionId == EditorInfo.IME_ACTION_SEND) { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
val cmd = text.toString().trim() 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()) { if (cmd.isNotEmpty()) {
coroutineScope.launch { coroutineScope.launch {
manager.sendCommand(cmd) manager.sendCommand(cmd)
@@ -533,17 +538,10 @@ fun SshTerminalScreen(
} }
setText("") setText("")
currentInput = "" currentInput = ""
true
} else { } 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 -> setOnKeyListener { _, keyCode, event ->
if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) { if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) {