use a proper status bar (just row:col for now)
This commit is contained in:
parent
0b8aeca688
commit
bd179ccc99
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user