Documentation ¶
Index ¶
- Constants
- Variables
- func AddRealRuntimeFile(fileType RTFiletype, file RuntimeFile)
- func AddRuntimeFile(fileType RTFiletype, file RuntimeFile)
- func AddRuntimeFilesFromAssets(fileType RTFiletype, directory, pattern string)
- func AddRuntimeFilesFromDirectory(fileType RTFiletype, directory, pattern string)
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func ColorschemeExists(colorschemeName string) bool
- func DefaultAllSettings() map[string]interface{}
- func DefaultCommonSettings() map[string]interface{}
- func DefaultGlobalSettings() map[string]interface{}
- func GetAutoTime() int
- func GetColor(color string) tcell.Style
- func GetColor256(color int) tcell.Color
- func GetGlobalOption(name string) interface{}
- func GetInfoBarOffset() int
- func GetNativeValue(option string, realValue interface{}, value string) (interface{}, error)
- func InitColorscheme() error
- func InitConfigDir(flagConfigDir string) error
- func InitGlobalSettings()
- func InitLocalSettings(settings map[string]interface{}, path string) error
- func InitRuntimeFiles()
- func LoadAllPlugins() error
- func LoadColorscheme(colorschemeName string) error
- func LoadDefaultColorscheme() error
- func MustAsset(name string) []byte
- func OptionIsValid(option string, value interface{}) error
- func ParseColorscheme(text string) (map[string]tcell.Style, error)
- func PluginAddRuntimeFile(plugin string, filetype RTFiletype, filePath string) error
- func PluginAddRuntimeFileFromMemory(filetype RTFiletype, filename, data string)
- func PluginAddRuntimeFilesFromDirectory(plugin string, filetype RTFiletype, directory, pattern string) error
- func PluginListRuntimeFiles(fileType RTFiletype) []string
- func PluginReadRuntimeFile(fileType RTFiletype, name string) string
- func ReadSettings() error
- func RegisterCommonOption(name string, defaultvalue interface{}) error
- func RegisterGlobalOption(name string, defaultvalue interface{}) error
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func RunPluginFn(fn string, args ...lua.LValue) error
- func RunPluginFnBool(fn string, args ...lua.LValue) (bool, error)
- func SetAutoTime(a int)
- func StartAutoSave()
- func StringToColor(str string) tcell.Color
- func StringToStyle(str string) tcell.Style
- func WriteSettings(filename string) error
- type Plugin
- type PluginInfo
- type RTFiletype
- type RuntimeFile
Constants ¶
const ( RTColorscheme = 0 RTSyntax = 1 RTHelp = 2 RTPlugin = 3 RTSyntaxHeader = 4 NumTypes = 5 // How many filetypes are there )
const (
DoubleClickThreshold = 400 // How many milliseconds to wait before a second click is not a double click
)
Variables ¶
var ( ErrMissingName = errors.New("Missing or empty name field") ErrMissingDesc = errors.New("Missing or empty description field") ErrMissingSite = errors.New("Missing or empty website field") ErrMissingInstall = errors.New("Missing or empty install field") ErrMissingVstr = errors.New("Missing or empty versions field") ErrMissingRequire = errors.New("Missing or empty require field") )
var ( ErrInvalidOption = errors.New("Invalid option") ErrInvalidValue = errors.New("Invalid value") // The options that the user can set GlobalSettings map[string]interface{} )
var Autosave chan bool
var Bindings map[string]string
var Colorscheme map[string]tcell.Style
The current colorscheme
var ConfigDir string
var DefStyle tcell.Style = tcell.StyleDefault
Micro's default style
var ErrNoSuchFunction = errors.New("No such function exists")
var Plugins []*Plugin
Functions ¶
func AddRealRuntimeFile ¶
func AddRealRuntimeFile(fileType RTFiletype, file RuntimeFile)
AddRealRuntimeFile registers a file for the given filetype
func AddRuntimeFile ¶
func AddRuntimeFile(fileType RTFiletype, file RuntimeFile)
AddRuntimeFile registers a file for the given filetype
func AddRuntimeFilesFromAssets ¶
func AddRuntimeFilesFromAssets(fileType RTFiletype, directory, pattern string)
AddRuntimeFilesFromAssets registers each file from the given asset-directory for the filetype which matches the file-pattern
func AddRuntimeFilesFromDirectory ¶
func AddRuntimeFilesFromDirectory(fileType RTFiletype, directory, pattern string)
AddRuntimeFilesFromDirectory registers each file from the given directory for the filetype which matches the file-pattern
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func ColorschemeExists ¶
ColorschemeExists checks if a given colorscheme exists
func DefaultAllSettings ¶
func DefaultAllSettings() map[string]interface{}
DefaultAllSettings returns a map of all settings and their default values (both common and global settings)
func DefaultCommonSettings ¶
func DefaultCommonSettings() map[string]interface{}
DefaultCommonSettings returns the default global settings for micro Note that colorscheme is a global only option
func DefaultGlobalSettings ¶
func DefaultGlobalSettings() map[string]interface{}
DefaultGlobalSettings returns the default global settings for micro Note that colorscheme is a global only option
func GetAutoTime ¶
func GetAutoTime() int
func GetColor256 ¶
GetColor256 returns the tcell color for a number between 0 and 255
func GetGlobalOption ¶
func GetGlobalOption(name string) interface{}
GetGlobalOption returns the global value of the given option
func GetInfoBarOffset ¶
func GetInfoBarOffset() int
func GetNativeValue ¶
func InitColorscheme ¶
func InitColorscheme() error
InitColorscheme picks and initializes the colorscheme when micro starts
func InitConfigDir ¶
InitConfigDir finds the configuration directory for micro according to the XDG spec. If no directory is found, it creates one.
func InitGlobalSettings ¶
func InitGlobalSettings()
InitGlobalSettings initializes the options map and sets all options to their default values Must be called after ReadSettings
func InitLocalSettings ¶
InitLocalSettings scans the json in settings.json and sets the options locally based on whether the filetype or path matches ft or glob local settings Must be called after ReadSettings
func InitRuntimeFiles ¶
func InitRuntimeFiles()
InitRuntimeFiles initializes all assets file and the config directory
func LoadAllPlugins ¶
func LoadAllPlugins() error
LoadAllPlugins loads all detected plugins (in runtime/plugins and ConfigDir/plugins)
func LoadColorscheme ¶
LoadColorscheme loads the given colorscheme from a directory
func LoadDefaultColorscheme ¶
func LoadDefaultColorscheme() error
LoadDefaultColorscheme loads the default colorscheme from $(ConfigDir)/colorschemes
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func OptionIsValid ¶
OptionIsValid checks if a value is valid for a certain option
func ParseColorscheme ¶
ParseColorscheme parses the text definition for a colorscheme and returns the corresponding object Colorschemes are made up of color-link statements linking a color group to a list of colors For example, color-link keyword (blue,red) makes all keywords have a blue foreground and red background
func PluginAddRuntimeFile ¶
func PluginAddRuntimeFile(plugin string, filetype RTFiletype, filePath string) error
PluginAddRuntimeFile adds a file to the runtime files for a plugin
func PluginAddRuntimeFileFromMemory ¶
func PluginAddRuntimeFileFromMemory(filetype RTFiletype, filename, data string)
PluginAddRuntimeFileFromMemory adds a file to the runtime files for a plugin from a given string
func PluginAddRuntimeFilesFromDirectory ¶
func PluginAddRuntimeFilesFromDirectory(plugin string, filetype RTFiletype, directory, pattern string) error
PluginAddRuntimeFilesFromDirectory adds files from a directory to the runtime files for a plugin
func PluginListRuntimeFiles ¶
func PluginListRuntimeFiles(fileType RTFiletype) []string
PluginListRuntimeFiles allows plugins to lists all runtime files of the given type
func PluginReadRuntimeFile ¶
func PluginReadRuntimeFile(fileType RTFiletype, name string) string
PluginReadRuntimeFile allows plugin scripts to read the content of a runtime file
func ReadSettings ¶
func ReadSettings() error
func RegisterCommonOption ¶
RegisterCommonOption creates a new option. This is meant to be called by plugins to add options.
func RegisterGlobalOption ¶
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func RunPluginFn ¶
RunPluginFn runs a given function in all plugins returns an error if any of the plugins had an error
func RunPluginFnBool ¶
RunPluginFnBool runs a function in all plugins and returns false if any one of them returned false also returns an error if any of the plugins had an error
func SetAutoTime ¶
func SetAutoTime(a int)
func StartAutoSave ¶
func StartAutoSave()
func StringToColor ¶
StringToColor returns a tcell color from a string representation of a color We accept either bright... or light... to mean the brighter version of a color
func StringToStyle ¶
StringToStyle returns a style from a string The strings must be in the format "extra foregroundcolor,backgroundcolor" The 'extra' can be bold, reverse, or underline
func WriteSettings ¶
WriteSettings writes the settings to the specified filename as JSON
Types ¶
type Plugin ¶
type Plugin struct { DirName string // name of plugin folder Name string // name of plugin Info *PluginInfo // json file containing info Srcs []RuntimeFile // lua files Loaded bool Default bool // pre-installed plugin }
func FindPlugin ¶
type PluginInfo ¶
type PluginInfo struct { Name string `json:"name"` Desc string `json:"description"` Site string `json:"website"` Install string `json:"install"` Vstr string `json:"version"` Require []string `json:"require"` }
PluginInfo contains all the needed info about a plugin The info is just strings and are not used beyond that (except the Site and Install fields should be valid URLs). This means that the requirements for example can be formatted however the plugin maker decides, the fields will only be parsed by humans Name: name of plugin Desc: description of plugin Site: home website of plugin Install: install link for plugin (can be link to repo or zip file) Vstr: version Require: list of dependencies and requirements
func NewPluginInfo ¶
func NewPluginInfo(data []byte) (*PluginInfo, error)
NewPluginInfo parses a JSON input into a valid PluginInfo struct Returns an error if there are any missing fields or any invalid fields There are no optional fields in a plugin info json file
type RTFiletype ¶
type RTFiletype byte
type RuntimeFile ¶
type RuntimeFile interface { // Name returns a name of the file without paths or extensions Name() string // Data returns the content of the file. Data() ([]byte, error) }
RuntimeFile allows the program to read runtime data like colorschemes or syntax files
func FindRuntimeFile ¶
func FindRuntimeFile(fileType RTFiletype, name string) RuntimeFile
FindRuntimeFile finds a runtime file of the given filetype and name will return nil if no file was found
func ListRealRuntimeFiles ¶
func ListRealRuntimeFiles(fileType RTFiletype) []RuntimeFile
ListRealRuntimeFiles lists all real runtime files (on disk) for a filetype these runtime files will be ones defined by the user and loaded from the config directory
func ListRuntimeFiles ¶
func ListRuntimeFiles(fileType RTFiletype) []RuntimeFile
ListRuntimeFiles lists all known runtime files for the given filetype