package tui import ( "fmt" "github.com/charmbracelet/lipgloss" ) var ( listStyle = lipgloss.NewStyle().Padding(0, 1) detailStyle = lipgloss.NewStyle().Padding(0, 1) focusedStyle = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("62")) statusStyle = lipgloss.NewStyle().Padding(0, 1).Foreground(lipgloss.Color("240")).Background(lipgloss.Color("236")) ) // View renders the two-pane layout. func (m Model) View() string { listView := m.list.View() detailView := m.detail.View() // compute dimensions for each pane accounting for padding and focus border leftWidth := m.width / 2 rightWidth := m.width - leftWidth leftHeight := m.height rightHeight := m.height if m.focus == listPane { leftWidth -= 2 // border leftHeight -= 2 } else { rightWidth -= 2 rightHeight -= 2 } // account for horizontal padding leftWidth -= 2 rightWidth -= 2 left := listStyle.Width(leftWidth).Height(leftHeight).Render(listView) right := detailStyle.Width(rightWidth).Height(rightHeight).Render(detailView) if m.focus == listPane { left = focusedStyle.Render(left) } else { right = focusedStyle.Render(right) } // join panes and status bar panes := lipgloss.JoinHorizontal(lipgloss.Top, left, right) modeLabel := "VIEW" if m.mode == EditMode { modeLabel = "EDIT" } status := fmt.Sprintf("%s MODE • %d entries", modeLabel, len(m.hosts.Entries)) bar := statusStyle.Width(m.width).Render(status) return lipgloss.JoinVertical(lipgloss.Left, panes, bar) }