Show filename and row count in status bar
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-01 12:37:28 -04:00
parent 1d4c8f99c0
commit 6e5e287bb3

View File

@ -105,10 +105,32 @@ func (e *editor) drawPlaceholderRow(y int, ab *buffer) {
} }
func (e *editor) drawStatusBar(ab *buffer) { func (e *editor) drawStatusBar(ab *buffer) {
cols := e.screen.Cols
ab.append(terminal.InvertColor) ab.append(terminal.InvertColor)
str := strings.Repeat(" ", e.screen.Cols) fileName := "[No Name]"
ab.append(str) 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) ab.append(terminal.ResetColor)
} }