auto_pager config option
This commit is contained in:
parent
1eec3cbbc2
commit
2eee2b0560
13
actions.go
13
actions.go
|
@ -320,6 +320,19 @@ func print(state *BrowserState) error {
|
|||
if state.Modal != nil {
|
||||
out = state.Modal
|
||||
}
|
||||
|
||||
if state.AutoPager {
|
||||
less, err := exec.LookPath("less")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.Command(less, "-F")
|
||||
cmd.Stdin = bytes.NewBuffer(out)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
_, err := os.Stdout.Write(out)
|
||||
return err
|
||||
}
|
||||
|
|
2
files.go
2
files.go
|
@ -19,6 +19,7 @@ type ConfigMain struct {
|
|||
DownloadFolder string `toml:"download_folder"`
|
||||
VimKeys bool `toml:"vim_keys"`
|
||||
Quiet bool `toml:"quiet"`
|
||||
AutoPager bool `toml:"auto_pager"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
@ -44,6 +45,7 @@ func getConfig() (*Config, error) {
|
|||
SoftWrap: 80,
|
||||
DownloadFolder: home,
|
||||
Quiet: false,
|
||||
AutoPager: true,
|
||||
},
|
||||
}
|
||||
if _, err := toml.DecodeFile(path, &c); err != nil {
|
||||
|
|
12
help.go
12
help.go
|
@ -27,7 +27,7 @@ var helpTopics = map[string]string{
|
|||
help topics
|
||||
-----------
|
||||
commands: Basics of x-1 commands, and a full listing of them. Each
|
||||
command is also its own help topic.
|
||||
command also has its own help topic.
|
||||
urls: The forms of URLs which can be entered into x-1 commands.
|
||||
mark: Information on the "mark" meta-command.
|
||||
tour: Information about the "tour" meta-command.
|
||||
|
@ -96,9 +96,12 @@ The section "[main]" contains general configuration options:
|
|||
link indices.
|
||||
* download_folder (string): The folder in which to store files saved
|
||||
by the "save" command. This string may also start with "~", which
|
||||
stands in for $HOME. The default is "~" (or $HOME).
|
||||
stands in for $HOME. The default is "~" (the user's home directory).
|
||||
* quiet (boolean): Disables automatically printing the page after any
|
||||
navigation action. The default is false.
|
||||
* auto_pager (boolean): Sends pages through "less -F", where the -F
|
||||
switch disables the pager if the output fits in a single screen.
|
||||
This is true by default.
|
||||
|
||||
`[1:],
|
||||
|
||||
|
@ -213,6 +216,11 @@ Displays the current page.
|
|||
|
||||
This will happen anyway by default with any navigation action, but the
|
||||
"quiet" configuration option can disable that.
|
||||
|
||||
By default, the print action (whether automatic or upon the print
|
||||
command) will pipe the output through "less -F", where the -F switch
|
||||
disables the pager if the output fits in one screen. This can be
|
||||
disabled with the "auto_pager" configuration option.
|
||||
`[1:],
|
||||
|
||||
"pipe": `
|
||||
|
|
1
main.go
1
main.go
|
@ -17,6 +17,7 @@ func main() {
|
|||
|
||||
state := NewBrowserState()
|
||||
state.Quiet = conf.Quiet
|
||||
state.AutoPager = conf.AutoPager
|
||||
|
||||
rl, err := readline.New(Prompt)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue