62159
Sy
symb / files
symb / internal / tui / view.go
1.2 KB
1package tui 2 3import ( 4 "strings" 5 6 tea "charm.land/bubbletea/v2" 7) 8 9// --------------------------------------------------------------------------- 10// View 11// --------------------------------------------------------------------------- 12 13func (m Model) View() tea.View { 14 content := m.renderContent() 15 switch { 16 case m.keybindsModal != nil: 17 content = m.keybindsModal.View(m.width, m.height) 18 case m.fileModal != nil: 19 content = m.fileModal.View(m.width, m.height) 20 case m.modelsModal != nil: 21 content = m.modelsModal.View(m.width, m.height) 22 case m.toolViewModal != nil: 23 content = m.toolViewModal.View(m.width, m.height) 24 } 25 v := tea.NewView(content) 26 v.AltScreen = true 27 v.MouseMode = tea.MouseModeAllMotion 28 return v 29} 30 31// renderContent produces the string content for the view. 32func (m Model) renderContent() string { 33 if m.width == 0 { 34 return "" 35 } 36 37 contentH := m.height - statusRows 38 var b strings.Builder 39 40 inputLines := strings.Split(m.agentInput.View(), "\n") 41 convLines := m.wrappedConvLines() 42 startLine := m.visibleStartLine() 43 bgFill := m.styles.BgFill 44 45 for row := 0; row < contentH; row++ { 46 m.renderPaneRow(&b, convLines, inputLines, row, startLine, bgFill) 47 b.WriteByte('\n') 48 } 49 50 m.renderStatusBar(&b, bgFill) 51 return b.String() 52}