Sha256: 5be20d7ecc24e1dc27af6b4cb389d7b6fb9d12631dc3954a70905274a5e1cfef

Contents?: true

Size: 1.59 KB

Versions: 32

Compression:

Stored size: 1.59 KB

Contents

=begin
Copyright 2010, Roger Pack 
This file is part of Sensible Cinema.

    Sensible Cinema is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Sensible Cinema is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Sensible Cinema.  If not, see <http://www.gnu.org/licenses/>.
=end
require 'rubygems'
require 'sane'
require 'Win32API'

# does the jruby check inline

class KeyboardInput

 def initialize fella
  @fella = fella
 end

 def start_thread
  Thread.new { loop { 
    print get_line_printout
    sleep 0.1
   } }
 end

 def get_line_printout
    status  = @fella.status
    # scary hard coded values here...
    " " * 20 + "\b"*150 + status
 end

 def getch
  @getch ||= Win32API.new('crtdll', '_getch', [], 'L')
  @getch.call
 end

 def handle_keystrokes_forever
   raise 'only jruby supported, as it looks just too messy in normal ruby' unless OS.java?
   while(ch = getch)
     exit if ch == 3 # ctrl+c
     # lodo handle arrow keys, too, which is a bit more complicated...
     handle_keystroke ch
   end
 end

 def handle_keystroke ch
   string = "" << ch
   @fella.keyboard_input(string)
 end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
sensible-cinema-0.24.1 lib/keyboard_input.rb
sensible-cinema-0.24.0 lib/keyboard_input.rb
sensible-cinema-0.23.6 lib/keyboard_input.rb
sensible-cinema-0.23.5 lib/keyboard_input.rb
sensible-cinema-0.23.4 lib/keyboard_input.rb
sensible-cinema-0.23.3 lib/keyboard_input.rb
sensible-cinema-0.23.2 lib/keyboard_input.rb
sensible-cinema-0.23.1 lib/keyboard_input.rb
sensible-cinema-0.23.0 lib/keyboard_input.rb
sensible-cinema-0.22.1 lib/keyboard_input.rb
sensible-cinema-0.22.0 lib/keyboard_input.rb
sensible-cinema-0.21.10 lib/keyboard_input.rb
sensible-cinema-0.21.9 lib/keyboard_input.rb
sensible-cinema-0.21.5 lib/keyboard_input.rb
sensible-cinema-0.21.4 lib/keyboard_input.rb
sensible-cinema-0.21.3 lib/keyboard_input.rb
sensible-cinema-0.20.5 lib/keyboard_input.rb
sensible-cinema-0.20.1 lib/keyboard_input.rb
sensible-cinema-0.20.0 lib/keyboard_input.rb
sensible-cinema-0.19.7 lib/keyboard_input.rb