The implementation of this class is borrowed from RDoc’s lib/rdoc/ri/driver.rb. Please do NOT use this class directly outside of IRB
.
Methods
- P
Constants
PAGE_COMMANDS | = | [ENV['RI_PAGER'], ENV['PAGER'], 'less', 'more'].compact.uniq |
Class Public methods
page(retain_content: false) Link
# File ruby/lib/irb/pager.rb, line 20 def page(retain_content: false) if should_page? && pager = setup_pager(retain_content: retain_content) begin pid = pager.pid yield pager ensure pager.close end else yield $stdout end # When user presses Ctrl-C, IRB would raise `IRB::Abort` # But since Pager is implemented by running paging commands like `less` in another process with `IO.popen`, # the `IRB::Abort` exception only interrupts IRB's execution but doesn't affect the pager # So to properly terminate the pager with Ctrl-C, we need to catch `IRB::Abort` and kill the pager process rescue IRB::Abort Process.kill("TERM", pid) if pid nil rescue Errno::EPIPE end