aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reline
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-07-04 20:58:11 +0900
committeraycabta <aycabta@gmail.com>2019-07-04 20:58:11 +0900
commit6c2b59f9237843a4570d0ab932705b3fa5c18524 (patch)
tree2e0c0b5e2ef5f021cb0f98e3272d91b4b146e3b6 /lib/reline
parentd9f8b88b47c141e7dcbc50eb10812acaeca2a325 (diff)
downloadruby-6c2b59f9237843a4570d0ab932705b3fa5c18524.tar.gz
Support Control- and Meta-
Diffstat (limited to 'lib/reline')
-rw-r--r--lib/reline/config.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb
index 79eb15a1aa..bf77eca5bb 100644
--- a/lib/reline/config.rb
+++ b/lib/reline/config.rb
@@ -5,8 +5,7 @@ class Reline::Config
DEFAULT_PATH = '~/.inputrc'
- # TODO: Control- and Meta-
- KEYSEQ_PATTERN = /\\C-[A-Za-z_]|\\M-[0-9A-Za-z_]|\\C-M-[A-Za-z_]|\\M-C-[A-Za-z_]|\\e|\\[\\\"\'abdfnrtv]|\\\d{1,3}|\\x\h{1,2}|./
+ KEYSEQ_PATTERN = /\\(?:C|Control)-[A-Za-z_]|\\(?:M|Meta)-[0-9A-Za-z_]|\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]|\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]|\\e|\\[\\\"\'abdfnrtv]|\\\d{1,3}|\\x\h{1,2}|./
class InvalidInputrc < RuntimeError
attr_accessor :file, :lineno
@@ -246,9 +245,9 @@ class Reline::Config
def key_notation_to_code(notation)
case notation
- when /\\C-([A-Za-z_])/
+ when /\\(?:C|Control)-([A-Za-z_])/
(1 + $1.downcase.ord - ?a.ord)
- when /\\M-([0-9A-Za-z_])/
+ when /\\(?:M|Meta)-([0-9A-Za-z_])/
modified_key = $1
case $1
when /[0-9]/
@@ -258,7 +257,7 @@ class Reline::Config
when /[a-z]/
?\M-a.bytes.first + (modified_key.ord - ?a.ord)
end
- when /\\C-M-[A-Za-z_]/, /\\M-C-[A-Za-z_]/
+ when /\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]/, /\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]/
# 129 M-^A
when /\\(\d{1,3})/ then $1.to_i(8) # octal
when /\\x(\h{1,2})/ then $1.to_i(16) # hexadecimal