rubyinstaller-build 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +8 -0
  3. data/.gitignore +12 -0
  4. data/.yardopts +7 -0
  5. data/CHANGELOG-2.4.md +166 -0
  6. data/CHANGELOG-2.5.md +87 -0
  7. data/CHANGELOG-2.6.md +62 -0
  8. data/CHANGELOG-2.7.md +22 -0
  9. data/Gemfile +6 -0
  10. data/LICENSE.txt +25 -0
  11. data/README.md +114 -0
  12. data/Rakefile +164 -0
  13. data/appveyor-key.asc.asc +61 -0
  14. data/appveyor.yml +141 -0
  15. data/docker/Dockerfile +50 -0
  16. data/docker/Rakefile +22 -0
  17. data/gems/rubyinstaller-build.yaml +2 -0
  18. data/lib/devkit.rb +3 -0
  19. data/lib/ruby_installer.rb +3 -0
  20. data/lib/ruby_installer/build.rb +23 -0
  21. data/lib/ruby_installer/build/ca_cert_file.rb +66 -0
  22. data/lib/ruby_installer/build/colors.rb +45 -0
  23. data/lib/ruby_installer/build/components/01_msys2.rb +97 -0
  24. data/lib/ruby_installer/build/components/02_pacman_update.rb +35 -0
  25. data/lib/ruby_installer/build/components/03_dev_tools.rb +68 -0
  26. data/lib/ruby_installer/build/components/base.rb +58 -0
  27. data/lib/ruby_installer/build/components_installer.rb +53 -0
  28. data/lib/ruby_installer/build/dll_directory.rb +97 -0
  29. data/lib/ruby_installer/build/erb_compiler.rb +61 -0
  30. data/lib/ruby_installer/build/gem_version.rb +5 -0
  31. data/lib/ruby_installer/build/gems.rb +74 -0
  32. data/lib/ruby_installer/build/msys2_installation.rb +280 -0
  33. data/lib/ruby_installer/build/openstruct.rb +29 -0
  34. data/lib/ruby_installer/build/release.rb +120 -0
  35. data/lib/ruby_installer/build/singleton.rb +45 -0
  36. data/lib/ruby_installer/build/task.rb +20 -0
  37. data/lib/ruby_installer/build/utils.rb +110 -0
  38. data/lib/ruby_installer/runtime.rb +18 -0
  39. data/lib/ruby_installer/runtime/ridk.rb +195 -0
  40. data/packages/ri-msys/Rakefile +72 -0
  41. data/packages/ri-msys/recipes/sandbox/70-add-msys2-installation.rake +18 -0
  42. data/packages/ri/Rakefile +60 -0
  43. data/recipes/archive-7z/10-define-variables.rake +2 -0
  44. data/recipes/archive-7z/70-create-archive.rake +10 -0
  45. data/recipes/archive-7z/90-define-main-task.rake +2 -0
  46. data/recipes/installer-inno/10-define-variables.rake +2 -0
  47. data/recipes/installer-inno/50-generate-filelist.rake +28 -0
  48. data/recipes/installer-inno/60-generate-iss-file.rake +8 -0
  49. data/recipes/installer-inno/70-run-iscc.rake +19 -0
  50. data/recipes/installer-inno/90-define-main-task.rake +2 -0
  51. data/recipes/installer-inno/events.iss +88 -0
  52. data/recipes/installer-inno/images/fake.bmp +0 -0
  53. data/recipes/installer-inno/images/wizard-large.bmp +0 -0
  54. data/recipes/installer-inno/images/wizard-logo.bmp +0 -0
  55. data/recipes/installer-inno/ri_gui.iss +286 -0
  56. data/recipes/installer-inno/rubyinstaller.iss.erb +157 -0
  57. data/recipes/installer-inno/util.iss +271 -0
  58. data/recipes/msys2/10-define-variables.rake +6 -0
  59. data/recipes/msys2/30-download-msys2-base.rake +4 -0
  60. data/recipes/msys2/40-extract-msys2-base.rake +9 -0
  61. data/recipes/msys2/50-init-msys.rake +8 -0
  62. data/recipes/msys2/50-install-components.rake +19 -0
  63. data/recipes/msys2/90-define-main-task.rake +2 -0
  64. data/recipes/sandbox/10-define-variables.rake +6 -0
  65. data/recipes/sandbox/20-add-runtime-files.rake +15 -0
  66. data/recipes/sandbox/20-define-import-files.rake +16 -0
  67. data/recipes/sandbox/20-define-import-readline.rake +28 -0
  68. data/recipes/sandbox/20-extend-irb.rake +13 -0
  69. data/recipes/sandbox/40-fix-rake-shebang.rake +6 -0
  70. data/recipes/sandbox/40-generate-rake-cmd.rake +7 -0
  71. data/recipes/sandbox/40-generate-version-file.rake +20 -0
  72. data/recipes/sandbox/50-do-import-files.rake +17 -0
  73. data/recipes/sandbox/50-gather-sandbox-files.rake +6 -0
  74. data/recipes/sandbox/60-define-gem-wrappers.rake +5 -0
  75. data/recipes/sandbox/60-side-by-side-assembly.rake +81 -0
  76. data/recipes/sandbox/70-add-gem-bin-wrappers.rake +10 -0
  77. data/recipes/sandbox/70-install-gems.rake +11 -0
  78. data/recipes/sandbox/80-copy-msys-files.rake +8 -0
  79. data/recipes/sandbox/90-define-main-task.rake +2 -0
  80. data/recipes/sandbox/LICENSE.txt +24 -0
  81. data/recipes/sandbox/rubyinstaller-2.3.4-x64.files +4 -0
  82. data/recipes/sandbox/rubyinstaller-2.3.4-x86.files +4 -0
  83. data/recipes/sandbox/rubyinstaller-2.3.4.files +43 -0
  84. data/recipes/sandbox/rubyinstaller-2.4.10-x64.files +4 -0
  85. data/recipes/sandbox/rubyinstaller-2.4.10-x86.files +4 -0
  86. data/recipes/sandbox/rubyinstaller-2.4.10.files +44 -0
  87. data/recipes/sandbox/rubyinstaller-2.5.8-x64.files +6 -0
  88. data/recipes/sandbox/rubyinstaller-2.5.8-x86.files +6 -0
  89. data/recipes/sandbox/rubyinstaller-2.5.8.files +33 -0
  90. data/recipes/sandbox/rubyinstaller-2.6.6-x64.files +6 -0
  91. data/recipes/sandbox/rubyinstaller-2.6.6-x86.files +6 -0
  92. data/recipes/sandbox/rubyinstaller-2.6.6.files +35 -0
  93. data/recipes/sandbox/rubyinstaller-2.7.1-x64.files +6 -0
  94. data/recipes/sandbox/rubyinstaller-2.7.1-x86.files +6 -0
  95. data/recipes/sandbox/rubyinstaller-2.7.1.files +35 -0
  96. data/recipes/sandbox/rubyinstaller-head-x64.files +6 -0
  97. data/recipes/sandbox/rubyinstaller-head-x86.files +6 -0
  98. data/recipes/sandbox/rubyinstaller-head.files +35 -0
  99. data/recipes/unpack/10-define-variables.rake +5 -0
  100. data/recipes/unpack/20-define-msys-packages.rake +1 -0
  101. data/recipes/unpack/30-add-ri2-repo-to-msys.rake +41 -0
  102. data/recipes/unpack/50-install-msys-packages.rake +28 -0
  103. data/recipes/unpack/90-define-main-task.rake +2 -0
  104. data/recipes/unpack/appveyor-repo-key.asc +29 -0
  105. data/resources/files/irbrc_predefiner.rb +21 -0
  106. data/resources/files/operating_system.rb +21 -0
  107. data/resources/files/readline.rb +17 -0
  108. data/resources/files/reline.rb +437 -0
  109. data/resources/files/reline/ansi.rb +177 -0
  110. data/resources/files/reline/config.rb +297 -0
  111. data/resources/files/reline/general_io.rb +75 -0
  112. data/resources/files/reline/history.rb +56 -0
  113. data/resources/files/reline/key_actor.rb +7 -0
  114. data/resources/files/reline/key_actor/base.rb +7 -0
  115. data/resources/files/reline/key_actor/emacs.rb +517 -0
  116. data/resources/files/reline/key_actor/vi_command.rb +518 -0
  117. data/resources/files/reline/key_actor/vi_insert.rb +517 -0
  118. data/resources/files/reline/key_stroke.rb +53 -0
  119. data/resources/files/reline/kill_ring.rb +113 -0
  120. data/resources/files/reline/line_editor.rb +2231 -0
  121. data/resources/files/reline/unicode.rb +527 -0
  122. data/resources/files/reline/unicode/east_asian_width.rb +1145 -0
  123. data/resources/files/reline/version.rb +3 -0
  124. data/resources/files/reline/windows.rb +273 -0
  125. data/resources/files/ridk.cmd +39 -0
  126. data/resources/files/ridk.ps1 +26 -0
  127. data/resources/files/ridk_use/ridk.cmd +13 -0
  128. data/resources/files/ridk_use/ridk.ps1 +17 -0
  129. data/resources/files/ridk_use/ridk_use.rb +221 -0
  130. data/resources/files/setrbvars.cmd +14 -0
  131. data/resources/icons/ruby-doc.ico +0 -0
  132. data/resources/ssl/README-SSL.md +37 -0
  133. data/resources/ssl/c_rehash.rb +167 -0
  134. data/resources/ssl/cacert.pem +4105 -0
  135. data/rubyinstaller-build.gemspec +28 -0
  136. metadata +226 -0
