1 parent
9f1428582f
commit
a85ce898a1
6 files changed
+60
-2
No files matched your search
@@ -471,6 +471,10 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type cleanFunc func()
|
||||||
|
|
||||||
|
var noopCleanFunc = func() {}
|
||||||
|
|
||||||
// This function is used to run a shell command. Modes are as follows:
|
// This function is used to run a shell command. Modes are as follows:
|
||||||
//
|
//
|
||||||
// Prefix Wait Async Stdin Stdout Stderr UI action
|
// Prefix Wait Async Stdin Stdout Stderr UI action
|
||||||
@@ -478,7 +482,8 @@ func (app *app) loop() {
|
|||||||
// % No No Yes Yes Yes Statline for input/output
|
// % No No Yes Yes Yes Statline for input/output
|
||||||
// ! Yes No Yes Yes Yes Pause and then resume
|
// ! Yes No Yes Yes Yes Pause and then resume
|
||||||
// & No Yes No No No Do nothing
|
// & No Yes No No No Do nothing
|
||||||
func (app *app) runShell(s string, args []string, prefix string) {
|
// $| No No Pipe Yes Yes Pause, Pipe execute, return cleanup to resume
|
||||||
|
func (app *app) runShell(s string, args []string, prefix string) cleanFunc {
|
||||||
app.nav.exportFiles()
|
app.nav.exportFiles()
|
||||||
app.ui.exportSizes()
|
app.ui.exportSizes()
|
||||||
exportOpts()
|
exportOpts()
|
||||||
@@ -488,6 +493,24 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
var out io.Reader
|
var out io.Reader
|
||||||
var err error
|
var err error
|
||||||
switch prefix {
|
switch prefix {
|
||||||
|
case "$|":
|
||||||
|
var stdin io.WriteCloser
|
||||||
|
stdin, err = cmd.StdinPipe()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("writing stdin: %s", err)
|
||||||
|
}
|
||||||
|
app.cmdIn = stdin
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
|
app.nav.previewChan <- ""
|
||||||
|
app.nav.dirPreviewChan <- nil
|
||||||
|
|
||||||
|
if err := app.ui.suspend(); err != nil {
|
||||||
|
log.Printf("suspend: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = cmd.Start()
|
||||||
case "$", "!":
|
case "$", "!":
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
@@ -512,7 +535,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
case "%":
|
case "%":
|
||||||
shellSetPG(cmd)
|
shellSetPG(cmd)
|
||||||
if app.ui.cmdPrefix == ">" {
|
if app.ui.cmdPrefix == ">" {
|
||||||
return
|
return noopCleanFunc
|
||||||
}
|
}
|
||||||
stdin, err := cmd.StdinPipe()
|
stdin, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -585,5 +608,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
log.Printf("running shell: %s", err)
|
log.Printf("running shell: %s", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
case "$|":
|
||||||
|
return func() {
|
||||||
|
if err := cmd.Wait(); err != nil {
|
||||||
|
log.Printf("running shell: %s", err)
|
||||||
|
}
|
||||||
|
app.nav.renew()
|
||||||
|
if err := app.ui.resume(); err != nil {
|
||||||
|
app.quit()
|
||||||
|
os.Exit(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return noopCleanFunc
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ var (
|
|||||||
gCmdWords = []string{
|
gCmdWords = []string{
|
||||||
"set",
|
"set",
|
||||||
"map",
|
"map",
|
||||||
|
"maps",
|
||||||
"cmap",
|
"cmap",
|
||||||
"cmd",
|
"cmd",
|
||||||
"quit",
|
"quit",
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ The following commands are provided by lf:
|
|||||||
mark-remove (modal) (default '"')
|
mark-remove (modal) (default '"')
|
||||||
tag
|
tag
|
||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
|
maps
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
@@ -600,6 +601,10 @@ Delete the next word in forward direction.
|
|||||||
|
|
||||||
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
||||||
|
|
||||||
|
maps
|
||||||
|
|
||||||
|
List all key mappings.
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
This section shows information about options to customize the behavior.
|
This section shows information about options to customize the behavior.
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ The following commands are provided by lf:
|
|||||||
mark-remove (modal) (default '"')
|
mark-remove (modal) (default '"')
|
||||||
tag
|
tag
|
||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
|
maps
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
@@ -627,6 +628,10 @@ Delete the next word in forward direction.
|
|||||||
|
|
||||||
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
||||||
|
|
||||||
|
maps
|
||||||
|
|
||||||
|
List all key mappings.
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
This section shows information about options to customize the behavior.
|
This section shows information about options to customize the behavior.
|
||||||
|
|||||||
@@ -2076,6 +2076,11 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
|
|
||||||
app.ui.cmdAccLeft = acc
|
app.ui.cmdAccLeft = acc
|
||||||
update(app)
|
update(app)
|
||||||
|
case "maps":
|
||||||
|
cleanUp := app.runShell("$PAGER", nil, "$|")
|
||||||
|
io.Copy(app.cmdIn, listBinds(gOpts.keys))
|
||||||
|
app.cmdIn.Close()
|
||||||
|
cleanUp()
|
||||||
default:
|
default:
|
||||||
cmd, ok := gOpts.cmds[e.name]
|
cmd, ok := gOpts.cmds[e.name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ The following commands are provided by lf:
|
|||||||
mark-remove (modal) (default '"')
|
mark-remove (modal) (default '"')
|
||||||
tag
|
tag
|
||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
|
maps
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
@@ -740,6 +741,12 @@ Delete the next word in forward direction.
|
|||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
maps
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
List all key mappings.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
|
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
Reference in new issue
Block a user