Class: HighLine::Terminal::IOConsole

Inherits:
HighLine::Terminal show all
Defined in:
lib/highline/terminal/io_console.rb

Overview

io/console option for HighLine::Terminal. It’s the most used terminal. TODO: We’re rescuing when not a terminal.

We should make a more robust implementation.

Instance Attribute Summary

Attributes inherited from HighLine::Terminal

#input, #output

Instance Method Summary collapse

Methods inherited from HighLine::Terminal

#character_mode, #get_line, #get_line_default, #get_line_with_readline, get_terminal, #initialize, #initialize_system_extensions, #jruby?, #raw_no_echo_mode_exec, #readline_read, #rubinius?, #windows?

Constructor Details

This class inherits a constructor from HighLine::Terminal

Instance Method Details

#get_characterString

Get one character from the terminal

Returns:



29
30
31
32
33
# File 'lib/highline/terminal/io_console.rb', line 29

def get_character
  input.getch(intr: true) # from ruby io/console
rescue Errno::ENOTTY
  input.getc
end

#raw_no_echo_modeObject

Enter Raw No Echo mode.



17
18
19
20
# File 'lib/highline/terminal/io_console.rb', line 17

def raw_no_echo_mode
  input.echo = false
rescue Errno::ENOTTY
end

#restore_modeObject

Restore terminal to its default mode



23
24
25
26
# File 'lib/highline/terminal/io_console.rb', line 23

def restore_mode
  input.echo = true
rescue Errno::ENOTTY
end

#terminal_sizeArray<Integer, Integer>

Returns two value terminal size like [columns, lines].

Returns:

  • (Array<Integer, Integer>)

    two value terminal size like [columns, lines]



11
12
13
14
# File 'lib/highline/terminal/io_console.rb', line 11

def terminal_size
  output.winsize.reverse
rescue Errno::ENOTTY
end