mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
@@ -7,7 +7,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-errors/errors"
|
||||
@@ -434,17 +433,13 @@ func main() {
|
||||
|
||||
for _, t := range tabs {
|
||||
for _, v := range t.views {
|
||||
for pl := range loadedPlugins {
|
||||
_, err := Call(pl+".onViewOpen", v)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
GlobalPluginCall("onViewOpen", v)
|
||||
GlobalPluginCall("onBufferOpen", v.Buf)
|
||||
}
|
||||
}
|
||||
|
||||
InitColorscheme()
|
||||
messenger.style = defStyle
|
||||
|
||||
// Here is the event loop which runs in a separate thread
|
||||
go func() {
|
||||
|
||||
@@ -170,3 +170,15 @@ func LoadPlugins() {
|
||||
loadedPlugins["init"] = "init"
|
||||
}
|
||||
}
|
||||
|
||||
// GlobalCall makes a call to a function in every plugin that is currently
|
||||
// loaded
|
||||
func GlobalPluginCall(function string, args ...interface{}) {
|
||||
for pl := range loadedPlugins {
|
||||
_, err := Call(pl+"."+function, args...)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -277,6 +277,8 @@ func (v *View) OpenBuffer(buf *Buffer) {
|
||||
// is opened
|
||||
v.isOverwriteMode = false
|
||||
v.lastClickTime = time.Time{}
|
||||
|
||||
GlobalPluginCall("onBufferOpen", v.Buf)
|
||||
}
|
||||
|
||||
// Open opens the given file in the view
|
||||
|
||||
Reference in New Issue
Block a user