rb_termbox 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ vendor/**
2
+ .bundle/**
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rb_termbox (0.1.0)
5
+ ffi
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.2)
11
+ ffi (1.0.7)
12
+ rake (>= 0.8.7)
13
+ rake (0.8.7)
14
+ rspec (2.5.0)
15
+ rspec-core (~> 2.5.0)
16
+ rspec-expectations (~> 2.5.0)
17
+ rspec-mocks (~> 2.5.0)
18
+ rspec-core (2.5.1)
19
+ rspec-expectations (2.5.0)
20
+ diff-lcs (~> 1.1.2)
21
+ rspec-mocks (2.5.0)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ rb_termbox!
28
+ rspec
data/README ADDED
@@ -0,0 +1,10 @@
1
+ Ruby termbox binding
2
+ ===
3
+
4
+ - Get termbox source and compile. Newer versions may build the shared lib for you, else tweak the gcc command as necessary.
5
+ - See https://github.com/nsf/termbox/issues#issue/6 if on OSX (requires a tweak to termbox.c as of 2011-04-4)
6
+ - Install bundler && bundle install
7
+ - Edit sample/keyboard.rb and point Termbox.termbox_library_path to your shared lib.
8
+ - Run ruby sample/keyboard.rb to get a feel for what you can do. It's a partial port of termbox's own sample keyboard application. (Ctrl + Q to quit)
9
+
10
+
@@ -0,0 +1,12 @@
1
+ module Termbox
2
+ Colors = {
3
+ :black => 0x00,
4
+ :red => 0x01,
5
+ :green => 0x02,
6
+ :yellow => 0x03,
7
+ :blue => 0x04,
8
+ :magenta => 0x05,
9
+ :cyan => 0x06,
10
+ :white => 0x07
11
+ }
12
+ end
@@ -0,0 +1,119 @@
1
+ module Termbox
2
+ Keys = {
3
+ "F1" => 0xFFFF - 0,
4
+ "F2" => 0xFFFF - 1,
5
+ "F3" => 0xFFFF - 2,
6
+ "F4" => 0xFFFF - 3,
7
+ "F5" => 0xFFFF - 4,
8
+ "F6" => 0xFFFF - 5,
9
+ "F7" => 0xFFFF - 6,
10
+ "F8" => 0xFFFF - 7,
11
+ "F9" => 0xFFFF - 8,
12
+ "F10" => 0xFFFF - 9,
13
+ "F11" => 0xFFFF - 10,
14
+ "F12" => 0xFFFF - 11,
15
+
16
+ "INS" => 0xFFFF - 12,
17
+ "INSERT" => 0xFFFF - 12,
18
+ "DELETE" => 0xFFFF - 13,
19
+ "HOME" => 0xFFFF - 14,
20
+ "END" => 0xFFFF - 15,
21
+ "PGUP" => 0xFFFF - 16,
22
+ "PGDN" => 0xFFFF - 17,
23
+
24
+ "ARROW_UP" => 0xFFFF - 18,
25
+ "ARROW_DOWN" => 0xFFFF - 19,
26
+ "ARROW_LEFT" => 0xFFFF - 20,
27
+ "ARROW_RIGHT" => 0xFFFF - 21,
28
+
29
+ "UP" => 0xFFFF - 18,
30
+ "DOWN" => 0xFFFF - 19,
31
+ "LEFT" => 0xFFFF - 20,
32
+ "RIGHT" => 0xFFFF - 21,
33
+
34
+ "CTRL" => {
35
+ "~" => 0x00, # this or below can't be right can it?
36
+ "A" => 0x01,
37
+ "B" => 0x02,
38
+ "C" => 0x03,
39
+ "D" => 0x04,
40
+ "E" => 0x05,
41
+ "F" => 0x06,
42
+ "G" => 0x07,
43
+ "H" => 0x08, # same as backspace??
44
+ "I" => 0x09, # same as tab??
45
+ "J" => 0x0A,
46
+ "L" => 0x0B,
47
+ "M" => 0x0D, # same as ENTER?
48
+ "N" => 0x0E,
49
+ "O" => 0x0F,
50
+ "P" => 0x10,
51
+ "Q" => 0x11,
52
+ "R" => 0x12,
53
+ "S" => 0x13,
54
+ "T" => 0x14,
55
+ "U" => 0x15,
56
+ "V" => 0x16,
57
+ "W" => 0x17,
58
+ "X" => 0x18,
59
+ "Y" => 0x19,
60
+ "Z" => 0x1A,
61
+ "2" => 0x00,
62
+ "3" => 0x1B,
63
+ "4" => 0x1C,
64
+ "5" => 0x1D,
65
+ "6" => 0x1E,
66
+ "7" => 0x1F,
67
+ "8" => 0x7F,
68
+ "\\"=> 0x1C,
69
+ "/" => 0x1F,
70
+ "[" => 0x1B,
71
+ "]" => 0x1D,
72
+ "_" => 0x1F, # same as few others
73
+ " " => 0x20, # same as few others
74
+ },
75
+
76
+ "BACKSPACE" => 0x08,
77
+ "BACKSPACE2"=> 0x7F,
78
+ "TAB" => 0x09,
79
+ "ENTER" => 0x0D,
80
+ "RETURN" => 0x0D,
81
+ "ESC" => 0x1B,
82
+ "ESCAPE" => 0x1B,
83
+ }
84
+
85
+ def lookup_key string
86
+ if string =~ /CTRL/i
87
+ if string =~ /CTRL\s\+\s/i
88
+ string.sub! /CTRL\s\+\s/i, '' # CTRL + y
89
+ return Keys["CTRL"][string.upcase]
90
+ else
91
+ string.sub! /CTRL\s/i, '' # CTRL x
92
+ return Keys["CTRL"][string.upcase]
93
+ end
94
+ end
95
+
96
+ # assume other keys like "ESC"
97
+ return Keys[string.upcase]
98
+ end
99
+
100
+ def reverse_key_lookup num # 102 => f
101
+ # Quick check of top level keys
102
+ match = Keys.select{|k,v| v.is_a?(Numeric) }.detect{|k,v| v == num }
103
+ return match.shift if match
104
+
105
+ # Now look through Ctrl sequences
106
+ combo = Keys.select{|k,v| v.is_a?(Hash) }
107
+ if combo.any?
108
+ combo.each do |k,v| #k == CTRL
109
+ match = v.detect{|k,v| v == num }
110
+ if match
111
+ return "CTRL + #{match.shift}"
112
+ else
113
+ return nil
114
+ end
115
+ end
116
+ end
117
+ end
118
+ module_function :lookup_key, :reverse_key_lookup
119
+ end
@@ -0,0 +1,3 @@
1
+ module Termbox
2
+ VERSION = "0.1.0"
3
+ end
data/lib/termbox.rb ADDED
@@ -0,0 +1,56 @@
1
+ require "bundler/setup"
2
+ require "ffi"
3
+
4
+ lib = File.expand_path('../../', __FILE__)
5
+ $:.unshift lib unless $:.include?(lib)
6
+
7
+ module Termbox
8
+ extend FFI::Library
9
+
10
+ class Cell < FFI::Struct
11
+ layout :ch, :ulong,
12
+ :fg, :uint16,
13
+ :bg, :uint16
14
+ end
15
+
16
+ class Event < FFI::Struct
17
+ layout :type, :uint8,
18
+ :mod, :uint8,
19
+ :key, :uint16,
20
+ :ch, :uint32,
21
+ :w, :int32,
22
+ :h, :int32
23
+ end
24
+
25
+ def termbox_library_path path=nil
26
+ if path
27
+ @library_path = path
28
+ end
29
+
30
+ @library_path
31
+ end
32
+
33
+ def initialize_library path=nil
34
+ ffi_lib path || termbox_library_path
35
+ attach_function :tb_init, [], :int
36
+ attach_function :tb_shutdown, [], :void
37
+ attach_function :tb_width, [], :uint
38
+ attach_function :tb_height, [], :uint
39
+ attach_function :tb_clear, [], :void
40
+ attach_function :tb_present, [], :void
41
+ attach_function :tb_set_cursor, [:int, :int], :void
42
+ attach_function :tb_put_cell, [:uint, :uint, :pointer], :void #pointer follows TbCell
43
+ attach_function :tb_change_cell, [:uint, :uint, :ulong, :uint16, :uint16], :void
44
+ attach_function :tb_blit, [:uint, :uint, :uint, :uint, :pointer], :void # pointer follows TbCell
45
+
46
+ # with 0 returns current input mode
47
+ attach_function :tb_select_input_mode, [:int], :int
48
+ attach_function :tb_peek_event, [:pointer, :int], :int
49
+ attach_function :tb_poll_event, [:pointer], :int
50
+ end
51
+
52
+ module_function :initialize_library, :termbox_library_path
53
+
54
+ require_relative "termbox/keys"
55
+ require_relative "termbox/colors"
56
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'termbox/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "rb_termbox"
9
+ s.version = Termbox::VERSION
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = ["James Cook"]
12
+ s.email = ["jamecook@gmail.com"]
13
+ s.summary = %q{Ruby binding to Termbox, a ncurses alternative.}
14
+ #s.description = %q{}
15
+
16
+ s.required_rubygems_version = ">= 1.3.6"
17
+ s.rubyforge_project = "rb_termbox"
18
+
19
+ s.add_dependency "ffi"
20
+ s.add_development_dependency "rspec"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,215 @@
1
+ load File.join(File.expand_path("."), "/lib/termbox.rb")
2
+ load File.join(File.expand_path("."), "sample/keyboard_keys.rb")
3
+ load File.join(File.expand_path("."), "sample/keyboard_keys.rb")
4
+
5
+ class Keyboard
6
+ def self.run
7
+
8
+ # Tell termbox where your shared lib is
9
+ Termbox.termbox_library_path File.join(File.expand_path("~/"), "work", "termbox_src", "termbox.dylib")
10
+
11
+ # Call initialize_library once the above is set, this links us to the library C functions
12
+ Termbox.initialize_library
13
+
14
+ start = Termbox.tb_init
15
+ if start
16
+ Termbox.tb_select_input_mode 1 # TB_INPUT_ESC
17
+ ev = Termbox::Event.new
18
+ Termbox.tb_clear
19
+ draw
20
+ draw_word "Keyboard started. Press CTRL + Q to quit."
21
+ Termbox.tb_present
22
+ while Termbox.tb_poll_event(ev) >= 0 do
23
+ case ev[:type]
24
+ when 1 #TB_EVENT_KEY
25
+ if ev[:key] == 0x11 # CTRL_Q
26
+ Termbox.tb_shutdown
27
+ exit
28
+ end
29
+
30
+ Termbox.tb_clear
31
+ draw
32
+ if ev[:mod] > 0
33
+ draw_word "Pressed mod? (#{ev[:mod].inspect})", 60, 35
34
+ end
35
+
36
+ if ev[:key] > 0
37
+ draw_word "Pressed #{Termbox.reverse_key_lookup(ev[:key]) || "?"} -- #{ev[:ch].inspect}"
38
+ elsif ev[:ch]> 0
39
+ draw_word "Pressed key #{[ev[:ch]].pack("C*")} (#{ev[:ch]})"
40
+ end
41
+ Termbox.tb_present
42
+ else
43
+ draw_word "????"
44
+ end
45
+ end
46
+ else
47
+ raise "tb_init() failed"
48
+ end
49
+ end
50
+
51
+ def self.draw
52
+ Termbox.tb_change_cell(0, 0, 0x250C, Termbox::Colors[:white], Termbox::Colors[:black])
53
+ Termbox.tb_change_cell(79, 0, 0x2510, Termbox::Colors[:white], Termbox::Colors[:black])
54
+ Termbox.tb_change_cell(0, 23, 0x2514, Termbox::Colors[:white], Termbox::Colors[:black])
55
+ Termbox.tb_change_cell(79, 23, 0x2518, Termbox::Colors[:white], Termbox::Colors[:black])
56
+
57
+
58
+ 1.upto(79) do |i|
59
+ Termbox.tb_change_cell(i, 0, 0x2500, Termbox::Colors[:white], Termbox::Colors[:black])
60
+ Termbox.tb_change_cell(i, 23, 0x2500, Termbox::Colors[:white], Termbox::Colors[:black])
61
+ Termbox.tb_change_cell(i, 17, 0x2500, Termbox::Colors[:white], Termbox::Colors[:black])
62
+ Termbox.tb_change_cell(i, 4, 0x2500, Termbox::Colors[:white], Termbox::Colors[:black])
63
+ end
64
+
65
+ 1.upto(23) do |i|
66
+ Termbox.tb_change_cell(0, i, 0x2502, Termbox::Colors[:white], Termbox::Colors[:black])
67
+ Termbox.tb_change_cell(79, i, 0x2502, Termbox::Colors[:white], Termbox::Colors[:black])
68
+ end
69
+
70
+ Termbox.tb_change_cell(0, 17, 0x251C, Termbox::Colors[:white], Termbox::Colors[:black])
71
+ Termbox.tb_change_cell(79, 17, 0x2524, Termbox::Colors[:white], Termbox::Colors[:black])
72
+ Termbox.tb_change_cell(0, 4, 0x251C, Termbox::Colors[:white], Termbox::Colors[:black])
73
+ Termbox.tb_change_cell(79, 4, 0x2524, Termbox::Colors[:white], Termbox::Colors[:black])
74
+
75
+ 5.upto(17) do |i|
76
+ Termbox.tb_change_cell(1, i, 0x2588, Termbox::Colors[:yellow], Termbox::Colors[:yellow])
77
+ Termbox.tb_change_cell(78, i, 0x2588, Termbox::Colors[:yellow], Termbox::Colors[:yellow])
78
+ end
79
+ draw_key "ESC", Termbox::Colors[:white], Termbox::Colors[:blue]
80
+ draw_key "F1", Termbox::Colors[:white], Termbox::Colors[:blue]
81
+ draw_key "F2", Termbox::Colors[:white], Termbox::Colors[:blue]
82
+ draw_key "F3", Termbox::Colors[:white], Termbox::Colors[:blue]
83
+ draw_key "F4", Termbox::Colors[:white], Termbox::Colors[:blue]
84
+ draw_key "F5", Termbox::Colors[:white], Termbox::Colors[:blue]
85
+ draw_key "F6", Termbox::Colors[:white], Termbox::Colors[:blue]
86
+ draw_key "F7", Termbox::Colors[:white], Termbox::Colors[:blue]
87
+ draw_key "F8", Termbox::Colors[:white], Termbox::Colors[:blue]
88
+ draw_key "F9", Termbox::Colors[:white], Termbox::Colors[:blue]
89
+ draw_key "F10", Termbox::Colors[:white], Termbox::Colors[:blue]
90
+ draw_key "F11", Termbox::Colors[:white], Termbox::Colors[:blue]
91
+ draw_key "F12", Termbox::Colors[:white], Termbox::Colors[:blue]
92
+ draw_key "PRN", Termbox::Colors[:white], Termbox::Colors[:blue]
93
+ draw_key "BRK", Termbox::Colors[:white], Termbox::Colors[:blue]
94
+ draw_key "LED1", Termbox::Colors[:white], Termbox::Colors[:blue]
95
+ draw_key "LED2", Termbox::Colors[:white], Termbox::Colors[:blue]
96
+ draw_key "LED3", Termbox::Colors[:white], Termbox::Colors[:blue]
97
+ draw_key "`", Termbox::Colors[:white], Termbox::Colors[:blue]
98
+ draw_key "1", Termbox::Colors[:white], Termbox::Colors[:blue]
99
+ draw_key "2", Termbox::Colors[:white], Termbox::Colors[:blue]
100
+ draw_key "3", Termbox::Colors[:white], Termbox::Colors[:blue]
101
+ draw_key "4", Termbox::Colors[:white], Termbox::Colors[:blue]
102
+ draw_key "5", Termbox::Colors[:white], Termbox::Colors[:blue]
103
+ draw_key "6", Termbox::Colors[:white], Termbox::Colors[:blue]
104
+ draw_key "7", Termbox::Colors[:white], Termbox::Colors[:blue]
105
+ draw_key "8", Termbox::Colors[:white], Termbox::Colors[:blue]
106
+ draw_key "9", Termbox::Colors[:white], Termbox::Colors[:blue]
107
+ draw_key "0", Termbox::Colors[:white], Termbox::Colors[:blue]
108
+ draw_key "-", Termbox::Colors[:white], Termbox::Colors[:blue]
109
+ draw_key "=", Termbox::Colors[:white], Termbox::Colors[:blue]
110
+ draw_key "\\", Termbox::Colors[:white], Termbox::Colors[:blue]
111
+ draw_key "BACKSPACE", Termbox::Colors[:white], Termbox::Colors[:blue]
112
+ draw_key "INS", Termbox::Colors[:white], Termbox::Colors[:blue]
113
+ draw_key "HOM", Termbox::Colors[:white], Termbox::Colors[:blue]
114
+ draw_key "PGU", Termbox::Colors[:white], Termbox::Colors[:blue]
115
+ draw_key "PGU", Termbox::Colors[:white], Termbox::Colors[:blue]
116
+ draw_key "NUMLOCK", Termbox::Colors[:white], Termbox::Colors[:blue]
117
+ draw_key "K_SLASH", Termbox::Colors[:white], Termbox::Colors[:blue]
118
+ draw_key "K_STAR", Termbox::Colors[:white], Termbox::Colors[:blue]
119
+ draw_key "K_MINUS", Termbox::Colors[:white], Termbox::Colors[:blue]
120
+ draw_key "TAB", Termbox::Colors[:white], Termbox::Colors[:blue]
121
+ draw_key "q", Termbox::Colors[:white], Termbox::Colors[:blue]
122
+ draw_key "w", Termbox::Colors[:white], Termbox::Colors[:blue]
123
+ draw_key "e", Termbox::Colors[:white], Termbox::Colors[:blue]
124
+ draw_key "r", Termbox::Colors[:white], Termbox::Colors[:blue]
125
+ draw_key "t", Termbox::Colors[:white], Termbox::Colors[:blue]
126
+ draw_key "y", Termbox::Colors[:white], Termbox::Colors[:blue]
127
+ draw_key "u", Termbox::Colors[:white], Termbox::Colors[:blue]
128
+ draw_key "i", Termbox::Colors[:white], Termbox::Colors[:blue]
129
+ draw_key "o", Termbox::Colors[:white], Termbox::Colors[:blue]
130
+ draw_key "p", Termbox::Colors[:white], Termbox::Colors[:blue]
131
+ draw_key "u", Termbox::Colors[:white], Termbox::Colors[:blue]
132
+ draw_key "i", Termbox::Colors[:white], Termbox::Colors[:blue]
133
+ draw_key "o", Termbox::Colors[:white], Termbox::Colors[:blue]
134
+ draw_key "p", Termbox::Colors[:white], Termbox::Colors[:blue]
135
+ draw_key "[", Termbox::Colors[:white], Termbox::Colors[:blue]
136
+ draw_key "]", Termbox::Colors[:white], Termbox::Colors[:blue]
137
+ draw_key "DEL", Termbox::Colors[:white], Termbox::Colors[:blue]
138
+ draw_key "PGD", Termbox::Colors[:white], Termbox::Colors[:blue]
139
+ draw_key "K_7", Termbox::Colors[:white], Termbox::Colors[:blue]
140
+ draw_key "K_8", Termbox::Colors[:white], Termbox::Colors[:blue]
141
+ draw_key "K_9", Termbox::Colors[:white], Termbox::Colors[:blue]
142
+ draw_key "K_PLUS", Termbox::Colors[:white], Termbox::Colors[:blue]
143
+ draw_key "CAPS", Termbox::Colors[:white], Termbox::Colors[:blue]
144
+ draw_key "a", Termbox::Colors[:white], Termbox::Colors[:blue]
145
+ draw_key "s", Termbox::Colors[:white], Termbox::Colors[:blue]
146
+ draw_key "d", Termbox::Colors[:white], Termbox::Colors[:blue]
147
+ draw_key "f", Termbox::Colors[:white], Termbox::Colors[:blue]
148
+ draw_key "g", Termbox::Colors[:white], Termbox::Colors[:blue]
149
+ draw_key "h", Termbox::Colors[:white], Termbox::Colors[:blue]
150
+ draw_key "j", Termbox::Colors[:white], Termbox::Colors[:blue]
151
+ draw_key "k", Termbox::Colors[:white], Termbox::Colors[:blue]
152
+ draw_key "l", Termbox::Colors[:white], Termbox::Colors[:blue]
153
+ draw_key ";", Termbox::Colors[:white], Termbox::Colors[:blue]
154
+ draw_key "'", Termbox::Colors[:white], Termbox::Colors[:blue]
155
+ draw_key "K_4", Termbox::Colors[:white], Termbox::Colors[:blue]
156
+ draw_key "K_5", Termbox::Colors[:white], Termbox::Colors[:blue]
157
+ draw_key "K_6", Termbox::Colors[:white], Termbox::Colors[:blue]
158
+ draw_key "L_SHIFT", Termbox::Colors[:white], Termbox::Colors[:blue]
159
+ draw_key "z", Termbox::Colors[:white], Termbox::Colors[:blue]
160
+ draw_key "x", Termbox::Colors[:white], Termbox::Colors[:blue]
161
+ draw_key "c", Termbox::Colors[:white], Termbox::Colors[:blue]
162
+ draw_key "v", Termbox::Colors[:white], Termbox::Colors[:blue]
163
+ draw_key "b", Termbox::Colors[:white], Termbox::Colors[:blue]
164
+ draw_key "n", Termbox::Colors[:white], Termbox::Colors[:blue]
165
+ draw_key "m", Termbox::Colors[:white], Termbox::Colors[:blue]
166
+ draw_key ",", Termbox::Colors[:white], Termbox::Colors[:blue]
167
+ draw_key ".", Termbox::Colors[:white], Termbox::Colors[:blue]
168
+ draw_key "/", Termbox::Colors[:white], Termbox::Colors[:blue]
169
+ draw_key "R_SHIFT", Termbox::Colors[:white], Termbox::Colors[:blue]
170
+ draw_key "ARROW_UP", Termbox::Colors[:white], Termbox::Colors[:blue]
171
+ draw_key "K_1", Termbox::Colors[:white], Termbox::Colors[:blue]
172
+ draw_key "K_2", Termbox::Colors[:white], Termbox::Colors[:blue]
173
+ draw_key "K_3", Termbox::Colors[:white], Termbox::Colors[:blue]
174
+ draw_key "K_ENTER", Termbox::Colors[:white], Termbox::Colors[:blue]
175
+ draw_key "L_CTRL", Termbox::Colors[:white], Termbox::Colors[:blue]
176
+ draw_key "L_MOD4", Termbox::Colors[:white], Termbox::Colors[:blue]
177
+ draw_key "SPACE", Termbox::Colors[:white], Termbox::Colors[:blue]
178
+ draw_key "R_CTRL", Termbox::Colors[:white], Termbox::Colors[:blue]
179
+ draw_key "R_PROP", Termbox::Colors[:white], Termbox::Colors[:blue]
180
+ draw_key "R_MOD4", Termbox::Colors[:white], Termbox::Colors[:blue]
181
+ draw_key "R_ALT", Termbox::Colors[:white], Termbox::Colors[:blue]
182
+ draw_key "ARROW_LEFT", Termbox::Colors[:white], Termbox::Colors[:blue]
183
+ draw_key "ARROW_DOWN", Termbox::Colors[:white], Termbox::Colors[:blue]
184
+ draw_key "ARROW_RIGHT", Termbox::Colors[:white], Termbox::Colors[:blue]
185
+ draw_key "K_0", Termbox::Colors[:white], Termbox::Colors[:blue]
186
+ draw_key "K_PERIOD", Termbox::Colors[:white], Termbox::Colors[:blue]
187
+ end
188
+
189
+
190
+ def self.draw_key key, fg, bg
191
+
192
+ seq = Keyboard::KEYS[key] || []
193
+ seq.each do |k|
194
+ Termbox.tb_change_cell(k[:x]+2,k[:y]+4, k[:ch], fg, bg);
195
+ end
196
+ end
197
+
198
+ def self.draw_word phrase, x=70, y=30
199
+ cur_x = x
200
+ cur_y = y
201
+ phrase.split("").each do |char|
202
+ Termbox.tb_change_cell(cur_x,cur_y, char.ord, Termbox::Colors[:white], Termbox::Colors[:blue]);
203
+ cur_x = cur_x + 1
204
+ end
205
+ end
206
+
207
+ def self.handle_keypress event
208
+ draw_word "Pressed '#{event.inspect}'"
209
+ end
210
+ end
211
+
212
+ if __FILE__ == $0
213
+ Keyboard.run
214
+ end
215
+
@@ -0,0 +1,427 @@
1
+ class Keyboard
2
+ STOP_SEQ = {:x => 0, :y => 0, :ch => 0 }
3
+ KEYS =
4
+ {
5
+ "q" => [{:x => 6, :y => 6, :ch => 'q'.ord}, STOP_SEQ],
6
+ "ESC" => [{:x => 1, :y => 1, :ch => "E".ord},
7
+ {:x => 2, :y => 1, :ch => "S".ord},
8
+ {:x => 3, :y => 1, :ch => "C".ord},
9
+ STOP_SEQ],
10
+
11
+ "F1" => [{:x => 6, :y => 1, :ch => 'F'.ord},
12
+ {:x => 7, :y => 1, :ch => '1'.ord},
13
+ STOP_SEQ],
14
+ "F2" => [{:x => 9, :y => 1, :ch => 'F'.ord},
15
+ {:x => 10, :y => 1, :ch => '2'.ord},
16
+ STOP_SEQ],
17
+ "F3" => [{:x => 12, :y => 1, :ch => 'F'.ord},
18
+ {:x => 13, :y => 1, :ch => '3'.ord},
19
+ STOP_SEQ],
20
+ "F4" => [{:x => 15, :y => 1, :ch => 'F'.ord},
21
+ {:x => 16, :y => 1, :ch => '4'.ord},
22
+ STOP_SEQ],
23
+ "F5" => [{:x => 19, :y => 1, :ch => 'F'.ord},
24
+ {:x => 20, :y => 1, :ch => '5'.ord},
25
+ STOP_SEQ],
26
+ "F6" => [{:x => 22, :y => 1, :ch => 'F'.ord},
27
+ {:x => 23, :y => 1, :ch => '6'.ord},
28
+ STOP_SEQ],
29
+ "F7" => [{:x => 25, :y => 1, :ch => 'F'.ord},
30
+ {:x => 26, :y => 1, :ch => '6'.ord},
31
+ STOP_SEQ],
32
+ "F8" => [{:x => 28, :y => 1, :ch => 'F'.ord},
33
+ {:x => 29, :y => 1, :ch => '8'.ord},
34
+ STOP_SEQ],
35
+ "F9" => [{:x => 33, :y => 1, :ch => 'F'.ord},
36
+ {:x => 34, :y => 1, :ch => '9'.ord},
37
+ STOP_SEQ],
38
+ "F10" => [{:x => 36, :y => 1, :ch => 'F'.ord},
39
+ {:x => 37, :y => 1, :ch => '1'.ord},
40
+ {:x => 38, :y => 1, :ch => '0'.ord},
41
+ STOP_SEQ],
42
+ "F11" => [{:x => 40, :y => 1, :ch => 'F'.ord},
43
+ {:x => 41, :y => 1, :ch => '1'.ord},
44
+ {:x => 42, :y => 1, :ch => '1'.ord},
45
+ STOP_SEQ],
46
+ "F12" => [{:x => 44, :y => 1, :ch => 'F'.ord},
47
+ {:x => 45, :y => 1, :ch => '1'.ord},
48
+ {:x => 46, :y => 1, :ch => '2'.ord},
49
+ STOP_SEQ],
50
+ "PRN" => [{:x => 50, :y => 1, :ch => 'P'.ord},
51
+ {:x => 51, :y => 1, :ch => 'R'.ord},
52
+ {:x => 52, :y => 1, :ch => 'N'.ord},
53
+ STOP_SEQ],
54
+ "SCR" => [{:x => 54, :y => 1, :ch => 'S'.ord},
55
+ {:x => 55, :y => 1, :ch => 'C'.ord},
56
+ {:x => 56, :y => 1, :ch => 'R'.ord},
57
+ STOP_SEQ],
58
+ "BRK" => [{:x => 58, :y => 1, :ch => 'B'.ord},
59
+ {:x => 59, :y => 1, :ch => 'R'.ord},
60
+ {:x => 60, :y => 1, :ch => 'K'.ord},
61
+ STOP_SEQ],
62
+ "LED1" => [{:x => 66, :y => 1, :ch => '-'.ord},
63
+ STOP_SEQ],
64
+ "LED2" => [{:x => 70, :y => 1, :ch => '-'.ord},
65
+ STOP_SEQ],
66
+ "LED3" => [{:x => 74, :y => 1, :ch => '-'.ord},
67
+ STOP_SEQ],
68
+ "BACKTICK" => [{:x => 1, :y => 4, :ch => '`'.ord},
69
+ STOP_SEQ],
70
+ "TILDE" => [{:x => 1, :y => 4, :ch => '~'.ord},
71
+ STOP_SEQ],
72
+ "1" => [{:x => 4, :y => 4, :ch => '1'.ord},
73
+ STOP_SEQ],
74
+ "!" => [{:x => 4, :y => 4, :ch => '!'.ord},
75
+ STOP_SEQ],
76
+ "2" => [{:x => 7, :y => 4, :ch => '2'.ord},
77
+ STOP_SEQ],
78
+ "@" => [{:x => 7, :y => 4, :ch => '@'.ord},
79
+ STOP_SEQ],
80
+ "3" => [{:x => 10, :y => 4, :ch => '3'.ord},
81
+ STOP_SEQ],
82
+ "#" => [{:x => 10, :y => 4, :ch => '#'.ord},
83
+ STOP_SEQ],
84
+ "4" => [{:x => 13, :y => 4, :ch => '4'.ord},
85
+ STOP_SEQ],
86
+ "$" => [{:x => 13, :y => 4, :ch => '$'.ord},
87
+ STOP_SEQ],
88
+ "5" => [{:x => 16, :y => 4, :ch => '5'.ord},
89
+ STOP_SEQ],
90
+ "%" => [{:x => 16, :y => 4, :ch => '%'.ord},
91
+ STOP_SEQ],
92
+ "6" => [{:x => 19, :y => 4, :ch => '6'.ord},
93
+ STOP_SEQ],
94
+ "^" => [{:x => 19, :y => 4, :ch => '^'.ord},
95
+ STOP_SEQ],
96
+ "7" => [{:x => 22, :y => 4, :ch => '7'.ord},
97
+ STOP_SEQ],
98
+ "&" => [{:x => 22, :y => 4, :ch => '&'.ord},
99
+ STOP_SEQ],
100
+ "8" => [{:x => 25, :y => 4, :ch => '8'.ord},
101
+ STOP_SEQ],
102
+ "*" => [{:x => 25, :y => 4, :ch => '*'.ord},
103
+ STOP_SEQ],
104
+ "9" => [{:x => 28, :y => 4, :ch => '9'.ord},
105
+ STOP_SEQ],
106
+ "(" => [{:x => 28, :y => 4, :ch => '('.ord},
107
+ STOP_SEQ],
108
+ "0" => [{:x => 31, :y => 4, :ch => '0'.ord},
109
+ STOP_SEQ],
110
+ ")" => [{:x => 31, :y => 4, :ch => ')'.ord},
111
+ STOP_SEQ],
112
+ "-" => [{:x => 34, :y => 4, :ch => '-'.ord},
113
+ STOP_SEQ],
114
+ "_" => [{:x => 34, :y => 4, :ch => '_'.ord},
115
+ STOP_SEQ],
116
+ "=" => [{:x => 37, :y => 4, :ch => '='.ord},
117
+ STOP_SEQ],
118
+ "+" => [{:x => 37, :y => 4, :ch => '+'.ord},
119
+ STOP_SEQ],
120
+ "\\" => [{:x => 40, :y => 4, :ch => "\\".ord},
121
+ STOP_SEQ],
122
+ "|" => [{:x => 40, :y => 4, :ch => "|".ord},
123
+ STOP_SEQ],
124
+ "BACKSPACE" => [{:x => 44, :y => 4, :ch => 0x2190},
125
+ {:x => 45, :y => 4, :ch => 0x2500},
126
+ {:x => 46, :y => 4, :ch => 0x2500},
127
+ STOP_SEQ],
128
+ "INS" => [{:x => 50, :y => 4, :ch => 'I'.ord},
129
+ {:x => 51, :y => 4, :ch => 'N'.ord},
130
+ {:x => 52, :y => 4, :ch => 'S'.ord},
131
+ STOP_SEQ],
132
+ "HOM" => [{:x => 54, :y => 4, :ch => 'H'.ord},
133
+ {:x => 55, :y => 4, :ch => 'O'.ord},
134
+ {:x => 56, :y => 4, :ch => 'M'.ord},
135
+ STOP_SEQ],
136
+ "PGU" => [{:x => 58, :y => 4, :ch => 'P'.ord},
137
+ {:x => 59, :y => 4, :ch => 'G'.ord},
138
+ {:x => 60, :y => 4, :ch => 'U'.ord},
139
+ STOP_SEQ],
140
+ "NUMLOCK" => [{:x => 65, :y => 4, :ch => 'N'.ord},
141
+ STOP_SEQ],
142
+ "K_SLASH" => [{:x => 68, :y => 4, :ch => '/'.ord},
143
+ STOP_SEQ],
144
+ "K_STAR" => [{:x => 71, :y => 4, :ch => '*'.ord},
145
+ STOP_SEQ],
146
+ "K_MINUS" => [{:x => 74, :y => 4, :ch => '-'.ord},
147
+ STOP_SEQ],
148
+ "TAB" => [{:x => 1, :y => 6, :ch => 'T'.ord},
149
+ {:x => 2, :y => 6, :ch => 'A'.ord},
150
+ {:x => 3, :y => 6, :ch => 'B'.ord},
151
+ STOP_SEQ],
152
+ "q" => [{:x => 6, :y => 6, :ch => 'q'.ord},
153
+ STOP_SEQ],
154
+ "Q" => [{:x => 6, :y => 6, :ch => 'Q'.ord},
155
+ STOP_SEQ],
156
+ "w" => [{:x => 9, :y => 6, :ch => 'w'.ord},
157
+ STOP_SEQ],
158
+ "W" => [{:x => 9, :y => 6, :ch => 'W'.ord},
159
+ STOP_SEQ],
160
+ "e" => [{:x => 12, :y => 6, :ch => 'e'.ord},
161
+ STOP_SEQ],
162
+ "E" => [{:x => 12, :y => 6, :ch => 'E'.ord},
163
+ STOP_SEQ],
164
+ "r" => [{:x => 15, :y => 6, :ch => 'r'.ord},
165
+ STOP_SEQ],
166
+ "R" => [{:x => 15, :y => 6, :ch => 'R'.ord},
167
+ STOP_SEQ],
168
+ "t" => [{:x => 18, :y => 6, :ch => 't'.ord},
169
+ STOP_SEQ],
170
+ "T" => [{:x => 18, :y => 6, :ch => 'T'.ord},
171
+ STOP_SEQ],
172
+ "y" => [{:x => 21, :y => 6, :ch => 'y'.ord},
173
+ STOP_SEQ],
174
+ "Y" => [{:x => 21, :y => 6, :ch => 'Y'.ord},
175
+ STOP_SEQ],
176
+ "u" => [{:x => 24, :y => 6, :ch => 'u'.ord},
177
+ STOP_SEQ],
178
+ "U" => [{:x => 24, :y => 6, :ch => 'U'.ord},
179
+ STOP_SEQ],
180
+ "i" => [{:x => 27, :y => 6, :ch => 'i'.ord},
181
+ STOP_SEQ],
182
+ "I" => [{:x => 27, :y => 6, :ch => 'I'.ord},
183
+ STOP_SEQ],
184
+ "o" => [{:x => 30, :y => 6, :ch => 'o'.ord},
185
+ STOP_SEQ],
186
+ "O" => [{:x => 30, :y => 6, :ch => 'O'.ord},
187
+ STOP_SEQ],
188
+ "p" => [{:x => 33, :y => 6, :ch => 'p'.ord},
189
+ STOP_SEQ],
190
+ "P" => [{:x => 33, :y => 6, :ch => 'P'.ord},
191
+ STOP_SEQ],
192
+ "[" => [{:x => 36, :y => 6, :ch => '['.ord},
193
+ STOP_SEQ],
194
+ "{" => [{:x => 36, :y => 6, :ch => '{'.ord},
195
+ STOP_SEQ],
196
+ "]" => [{:x => 39, :y => 6, :ch => ']'.ord},
197
+ STOP_SEQ],
198
+ "}" => [{:x => 39, :y => 6, :ch => '}'.ord},
199
+ STOP_SEQ],
200
+ "ENTER" => [{:x => 43, :y => 6, :ch => 0x2591},
201
+ {:x => 43, :y => 7, :ch => 0x2591},
202
+ {:x => 41, :y => 8, :ch => 0x2591},
203
+ {:x => 45, :y => 8, :ch => 0x2591},
204
+
205
+ {:x => 44, :y => 6, :ch => 0x2591},
206
+ {:x => 44, :y => 7, :ch => 0x2591},
207
+ {:x => 42, :y => 8, :ch => 0x2591},
208
+ {:x => 46, :y => 8, :ch => 0x2591},
209
+
210
+ {:x => 46, :y => 6, :ch => 0x2591},
211
+ {:x => 46, :y => 7, :ch => 0x2591},
212
+ {:x => 44, :y => 8, :ch => 0x2591},
213
+
214
+ {:x => 46, :y => 8, :ch => 0x2591},
215
+ STOP_SEQ],
216
+ "DEL" => [{:x => 50, :y => 6, :ch => 'D'.ord},
217
+ {:x => 51, :y => 6, :ch => 'E'.ord},
218
+ {:x => 52, :y => 6, :ch => 'L'.ord},
219
+ STOP_SEQ],
220
+ "END" => [{:x => 54, :y => 6, :ch => 'E'.ord},
221
+ {:x => 55, :y => 6, :ch => 'N'.ord},
222
+ {:x => 56, :y => 6, :ch => 'D'.ord},
223
+ STOP_SEQ],
224
+ "PGD" => [{:x => 50, :y => 6, :ch => 'P'.ord},
225
+ {:x => 51, :y => 6, :ch => 'G'.ord},
226
+ {:x => 52, :y => 6, :ch => 'D'.ord},
227
+ STOP_SEQ],
228
+ "K_7" => [{:x => 65, :y => 6, :ch => '7'.ord},
229
+ STOP_SEQ],
230
+ "K_8" => [{:x => 68, :y => 6, :ch => '8'.ord},
231
+ STOP_SEQ],
232
+ "K_9" => [{:x => 71, :y => 6, :ch => '9'.ord},
233
+ STOP_SEQ],
234
+ "K_PLUS" => [{:x => 74, :y => 6, :ch => ' '.ord},
235
+ {:x => 75, :y => 7, :ch => '+'.ord},
236
+ {:x => 76, :y => 8, :ch => ' '.ord},
237
+ STOP_SEQ],
238
+ "K_CAPS" => [{:x => 1, :y => 8, :ch => 'C'.ord},
239
+ {:x => 2, :y => 8, :ch => 'A'.ord},
240
+ {:x => 3, :y => 8, :ch => 'P'.ord},
241
+ {:x => 4, :y => 8, :ch => 'S'.ord},
242
+ STOP_SEQ],
243
+ "a" => [{:x => 7, :y => 8, :ch => 'a'.ord},
244
+ STOP_SEQ],
245
+ "A" => [{:x => 7, :y => 8, :ch => 'A'.ord},
246
+ STOP_SEQ],
247
+ "s" => [{:x => 10, :y => 8, :ch => 's'.ord},
248
+ STOP_SEQ],
249
+ "S" => [{:x => 10, :y => 8, :ch => 'S'.ord},
250
+ STOP_SEQ],
251
+ "d" => [{:x => 13, :y => 8, :ch => 'd'.ord},
252
+ STOP_SEQ],
253
+ "D" => [{:x => 13, :y => 8, :ch => 'D'.ord},
254
+ STOP_SEQ],
255
+ "f" => [{:x => 16, :y => 8, :ch => 'f'.ord},
256
+ STOP_SEQ],
257
+ "F" => [{:x => 16, :y => 8, :ch => 'F'.ord},
258
+ STOP_SEQ],
259
+ "g" => [{:x => 19, :y => 8, :ch => 'g'.ord},
260
+ STOP_SEQ],
261
+ "G" => [{:x => 19, :y => 8, :ch => 'G'.ord},
262
+ STOP_SEQ],
263
+ "h" => [{:x => 22, :y => 8, :ch => 'h'.ord},
264
+ STOP_SEQ],
265
+ "H" => [{:x => 22, :y => 8, :ch => 'H'.ord},
266
+ STOP_SEQ],
267
+ "j" => [{:x => 25, :y => 8, :ch => 'j'.ord},
268
+ STOP_SEQ],
269
+ "J" => [{:x => 25, :y => 8, :ch => 'J'.ord},
270
+ STOP_SEQ],
271
+ "k" => [{:x => 28, :y => 8, :ch => 'k'.ord},
272
+ STOP_SEQ],
273
+ "K" => [{:x => 28, :y => 8, :ch => 'K'.ord},
274
+ STOP_SEQ],
275
+ "l" => [{:x => 31, :y => 8, :ch => 'l'.ord},
276
+ STOP_SEQ],
277
+ "L" => [{:x => 31, :y => 8, :ch => 'L'.ord},
278
+ STOP_SEQ],
279
+ ";" => [{:x => 34, :y => 8, :ch => ';'.ord},
280
+ STOP_SEQ],
281
+ ":" => [{:x => 34, :y => 8, :ch => ':'.ord},
282
+ STOP_SEQ],
283
+ "'" => [{:x => 37, :y => 8, :ch => "'".ord},
284
+ STOP_SEQ],
285
+ "\"" => [{:x => 37, :y => 8, :ch => "\"".ord},
286
+ STOP_SEQ],
287
+ "K_4" => [{:x => 65, :y => 8, :ch => "4".ord},
288
+ STOP_SEQ],
289
+ "K_5" => [{:x => 68, :y => 8, :ch => "5".ord},
290
+ STOP_SEQ],
291
+ "K_6" => [{:x => 71, :y => 8, :ch => "6".ord},
292
+ STOP_SEQ],
293
+ "L_SHIFT" => [{:x => 1, :y => 10, :ch => "S".ord},
294
+ {:x => 2, :y => 10, :ch => "H".ord},
295
+ {:x => 3, :y => 10, :ch => "I".ord},
296
+ {:x => 4, :y => 10, :ch => "F".ord},
297
+ {:x => 5, :y => 10, :ch => "T".ord},
298
+ STOP_SEQ],
299
+ "z" => [{:x => 9 , :y => 10, :ch => "z".ord},
300
+ STOP_SEQ],
301
+ "Z" => [{:x => 9 , :y => 10, :ch => "Z".ord},
302
+ STOP_SEQ],
303
+ "x" => [{:x => 12 , :y => 10, :ch => "x".ord},
304
+ STOP_SEQ],
305
+ "X" => [{:x => 12 , :y => 10, :ch => "X".ord},
306
+ STOP_SEQ],
307
+ "c" => [{:x => 15 , :y => 10, :ch => "c".ord},
308
+ STOP_SEQ],
309
+ "C" => [{:x => 15 , :y => 10, :ch => "C".ord},
310
+ STOP_SEQ],
311
+ "v" => [{:x => 18 , :y => 10, :ch => "v".ord},
312
+ STOP_SEQ],
313
+ "V" => [{:x => 18 , :y => 10, :ch => "V".ord},
314
+ STOP_SEQ],
315
+ "b" => [{:x => 21 , :y => 10, :ch => "b".ord},
316
+ STOP_SEQ],
317
+ "B" => [{:x => 21 , :y => 10, :ch => "B".ord},
318
+ STOP_SEQ],
319
+ "n" => [{:x => 24 , :y => 10, :ch => "n".ord},
320
+ STOP_SEQ],
321
+ "N" => [{:x => 24 , :y => 10, :ch => "N".ord},
322
+ STOP_SEQ],
323
+ "m" => [{:x => 27 , :y => 10, :ch => "m".ord},
324
+ STOP_SEQ],
325
+ "M" => [{:x => 27 , :y => 10, :ch => "M".ord},
326
+ STOP_SEQ],
327
+ "," => [{:x => 30 , :y => 10, :ch => ",".ord},
328
+ STOP_SEQ],
329
+ "<" => [{:x => 30 , :y => 10, :ch => "<".ord},
330
+ STOP_SEQ],
331
+ "." => [{:x => 33 , :y => 10, :ch => ".".ord},
332
+ STOP_SEQ],
333
+ ">" => [{:x => 33 , :y => 10, :ch => ">".ord},
334
+ STOP_SEQ],
335
+ "/" => [{:x => 36 , :y => 10, :ch => "/".ord},
336
+ STOP_SEQ],
337
+ "?" => [{:x => 36 , :y => 10, :ch => "?".ord},
338
+ STOP_SEQ],
339
+ "R_SHIFT" => [{:x => 42, :y => 10, :ch => "S".ord},
340
+ {:x => 43, :y => 10, :ch => "H".ord},
341
+ {:x => 44, :y => 10, :ch => "I".ord},
342
+ {:x => 45, :y => 10, :ch => "F".ord},
343
+ {:x => 46, :y => 10, :ch => "T".ord},
344
+ STOP_SEQ],
345
+ "ARROW_UP" => [{:x => 54 , :y => 10, :ch => "(".ord},
346
+ {:x => 55 , :y => 10, :ch => 0x2191},
347
+ {:x => 56 , :y => 10, :ch => ")".ord},
348
+ STOP_SEQ],
349
+ "K_1" => [{:x => 65 , :y => 10, :ch => "1".ord},
350
+ STOP_SEQ],
351
+ "K_2" => [{:x => 68 , :y => 10, :ch => "2".ord},
352
+ STOP_SEQ],
353
+ "K_3" => [{:x => 71 , :y => 10, :ch => "3".ord},
354
+ STOP_SEQ],
355
+ "K_ENTER" => [{:x => 74, :y => 10, :ch => 0x2591},
356
+ {:x => 74, :y => 11, :ch => 0x2591},
357
+ {:x => 74, :y => 12, :ch => 0x2591},
358
+ STOP_SEQ],
359
+ "L_CTRL" => [ {:x => 1, :y => 12, :ch => "C".ord},
360
+ {:x => 2, :y => 12, :ch => "T".ord},
361
+ {:x => 3, :y => 12, :ch => "R".ord},
362
+ {:x => 4, :y => 12, :ch => "L".ord},
363
+ STOP_SEQ],
364
+ "L_MOD4" => [ {:x => 6, :y => 12, :ch => "W".ord},
365
+ {:x => 7, :y => 12, :ch => "I".ord},
366
+ {:x => 8, :y => 12, :ch => "N".ord},
367
+ STOP_SEQ],
368
+ "L_ALT" => [ {:x => 10, :y => 12, :ch => "A".ord},
369
+ {:x => 11, :y => 12, :ch => "L".ord},
370
+ {:x => 12, :y => 12, :ch => "T".ord},
371
+ STOP_SEQ],
372
+ "SPACE" => [ {:x => 14, :y => 12, :ch => " ".ord},
373
+ {:x => 15, :y => 12, :ch => " ".ord},
374
+ {:x => 16, :y => 12, :ch => " ".ord},
375
+ {:x => 17, :y => 12, :ch => " ".ord},
376
+ {:x => 18, :y => 12, :ch => " ".ord},
377
+
378
+ {:x => 19, :y => 12, :ch => "S".ord},
379
+ {:x => 20, :y => 12, :ch => "P".ord},
380
+ {:x => 21, :y => 12, :ch => "A".ord},
381
+ {:x => 22, :y => 12, :ch => "C".ord},
382
+ {:x => 23, :y => 12, :ch => "E".ord},
383
+
384
+ {:x => 24, :y => 12, :ch => " ".ord},
385
+ {:x => 25, :y => 12, :ch => " ".ord},
386
+ {:x => 26, :y => 12, :ch => " ".ord},
387
+ {:x => 27, :y => 12, :ch => " ".ord},
388
+ {:x => 28, :y => 12, :ch => " ".ord},
389
+ STOP_SEQ],
390
+ "R_ALT" => [ {:x => 30, :y => 12, :ch => "A".ord},
391
+ {:x => 31, :y => 12, :ch => "L".ord},
392
+ {:x => 32, :y => 12, :ch => "T".ord},
393
+ STOP_SEQ],
394
+ "R_MOD4" => [ {:x => 34, :y => 12, :ch => "W".ord},
395
+ {:x => 35, :y => 12, :ch => "I".ord},
396
+ {:x => 36, :y => 12, :ch => "N".ord},
397
+ STOP_SEQ],
398
+ "R_PROP" => [ {:x => 38, :y => 12, :ch => "P".ord},
399
+ {:x => 39, :y => 12, :ch => "R".ord},
400
+ {:x => 40, :y => 12, :ch => "P".ord},
401
+ STOP_SEQ],
402
+ "R_CTRL" => [ {:x => 43, :y => 12, :ch => "C".ord},
403
+ {:x => 44, :y => 12, :ch => "T".ord},
404
+ {:x => 45, :y => 12, :ch => "R".ord},
405
+ {:x => 46, :y => 12, :ch => "L".ord},
406
+ STOP_SEQ],
407
+ "ARROW_LEFT" => [{:x => 50 , :y => 12, :ch => "(".ord},
408
+ {:x => 51 , :y => 12, :ch => 0x2190},
409
+ {:x => 52 , :y => 12, :ch => ")".ord},
410
+ STOP_SEQ],
411
+ "ARROW_DOWN" => [{:x => 50, :y => 12, :ch => "(".ord},
412
+ {:x => 51, :y => 12, :ch => 0x2193},
413
+ {:x => 52, :y => 12, :ch => ")".ord},
414
+ STOP_SEQ],
415
+ "ARROW_RIGHT" => [{:x => 58, :y => 12, :ch => "(".ord},
416
+ {:x => 59, :y => 12, :ch => 0x2192},
417
+ {:x => 60, :y => 12, :ch => ")".ord},
418
+ STOP_SEQ],
419
+ "K_0" => [{:x => 65, :y => 12, :ch => " ".ord},
420
+ {:x => 66, :y => 12, :ch => "0".ord},
421
+ {:x => 67, :y => 12, :ch => " ".ord},
422
+ {:x => 68, :y => 12, :ch => " ".ord},
423
+ STOP_SEQ],
424
+ "K_PERIOD" => [{:x => 71, :y => 12, :ch => " ".ord},
425
+ STOP_SEQ]
426
+ }
427
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rb_termbox
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - James Cook
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-09 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: ffi
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ description:
47
+ email:
48
+ - jamecook@gmail.com
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ extra_rdoc_files: []
54
+
55
+ files:
56
+ - .gitignore
57
+ - Gemfile
58
+ - Gemfile.lock
59
+ - README
60
+ - lib/termbox.rb
61
+ - lib/termbox/colors.rb
62
+ - lib/termbox/keys.rb
63
+ - lib/termbox/version.rb
64
+ - rb_termbox.gemspec
65
+ - sample/keyboard.rb
66
+ - sample/keyboard_keys.rb
67
+ has_rdoc: true
68
+ homepage:
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 1
91
+ - 3
92
+ - 6
93
+ version: 1.3.6
94
+ requirements: []
95
+
96
+ rubyforge_project: rb_termbox
97
+ rubygems_version: 1.3.7
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Ruby binding to Termbox, a ncurses alternative.
101
+ test_files: []
102
+