Class: SelectaTTY
Instance Attribute Summary collapse
-
#console_file ⇒ Object
Returns the value of attribute console_file.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#console_file ⇒ Object
Returns the value of attribute console_file
761 762 763 |
# File 'lib/selecta.rb', line 761 def console_file @console_file end |
Class Method Details
.with_tty(&block) ⇒ Object
762 763 764 765 766 767 768 769 |
# File 'lib/selecta.rb', line 762 def self.with_tty(&block) # Selecta reads data from stdin and writes it to stdout, so we can't draw # UI and receive keystrokes through them. Fortunately, all modern # Unix-likes provide /dev/tty, which IO.console gives us. console_file = IO.console tty = SelectaTTY.new(console_file) block.call(tty) end |
Instance Method Details
#get_available_input ⇒ Object
771 772 773 774 775 776 777 |
# File 'lib/selecta.rb', line 771 def get_available_input input = console_file.getc while console_file.ready? input += console_file.getc end input end |
#puts ⇒ Object
779 780 781 |
# File 'lib/selecta.rb', line 779 def puts console_file.puts end |
#stty(args) ⇒ Object
787 788 789 |
# File 'lib/selecta.rb', line 787 def stty(args) command("stty #{args}").strip end |
#winsize ⇒ Object
783 784 785 |
# File 'lib/selecta.rb', line 783 def winsize console_file.winsize end |