make read commands work when typed manually
This commit is contained in:
parent
0fc14e3b2d
commit
951529ebc0
22
eval.go
22
eval.go
@ -853,6 +853,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
switch app.ui.cmdPrefix {
|
switch app.ui.cmdPrefix {
|
||||||
case ":":
|
case ":":
|
||||||
log.Printf("command: %s", s)
|
log.Printf("command: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
||||||
p := newParser(strings.NewReader(s))
|
p := newParser(strings.NewReader(s))
|
||||||
for p.parse() {
|
for p.parse() {
|
||||||
p.expr.eval(app, nil)
|
p.expr.eval(app, nil)
|
||||||
@ -860,30 +862,28 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if p.err != nil {
|
if p.err != nil {
|
||||||
app.ui.printf("%s", p.err)
|
app.ui.printf("%s", p.err)
|
||||||
}
|
}
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
|
||||||
case "$":
|
case "$":
|
||||||
log.Printf("shell: %s", s)
|
log.Printf("shell: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
||||||
|
app.runShell(s, nil, "$")
|
||||||
case "%":
|
case "%":
|
||||||
log.Printf("shell-pipe: %s", s)
|
log.Printf("shell-pipe: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
||||||
|
app.runShell(s, nil, "%")
|
||||||
case ">":
|
case ">":
|
||||||
io.WriteString(app.cmdIn, s+"\n")
|
io.WriteString(app.cmdIn, s+"\n")
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
case "!":
|
case "!":
|
||||||
log.Printf("shell-wait: %s", s)
|
log.Printf("shell-wait: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
||||||
|
app.runShell(s, nil, "!")
|
||||||
case "&":
|
case "&":
|
||||||
log.Printf("shell-async: %s", s)
|
log.Printf("shell-async: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
||||||
|
app.runShell(s, nil, "&")
|
||||||
case "/":
|
case "/":
|
||||||
if gOpts.incsearch {
|
if gOpts.incsearch {
|
||||||
last := app.nav.currDir()
|
last := app.nav.currDir()
|
||||||
@ -891,6 +891,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
last.pos = app.nav.searchPos
|
last.pos = app.nav.searchPos
|
||||||
}
|
}
|
||||||
log.Printf("search: %s", s)
|
log.Printf("search: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.printf("search: %s: %s", err, app.nav.search)
|
app.ui.printf("search: %s: %s", err, app.nav.search)
|
||||||
@ -898,7 +899,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
app.ui.cmdPrefix = ""
|
|
||||||
case "?":
|
case "?":
|
||||||
if gOpts.incsearch {
|
if gOpts.incsearch {
|
||||||
last := app.nav.currDir()
|
last := app.nav.currDir()
|
||||||
@ -906,6 +906,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
last.pos = app.nav.searchPos
|
last.pos = app.nav.searchPos
|
||||||
}
|
}
|
||||||
log.Printf("search-back: %s", s)
|
log.Printf("search-back: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.printf("search-back: %s: %s", err, app.nav.search)
|
app.ui.printf("search-back: %s: %s", err, app.nav.search)
|
||||||
@ -913,7 +914,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
app.ui.cmdPrefix = ""
|
|
||||||
default:
|
default:
|
||||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user