mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-20 15:57:10 +09:00
Add eval command
This commit is contained in:
@@ -38,6 +38,7 @@ var commandActions = map[string]func([]string){
|
||||
"HSplit": HSplit,
|
||||
"Tab": NewTab,
|
||||
"Help": Help,
|
||||
"Eval": Eval,
|
||||
}
|
||||
|
||||
// InitCommands initializes the default commands
|
||||
@@ -82,6 +83,7 @@ func DefaultCommands() map[string]StrCommand {
|
||||
"hsplit": {"HSplit", []Completion{FileCompletion, NoCompletion}},
|
||||
"tab": {"Tab", []Completion{FileCompletion, NoCompletion}},
|
||||
"help": {"Help", []Completion{HelpCompletion, NoCompletion}},
|
||||
"eval": {"Eval", []Completion{NoCompletion}},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +146,18 @@ func HSplit(args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Eval evaluates a lua expression
|
||||
func Eval(args []string) {
|
||||
if len(args) >= 1 {
|
||||
err := L.DoString(args[0])
|
||||
if err != nil {
|
||||
messenger.Error(err)
|
||||
}
|
||||
} else {
|
||||
messenger.Error("Not enough arguments")
|
||||
}
|
||||
}
|
||||
|
||||
// NewTab opens the given file in a new tab
|
||||
func NewTab(args []string) {
|
||||
if len(args) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user