From bd179ccc99c570c64677be0c638b9bde4b30c8a2 Mon Sep 17 00:00:00 2001 From: Keiran Date: Wed, 6 Aug 2025 10:09:33 +0100 Subject: [PATCH] use a proper status bar (just row:col for now) --- cmd/goedit/main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/goedit/main.go b/cmd/goedit/main.go index 5882ea4..06a1736 100644 --- a/cmd/goedit/main.go +++ b/cmd/goedit/main.go @@ -149,7 +149,12 @@ func (m Model) View() string { b.WriteString("Text Editor (Ctrl+C or Esc to quit)\n\n") + contentHeight := m.height - 4 + for i, line := range m.lines { + if i >= contentHeight { + break + } if i == m.row { if m.col == 0 { b.WriteString("█" + line + "\n") @@ -163,11 +168,16 @@ func (m Model) View() string { } } - b.WriteString(fmt.Sprintf("\nRow: %d, Col: %d", m.row+1, m.col+1)) + for i := len(m.lines); i < contentHeight; i++ { + b.WriteString("\n") + } + + statusBar := fmt.Sprintf("%d:%d", m.row+1, m.col+1) + padding := strings.Repeat(" ", m.width-len(statusBar)) + b.WriteString(padding + statusBar) return b.String() } - func main() { p := tea.NewProgram(NewModel(), tea.WithAltScreen()) if _, err := p.Run(); err != nil {