@@ -0,0 +1,177 @@
1
+ require 'io/console'
2
+
3
+ class Reline::ANSI
4
+ def self.encoding
5
+ Encoding.default_external
6
+ end
7
+
8
+ def self.win?
9
+ false
10
+ end
11
+
12
+ RAW_KEYSTROKE_CONFIG = {
13
+ # Console (80x25)
14
+ [27, 91, 49, 126] => :ed_move_to_beg, # Home
15
+ [27, 91, 52, 126] => :ed_move_to_end, # End
16
+ [27, 91, 51, 126] => :key_delete, # Del
17
+ [27, 91, 65] => :ed_prev_history, # ↑
18
+ [27, 91, 66] => :ed_next_history, # ↓
19
+ [27, 91, 67] => :ed_next_char, # →
20
+ [27, 91, 68] => :ed_prev_char, # ←
21
+
22
+ # KDE
23
+ [27, 91, 72] => :ed_move_to_beg, # Home
24
+ [27, 91, 70] => :ed_move_to_end, # End
25
+ # Del is 0x08
26
+ [27, 71, 65] => :ed_prev_history, # ↑
27
+ [27, 71, 66] => :ed_next_history, # ↓
28
+ [27, 71, 67] => :ed_next_char, # →
29
+ [27, 71, 68] => :ed_prev_char, # ←
30
+
31
+ # GNOME
32
+ [27, 79, 72] => :ed_move_to_beg, # Home
33
+ [27, 79, 70] => :ed_move_to_end, # End
34
+ # Del is 0x08
35
+ # Arrow keys are the same of KDE
36
+
37
+ # others
38
+ [27, 32] => :em_set_mark, # M-<space>
39
+ [24, 24] => :em_exchange_mark, # C-x C-x TODO also add Windows
40
+ [27, 91, 49, 59, 53, 67] => :em_next_word, # Ctrl+→
41
+ [27, 91, 49, 59, 53, 68] => :ed_prev_word, # Ctrl+←
42
+
43
+ [27, 79, 65] => :ed_prev_history, # ↑
44
+ [27, 79, 66] => :ed_next_history, # ↓
45
+ [27, 79, 67] => :ed_next_char, # →
46
+ [27, 79, 68] => :ed_prev_char, # ←
47
+ }
48
+
49
+ @@input = STDIN
50
+ def self.input=(val)
51
+ @@input = val
52
+ end
53
+
54
+ @@output = STDOUT
55
+ def self.output=(val)
56
+ @@output = val
57
+ end
58
+
59
+ @@buf = []
60
+ def self.getc
61
+ unless @@buf.empty?
62
+ return @@buf.shift
63
+ end
64
+ c = @@input.raw(intr: true, &:getbyte)
65
+ (c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
66
+ end
67
+
68
+ def self.ungetc(c)
69
+ @@buf.unshift(c)
70
+ end
71
+
72
+ def self.retrieve_keybuffer
73
+ begin
74
+ result = select([@@input], [], [], 0.001)
75
+ return if result.nil?
76
+ str = @@input.read_nonblock(1024)
77
+ str.bytes.each do |c|
78
+ @@buf.push(c)
79
+ end
80
+ rescue EOFError
81
+ end
82
+ end
83
+
84
+ def self.get_screen_size
85
+ s = @@input.winsize
86
+ return s if s[0] > 0 && s[1] > 0
87
+ s = [ENV["LINES"].to_i, ENV["COLUMNS"].to_i]
88
+ return s if s[0] > 0 && s[1] > 0
89
+ [24, 80]
90
+ rescue Errno::ENOTTY
91
+ [24, 80]
92
+ end
93
+
94
+ def self.set_screen_size(rows, columns)
95
+ @@input.winsize = [rows, columns]
96
+ self
97
+ rescue Errno::ENOTTY
98
+ self
99
+ end
100
+
101
+ def self.cursor_pos
102
+ begin
103
+ res = ''
104
+ m = nil
105
+ @@input.raw do |stdin|
106
+ @@output << "\e[6n"
107
+ @@output.flush
108
+ while (c = stdin.getc) != 'R'
109
+ res << c if c
110
+ end
111
+ m = res.match(/\e\[(?<row>\d+);(?<column>\d+)/)
112
+ (m.pre_match + m.post_match).chars.reverse_each do |ch|
113
+ stdin.ungetc ch
114
+ end
115
+ end
116
+ column = m[:column].to_i - 1
117
+ row = m[:row].to_i - 1
118
+ rescue Errno::ENOTTY
119
+ buf = @@output.pread(@@output.pos, 0)
120
+ row = buf.count("\n")
121
+ column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
122
+ end
123
+ Reline::CursorPos.new(column, row)
124
+ end
125
+
126
+ def self.move_cursor_column(x)
127
+ @@output.write "\e[#{x + 1}G"
128
+ end
129
+
130
+ def self.move_cursor_up(x)
131
+ if x > 0
132
+ @@output.write "\e[#{x}A" if x > 0
133
+ elsif x < 0
134
+ move_cursor_down(-x)
135
+ end
136
+ end
137
+
138
+ def self.move_cursor_down(x)
139
+ if x > 0
140
+ @@output.write "\e[#{x}B" if x > 0
141
+ elsif x < 0
142
+ move_cursor_up(-x)
143
+ end
144
+ end
145
+
146
+ def self.erase_after_cursor
147
+ @@output.write "\e[K"
148
+ end
149
+
150
+ def self.scroll_down(x)
151
+ return if x.zero?
152
+ @@output.write "\e[#{x}S"
153
+ end
154
+
155
+ def self.clear_screen
156
+ @@output.write "\e[2J"
157
+ @@output.write "\e[1;1H"
158
+ end
159
+
160
+ @@old_winch_handler = nil
161
+ def self.set_winch_handler(&handler)
162
+ @@old_winch_handler = Signal.trap('WINCH', &handler)
163
+ end
164
+
165
+ def self.prep
166
+ retrieve_keybuffer
167
+ int_handle = Signal.trap('INT', 'IGNORE')
168
+ Signal.trap('INT', int_handle)
169
+ nil
170
+ end
171
+
172
+ def self.deprep(otio)
173
+ int_handle = Signal.trap('INT', 'IGNORE')
174
+ Signal.trap('INT', int_handle)
175
+ Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
176
+ end
177
+ end
@@ -0,0 +1,297 @@
1
+ require 'pathname'
2
+
3
+ class Reline::Config
4
+ attr_reader :test_mode
5
+
6
+ DEFAULT_PATH = '~/.inputrc'
7
+
8
+ 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}|./
9
+
10
+ class InvalidInputrc < RuntimeError
11
+ attr_accessor :file, :lineno
12
+ end
13
+
14
+ VARIABLE_NAMES = %w{
15
+ bind-tty-special-chars
16
+ blink-matching-paren
17
+ byte-oriented
18
+ completion-ignore-case
19
+ convert-meta
20
+ disable-completion
21
+ enable-keypad
22
+ expand-tilde
23
+ history-preserve-point
24
+ history-size
25
+ horizontal-scroll-mode
26
+ input-meta
27
+ keyseq-timeout
28
+ mark-directories
29
+ mark-modified-lines
30
+ mark-symlinked-directories
31
+ match-hidden-files
32
+ meta-flag
33
+ output-meta
34
+ page-completions
35
+ prefer-visible-bell
36
+ print-completions-horizontally
37
+ show-all-if-ambiguous
38
+ show-all-if-unmodified
39
+ visible-stats
40
+ }
41
+ VARIABLE_NAME_SYMBOLS = VARIABLE_NAMES.map { |v| :"#{v.tr(?-, ?_)}" }
42
+ VARIABLE_NAME_SYMBOLS.each do |v|
43
+ attr_accessor v
44
+ end
45
+
46
+ def initialize
47
+ @additional_key_bindings = {} # from inputrc
48
+ @default_key_bindings = {} # environment-dependent
49
+ @skip_section = nil
50
+ @if_stack = nil
51
+ @editing_mode_label = :emacs
52
+ @keymap_label = :emacs
53
+ @key_actors = {}
54
+ @key_actors[:emacs] = Reline::KeyActor::Emacs.new
55
+ @key_actors[:vi_insert] = Reline::KeyActor::ViInsert.new
56
+ @key_actors[:vi_command] = Reline::KeyActor::ViCommand.new
57
+ @history_size = 500
58
+ @keyseq_timeout = 500
59
+ @test_mode = false
60
+ end
61
+
62
+ def reset
63
+ if editing_mode_is?(:vi_command)
64
+ @editing_mode_label = :vi_insert
65
+ end
66
+ @additional_key_bindings = {}
67
+ @default_key_bindings = {}
68
+ end
69
+
70
+ def editing_mode
71
+ @key_actors[@editing_mode_label]
72
+ end
73
+
74
+ def editing_mode=(val)
75
+ @editing_mode_label = val
76
+ end
77
+
78
+ def editing_mode_is?(*val)
79
+ (val.respond_to?(:any?) ? val : [val]).any?(@editing_mode_label)
80
+ end
81
+
82
+ def keymap
83
+ @key_actors[@keymap_label]
84
+ end
85
+
86
+ def inputrc_path
87
+ case ENV['INPUTRC']
88
+ when nil, ''
89
+ DEFAULT_PATH
90
+ else
91
+ ENV['INPUTRC']
92
+ end
93
+ end
94
+
95
+ def read(file = nil)
96
+ file ||= File.expand_path(inputrc_path)
97
+ begin
98
+ if file.respond_to?(:readlines)
99
+ lines = file.readlines
100
+ else
101
+ lines = File.readlines(file)
102
+ end
103
+ rescue Errno::ENOENT
104
+ return nil
105
+ end
106
+
107
+ read_lines(lines, file)
108
+ self
109
+ rescue InvalidInputrc => e
110
+ warn e.message
111
+ nil
112
+ end
113
+
114
+ def key_bindings
115
+ # override @default_key_bindings with @additional_key_bindings
116
+ @default_key_bindings.merge(@additional_key_bindings)
117
+ end
118
+
119
+ def add_default_key_binding(keystroke, target)
120
+ @default_key_bindings[keystroke] = target
121
+ end
122
+
123
+ def reset_default_key_bindings
124
+ @default_key_bindings = {}
125
+ end
126
+
127
+ def read_lines(lines, file = nil)
128
+ conditions = [@skip_section, @if_stack]
129
+ @skip_section = nil
130
+ @if_stack = []
131
+
132
+ lines.each_with_index do |line, no|
133
+ next if line.match(/\A\s*#/)
134
+
135
+ no += 1
136
+
137
+ line = line.chomp.lstrip
138
+ if line.start_with?('$')
139
+ handle_directive(line[1..-1], file, no)
140
+ next
141
+ end
142
+
143
+ next if @skip_section
144
+
145
+ case line
146
+ when /^set +([^ ]+) +([^ ]+)/i
147
+ var, value = $1.downcase, $2.downcase
148
+ bind_variable(var, value)
149
+ next
150
+ when /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/o
151
+ key, func_name = $1, $2
152
+ keystroke, func = bind_key(key, func_name)
153
+ next unless keystroke
154
+ @additional_key_bindings[keystroke] = func
155
+ end
156
+ end
157
+ unless @if_stack.empty?
158
+ raise InvalidInputrc, "#{file}:#{@if_stack.last[1]}: unclosed if"
159
+ end
160
+ ensure
161
+ @skip_section, @if_stack = conditions
162
+ end
163
+
164
+ def handle_directive(directive, file, no)
165
+ directive, args = directive.split(' ')
166
+ case directive
167
+ when 'if'
168
+ condition = false
169
+ case args
170
+ when 'mode'
171
+ when 'term'
172
+ when 'version'
173
+ else # application name
174
+ condition = true if args == 'Ruby'
175
+ condition = true if args == 'Reline'
176
+ end
177
+ @if_stack << [file, no, @skip_section]
178
+ @skip_section = !condition
179
+ when 'else'
180
+ if @if_stack.empty?
181
+ raise InvalidInputrc, "#{file}:#{no}: unmatched else"
182
+ end
183
+ @skip_section = !@skip_section
184
+ when 'endif'
185
+ if @if_stack.empty?
186
+ raise InvalidInputrc, "#{file}:#{no}: unmatched endif"
187
+ end
188
+ @skip_section = @if_stack.pop
189
+ when 'include'
190
+ read(args)
191
+ end
192
+ end
193
+
194
+ def bind_variable(name, value)
195
+ case name
196
+ when 'history-size'
197
+ @history_size = value.to_i
198
+ when 'bell-style'
199
+ @bell_style =
200
+ case value
201
+ when 'none', 'off'
202
+ :none
203
+ when 'audible', 'on'
204
+ :audible
205
+ when 'visible'
206
+ :visible
207
+ else
208
+ :audible
209
+ end
210
+ when 'comment-begin'
211
+ @comment_begin = value.dup
212
+ when 'completion-query-items'
213
+ @completion_query_items = value.to_i
214
+ when 'isearch-terminators'
215
+ @isearch_terminators = instance_eval(value)
216
+ when 'editing-mode'
217
+ case value
218
+ when 'emacs'
219
+ @editing_mode_label = :emacs
220
+ @keymap_label = :emacs
221
+ when 'vi'
222
+ @editing_mode_label = :vi_insert
223
+ @keymap_label = :vi_insert
224
+ end
225
+ when 'keymap'
226
+ case value
227
+ when 'emacs', 'emacs-standard', 'emacs-meta', 'emacs-ctlx'
228
+ @keymap_label = :emacs
229
+ when 'vi', 'vi-move', 'vi-command'
230
+ @keymap_label = :vi_command
231
+ when 'vi-insert'
232
+ @keymap_label = :vi_insert
233
+ end
234
+ when 'keyseq-timeout'
235
+ @keyseq_timeout = value.to_i
236
+ when *VARIABLE_NAMES then
237
+ variable_name = :"@#{name.tr(?-, ?_)}"
238
+ instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on')
239
+ end
240
+ end
241
+
242
+ def bind_key(key, func_name)
243
+ if key =~ /\A"(.*)"\z/
244
+ keyseq = parse_keyseq($1)
245
+ else
246
+ keyseq = nil
247
+ end
248
+ if func_name =~ /"(.*)"/
249
+ func = parse_keyseq($1)
250
+ else
251
+ func = func_name.tr(?-, ?_).to_sym # It must be macro.
252
+ end
253
+ [keyseq, func]
254
+ end
255
+
256
+ def key_notation_to_code(notation)
257
+ case notation
258
+ when /\\(?:C|Control)-([A-Za-z_])/
259
+ (1 + $1.downcase.ord - ?a.ord)
260
+ when /\\(?:M|Meta)-([0-9A-Za-z_])/
261
+ modified_key = $1
262
+ case $1
263
+ when /[0-9]/
264
+ ?\M-0.bytes.first + (modified_key.ord - ?0.ord)
265
+ when /[A-Z]/
266
+ ?\M-A.bytes.first + (modified_key.ord - ?A.ord)
267
+ when /[a-z]/
268
+ ?\M-a.bytes.first + (modified_key.ord - ?a.ord)
269
+ end
270
+ when /\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]/, /\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]/
271
+ # 129 M-^A
272
+ when /\\(\d{1,3})/ then $1.to_i(8) # octal
273
+ when /\\x(\h{1,2})/ then $1.to_i(16) # hexadecimal
274
+ when "\\e" then ?\e.ord
275
+ when "\\\\" then ?\\.ord
276
+ when "\\\"" then ?".ord
277
+ when "\\'" then ?'.ord
278
+ when "\\a" then ?\a.ord
279
+ when "\\b" then ?\b.ord
280
+ when "\\d" then ?\d.ord
281
+ when "\\f" then ?\f.ord
282
+ when "\\n" then ?\n.ord
283
+ when "\\r" then ?\r.ord
284
+ when "\\t" then ?\t.ord
285
+ when "\\v" then ?\v.ord
286
+ else notation.ord
287
+ end
288
+ end
289
+
290
+ def parse_keyseq(str)
291
+ ret = []
292
+ str.scan(KEYSEQ_PATTERN) do
293
+ ret << key_notation_to_code($&)
294
+ end
295
+ ret
296
+ end
297
+ end