diff options
| -rw-r--r-- | actions.go | 13 | ||||
| -rw-r--r-- | files.go | 2 | ||||
| -rw-r--r-- | help.go | 12 | ||||
| -rw-r--r-- | main.go | 1 | ||||
| -rw-r--r-- | state.go | 1 |
5 files changed, 27 insertions, 2 deletions
@@ -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 } @@ -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 { @@ -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": ` @@ -17,6 +17,7 @@ func main() { state := NewBrowserState() state.Quiet = conf.Quiet + state.AutoPager = conf.AutoPager rl, err := readline.New(Prompt) if err != nil { @@ -18,6 +18,7 @@ type BrowserState struct { CurrentTour *Tour Quiet bool + AutoPager bool Readline *readline.Instance } |
