Module: GLW::Input
- Defined in:
- lib/glw/input.rb
Constant Summary collapse
- ESCAPE_TIMEOUT =
20ms
0.02- BYTES =
{ "\t" => :k_tab, "\r" => :k_enter, "\n" => :k_enter, "\x7F" => :k_backspace, "\b" => :k_backspace, " " => :k_space, "\x03" => :k_ctrl_c, "[" => :k_left_bracket, "]" => :k_right_bracket, ";" => :k_semicolon, "'" => :k_single_quote, "," => :k_comma, "." => :k_period }.tap do |h| ("a".."z").each { |c| h[c] = :"k_#{c}" } ("A".."Z").each { |c| h[c] = :"k_#{c}" } ("0".."9").each { |c| h[c] = :"k_#{c}" } end
Class Method Summary collapse
Class Method Details
.pop ⇒ Object
28 29 30 |
# File 'lib/glw/input.rb', line 28 def pop @queue.pop end |
.start! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/glw/input.rb', line 32 def start! return if @queue @queue = Thread::Queue.new Thread.new do loop do byte = read_byte if byte == "\e" handle_escape byte else handle_byte byte end rescue EOFError break end end end |