Class: Dispel::Keyboard
- Inherits:
-
Object
- Object
- Dispel::Keyboard
- Defined in:
- lib/dispel/keyboard.rb
Constant Summary collapse
- MAX_CHAR =
255- ENTER =
13- ESCAPE =
27- IS_18 =
RUBY_VERSION =~ /^1\.8/
- SEQUENCE_TIMEOUT =
0.005- NOTHING =
getch returns this as ‘nothing’ on 1.8 but nil on 1.9.2
(2**32 - 1)
- A_TO_Z =
('a'..'z').to_a
Class Method Summary collapse
Class Method Details
.input(&block) ⇒ Object
13 14 15 |
# File 'lib/dispel/keyboard.rb', line 13 def self.input(&block) @input = block end |
.output ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dispel/keyboard.rb', line 17 def self.output input { Curses.getch } unless @input # keep input replaceable for tests, but default to curses @sequence = [] @started = Time.now.to_f loop do key = fetch_user_input if sequence_finished? sequence_to_keys(@sequence).each{|k| yield k } @sequence = [] end next unless key append_to_sequence key end end |