diff options
| -rw-r--r-- | actions.go | 15 | ||||
| -rw-r--r-- | files.go | 4 | ||||
| -rw-r--r-- | help.go | 7 | ||||
| -rw-r--r-- | main.go | 2 | ||||
| -rw-r--r-- | state.go | 2 |
5 files changed, 19 insertions, 11 deletions
@@ -440,20 +440,27 @@ func print(state *BrowserState) error { out = state.Modal } - if state.AutoPager { + lessarg := []string{} + switch state.Pager { + case "auto": + lessarg = []string{"-F"} + fallthrough + case "always": less, err := exec.LookPath("less") if err != nil { return err } - cmd := exec.Command(less, "-F") + cmd := exec.Command(less, lessarg...) cmd.Stdin = bytes.NewBuffer(out) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr return cmd.Run() + case "never": + _, err := os.Stdout.Write(out) + return err } - _, err := os.Stdout.Write(out) - return err + return errors.New("invalid 'pager' value in configuration") } func Print(state *BrowserState) error { @@ -19,7 +19,7 @@ type ConfigMain struct { DownloadFolder string `toml:"download_folder"` VimKeys bool `toml:"vim_keys"` Quiet bool `toml:"quiet"` - AutoPager bool `toml:"auto_pager"` + Pager string `toml:"pager"` } type Config struct { @@ -45,7 +45,7 @@ func getConfig() (*Config, error) { SoftWrap: 80, DownloadFolder: home, Quiet: false, - AutoPager: true, + Pager: "auto", }, } if _, err := toml.DecodeFile(path, &c); err != nil { @@ -99,9 +99,10 @@ The section "[main]" contains general configuration options: 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. + * pager (string): Set this to "always", "never", or "auto". "always" + will pipe every page printed through less(1), "never" will not, and + "auto" will pipe it through "less -F", which skips the pager when + the output fits on a single screen anyway. `[1:], @@ -17,7 +17,7 @@ func main() { state := NewBrowserState() state.Quiet = conf.Quiet - state.AutoPager = conf.AutoPager + state.Pager = conf.Pager rl, err := readline.New(Prompt) if err != nil { @@ -18,7 +18,7 @@ type BrowserState struct { CurrentTour *Tour Quiet bool - AutoPager bool + Pager string Readline *readline.Instance } |
