mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-28 18:00:23 +09:00
39 lines
847 B
Go
39 lines
847 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
)
|
|
|
|
type HelpPage interface {
|
|
HelpFile() ([]byte, error)
|
|
}
|
|
|
|
var helpPages map[string]HelpPage = map[string]HelpPage{
|
|
"help": assetHelpPage("help"),
|
|
"keybindings": assetHelpPage("keybindings"),
|
|
"plugins": assetHelpPage("plugins"),
|
|
"colors": assetHelpPage("colors"),
|
|
"options": assetHelpPage("options"),
|
|
"commands": assetHelpPage("commands"),
|
|
"tutorial": assetHelpPage("tutorial"),
|
|
}
|
|
|
|
type assetHelpPage string
|
|
|
|
func (file assetHelpPage) HelpFile() ([]byte, error) {
|
|
return Asset("runtime/help/" + string(file) + ".md")
|
|
}
|
|
|
|
type fileHelpPage string
|
|
|
|
func (file fileHelpPage) HelpFile() ([]byte, error) {
|
|
return ioutil.ReadFile(string(file))
|
|
}
|
|
|
|
func AddPluginHelp(name, file string) {
|
|
if _, exists := helpPages[name]; exists {
|
|
return
|
|
}
|
|
helpPages[name] = fileHelpPage(file)
|
|
}
|