summaryrefslogtreecommitdiff
path: root/lib/highline/terminal/io_console.rb
blob: 699db9136b72d8124e294ce629c96c726bca59f0 (plain)
1
2
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
# coding: utf-8

class HighLine
  class Terminal
    # io/console option for HighLine::Terminal.
    # It's the most used terminal.
    class IOConsole < Terminal
      # (see Terminal#terminal_size)
      def terminal_size
        output.winsize.reverse
      end

      # (see Terminal#raw_no_echo_mode)
      def raw_no_echo_mode
        input.echo = false
      end

      # (see Terminal#restore_mode)
      def restore_mode
        input.echo = true
      end

      # (see Terminal#get_character)
      def get_character
        input.getch # from ruby io/console
      end
    end
  end
end