parent
9a6054fc43
commit
3f01101da4
5 changed files with 20 additions and 9 deletions
|
@ -7,7 +7,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
@ -434,17 +433,13 @@ func main() {
|
||||||
|
|
||||||
for _, t := range tabs {
|
for _, t := range tabs {
|
||||||
for _, v := range t.views {
|
for _, v := range t.views {
|
||||||
for pl := range loadedPlugins {
|
GlobalPluginCall("onViewOpen", v)
|
||||||
_, err := Call(pl+".onViewOpen", v)
|
GlobalPluginCall("onBufferOpen", v.Buf)
|
||||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
|
||||||
TermMessage(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InitColorscheme()
|
InitColorscheme()
|
||||||
|
messenger.style = defStyle
|
||||||
|
|
||||||
// Here is the event loop which runs in a separate thread
|
// Here is the event loop which runs in a separate thread
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -170,3 +170,15 @@ func LoadPlugins() {
|
||||||
loadedPlugins["init"] = "init"
|
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
|
// is opened
|
||||||
v.isOverwriteMode = false
|
v.isOverwriteMode = false
|
||||||
v.lastClickTime = time.Time{}
|
v.lastClickTime = time.Time{}
|
||||||
|
|
||||||
|
GlobalPluginCall("onBufferOpen", v.Buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open opens the given file in the view
|
// Open opens the given file in the view
|
||||||
|
|
|
@ -45,6 +45,8 @@ view is passed in. This is useful for setting local options based on the
|
||||||
filetype, for example turning off `tabstospaces` only for Go files when they are
|
filetype, for example turning off `tabstospaces` only for Go files when they are
|
||||||
opened.
|
opened.
|
||||||
|
|
||||||
|
Similar to `onViewOpen(view)` there is also `onBufferOpen(buf)`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
There are a number of functions and variables that are available to you in order
|
There are a number of functions and variables that are available to you in order
|
||||||
|
|
Loading…
Reference in a new issue