Add reload command

Closes #427
This commit is contained in:
Zachary Yedidia
2016-10-21 11:51:36 -04:00
parent 97fc52093f
commit ee553b7830
4 changed files with 56 additions and 28 deletions

View File

@@ -26,22 +26,27 @@ type StrCommand struct {
var commands map[string]Command
var commandActions = map[string]func([]string){
"Set": Set,
"SetLocal": SetLocal,
"Show": Show,
"Run": Run,
"Bind": Bind,
"Quit": Quit,
"Save": Save,
"Replace": Replace,
"VSplit": VSplit,
"HSplit": HSplit,
"Tab": NewTab,
"Help": Help,
"Eval": Eval,
"ToggleLog": ToggleLog,
"Plugin": PluginCmd,
var commandActions map[string]func([]string)
func init() {
commandActions = map[string]func([]string){
"Set": Set,
"SetLocal": SetLocal,
"Show": Show,
"Run": Run,
"Bind": Bind,
"Quit": Quit,
"Save": Save,
"Replace": Replace,
"VSplit": VSplit,
"HSplit": HSplit,
"Tab": NewTab,
"Help": Help,
"Eval": Eval,
"ToggleLog": ToggleLog,
"Plugin": PluginCmd,
"Reload": Reload,
}
}
// InitCommands initializes the default commands
@@ -89,6 +94,7 @@ func DefaultCommands() map[string]StrCommand {
"eval": {"Eval", []Completion{NoCompletion}},
"log": {"ToggleLog", []Completion{NoCompletion}},
"plugin": {"Plugin", []Completion{PluginCmdCompletion, PluginNameCompletion}},
"reload": {"Reload", []Completion{NoCompletion}},
}
}
@@ -178,6 +184,10 @@ func ToggleLog(args []string) {
}
}
func Reload(args []string) {
LoadAll()
}
// Help tries to open the given help page in a horizontal split
func Help(args []string) {
if len(args) < 1 {

View File

@@ -199,6 +199,31 @@ func RedrawAll() {
screen.Show()
}
func LoadAll() {
// Find the user's configuration directory (probably $XDG_CONFIG_HOME/micro)
InitConfigDir()
// Build a list of available Extensions (Syntax, Colorscheme etc.)
InitRuntimeFiles()
// Load the user's settings
InitGlobalSettings()
InitCommands()
InitBindings()
LoadSyntaxFiles()
for _, tab := range tabs {
for _, v := range tab.views {
v.Buf.UpdateRules()
if v.Buf.Settings["syntax"].(bool) {
v.matches = Match(v)
}
}
}
}
// Passing -version as a flag will have micro print out the version number
var flagVersion = flag.Bool("version", false, "Show the version number and information")
var flagStartPos = flag.String("startpos", "", "LINE,COL to start the cursor at when opening a buffer.")
@@ -234,17 +259,7 @@ func main() {
encoding.Register()
tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
// Find the user's configuration directory (probably $XDG_CONFIG_HOME/micro)
InitConfigDir()
// Build a list of available Extensions (Syntax, Colorscheme etc.)
InitRuntimeFiles()
// Load the user's settings
InitGlobalSettings()
InitCommands()
InitBindings()
LoadAll()
// Start the screen
InitScreen()
@@ -319,6 +334,7 @@ func main() {
}))
L.SetGlobal("JoinPaths", luar.New(L, filepath.Join))
L.SetGlobal("configDir", luar.New(L, configDir))
L.SetGlobal("Reload", luar.New(L, LoadAll))
// Used for asynchronous jobs
L.SetGlobal("JobStart", luar.New(L, JobStart))

View File

@@ -400,7 +400,7 @@ func runtimeHelpColorsMd() (*asset, error) {
return a, nil
}
var _runtimeHelpCommandsMd = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x56\x4d\x8f\xdc\x36\x0c\xbd\xcf\xaf\x20\xa6\x87\x4d\x8a\x1d\xe7\x3e\x97\xa2\x28\x0a\xb4\x40\x52\xa4\x48\x2e\x3d\x55\xb4\x4d\xdb\xc2\xc8\xa2\x23\xca\x33\x3b\xfd\xf5\x05\x45\xcd\xd7\xee\x21\x39\xad\x57\xfc\x7a\x7a\x24\xdf\xe8\x27\xf8\xcc\x22\xbe\x0d\x04\x1d\xcf\x33\xc6\x5e\x36\x9b\x7f\x78\x85\x0e\x23\xd0\x0b\x75\x6b\x26\xd0\xcf\xde\x67\x4e\x17\x1f\x68\xcf\xb0\x24\x12\xf1\x71\x04\xf7\x5b\x4e\x61\x47\x0e\x06\x0e\x81\x4f\x54\xac\x79\xba\x26\x6c\x36\x7f\x50\x22\xc0\x44\xe5\x74\x79\x5d\x0f\xf2\x84\x19\xce\xb5\xe6\x2a\xd4\x6c\x36\x3f\x83\xfb\xb6\xfa\xec\xf6\xf0\xf7\xea\xb3\xc0\xec\xbb\xc4\x76\x2e\x78\x24\x18\x7c\xa0\x88\x33\xfd\xe2\xf6\xf0\x05\x8f\x24\x56\x70\x4d\x89\x62\x86\x76\x1d\x06\x4a\x0d\xfc\x39\x94\xe3\x8b\x33\x78\x81\x25\xf1\xd1\xf7\xd4\x83\xcf\x70\xf2\x21\x6c\x00\xe0\xa9\xa4\x44\x79\x7a\xf0\xb6\x6a\x89\x96\x80\x1d\xc1\x56\x08\x53\x37\x6d\x61\x7b\xc4\xb0\xd2\x16\x86\x80\xa3\xb8\x3d\x7c\x9d\xbc\x94\x4c\x70\x71\x75\xe6\xea\xe0\xe4\xf3\x04\xae\xf8\xbb\x06\xb4\xd2\xd7\x89\xc0\x59\x64\xe1\x83\x97\xec\x39\x62\x68\xd4\xf8\x6b\x86\xac\xc9\x16\xf6\x31\x3f\x2b\x96\x54\x20\x73\x0c\x67\xe0\x48\xa5\xe4\x1e\x5c\xe7\x9e\xe1\x34\xf9\x6e\x02\x8a\xd8\x06\x12\x70\xdd\x44\xdd\xc1\xc1\xcc\x3d\x95\x3a\x66\x46\x39\x08\xf8\x41\xa9\x7d\xea\x21\xf8\x03\x41\x66\x58\x28\x0d\x9c\xe6\x72\xd7\x0a\x79\x56\xd2\x08\xbb\x09\xb2\x2f\x17\x07\x80\xbf\x38\x93\x75\xe6\x7a\x9f\x79\x95\x0c\x2d\x01\xc2\x11\x83\xef\x21\xd1\x48\x2f\x0d\x28\xcd\x0a\x8f\x8d\x6d\x4c\xe3\xaa\x09\x45\xb3\xf4\x4c\x02\x91\x33\x4c\x85\xe2\x78\x06\x59\xb0\x23\x01\x1f\xc1\xe7\xe7\xd2\xf5\x19\xcf\xc0\xb3\xcf\x25\xfa\xdb\xca\x99\xa4\x76\x9a\x72\x65\x08\x8c\xc4\x3d\x08\x65\x6b\x75\x3d\xcf\x6c\xa6\x06\xbe\x90\x8d\x97\x33\x8b\x38\x98\x28\x2c\x90\x79\xf1\x9d\x22\x19\x38\x01\x42\xf0\x92\x15\x68\x75\xba\x4e\x9d\x50\xbe\xd6\x0c\xdc\x61\xf8\xd1\xc2\x50\xbc\xc3\x19\xde\x95\x36\xf9\x78\x3f\x88\x5a\xd7\x66\xf1\x7d\xcd\x3e\xf1\xa9\x66\xd0\x9c\x13\x9f\x1e\x07\xd7\x52\x56\x22\x47\x7f\xa4\x58\xbd\x2d\x9c\x8e\x18\x60\x4b\x2f\xb6\x7a\x1c\xb7\x6e\x0f\xbf\x6b\x0c\x66\x12\x40\xf8\xb8\x22\xdc\xac\xcd\x5d\x0f\xcb\xfe\xd8\x98\x46\x2e\xb8\x96\xe4\x63\xd6\x8e\xe4\x49\x97\x58\xb8\x70\x21\x13\xaf\xa1\xd7\x25\x04\x37\x93\x08\xc5\x91\xd2\xfe\x13\x89\xe0\x48\xef\x9a\xa6\x79\xef\xf4\xea\xbd\x97\x25\xe0\x19\x50\x33\x59\x03\x6c\x5b\xd6\x08\x32\xed\xea\x66\xbb\x3d\xa4\x35\xca\xdd\x65\x64\xa2\x10\xae\x22\x52\xc9\x6a\xb1\x3b\x8c\x89\xd7\xd8\x37\x65\x41\x34\x67\x75\x79\x12\xe0\x35\x2f\xab\xed\xaa\xce\x5e\xad\x4c\x25\x5a\xa7\x2e\xf8\x48\x70\x9a\x48\xe7\x09\x06\x1f\xbd\x4c\x24\x5a\x37\xfa\x38\x1a\xaa\xd6\xc7\x1e\x0e\x74\x06\xec\x2a\xf3\x5d\xa2\x4a\xd9\x81\xce\x6a\x56\x0a\x86\xc4\x73\x71\xcb\x5c\x3d\x6f\x53\x25\xd4\xd9\xc0\x70\x54\x78\xb7\x28\x01\x6c\x59\x05\x89\x13\xcc\xac\x0b\x1b\x07\xd6\x33\xc5\xac\xcc\x1f\xe8\x2c\xa0\xb7\xc5\x9a\x41\xf7\x1e\x8f\xe8\x83\xee\xae\x01\x3c\xca\x12\x0a\x7a\x53\x1e\xb7\x07\x5e\x48\x5d\xe1\x48\x29\x7b\x1d\x47\xf3\x30\x45\xb9\xfa\x15\x85\x8b\x7c\x2f\x70\xd6\x5a\xd3\xb8\xe7\xb7\x09\x54\x4e\x16\x8a\xd4\x5b\x2a\x15\xf6\x79\xc9\xe7\x8b\x62\x16\x34\xd3\x1b\x34\xa2\xb9\x51\x2e\x40\x1d\xb4\x6b\xbe\x42\x9c\x38\xf9\xff\x38\xe6\x5b\x8d\x28\x99\xb0\x07\x1e\x14\xcc\x6b\x08\x56\x23\x63\xfb\xf6\xba\xb7\x39\x51\x93\x36\x18\x21\xd2\x09\x32\xb6\x16\x15\x78\xbc\xe3\x26\xf0\xa8\xab\x82\x21\xc0\x6c\x03\x6a\x44\xf7\xd4\xae\x23\x48\xc6\x5c\x84\xad\x8a\xc9\x12\xd6\x51\x45\x27\x4a\xd6\x08\xfb\xf7\xdf\x5a\xbf\x9e\xde\x43\x30\x87\x87\xd8\x44\xb3\xb6\xfa\x31\xd4\x0e\xbf\x13\xa9\xb2\xe3\xf6\xe5\x8f\x14\xc0\xb5\x20\xf5\xd5\xfb\x11\xe4\xba\xf4\x98\x35\xb9\x7d\xfc\x48\x88\x69\xf4\x2b\x6c\x76\x48\x52\xa6\xf3\x2d\xc0\x07\x95\xbf\x28\xe1\xa0\xcb\x72\x13\x4a\xad\x7c\x9d\xd6\x4b\x65\xc0\x22\x21\xa3\xcf\xd3\xda\x36\x1d\xcf\x1f\x8a\xbe\xec\xec\x91\xf0\xc1\xbc\x76\xdd\x84\x31\x52\xb0\x9f\x93\xcb\x93\x02\x83\x30\x08\xd1\x6d\x59\xd2\x8c\x45\x51\x6d\x67\xca\x0b\xc1\xae\x34\x63\xc4\x91\x92\x46\x57\xa5\x70\x9f\xcd\xf2\xc9\x2c\xee\xb2\x96\x17\xc5\xac\x64\x3c\x68\x7f\xb3\xd9\xec\x76\xbb\xcd\x46\x95\xc5\x1e\x28\xba\xeb\xd7\xb7\x87\x6e\xe3\xf5\x4d\x50\xdf\x2d\x3d\x0d\xb8\x86\x7c\xb9\xed\xde\x66\xcf\x47\x6d\xe1\x47\x55\xcd\x7b\xc9\x2e\xa3\xaa\xfc\x52\x4a\x9c\xa4\xd9\xfc\x1f\x00\x00\xff\xff\x52\x11\x54\xb8\x52\x09\x00\x00")
var _runtimeHelpCommandsMd = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x56\x4d\x8f\x1b\x37\x0f\xbe\xfb\x57\x10\xfb\x1e\x36\x79\xb1\x9e\xdc\x7d\x29\x8a\xa2\x40\x0b\x24\x45\x8a\xe4\xd2\x53\x45\xcf\x70\x66\x04\x6b\xc4\x89\x28\xd9\x71\x7f\x7d\x41\x51\xfe\xda\x3d\x34\xa7\xf5\x8a\x5f\x8f\x1e\x92\xcf\xe8\x7f\xf0\x99\x45\xfc\x3e\x10\xf4\xbc\x2c\x18\x07\xd9\x6c\xfe\xe2\x02\x3d\x46\xa0\xef\xd4\x97\x4c\xa0\x3f\x07\x9f\x39\x5d\x7c\x60\x7f\x86\x35\x91\x88\x8f\x13\xb8\x5f\x72\x0a\x5b\x72\x30\x72\x08\x7c\xa2\x6a\xcd\xf3\x35\x61\xb7\xf9\x8d\x12\x01\x26\xaa\xa7\xeb\xeb\x7a\x90\x67\xcc\x70\x6e\x35\x8b\x50\xb7\xd9\xfc\x1f\xdc\xb7\xe2\xb3\xdb\xc1\x9f\xc5\x67\x81\xc5\xf7\x89\xed\x5c\xf0\x48\x30\xfa\x40\x11\x17\xfa\xc9\xed\xe0\x0b\x1e\x49\xac\x60\x49\x89\x62\x86\x7d\x19\x47\x4a\x1d\xfc\x3e\xd6\xe3\x8b\x33\x78\x81\x35\xf1\xd1\x0f\x34\x80\xcf\x70\xf2\x21\x6c\x00\xe0\xb9\xa6\x44\x79\x7e\xf0\xb6\x6a\x89\xd6\x80\x3d\xc1\x93\x10\xa6\x7e\x7e\x82\xa7\x23\x86\x42\x4f\x30\x06\x9c\xc4\xed\xe0\xeb\xec\xa5\x66\x82\x8b\xab\x33\x57\x07\x27\x9f\x67\x70\xd5\xdf\x75\xa0\x95\xbe\xce\x04\xce\x22\x2b\x1f\xbc\x66\xcf\x11\x43\xa7\xc6\x9f\x33\x64\x4d\xb6\xb2\x8f\xf9\x45\xb1\xa4\x0a\x99\x63\x38\x03\x47\xaa\x25\x77\xe0\x7a\xf7\x02\xa7\xd9\xf7\x33\x50\xc4\x7d\x20\x01\xd7\xcf\xd4\x1f\x1c\x2c\x3c\x50\xad\x63\x66\x94\x83\x80\x1f\x95\xda\xe7\x01\x82\x3f\x10\x64\x86\x95\xd2\xc8\x69\xa9\x77\x6d\x90\x17\x25\x8d\xb0\x9f\x21\xfb\x7a\x71\x00\xf8\x83\x33\x59\x67\xae\xf7\x59\x8a\x64\xd8\x13\x20\x1c\x31\xf8\x01\x12\x4d\xf4\xbd\x03\xa5\x59\xe1\xb1\xb1\x8d\x69\x2a\x9a\x50\x34\xcb\xc0\x24\x10\x39\xc3\x5c\x29\x8e\x67\x90\x15\x7b\x12\xf0\x11\x7c\x7e\xa9\x5d\x5f\xf0\x0c\xbc\xf8\x5c\xa3\xbf\x15\xce\x24\xad\xd3\x94\x1b\x43\x60\x24\xee\x40\x28\x5b\xab\xdb\x79\x66\x33\x75\xf0\x85\x6c\xbc\x9c\x59\xc4\xc1\x4c\x61\x85\xcc\xab\xef\x15\xc9\xc8\x09\x10\x82\x97\xac\x40\x9b\xd3\x75\xea\x84\xf2\xb5\x66\xe0\x1e\xc3\x8f\x16\x86\xea\x1d\xce\xf0\xae\xb6\xc9\xc7\xfb\x41\xd4\xba\x36\x8b\xef\x5b\xf6\x99\x4f\x2d\x83\xe6\x9c\xf9\xf4\x38\xb8\x96\xb2\x11\x39\xf9\x23\xc5\xe6\x6d\xe1\x74\xc4\x00\x4f\xf4\xdd\x56\x8f\xe3\x93\xdb\xc1\xaf\x1a\x83\x99\x04\x10\x3e\x16\x84\x9b\xb5\xbb\xeb\x61\xdd\x1f\x1b\xd3\xc8\x15\xd7\x9a\x7c\xcc\xda\x91\x3c\xeb\x12\x0b\x57\x2e\x64\xe6\x12\x06\x5d\x42\x70\x0b\x89\x50\x9c\x28\xed\x3e\x91\x08\x4e\xf4\xae\xeb\xba\xf7\x4e\xaf\x3e\x78\x59\x03\x9e\x01\x35\x93\x35\xc0\xb6\xa5\x44\x90\x79\xdb\x36\xdb\xed\x20\x95\x28\x77\x97\x91\x99\x42\xb8\x8a\x48\x23\x6b\x8f\xfd\x61\x4a\x5c\xe2\xd0\xd5\x05\xd1\x9c\xcd\xe5\x59\x80\x4b\x5e\x8b\xed\xaa\xce\x5e\xab\x4c\x35\x5a\xa7\x2e\xf8\x48\x70\x9a\x49\xe7\x09\x46\x1f\xbd\xcc\x24\x5a\x37\xfa\x38\x19\xaa\xbd\x8f\x03\x1c\xe8\x0c\xd8\x37\xe6\xfb\x44\x8d\xb2\x03\x9d\xd5\xac\x14\x8c\x89\x97\xea\x96\xb9\x79\xde\xa6\x4a\xa8\xb7\x81\xe1\xa8\xf0\x6e\x51\x02\xb8\x67\x15\x24\x4e\xb0\xb0\x2e\x6c\x1c\x59\xcf\x14\xb3\x32\x7f\xa0\xb3\x80\xde\x16\x5b\x06\xdd\x7b\x3c\xa2\x0f\xba\xbb\x06\xf0\x28\x6b\xa8\xe8\x4d\x79\xdc\x0e\x78\x25\x75\x85\x23\xa5\xec\x75\x1c\xcd\xc3\x14\xe5\xea\x57\x15\x2e\xf2\xbd\xc0\x59\x6b\x4d\xe3\x5e\xde\x26\x50\x39\x59\x29\xd2\x60\xa9\x54\xd8\x97\x35\x9f\x2f\x8a\x59\xd1\xcc\x6f\xd0\x88\xe6\x46\xb9\x00\x75\xb0\x2f\xf9\x0a\x71\xe6\xe4\xff\xe1\x98\x6f\x35\xa2\x64\xc2\x01\x78\x54\x30\xaf\x21\x58\x8d\x8c\xfb\xb7\xd7\xbd\xcd\x89\x9a\xb4\xc1\x08\x91\x4e\x90\x71\x6f\x51\x81\xa7\x3b\x6e\x02\x4f\xba\x2a\x18\x02\x2c\x36\xa0\x46\xf4\x40\xfb\x32\x81\x64\xcc\x55\xd8\x9a\x98\xac\xa1\x4c\x2a\x3a\x51\xb2\x46\xd8\xbf\x7f\xb7\xfa\xed\xf4\x1e\x82\x39\x3c\xc4\x26\x5a\xb4\xd5\x8f\xa1\x76\xf8\x1f\x91\x2a\x3b\x6e\x57\xff\x48\x05\xdc\x0a\xd2\xd0\xbc\x1f\x41\x96\x75\xc0\xac\xc9\xed\xc7\x8f\x84\x98\x46\xbf\xc2\x66\x87\x24\x75\x3a\xdf\x02\x7c\x50\xf9\x8b\x12\x8e\xba\x2c\x37\xa1\xd4\xca\xd7\x69\xbd\x54\x06\xac\x12\x32\xf9\x3c\x97\x7d\xd7\xf3\xf2\xa1\xea\xcb\xd6\x1e\x09\x1f\xcc\x6b\xdb\xcf\x18\x23\x05\xfb\x9c\x5c\x9e\x14\x18\x84\x41\x88\x6e\xcb\x92\x16\xac\x8a\x6a\x3b\x53\x5f\x08\x76\xa5\x05\x23\x4e\x94\x34\xba\x29\x85\xfb\x6c\x96\x4f\x66\x71\x97\xb5\xbc\x28\x66\x23\xe3\x41\xfb\x2f\x9f\xf1\xc0\x58\x05\xa9\xfe\x30\x46\x53\x89\xfa\xbd\xab\xd3\xa6\x6c\x6e\xb7\xdb\xcd\x46\x15\xc8\x1e\x32\xaa\x09\xd7\x37\x8a\x6e\xed\xf5\xed\xd0\xde\x37\x03\x8d\x58\x42\xbe\xb0\xb2\xb3\x19\xf5\x51\x5b\xfd\x51\xd5\xf5\x5e\xda\xeb\x48\x6b\x1f\x28\x25\x4e\xd2\x6d\xfe\x0d\x00\x00\xff\xff\x82\x21\x32\x02\x7a\x09\x00\x00")
func runtimeHelpCommandsMdBytes() ([]byte, error) {
return bindataRead(

View File

@@ -59,6 +59,8 @@ Here are the possible commands that you can use.
You can also see more information about the plugin manager
in the `Plugin Manager` section of the `plugins` help topic.
* `reload`: reloads all runtime files.
---
The following commands are provided by the default plugins: