mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 14:22:42 +09:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user