Top Level Namespace
- Includes:
- Diff
Defined Under Namespace
Modules: Diff
Instance Method Summary collapse
Methods included from Diff
#file_diff, #file_extension, #files_infos, #files_names, #files_with_no_extension, #git_status, #main, #parse_diff, #parse_with_diff, #parse_with_lang, #process, #split_codes, #split_diff, #split_heads
Instance Method Details
#paginate ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pagination.rb', line 3 def paginate # doesn't run under Windows require 'rbconfig' return if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ return unless STDOUT.tty? read, write = IO.pipe unless Kernel.fork # child process STDOUT.reopen(write) STDERR.reopen(write) if STDERR.tty? read.close write.close return end # parent process becomes pager STDIN.reopen(read) read.close write.close ENV['LESS'] = 'FSRX' # Don't page if the input is short enough Kernel.select [STDIN] # Wait until we have input before we start the pager pager = ENV['PAGER'] || 'less' exec pager rescue exec '/bin/sh', '-c', pager end |