rkitover/vimpager — pull request #36 by clvv (2012-07-09 08:52:34+00:00)
Title: Pass through if content is short compared to terminal size.

* BSD-licensed calculation algorithm from [p][1] by Akinori MUSHA.
* Function `col_b' renamed to `fitler'.
* Moved terminal size detection code so that function `filter' can use it.
* ANSI-escape-code-removing sed command moved to `filter'.
* Global variable `$no_pass_thru' introduced.
* Set `$no_pass_thru` if we can't detect terminal size.

Note:
Outputting to STDERR in `filter' is not an elegant solution, but
`filter' has to be able to run in a sub-shell for `.gz' and `.Z' files,
which means `filter' cannot alter the outside shell environment.

[1]: https://github.com/knu/p

Please consider this a work-in-progress or a potential feature. Right now it requires arithmetic substitution, which I don't think works on Solaris. The un-portable part should be able to be rewritten in awk.