mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +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:
@@ -18,6 +18,7 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
luar "layeh.com/gopher-luar"
|
||||
)
|
||||
@@ -69,6 +70,8 @@ func Import(pkg string) *lua.LTable {
|
||||
return importTime()
|
||||
case "unicode/utf8", "utf8":
|
||||
return importUtf8()
|
||||
case "humanize":
|
||||
return importHumanize()
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@@ -556,3 +559,14 @@ func importUtf8() *lua.LTable {
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
func importHumanize() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Bytes", luar.New(L, humanize.Bytes))
|
||||
L.SetField(pkg, "Ordinal", luar.New(L, humanize.Ordinal))
|
||||
L.SetField(pkg, "Ftoa", luar.New(L, humanize.Ftoa))
|
||||
L.SetField(pkg, "FtoaWithDigits", luar.New(L, humanize.FtoaWithDigits))
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user