lib/ruco/keyboard.rb in ruco-0.0.52 vs lib/ruco/keyboard.rb in ruco-0.0.53
- old
+ new
@@ -1,8 +1,9 @@
require 'curses'
class Keyboard
+ SWAP_DELETE = (ENV['TERM'] == 'xterm-color')
MAX_CHAR = 255
ENTER = 13
ESCAPE = 27
IS_18 = RUBY_VERSION =~ /^1\.8/
SEQUENCE_TIMEOUT = 0.01
@@ -78,11 +79,11 @@
# modify
when 9 then :tab
when 353 then :"Shift+tab"
when ENTER then :enter # shadows Ctrl+m
- when 263, 127 then :backspace # ubuntu / mac
- when Curses::KEY_DC then :delete
+ when 263, (SWAP_DELETE ? Curses::KEY_DC : 127) then :backspace
+ when '^[3~', (SWAP_DELETE ? 127 : Curses::KEY_DC) then :delete
# misc
when 0 then :"Ctrl+space"
when 1..26 then :"Ctrl+#{A_TO_Z[key-1]}"
when ESCAPE then :escape