add 'cmd-interrupt' command to kill current shell
This commit is contained in:
parent
c63c8f63ac
commit
e55c490bf5
4
app.go
4
app.go
@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@ -19,6 +20,7 @@ type app struct {
|
||||
ui *ui
|
||||
nav *nav
|
||||
quitChan chan bool
|
||||
cmd *exec.Cmd
|
||||
cmdIn io.WriteCloser
|
||||
cmdHist []cmdItem
|
||||
cmdHistInd int
|
||||
@ -230,6 +232,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
||||
switch prefix {
|
||||
case "%":
|
||||
go func() {
|
||||
app.cmd = cmd
|
||||
app.ui.msg = ""
|
||||
app.ui.cmdPrefix = ">"
|
||||
|
||||
@ -252,6 +255,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
||||
log.Printf("running shell: %s", err)
|
||||
}
|
||||
app.nav.renew(app.ui.wins[0].h)
|
||||
app.cmd = nil
|
||||
app.ui.cmdPrefix = ""
|
||||
app.ui.draw(app.nav)
|
||||
}()
|
||||
|
1
doc.go
1
doc.go
@ -69,6 +69,7 @@ keybindings:
|
||||
cmd-delete-word (default '<c-w>')
|
||||
cmd-put (default '<c-y>')
|
||||
cmd-transpose (default '<c-t>')
|
||||
cmd-interrupt (default '<c-c>')
|
||||
|
||||
The following options can be used to customize the behavior of lf:
|
||||
|
||||
|
@ -73,6 +73,7 @@ keybindings:
|
||||
cmd-delete-word (default '<c-w>')
|
||||
cmd-put (default '<c-y>')
|
||||
cmd-transpose (default '<c-t>')
|
||||
cmd-interrupt (default '<c-c>')
|
||||
|
||||
The following options can be used to customize the behavior of lf:
|
||||
|
||||
|
8
eval.go
8
eval.go
@ -559,6 +559,14 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
if len(app.ui.cmdAccLeft) > 1 {
|
||||
app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2] = app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1]
|
||||
}
|
||||
case "cmd-interrupt":
|
||||
if app.cmd != nil {
|
||||
app.cmd.Process.Kill()
|
||||
}
|
||||
app.ui.menuBuf = nil
|
||||
app.ui.cmdAccLeft = nil
|
||||
app.ui.cmdAccRight = nil
|
||||
app.ui.cmdPrefix = ""
|
||||
default:
|
||||
cmd, ok := gOpts.cmds[e.name]
|
||||
if !ok {
|
||||
|
1
opts.go
1
opts.go
@ -124,6 +124,7 @@ func init() {
|
||||
gOpts.cmdkeys["<c-w>"] = &callExpr{"cmd-delete-word", nil}
|
||||
gOpts.cmdkeys["<c-y>"] = &callExpr{"cmd-put", nil}
|
||||
gOpts.cmdkeys["<c-t>"] = &callExpr{"cmd-transpose", nil}
|
||||
gOpts.cmdkeys["<c-c>"] = &callExpr{"cmd-interrupt", nil}
|
||||
|
||||
gOpts.cmds = make(map[string]expr)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user