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 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 GetInstalledPluginVersion(name string) string
- func GetNativeValue(option string, realValue interface{}, value string) (interface{}, error)
- func InitColorscheme() error
- func InitConfigDir(flagConfigDir string) error
- func InitGlobalSettings() error
- func InitLocalSettings(settings map[string]interface{}, path string) error
- func InitRuntimeFiles()
- func LoadAllPlugins() error
- func LoadColorscheme(colorschemeName string) error
- func LoadDefaultColorscheme() error
- func NewRTFiletype() int
- func OptionIsValid(option string, value interface{}) error
- func OverwriteSettings(filename string) 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 PluginCommand(out io.Writer, cmd string, args []string)
- func PluginListRuntimeFiles(fileType RTFiletype) []string
- func PluginReadRuntimeFile(fileType RTFiletype, name string) string
- func ReadSettings() error
- func RegisterCommonOption(name string, defaultvalue interface{}) error
- func RegisterCommonOptionPlug(pl string, name string, defaultvalue interface{}) error
- func RegisterGlobalOption(name string, defaultvalue interface{}) error
- func RegisterGlobalOptionPlug(pl string, name string, defaultvalue interface{}) error
- func RunPluginFn(fn string, args ...lua.LValue) error
- func RunPluginFnBool(settings map[string]interface{}, fn string, args ...lua.LValue) (bool, error)
- func SetAutoTime(a int)
- func StartAutoSave()
- func StringToColor(str string) (tcell.Color, bool)
- func StringToStyle(str string) tcell.Style
- func UninstallPlugin(out io.Writer, name string)
- func UpdatePlugins(out io.Writer, plugins []string)
- func WriteSettings(filename string) error
- type Plugin
- type PluginChannel
- type PluginChannels
- type PluginDependencies
- type PluginDependency
- type PluginInfo
- type PluginPackage
- type PluginPackages
- type PluginRepository
- type PluginVersion
- type PluginVersions
- type RTFiletype
- type RuntimeFile
Constants ¶
const ( RTColorscheme = 0 RTSyntax = 1 RTHelp = 2 RTPlugin = 3 RTSyntaxHeader = 4 )
const CorePluginName = "micro"
CorePluginName is a plugin dependency name for the micro core.
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") )
var ( ErrInvalidOption = errors.New("Invalid option") ErrInvalidValue = errors.New("Invalid value") // The options that the user can set GlobalSettings map[string]interface{} // ModifiedSettings is a map of settings which should be written to disk // because they have been modified by the user in this session ModifiedSettings map[string]bool )
var Autosave chan bool
var Bindings map[string]map[string]string
var Colorscheme map[string]tcell.Style
Colorscheme is the current colorscheme
var ConfigDir string
var DefStyle tcell.Style = tcell.StyleDefault
DefStyle is Micro's default style
var DefaultGlobalOnlySettings = map[string]interface{}{ "autosave": float64(0), "clipboard": "external", "colorscheme": "good", "divchars": "|-", "divreverse": true, "fakecursor": false, "infobar": true, "keymenu": false, "mouse": true, "multiopen": "tab", "parsecursor": false, "paste": false, "pluginchannels": []string{"https://raw.githubusercontent.com/micro-editor/plugin-channel/master/channel.json"}, "pluginrepos": []string{}, "savehistory": true, "scrollbarchar": "|", "sucmd": "sudo", "tabhighlight": false, "tabreverse": true, "xterm": false, }
a list of settings that should only be globally modified and their default values
var ErrNoSuchFunction = errors.New("No such function exists")
ErrNoSuchFunction is returned when Call is executed on a function that does not exist
var LocalSettings = []string{
"filetype",
"readonly",
}
a list of settings that should never be globally modified
var (
NumTypes = 5 // How many filetypes are there
)
var Plugins []*Plugin
Plugins is a list of all detected plugins (enabled or disabled)
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 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 GetColor ¶
func GetColor(color string) tcell.Style
GetColor takes in a syntax group and returns the colorscheme's style for that group
func GetColor256 ¶
func GetColor256(color int) tcell.Color
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 GetInstalledPluginVersion ¶
GetInstalledPluginVersion returns the string of the exported VERSION variable of a loaded plugin
func GetNativeValue ¶
GetNativeValue parses and validates a value for a given option
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() error
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 OptionIsValid ¶
OptionIsValid checks if a value is valid for a certain option
func OverwriteSettings ¶
OverwriteSettings writes the current settings to settings.json and resets any user configuration of local settings present in settings.json
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
func RegisterCommonOptionPlug ¶
RegisterCommonOptionPlug creates a new option (called pl.name). This is meant to be called by plugins to add options.
func RegisterGlobalOption ¶
RegisterGlobalOption creates a new global-only option
func RegisterGlobalOptionPlug ¶
RegisterGlobalOptionPlug creates a new global-only option (named pl.name)
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 ¶
func StringToStyle(str string) tcell.Style
StringToStyle returns a style from a string The strings must be in the format "extra foregroundcolor,backgroundcolor" The 'extra' can be bold, reverse, italic or underline
func UninstallPlugin ¶
UninstallPlugin deletes the plugin folder of the given plugin
func UpdatePlugins ¶
UpdatePlugins updates the given plugins
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 }
Plugin stores information about the source files/info for a plugin
func FindAnyPlugin ¶
FindAnyPlugin does not require the plugin to be enabled
func FindPlugin ¶
FindPlugin returns the plugin with the given name
type PluginChannel ¶
type PluginChannel string
PluginChannel contains an url to a json list of PluginRepository
func (PluginChannel) Fetch ¶
func (pc PluginChannel) Fetch(out io.Writer) PluginPackages
Fetch retrieves all available PluginPackages from the given channel
type PluginChannels ¶
type PluginChannels []PluginChannel
PluginChannels is a slice of PluginChannel
func (PluginChannels) Fetch ¶
func (pc PluginChannels) Fetch(out io.Writer) PluginPackages
Fetch retrieves all available PluginPackages from the given channels
type PluginDependencies ¶
type PluginDependencies []*PluginDependency
PluginDependencies is a slice of PluginDependency
func (PluginDependencies) Join ¶
func (req PluginDependencies) Join(other PluginDependencies) PluginDependencies
type PluginDependency ¶
PluginDependency descripes a dependency to another plugin or micro itself.
type PluginInfo ¶
type PluginInfo struct { Name string `json:"Name"` Desc string `json:"Description"` Site string `json:"Website"` }
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 PluginPackage ¶
type PluginPackage struct { Name string Description string Author string Tags []string Versions PluginVersions }
PluginPackage contains the meta-data of a plugin and all available versions
func (PluginPackage) Install ¶
func (pl PluginPackage) Install(out io.Writer)
Install installs the plugin
func (PluginPackage) IsInstallable ¶
func (pp PluginPackage) IsInstallable(out io.Writer) error
IsInstallable returns true if the package can be installed.
func (PluginPackage) Match ¶
func (pp PluginPackage) Match(text string) bool
Match returns true if the package matches a given search text
func (*PluginPackage) String ¶
func (pp *PluginPackage) String() string
func (*PluginPackage) UnmarshalJSON ¶
func (pp *PluginPackage) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals raw json to a PluginPackage
type PluginPackages ¶
type PluginPackages []*PluginPackage
PluginPackages is a list of PluginPackage instances.
func GetAllPluginPackages ¶
func GetAllPluginPackages(out io.Writer) PluginPackages
GetAllPluginPackages gets all PluginPackages which may be available.
func SearchPlugin ¶
func SearchPlugin(out io.Writer, texts []string) (plugins PluginPackages)
SearchPlugin retrieves a list of all PluginPackages which match the given search text and could be or are already installed
func (PluginPackages) Get ¶
func (pl PluginPackages) Get(name string) *PluginPackage
func (PluginPackages) GetAllVersions ¶
func (pl PluginPackages) GetAllVersions(name string) PluginVersions
func (PluginPackages) Resolve ¶
func (all PluginPackages) Resolve(selectedVersions PluginVersions, open PluginDependencies) (PluginVersions, error)
Resolve resolves dependencies between different plugins
type PluginRepository ¶
type PluginRepository string
PluginRepository contains an url to json file containing PluginPackages
func (PluginRepository) Fetch ¶
func (pr PluginRepository) Fetch(out io.Writer) PluginPackages
Fetch retrieves all available PluginPackages from the given repository
type PluginVersion ¶
type PluginVersion struct { Version semver.Version Url string Require PluginDependencies // contains filtered or unexported fields }
PluginVersion descripes a version of a PluginPackage. Containing a version, download url and also dependencies.
func (*PluginVersion) DownloadAndInstall ¶
func (pv *PluginVersion) DownloadAndInstall(out io.Writer) error
DownloadAndInstall downloads and installs the given plugin and version
func (*PluginVersion) Pack ¶
func (pv *PluginVersion) Pack() *PluginPackage
func (*PluginVersion) UnmarshalJSON ¶
func (pv *PluginVersion) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals raw json to a PluginVersion
type PluginVersions ¶
type PluginVersions []*PluginVersion
PluginVersions is a slice of PluginVersion
func GetInstalledVersions ¶
func GetInstalledVersions(withCore bool) PluginVersions
GetInstalledVersions returns a list of all currently installed plugins including an entry for micro itself. This can be used to resolve dependencies.
func (PluginVersions) Len ¶
func (pv PluginVersions) Len() int
Len returns the number of pluginversions in this slice
func (PluginVersions) Less ¶
func (pv PluginVersions) Less(i, j int) bool
Less returns true if the version at position i is greater then the version at position j (used for sorting)
type RTFiletype ¶
type RTFiletype int
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