This commit is contained in:
Gokcehan 2016-08-28 17:02:58 +03:00
parent 3d1b090359
commit a6ae19b0b3

36
eval.go
View File

@ -116,16 +116,12 @@ func (e *CmdExpr) eval(app *App, args []string) {
func (e *CallExpr) eval(app *App, args []string) { func (e *CallExpr) eval(app *App, args []string) {
// TODO: check for extra toks in each case // TODO: check for extra toks in each case
switch e.name { switch e.name {
case "quit":
gExitFlag = true
case "echo":
app.ui.message = strings.Join(e.args, " ")
case "down":
app.nav.down()
app.ui.echoFileInfo(app.nav)
case "up": case "up":
app.nav.up() app.nav.up()
app.ui.echoFileInfo(app.nav) app.ui.echoFileInfo(app.nav)
case "down":
app.nav.down()
app.ui.echoFileInfo(app.nav)
case "updir": case "updir":
if err := app.nav.updir(); err != nil { if err := app.nav.updir(); err != nil {
app.ui.message = err.Error() app.ui.message = err.Error()
@ -184,23 +180,14 @@ func (e *CallExpr) eval(app *App, args []string) {
if cmd, ok := gOpts.cmds["open-file"]; ok { if cmd, ok := gOpts.cmds["open-file"]; ok {
cmd.eval(app, e.args) cmd.eval(app, e.args)
} }
case "quit":
gExitFlag = true
case "bot": case "bot":
app.nav.bot() app.nav.bot()
app.ui.echoFileInfo(app.nav) app.ui.echoFileInfo(app.nav)
case "top": case "top":
app.nav.top() app.nav.top()
app.ui.echoFileInfo(app.nav) app.ui.echoFileInfo(app.nav)
case "cd":
path := "~"
if len(e.args) > 0 {
path = e.args[0]
}
if err := app.nav.cd(path); err != nil {
app.ui.message = err.Error()
log.Print(err)
return
}
app.ui.echoFileInfo(app.nav)
case "read": case "read":
s := app.ui.prompt(app.nav, ":") s := app.ui.prompt(app.nav, ":")
if len(s) == 0 { if len(s) == 0 {
@ -270,6 +257,19 @@ func (e *CallExpr) eval(app *App, args []string) {
app.ui.sync() app.ui.sync()
app.ui.renew() app.ui.renew()
app.nav.renew(app.ui.wins[0].h) app.nav.renew(app.ui.wins[0].h)
case "echo":
app.ui.message = strings.Join(e.args, " ")
case "cd":
path := "~"
if len(e.args) > 0 {
path = e.args[0]
}
if err := app.nav.cd(path); err != nil {
app.ui.message = err.Error()
log.Print(err)
return
}
app.ui.echoFileInfo(app.nav)
default: default:
cmd, ok := gOpts.cmds[e.name] cmd, ok := gOpts.cmds[e.name]
if !ok { if !ok {