From 240c2df41949e71ec9bfe4f82ea3f80a6709ff8c Mon Sep 17 00:00:00 2001 From: elliottcable Date: Fri, 13 Mar 2009 15:37:19 -0400 Subject: [PATCH] Re-worked `Key.process` some more. --- lib/nfoiled/key.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/nfoiled/key.rb b/lib/nfoiled/key.rb index a14e374..e05ae93 100644 --- a/lib/nfoiled/key.rb +++ b/lib/nfoiled/key.rb @@ -4,19 +4,20 @@ module Nfoiled class Key Names = { 0 => :null, 1 => :soh, 2 => :stx, 3 => :etx, 4 => :eot, 5 => :enq, 6 => :ack, 7 => :bell, 8 => :backspace, - 10 => :nl , 11 => :vt , 12 => :np , 13 => :cr , 14 => :so , - 15 => :si , 16 => :dle, 17 => :dc1, 18 => :dc2, 19 => :dc3, - 20 => :dc4, 21 => :nak, 22 => :syn, 23 => :etb, 24 => :can, - 25 => :em , 26 => :sub, 27 => :escape,28 => :fs,29 => :gs , - 30 => :rs , 31 => :us ,127 => :delete} + 9 => 9.chr,10 => :nl , 11 => :vt , 12 => :np , 13 => :cr , + 14 => :so , 15 => :si , 16 => :dle, 17 => :dc1, 18 => :dc2, + 19 => :dc3, 20 => :dc4, 21 => :nak, 22 => :syn, 23 => :etb, + 24 => :can, 25 => :em , 26 => :sub, 27=>:escape,28 => :fs, + 29 => :gs , 30 => :rs , 31 => :us ,127 => :delete } ## - # Responsible for processing input from `Nfoiled::read!`. Returns + # Responsible for processing input from `Window#gets`. Returns a new `Key` + # object. def self.process charint - return unless charint - new case charint - when 9, 32..126; then charint.chr - else Names[charint] + if (32..126).member? charint + new charint.chr.to_sym + elsif Names.member? charint + new Names[charint] end end -- 2.11.4.GIT