@@ -386,19 +386,28 @@ func (m *UI) Draw(scr uv.Screen, area uv.Rectangle) {
386386 }
387387}
388388
389+// Cursor returns the cursor position and properties for the UI model. It
390+// returns nil if the cursor should not be shown.
391+func (m *UI) Cursor() *tea.Cursor {
392+ if m.layout.editor.Dy() <= 0 {
393+ // Don't show cursor if editor is not visible
394+ return nil
395+ }
396+ if m.focus == uiFocusEditor && m.textarea.Focused() {
397+ cur := m.textarea.Cursor()
398+ cur.X++ // Adjust for app margins
399+ cur.Y += m.layout.editor.Min.Y
400+ return cur
401+ }
402+ return nil
403+}
404+
389405// View renders the UI model's view.
390406func (m *UI) View() tea.View {
391407 var v tea.View
392408 v.AltScreen = true
393409 v.BackgroundColor = m.com.Styles.Background
394−
395− layout := generateLayout(m, m.width, m.height)
396− if m.focus == uiFocusEditor && m.textarea.Focused() {
397− cur := m.textarea.Cursor()
398− cur.X++ // Adjust for app margins
399− cur.Y += layout.editor.Min.Y
400− v.Cursor = cur
401− }
410+ v.Cursor = m.Cursor()
402411
403412 // TODO: Switch to lipgloss.Canvas when available
404413 canvas := uv.NewScreenBuffer(m.width, m.height)