Allow binding commands

Bind commands with `command:...`

Ref #974
This commit is contained in:
Zachary Yedidia
2018-01-02 15:02:46 -05:00
parent 981263eb81
commit f6e9a16724
3 changed files with 36 additions and 3 deletions

View File

@@ -476,6 +476,9 @@ func BindKey(k, v string) {
for _, actionName := range actionNames {
if strings.HasPrefix(actionName, "Mouse") {
mouseActions = append(mouseActions, findMouseAction(actionName))
} else if strings.HasPrefix(actionName, "command:") {
cmd := strings.SplitN(actionName, ":", 2)[1]
actions = append(actions, CommandAction(cmd))
} else {
actions = append(actions, findAction(actionName))
}

View File

@@ -120,6 +120,13 @@ func DefaultCommands() map[string]StrCommand {
}
}
func CommandAction(cmd string) func(*View, bool) bool {
return func(v *View, usePlugin bool) bool {
HandleCommand(cmd)
return false
}
}
// PluginCmd installs, removes, updates, lists, or searches for given plugins
func PluginCmd(args []string) {
if len(args) >= 1 {

File diff suppressed because one or more lines are too long