diff --git a/editor/draw.go b/editor/draw.go index 09669a3..2e5b505 100644 --- a/editor/draw.go +++ b/editor/draw.go @@ -105,10 +105,32 @@ func (e *editor) drawPlaceholderRow(y int, ab *buffer) { } func (e *editor) drawStatusBar(ab *buffer) { + cols := e.screen.Cols + ab.append(terminal.InvertColor) - str := strings.Repeat(" ", e.screen.Cols) - ab.append(str) + fileName := "[No Name]" + if e.document.filename != "" { + fileName = e.document.filename + } + + statusLine := fmt.Sprintf("%.20s - %d lines", fileName, e.document.rowCount()) + length := len(statusLine) + if length > cols{ + statusLine = truncateString(statusLine, cols) + + ab.append(statusLine) + ab.append(terminal.ResetColor) + + return + } + + ab.append(statusLine) + + // Pad the rest of the status line + padding := strings.Repeat(" ", cols - length) + ab.append(padding) + ab.append(terminal.ResetColor) }