1
0
Fork 0

Show filename and row count in status bar
timw4mail/gilo/pipeline/head This commit looks good Details

This commit is contained in:
Timothy Warren 2021-04-01 12:37:28 -04:00
parent 1d4c8f99c0
commit 6e5e287bb3
1 changed files with 24 additions and 2 deletions

View File

@ -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)
}