Module: CLI::UI::Terminal
- Extended by:
- T::Sig
- Defined in:
- lib/cli/ui/terminal.rb
Constant Summary collapse
- DEFAULT_WIDTH =
80
- DEFAULT_HEIGHT =
24
Class Method Summary collapse
Methods included from T::Sig
Class Method Details
.height ⇒ Object
29 30 31 |
# File 'lib/cli/ui/terminal.rb', line 29 def height winsize[0] end |
.setup_winsize_trap ⇒ Object
50 51 52 53 54 |
# File 'lib/cli/ui/terminal.rb', line 50 def setup_winsize_trap @winsize_trap ||= Signal.trap('WINCH') do @winsize = nil end end |
.width ⇒ Object
21 22 23 |
# File 'lib/cli/ui/terminal.rb', line 21 def width winsize[1] end |
.winsize ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cli/ui/terminal.rb', line 34 def winsize @winsize ||= begin winsize = IO.console.winsize setup_winsize_trap if winsize.any?(&:zero?) [DEFAULT_HEIGHT, DEFAULT_WIDTH] else winsize end rescue [DEFAULT_HEIGHT, DEFAULT_WIDTH] end end |