feat: fix Ctrl+J newline in TUI
This commit is contained in:
@@ -161,11 +161,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
vpWidth := msg.Width - 4 // Account for viewportStyle padding and border
|
||||
vpHeight := msg.Height - headerHeight - inputHeight - 2
|
||||
|
||||
r, _ := glamour.NewTermRenderer(
|
||||
glamour.WithAutoStyle(),
|
||||
if vpWidth > 0 && vpHeight > 0 {
|
||||
r, err := glamour.NewTermRenderer(
|
||||
glamour.WithStandardStyle("dark"),
|
||||
glamour.WithWordWrap(vpWidth-2),
|
||||
)
|
||||
if err == nil {
|
||||
m.renderer = r
|
||||
}
|
||||
|
||||
if !m.ready {
|
||||
m.viewport = viewport.New(vpWidth, vpHeight)
|
||||
@@ -176,6 +179,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
m.updateViewportContent()
|
||||
m.viewport.GotoBottom()
|
||||
}
|
||||
|
||||
m.textarea.SetWidth(msg.Width - 4)
|
||||
|
||||
@@ -189,6 +193,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case tea.KeyPgDown, tea.KeyCtrlD:
|
||||
m.viewport.HalfViewDown()
|
||||
return m, nil
|
||||
case tea.KeyCtrlJ:
|
||||
m.textarea.InsertString("\n")
|
||||
return m, nil
|
||||
case tea.KeyEnter:
|
||||
v := m.textarea.Value()
|
||||
if strings.TrimSpace(v) == "" || m.isThinking {
|
||||
|
||||
Reference in New Issue
Block a user