mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
More command binding
Now can bind editable commands with `command-edit:` Ref #974
This commit is contained in:
@@ -479,6 +479,9 @@ func BindKey(k, v string) {
|
||||
} else if strings.HasPrefix(actionName, "command:") {
|
||||
cmd := strings.SplitN(actionName, ":", 2)[1]
|
||||
actions = append(actions, CommandAction(cmd))
|
||||
} else if strings.HasPrefix(actionName, "command-edit:") {
|
||||
cmd := strings.SplitN(actionName, ":", 2)[1]
|
||||
actions = append(actions, CommandEditAction(cmd))
|
||||
} else {
|
||||
actions = append(actions, findAction(actionName))
|
||||
}
|
||||
|
||||
@@ -120,6 +120,16 @@ func DefaultCommands() map[string]StrCommand {
|
||||
}
|
||||
}
|
||||
|
||||
func CommandEditAction(prompt string) func(*View, bool) bool {
|
||||
return func(v *View, usePlugin bool) bool {
|
||||
input, canceled := messenger.Prompt("> ", prompt, "Command", CommandCompletion)
|
||||
if !canceled {
|
||||
HandleCommand(input)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func CommandAction(cmd string) func(*View, bool) bool {
|
||||
return func(v *View, usePlugin bool) bool {
|
||||
HandleCommand(cmd)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user