feat: 模块7 - 多行输入支持 (textarea替换textinput)
This commit is contained in:
49
memory.md
49
memory.md
@@ -696,4 +696,53 @@ func (m model) View() string {
|
||||
return m.result
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## TUI界面改进知识
|
||||
|
||||
### TextInput vs Textarea
|
||||
- **textinput**: 单行输入,适合短文本
|
||||
- **textarea**: 多行输入,适合长段落
|
||||
- 切换时需要调整布局和样式
|
||||
|
||||
### Modal/弹出框设计
|
||||
```go
|
||||
type model struct {
|
||||
showModal bool
|
||||
modalType string // "help", "command", "info"
|
||||
}
|
||||
|
||||
// View中渲染modal
|
||||
func (m model) View() string {
|
||||
s := "主界面..."
|
||||
if m.showModal {
|
||||
s += m.renderModal()
|
||||
}
|
||||
return s
|
||||
}
|
||||
```
|
||||
|
||||
### 斜杠命令菜单
|
||||
```go
|
||||
type command struct {
|
||||
name string
|
||||
desc string
|
||||
handler func()
|
||||
}
|
||||
|
||||
var commands = []command{
|
||||
{"help", "显示帮助", handleHelp},
|
||||
{"clear", "清空内容", handleClear},
|
||||
{"copy", "复制结果", handleCopy},
|
||||
}
|
||||
|
||||
// 模糊匹配
|
||||
func matchCommand(input string) []command {
|
||||
// 过滤匹配的命令
|
||||
}
|
||||
```
|
||||
|
||||
### Viewport组件
|
||||
用于长文本滚动显示,配合scrollbar展示滚动位置。
|
||||
```
|
||||
Reference in New Issue
Block a user