v1.2.6: move EditText to top, 0 height, no overlap
This commit is contained in:
@@ -496,26 +496,22 @@ fun SshTerminalScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(bg)
|
.background(bg)
|
||||||
.onKeyEvent { handleKeyEvent(it) }
|
.onKeyEvent { handleKeyEvent(it) }
|
||||||
|
.clickable { requestEditTextFocus() }
|
||||||
) {
|
) {
|
||||||
// 原生 EditText 输入桥——任何输入法都能正确识别
|
// EditText 输入桥——在 Column 顶部,0高度不占空间
|
||||||
AndroidView(
|
AndroidView(
|
||||||
factory = { ctx ->
|
factory = { ctx ->
|
||||||
EditText(ctx).apply {
|
EditText(ctx).apply {
|
||||||
setTextColor(0x00000000) // 透明文字
|
setTextColor(0x00000000)
|
||||||
setBackgroundColor(0x00000000) // 透明背景
|
setBackgroundColor(0x00000000)
|
||||||
textSize = 1f // 极小的字号
|
textSize = 1f
|
||||||
val lp = android.view.ViewGroup.LayoutParams(1, 30)
|
|
||||||
layoutParams = lp
|
|
||||||
// IME 选项:Done 动作(回车即发送)
|
|
||||||
imeOptions = EditorInfo.IME_ACTION_SEND or EditorInfo.IME_FLAG_NO_EXTRACT_UI
|
imeOptions = EditorInfo.IME_ACTION_SEND or EditorInfo.IME_FLAG_NO_EXTRACT_UI
|
||||||
setSingleLine()
|
setSingleLine()
|
||||||
// 文本变化监听
|
|
||||||
// Editor action 监听——IME 回车按键
|
|
||||||
setOnEditorActionListener { _, actionId, _ ->
|
setOnEditorActionListener { _, actionId, _ ->
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE) {
|
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
val cmd = text.toString().trim()
|
val cmd = text.toString().trim()
|
||||||
@@ -531,7 +527,6 @@ fun SshTerminalScreen(
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 文本变化同步
|
|
||||||
addTextChangedListener(object : android.text.TextWatcher {
|
addTextChangedListener(object : android.text.TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||||
override fun afterTextChanged(s: android.text.Editable?) {}
|
override fun afterTextChanged(s: android.text.Editable?) {}
|
||||||
@@ -539,7 +534,6 @@ fun SshTerminalScreen(
|
|||||||
currentInput = s?.toString() ?: ""
|
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) {
|
||||||
val cmd = text.toString().trim()
|
val cmd = text.toString().trim()
|
||||||
@@ -555,16 +549,16 @@ fun SshTerminalScreen(
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// IDE 编辑器标记:用于焦点请求
|
|
||||||
tag = "terminal_input"
|
tag = "terminal_input"
|
||||||
editTextRef.value = this
|
editTextRef.value = this
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(1.dp)
|
.fillMaxWidth()
|
||||||
.height(30.dp)
|
.height(0.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ── 终端内容(顶栏 + 输出 + 输入行)──
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
|||||||
Reference in New Issue
Block a user