Compare commits

..

No commits in common. "1bb6c16786cf1fadd69607284c1853019395c800" and "0b8aeca6880c98b81e7b11bea559808252d11dda" have entirely different histories.

View File

@ -149,36 +149,21 @@ func (m Model) View() string {
b.WriteString("Text Editor (Ctrl+C or Esc to quit)\n\n") b.WriteString("Text Editor (Ctrl+C or Esc to quit)\n\n")
contentHeight := m.height - 4
lineNumWidth := len(fmt.Sprintf("%d", len(m.lines))) + 1
for i, line := range m.lines { for i, line := range m.lines {
if i >= contentHeight {
break
}
lineNum := fmt.Sprintf("%*d ", lineNumWidth, i+1)
if i == m.row { if i == m.row {
if m.col == 0 { if m.col == 0 {
b.WriteString(lineNum + "█" + line + "\n") b.WriteString("█" + line + "\n")
} else if m.col >= len(line) { } else if m.col >= len(line) {
b.WriteString(lineNum + line + "█\n") b.WriteString(line + "█\n")
} else { } else {
b.WriteString(lineNum + line[:m.col] + "█" + line[m.col:] + "\n") b.WriteString(line[:m.col] + "█" + line[m.col:] + "\n")
} }
} else { } else {
b.WriteString(lineNum + line + "\n") b.WriteString(line + "\n")
} }
} }
for i := len(m.lines); i < contentHeight; i++ { b.WriteString(fmt.Sprintf("\nRow: %d, Col: %d", m.row+1, m.col+1))
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() return b.String()
} }