-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
44 lines (37 loc) · 1.36 KB
/
Copy pathapi.go
File metadata and controls
44 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import "github.com/unxed/vtui"
import "github.com/unxed/f4/vfs"
import "github.com/unxed/vtinput"
// HostAPI defines the functions f4 exposes to plugins.
// coreAPI implements vfs.HostAPI.
type coreAPI struct{}
func (c *coreAPI) GetVersion() string {
return "v0.1.1-alpha" // 0.1.0 was a dummy value used during development
}
func (c *coreAPI) Log(msg string) {
vtui.DebugLog("PLUGIN.LOG: %s", msg)
}
func (c *coreAPI) Message(msg string) {
vtui.DebugLog("PLUGIN MESSAGE BOX: %s", msg)
// Safely push to the main UI thread to avoid race conditions from background plugin loads
vtui.FrameManager.PostTask(func() {
vtui.ShowMessage(" Plugin Message ", msg, []string{"&Ok"})
})
}
func (c *coreAPI) RegisterVFSProvider(p vfs.VFSProvider) {
vtui.DebugLog("CORE: Registering VFS Provider: %s", p.Name())
vfs.RegisterProvider(p)
}
func (c *coreAPI) RegisterHighlighter(p vtui.HighlighterProvider) {
vtui.DebugLog("CORE: Registering Highlighter: %s", p.Name())
vtui.RegisterHighlighter(p)
}
func (c *coreAPI) RegisterDrive(name string, factory func() vfs.VFS) {
RegisterDrive(name, factory)
}
func (c *coreAPI) RegisterGlobalHotkey(vk uint16, mods vtinput.ControlKeyState, handler func(app vfs.App)) {
RegisterGlobalHotkey(vk, mods, handler)
}
func (c *coreAPI) RegisterPluginMenuItem(label string, handler func(app vfs.App)) {
RegisterPluginMenuItem(label, handler)
}