Module: Diakonos::Keying
- Defined in:
- lib/diakonos/keying.rb
Constant Summary collapse
- KEYSTRINGS =
[ "ctrl+space", # 0 "ctrl+a", # 1 "ctrl+b", # 2 "ctrl+c", # 3 "ctrl+d", # 4 "ctrl+e", # 5 "ctrl+f", # 6 "ctrl+g", # 7 nil, # 8 "tab", # 9 "ctrl+j", # 10 "ctrl+k", # 11 "ctrl+l", # 12 "enter", # 13 "ctrl+n", # 14 "ctrl+o", # 15 "ctrl+p", # 16 "ctrl+q", # 17 "ctrl+r", # 18 "ctrl+s", # 19 "ctrl+t", # 20 "ctrl+u", # 21 "ctrl+v", # 22 "ctrl+w", # 23 "ctrl+x", # 24 "ctrl+y", # 25 "ctrl+z", # 26 "esc", # 27 nil, # 28 nil, # 29 nil, # 30 nil, # 31 "space", # 32 ] + (33..126).map(&:chr) + [ "backspace" # 127 ]
- UTF_8_2_BYTE_BEGIN =
0xc2
- UTF_8_2_BYTE_END =
0xdf
- UTF_8_3_BYTE_BEGIN =
0xe0
- UTF_8_3_BYTE_END =
0xef
- UTF_8_4_BYTE_BEGIN =
0xf0
- UTF_8_4_BYTE_END =
0xf4
Class Method Summary collapse
Class Method Details
.key_string_for(num) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/diakonos/keying.rb', line 110 def self.key_string_for( num ) retval = KEYSTRINGS[ num ] if retval.nil? retval = case num when Curses::KEY_DOWN "down" when Curses::KEY_UP "up" when Curses::KEY_LEFT "left" when Curses::KEY_RIGHT "right" when Curses::KEY_HOME "home" when Curses::KEY_END "end" when Curses::KEY_IC "insert" when Curses::KEY_DC "delete" when Curses::KEY_PPAGE "page-up" when Curses::KEY_NPAGE "page-down" when Curses::KEY_A1 "numpad7" when Curses::KEY_A3 "numpad9" when Curses::KEY_B2 "numpad5" when Curses::KEY_C1 "numpad1" when Curses::KEY_C3 "numpad3" when Curses::KEY_FIND "find" when Curses::KEY_SELECT "select" when Curses::KEY_SUSPEND "suspend" when Curses::KEY_F0..(Curses::KEY_F0 + 24) "f" + ( num - Curses::KEY_F0 ).to_s when CTRL_H "ctrl+h" when Curses::KEY_RESIZE "resize" when RESIZE2 "resize2" end end if retval.nil? && num.class == Integer retval = "keycode#{num}" end retval end |
.keycodes_for(str) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/diakonos/keying.rb', line 42 def self.keycodes_for( str ) retval = case str.downcase when "down" Curses::KEY_DOWN when "up" Curses::KEY_UP when "left" Curses::KEY_LEFT when "right" Curses::KEY_RIGHT when "home" Curses::KEY_HOME when "end" Curses::KEY_END when "insert", "ins" Curses::KEY_IC when "delete", "del" Curses::KEY_DC when "backspace" ::Diakonos::BACKSPACE when "tab" 9 when "pageup", "page-up" Curses::KEY_PPAGE when "pagedown", "page-down" Curses::KEY_NPAGE when "enter", "return" ::Diakonos::ENTER when "numpad7", "keypad7", "kp-7" Curses::KEY_A1 when "numpad9", "keypad9", "kp-9" Curses::KEY_A3 when "numpad5", "keypad5", "kp-5" Curses::KEY_B2 when "numpad1", "keypad1", "kp-1" Curses::KEY_C1 when "numpad3", "keypad3", "kp-3" Curses::KEY_C3 when "escape", "esc" ::Diakonos::ESCAPE when "space" 32 when "ctrl+space" 0 when "find" Curses::KEY_FIND when "select" Curses::KEY_SELECT when "suspend" Curses::KEY_SUSPEND when /^f(\d\d?)$/ Curses::KEY_F0 + $1.to_i when /^ctrl\+[a-gi-z]$/ str.downcase[ -1 ].ord - 96 when /^ctrl\+h$/ ::Diakonos::CTRL_H when /^alt\+(.)$/ [ ::Diakonos::ESCAPE, $1[ 0 ].ord ] when /^ctrl\+alt\+(.)$/, /^alt\+ctrl\+(.)$/ [ ::Diakonos::ESCAPE, str.downcase[ -1 ].ord - 96 ] when /^keycode(\d+)$/ $1.to_i when /^.$/ str[ 0 ].ord end Array( retval ) end |