MCPcopy
hub / github.com/micro-editor/micro / SetStatusInfoFnLua

Function SetStatusInfoFnLua

internal/display/statusline.go:64–89  ·  view source on GitHub ↗
(fn string)

Source from the content-addressed store, hash-verified

62}
63
64func SetStatusInfoFnLua(fn string) {
65 luaFn := strings.Split(fn, ".")
66 if len(luaFn) <= 1 {
67 return
68 }
69 plName, plFn := luaFn[0], luaFn[1]
70 pl := config.FindPlugin(plName)
71 if pl == nil {
72 return
73 }
74 statusInfo[fn] = func(b *buffer.Buffer) string {
75 if pl == nil || !pl.IsLoaded() {
76 return ""
77 }
78 val, err := pl.Call(plFn, luar.New(ulua.L, b))
79 if err == nil {
80 if v, ok := val.(lua.LString); !ok {
81 screen.TermMessage(plFn, "should return a string")
82 return ""
83 } else {
84 return string(v)
85 }
86 }
87 return ""
88 }
89}
90
91// NewStatusLine returns a statusline bound to a window
92func NewStatusLine(win *BufWindow) *StatusLine {

Callers

nothing calls this directly

Calls 4

FindPluginFunction · 0.92
TermMessageFunction · 0.92
IsLoadedMethod · 0.80
CallMethod · 0.80

Tested by

no test coverage detected