System.Pager

pager-0.1.1.0: Open up a pager, like 'less' or 'more'

Copyright | Copyright (c) 2015 Peter Harpending.
License | BSD2
Maintainer | Peter Harpending <peter@harpending.org>
Stability | experimental
Portability | Tested with GHC on Linux and FreeBSD
Safe Haskell | None
Language | Haskell2010

System.Pager

Description

Synopsis

- printOrPage :: Text -> IO ()
- sendToPager :: ByteString -> IO ()
- sendToPagerStrict :: ByteString -> IO ()
- findPager :: IO ByteString
- sendToPagerConduit :: Producer (ResourceT IO) ByteString -> IO ()

# Documentation

printOrPage :: Text -> IO () #

If the user's terminal is long enough to display the (strict) `Text`, just print it. Else, send it to the pager.

The text needs to be strict, because the function counts the number of lines in the text. (This is also why it needs to be text, and not a bytestring, because Text has stuff like line-counting).

sendToPager :: ByteString -> IO () #

Send a lazy `ByteString` to the user's `$PAGER`.

sendToPagerStrict :: ByteString -> IO () #

Send a strict `ByteString` to the user's `$PAGER`.

findPager :: IO ByteString #

This finds the user's `$PAGER`. This will fail if:

- There is no `$PATH` variable
- The user doesn't have a `less` or `more` installed, and hasn't specified an alternate program via `$PAGER`.

sendToPagerConduit :: Producer (ResourceT IO) ByteString -> IO () #

This is what `sendToPager` uses on the back end. It takes a `Producer`, from Data.Conduit, and then sends the produced bytes to the pager's stdin.