3 # This is the class of a single character of input received by Nfoiled.
6 # A container for some useful constants.
8 # TODO: Figure out meaning of, and proper capitalization of, some of
10 Null = NUL = 0; SOH = 1; STX = 2; ETX = 3; EOT = 4
11 ENQ = 5; Acknowledge = ACK = 6; Bell = BEL = 7; Backspace = BS = 8
12 Tab = HT = 9; Newline = NL = 10; VT = 11; NP = 12
13 CarriageReturn = CR = 13; SO = 14; SI = 15; DLE = 16
14 DC1 = 17; DC2 = 18; DC3 = 19; DC4 = 20
15 NAK = 21; SYN = 22; ETB = 23; CAN = 24
16 EM = 25; SUB = 26; Escape = ESC = 27; FS = 28
17 GS = 29; RS = 30; US = 31; Delete = DEL = 127
21 # Creates a `Key` out of an ASCII integer.
22 def self.ascii charint
23 if (32..126).member? charint
24 new charint.chr.to_sym
25 elsif Names.member? charint
30 # The character corresponding to this keypress
34 # Creates a new `Key`. Input will be turned into a symbol if possible.
35 def initialize stringish
36 @char = stringish.respond_to?(:to_s) ? stringish.to_s.to_sym : stringish.to_sym
40 # Compares two keys' characters.
42 return false unless o.is_a? Key