Replace CtrlO with open command

This comit also makes it possible for a binding to auto-type the
beginning of a command into command mode.

Closes #450
This commit is contained in:
Zachary Yedidia
2016-11-19 12:57:54 -05:00
parent 3ecdd96931
commit c692570212
5 changed files with 32 additions and 28 deletions

View File

@@ -49,6 +49,7 @@ func init() {
"Reload": Reload,
"Cd": Cd,
"Pwd": Pwd,
"Open": Open,
}
}
@@ -100,6 +101,7 @@ func DefaultCommands() map[string]StrCommand {
"reload": {"Reload", []Completion{NoCompletion}},
"cd": {"Cd", []Completion{FileCompletion}},
"pwd": {"Pwd", []Completion{NoCompletion}},
"open": {"Open", []Completion{FileCompletion}},
}
}
@@ -214,6 +216,18 @@ func Pwd(args []string) {
}
}
func Open(args []string) {
if len(args) > 0 {
filename := args[0]
// the filename might or might not be quoted, so unquote first then join the strings.
filename = strings.Join(SplitCommandArgs(filename), " ")
CurView().Open(filename)
} else {
messenger.Error("No filename")
}
}
func ToggleLog(args []string) {
buffer := messenger.getBuffer()
if CurView().Type != vtLog {