Add line number indication to status bar
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
This commit is contained in:
parent
6e5e287bb3
commit
587dfc686a
@ -114,18 +114,35 @@ func (e *editor) drawStatusBar(ab *buffer) {
|
||||
fileName = e.document.filename
|
||||
}
|
||||
|
||||
statusLine := fmt.Sprintf("%.20s - %d lines", fileName, e.document.rowCount())
|
||||
length := len(statusLine)
|
||||
if length > cols{
|
||||
statusLine = truncateString(statusLine, cols)
|
||||
leftStatus := fmt.Sprintf("%.20s - %d lines", fileName, e.document.rowCount())
|
||||
length := len(leftStatus)
|
||||
if length > cols {
|
||||
leftStatus = truncateString(leftStatus, cols)
|
||||
|
||||
ab.append(statusLine)
|
||||
ab.append(leftStatus)
|
||||
ab.append(terminal.ResetColor)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ab.append(statusLine)
|
||||
rightStatus := fmt.Sprintf("%d/%d", e.cursor.y, e.document.rowCount())
|
||||
rlength := len(rightStatus)
|
||||
statusLength := length + rlength
|
||||
|
||||
if statusLength <= cols {
|
||||
paddingLength := cols - statusLength
|
||||
padding := strings.Repeat(" ", paddingLength)
|
||||
|
||||
ab.append(leftStatus)
|
||||
ab.append(padding)
|
||||
ab.append(rightStatus)
|
||||
|
||||
ab.append(terminal.ResetColor)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ab.append(leftStatus)
|
||||
|
||||
// Pad the rest of the status line
|
||||
padding := strings.Repeat(" ", cols - length)
|
||||
|
Loading…
Reference in New Issue
Block a user