clear error message on succesful commands

Related #185 and #187
This commit is contained in:
Gokcehan 2019-06-26 17:52:29 +03:00
parent 16db95707e
commit afca893153

40
eval.go
View File

@ -285,31 +285,36 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.shellopts = strings.Split(e.val, ":") gOpts.shellopts = strings.Split(e.val, ":")
default: default:
app.ui.echoerrf("unknown option: %s", e.opt) app.ui.echoerrf("unknown option: %s", e.opt)
return
} }
app.ui.loadFileInfo(app.nav)
} }
func (e *mapExpr) eval(app *app, args []string) { func (e *mapExpr) eval(app *app, args []string) {
if e.expr == nil { if e.expr == nil {
delete(gOpts.keys, e.keys) delete(gOpts.keys, e.keys)
return } else {
}
gOpts.keys[e.keys] = e.expr gOpts.keys[e.keys] = e.expr
}
app.ui.loadFileInfo(app.nav)
} }
func (e *cmapExpr) eval(app *app, args []string) { func (e *cmapExpr) eval(app *app, args []string) {
if e.cmd == "" { if e.cmd == "" {
delete(gOpts.cmdkeys, e.key) delete(gOpts.cmdkeys, e.key)
return } else {
}
gOpts.cmdkeys[e.key] = &callExpr{e.cmd, nil, 1} gOpts.cmdkeys[e.key] = &callExpr{e.cmd, nil, 1}
}
app.ui.loadFileInfo(app.nav)
} }
func (e *cmdExpr) eval(app *app, args []string) { func (e *cmdExpr) eval(app *app, args []string) {
if e.expr == nil { if e.expr == nil {
delete(gOpts.cmds, e.name) delete(gOpts.cmds, e.name)
return } else {
}
gOpts.cmds[e.name] = e.expr gOpts.cmds[e.name] = e.expr
}
app.ui.loadFileInfo(app.nav)
} }
func splitKeys(s string) (keys []string) { func splitKeys(s string) (keys []string) {
@ -641,8 +646,10 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav) app.ui.loadFileInfo(app.nav)
case "invert": case "invert":
app.nav.invert() app.nav.invert()
app.ui.loadFileInfo(app.nav)
case "unselect": case "unselect":
app.nav.unselect() app.nav.unselect()
app.ui.loadFileInfo(app.nav)
case "copy": case "copy":
if err := app.nav.save(true); err != nil { if err := app.nav.save(true); err != nil {
app.ui.echoerrf("copy: %s", err) app.ui.echoerrf("copy: %s", err)
@ -651,7 +658,9 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.unselect() app.nav.unselect()
if err := remote("send sync"); err != nil { if err := remote("send sync"); err != nil {
app.ui.echoerrf("copy: %s", err) app.ui.echoerrf("copy: %s", err)
return
} }
app.ui.loadFileInfo(app.nav)
case "cut": case "cut":
if err := app.nav.save(false); err != nil { if err := app.nav.save(false); err != nil {
app.ui.echoerrf("cut: %s", err) app.ui.echoerrf("cut: %s", err)
@ -660,7 +669,9 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.unselect() app.nav.unselect()
if err := remote("send sync"); err != nil { if err := remote("send sync"); err != nil {
app.ui.echoerrf("cut: %s", err) app.ui.echoerrf("cut: %s", err)
return
} }
app.ui.loadFileInfo(app.nav)
case "paste": case "paste":
if cmd, ok := gOpts.cmds["paste"]; ok { if cmd, ok := gOpts.cmds["paste"]; ok {
cmd.eval(app, e.args) cmd.eval(app, e.args)
@ -668,12 +679,15 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("paste: %s", err) app.ui.echoerrf("paste: %s", err)
return return
} }
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
case "delete": case "delete":
if cmd, ok := gOpts.cmds["delete"]; ok { if cmd, ok := gOpts.cmds["delete"]; ok {
cmd.eval(app, e.args) cmd.eval(app, e.args)
app.nav.unselect() app.nav.unselect()
if err := remote("send load"); err != nil { if err := remote("send load"); err != nil {
app.ui.echoerrf("delete: %s", err) app.ui.echoerrf("delete: %s", err)
return
} }
} else { } else {
if _, err := app.nav.currFileOrSelections(); err != nil { if _, err := app.nav.currFileOrSelections(); err != nil {
@ -682,6 +696,8 @@ func (e *callExpr) eval(app *app, args []string) {
} }
app.ui.cmdPrefix = "delete?[y/N]: " app.ui.cmdPrefix = "delete?[y/N]: "
} }
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
case "clear": case "clear":
if err := saveFiles(nil, false); err != nil { if err := saveFiles(nil, false); err != nil {
app.ui.echoerrf("clear: %s", err) app.ui.echoerrf("clear: %s", err)
@ -689,18 +705,24 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if err := remote("send sync"); err != nil { if err := remote("send sync"); err != nil {
app.ui.echoerrf("clear: %s", err) app.ui.echoerrf("clear: %s", err)
return
} }
app.ui.loadFileInfo(app.nav)
case "draw": case "draw":
case "redraw": case "redraw":
app.ui.sync() app.ui.sync()
app.ui.renew() app.ui.renew()
app.nav.height = app.ui.wins[0].h app.nav.height = app.ui.wins[0].h
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
case "load": case "load":
app.nav.renew() app.nav.renew()
case "reload": case "reload":
if err := app.nav.reload(); err != nil { if err := app.nav.reload(); err != nil {
app.ui.echoerrf("reload: %s", err) app.ui.echoerrf("reload: %s", err)
} }
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
case "read": case "read":
app.ui.cmdPrefix = ":" app.ui.cmdPrefix = ":"
case "shell": case "shell":
@ -861,28 +883,28 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerr("glob-select: requires a pattern to match") app.ui.echoerr("glob-select: requires a pattern to match")
return return
} }
if err := app.nav.globSel(e.args[0], false); err != nil { if err := app.nav.globSel(e.args[0], false); err != nil {
app.ui.echoerrf("%s", err) app.ui.echoerrf("%s", err)
return return
} }
app.ui.loadFileInfo(app.nav)
case "glob-unselect": case "glob-unselect":
if len(e.args) != 1 { if len(e.args) != 1 {
app.ui.echoerr("glob-unselect: requires a pattern to match") app.ui.echoerr("glob-unselect: requires a pattern to match")
return return
} }
if err := app.nav.globSel(e.args[0], true); err != nil { if err := app.nav.globSel(e.args[0], true); err != nil {
app.ui.echoerrf("%s", err) app.ui.echoerrf("%s", err)
return return
} }
app.ui.loadFileInfo(app.nav)
case "source": case "source":
if len(e.args) != 1 { if len(e.args) != 1 {
app.ui.echoerr("source: requires an argument") app.ui.echoerr("source: requires an argument")
return return
} }
app.readFile(strings.Replace(e.args[0], "~", gUser.HomeDir, -1)) app.readFile(strings.Replace(e.args[0], "~", gUser.HomeDir, -1))
app.ui.loadFileInfo(app.nav)
case "push": case "push":
if len(e.args) != 1 { if len(e.args) != 1 {
app.ui.echoerr("push: requires an argument") app.ui.echoerr("push: requires an argument")