Add more functions to customize status bar

Adds `status.lines`, `status.vcol`, `status.bytes`, `status.size`,
and exposes some functions from go-humanize to plugins.

Ref #1727
This commit is contained in:
Zachary Yedidia
2020-06-24 17:19:42 -04:00
parent db1df05017
commit 5f62f550f3
5 changed files with 59 additions and 4 deletions

View File

@@ -534,6 +534,22 @@ func (b *Buffer) Modified() bool {
return buff != b.origHash
}
// Size returns the number of bytes in the current buffer
func (b *Buffer) Size() int {
nb := 0
for i := 0; i < b.LinesNum(); i++ {
nb += len(b.LineBytes(i))
if i != b.LinesNum()-1 {
if b.Endings == FFDos {
nb++ // carriage return
}
nb++ // newline
}
}
return nb
}
// calcHash calculates md5 hash of all lines in the buffer
func calcHash(b *Buffer, out *[md5.Size]byte) error {
h := md5.New()