Simplify run pager function (#1279)
* Simplify run pager function * RunPagerOn
This commit is contained in:
1 parent
7c33da2bc2
commit
51d0fec017
2 files changed
+5
-15
No files matched your search
@@ -602,26 +602,16 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
||||
|
||||
}
|
||||
|
||||
func (app *app) runPagerOnText(text io.Reader) {
|
||||
func (app *app) runPagerOn(stdin io.Reader) {
|
||||
app.nav.exportFiles()
|
||||
app.ui.exportSizes()
|
||||
exportOpts()
|
||||
|
||||
cmd := shellCommand(envPager, nil)
|
||||
|
||||
cmd.Stdin = stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("obtaining stdin pipe: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
io.Copy(stdin, text)
|
||||
stdin.Close()
|
||||
}()
|
||||
|
||||
app.runCmdSync(cmd, false)
|
||||
}
|
||||
@@ -2525,11 +2525,11 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
case "cmds":
|
||||
app.runPagerOnText(listCmds())
|
||||
case "maps":
|
||||
app.runPagerOnText(listBinds(gOpts.keys))
|
||||
app.runPagerOn(listBinds(gOpts.keys))
|
||||
case "cmaps":
|
||||
app.runPagerOnText(listBinds(gOpts.cmdkeys))
|
||||
app.runPagerOn(listBinds(gOpts.cmdkeys))
|
||||
case "jumps":
|
||||
app.runPagerOnText(listJumps(app.nav.jumpList, app.nav.jumpListInd))
|
||||
app.runPagerOn(listJumps(app.nav.jumpList, app.nav.jumpListInd))
|
||||
default:
|
||||
cmd, ok := gOpts.cmds[e.name]
|
||||
if !ok {
|
||||
|
||||
Reference in new issue
Block a user