v1.2.5: fix editor action, fix icons
@@ -515,38 +515,41 @@ fun SshTerminalScreen(
|
||||
imeOptions = EditorInfo.IME_ACTION_SEND or EditorInfo.IME_FLAG_NO_EXTRACT_UI
|
||||
setSingleLine()
|
||||
// 文本变化监听
|
||||
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() ?: ""
|
||||
// 检测回车
|
||||
val nlIdx = text.indexOf('\n')
|
||||
if (nlIdx >= 0) {
|
||||
val cmd = text.substring(0, nlIdx)
|
||||
if (cmd.isNotEmpty()) {
|
||||
coroutineScope.launch {
|
||||
manager.sendCommand(cmd)
|
||||
}
|
||||
}
|
||||
currentInput = ""
|
||||
post { setText("") }
|
||||
} else {
|
||||
currentInput = text
|
||||
}
|
||||
}
|
||||
})
|
||||
// 硬件键盘回车
|
||||
setOnKeyListener { _, keyCode, event ->
|
||||
if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) {
|
||||
val cmd = currentInput.trim()
|
||||
// Editor action 监听——IME 回车按键
|
||||
setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
val cmd = text.toString().trim()
|
||||
if (cmd.isNotEmpty()) {
|
||||
coroutineScope.launch {
|
||||
manager.sendCommand(cmd)
|
||||
}
|
||||
}
|
||||
setText("")
|
||||
currentInput = ""
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// 文本变化同步
|
||||
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) {
|
||||
val cmd = text.toString().trim()
|
||||
if (cmd.isNotEmpty()) {
|
||||
coroutineScope.launch {
|
||||
manager.sendCommand(cmd)
|
||||
}
|
||||
}
|
||||
setText("")
|
||||
currentInput = ""
|
||||
post { setText("") }
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
|
Before Width: | Height: | Size: 641 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 641 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 641 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 435 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 19 KiB |