Module: Kramdown::ANSI::Pager
- Defined in:
- lib/kramdown/ansi/pager.rb
Class Method Summary collapse
-
.pager(command: nil, lines: nil) {|IO| ... } ⇒ NilClass
If called without a block returns either the provided command for paging if the given number of lines are exceeding the available number of terminal lines or nil.
Class Method Details
.pager(command: nil, lines: nil) {|IO| ... } ⇒ NilClass
If called without a block returns either the provided command for paging if the given number of lines are exceeding the available number of terminal lines or nil. If a block was provided it yields to an IO handle for the pager command in the latter case or STDOUT in the former.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kramdown/ansi/pager.rb', line 15 def pager(command: nil, lines: nil, &block) if block if my_pager = pager(command:, lines:) IO.popen(my_pager, 'w') do |output| output.sync = true yield output output.close end else yield STDOUT end else return unless STDOUT.tty? if lines if lines >= Tins::Terminal.lines pager(command:) end else command end end end |