模块 Bundler::Thor::Shell::Terminal
常量
- DEFAULT_TERMINAL_WIDTH
公共类方法
terminal_width() 点击以切换源码
这段代码是从 Rake 复制而来,采用 MIT-LICENSE 授权,版权归 Jim Weirich 所有,© 2003, 2004。
# File bundler/vendor/thor/lib/thor/shell/terminal.rb, line 9 def terminal_width result = if ENV["THOR_COLUMNS"] ENV["THOR_COLUMNS"].to_i else unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH end result < 10 ? DEFAULT_TERMINAL_WIDTH : result rescue DEFAULT_TERMINAL_WIDTH end
unix?() 点击以切换源码
# File bundler/vendor/thor/lib/thor/shell/terminal.rb, line 20 def unix? RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i end
私有类方法
dynamic_width() 点击以切换源码
计算终端的动态宽度
# File bundler/vendor/thor/lib/thor/shell/terminal.rb, line 27 def dynamic_width @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) end
dynamic_width_stty() 点击以切换源码
# File bundler/vendor/thor/lib/thor/shell/terminal.rb, line 31 def dynamic_width_stty `stty size 2>/dev/null`.split[1].to_i end
dynamic_width_tput() 点击以切换源码
# File bundler/vendor/thor/lib/thor/shell/terminal.rb, line 35 def dynamic_width_tput `tput cols 2>/dev/null`.to_i end