Module: Tins::Terminal

Defined in:
lib/tins/terminal.rb

Class Method Summary collapse

Class Method Details

.colsObject



38
39
40
# File 'lib/tins/terminal.rb', line 38

def cols
  columns
end

.columnsObject



33
34
35
36
# File 'lib/tins/terminal.rb', line 33

def columns
  winsize[1] || `stty size 2>/dev/null`.split[1].to_i.nonzero? ||
    `tput cols 2>/dev/null`.to_i.nonzero? || 80
end

.linesObject



29
30
31
# File 'lib/tins/terminal.rb', line 29

def lines
  rows
end

.rowsObject



24
25
26
27
# File 'lib/tins/terminal.rb', line 24

def rows
  winsize[0] || `stty size 2>/dev/null`.split[0].to_i.nonzero? ||
    `tput lines 2>/dev/null`.to_i.nonzero? || 25
end

.winsizeObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tins/terminal.rb', line 11

def winsize
  if IO.respond_to?(:console)
    c = IO.console
    if c.respond_to?(:winsize)
      c.winsize
    else
      []
    end
  else
    []
  end
end