reline 0.5.1 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47d262bd9b8ab9b3fb314863af068783c217d53177f947372eb979df2ceaf3cf
4
- data.tar.gz: 8112b4441c7946a697adf3d16ec79531fc744fac132ea3cca89ef16b9b6518d3
3
+ metadata.gz: 45922535b3972631020c6b33bc6b88fd400062fb2c0820ab95ab991704c1fc42
4
+ data.tar.gz: 53f36ad5e7e196ba34a22990c32b38556653b7384bd99108a791d1b4c7cd3b36
5
5
  SHA512:
6
- metadata.gz: 22570f23bfa74602ef627bf977982304b0e5849cbc52abb33f321a32b3860348eabb3efd88bfcfa6b46032433a012813a0fa9aa70422438d0f0694a724ca3055
7
- data.tar.gz: 6a30e3c69c1a64149a5cd0517e3c46c6dfb9d724532ded4ab4475c6b595bcf5cdf6b6ffd1b9d32156b8a8a447885bb918d35f78be90934a2e2513f87fdf40bb0
6
+ metadata.gz: eb1b50add8dc60baeefd1fecce83abbaf0e134c16c30ca7fd268efe46d364638280bd2a16100e54be6dbf691bc8a9d4220c53210233a06a0278361c07bd5a56f
7
+ data.tar.gz: 5ed4f57373cd6e9329de58b9361037e4f8e510020c0ba59970de5733a8c8f4b5c004b871d8e21f013ee065daed9b55f433142529b5e4039276a0f0adbc00c4d9
data/lib/reline/ansi.rb CHANGED
@@ -284,7 +284,7 @@ class Reline::ANSI
284
284
  buf = @@output.pread(@@output.pos, 0)
285
285
  row = buf.count("\n")
286
286
  column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
287
- rescue Errno::ESPIPE
287
+ rescue Errno::ESPIPE, IOError
288
288
  # Just returns column 1 for ambiguous width because this I/O is not
289
289
  # tty and can't seek.
290
290
  row = 0
data/lib/reline/config.rb CHANGED
@@ -53,8 +53,6 @@ class Reline::Config
53
53
  @additional_key_bindings[:vi_insert] = {}
54
54
  @additional_key_bindings[:vi_command] = {}
55
55
  @oneshot_key_bindings = {}
56
- @skip_section = nil
57
- @if_stack = nil
58
56
  @editing_mode_label = :emacs
59
57
  @keymap_label = :emacs
60
58
  @keymap_prefix = []
@@ -190,9 +188,7 @@ class Reline::Config
190
188
  end
191
189
  end
192
190
  end
193
- conditions = [@skip_section, @if_stack]
194
- @skip_section = nil
195
- @if_stack = []
191
+ if_stack = []
196
192
 
197
193
  lines.each_with_index do |line, no|
198
194
  next if line.match(/\A\s*#/)
@@ -201,11 +197,11 @@ class Reline::Config
201
197
 
202
198
  line = line.chomp.lstrip
203
199
  if line.start_with?('$')
204
- handle_directive(line[1..-1], file, no)
200
+ handle_directive(line[1..-1], file, no, if_stack)
205
201
  next
206
202
  end
207
203
 
208
- next if @skip_section
204
+ next if if_stack.any? { |_no, skip| skip }
209
205
 
210
206
  case line
211
207
  when /^set +([^ ]+) +([^ ]+)/i
@@ -214,43 +210,47 @@ class Reline::Config
214
210
  next
215
211
  when /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/o
216
212
  key, func_name = $1, $2
213
+ func_name = func_name.split.first
217
214
  keystroke, func = bind_key(key, func_name)
218
215
  next unless keystroke
219
216
  @additional_key_bindings[@keymap_label][@keymap_prefix + keystroke] = func
220
217
  end
221
218
  end
222
- unless @if_stack.empty?
223
- raise InvalidInputrc, "#{file}:#{@if_stack.last[1]}: unclosed if"
219
+ unless if_stack.empty?
220
+ raise InvalidInputrc, "#{file}:#{if_stack.last[0]}: unclosed if"
224
221
  end
225
- ensure
226
- @skip_section, @if_stack = conditions
227
222
  end
228
223
 
229
- def handle_directive(directive, file, no)
224
+ def handle_directive(directive, file, no, if_stack)
230
225
  directive, args = directive.split(' ')
231
226
  case directive
232
227
  when 'if'
233
228
  condition = false
234
229
  case args
235
- when 'mode'
230
+ when /^mode=(vi|emacs)$/i
231
+ mode = $1.downcase
232
+ # NOTE: mode=vi means vi-insert mode
233
+ mode = 'vi_insert' if mode == 'vi'
234
+ if @editing_mode_label == mode.to_sym
235
+ condition = true
236
+ end
236
237
  when 'term'
237
238
  when 'version'
238
239
  else # application name
239
240
  condition = true if args == 'Ruby'
240
241
  condition = true if args == 'Reline'
241
242
  end
242
- @if_stack << [file, no, @skip_section]
243
- @skip_section = !condition
243
+ if_stack << [no, !condition]
244
244
  when 'else'
245
- if @if_stack.empty?
245
+ if if_stack.empty?
246
246
  raise InvalidInputrc, "#{file}:#{no}: unmatched else"
247
247
  end
248
- @skip_section = !@skip_section
248
+ if_stack.last[1] = !if_stack.last[1]
249
249
  when 'endif'
250
- if @if_stack.empty?
250
+ if if_stack.empty?
251
251
  raise InvalidInputrc, "#{file}:#{no}: unmatched endif"
252
252
  end
253
- @skip_section = @if_stack.pop
253
+ if_stack.pop
254
254
  when 'include'
255
255
  read(File.expand_path(args))
256
256
  end
@@ -49,13 +49,13 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
49
49
  # 23 ^W
50
50
  :em_kill_region,
51
51
  # 24 ^X
52
- :ed_sequence_lead_in,
52
+ :ed_unassigned,
53
53
  # 25 ^Y
54
54
  :em_yank,
55
55
  # 26 ^Z
56
56
  :ed_ignore,
57
57
  # 27 ^[
58
- :em_meta_next,
58
+ :ed_unassigned,
59
59
  # 28 ^\
60
60
  :ed_ignore,
61
61
  # 29 ^]
@@ -319,9 +319,9 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
319
319
  # 158 M-^^
320
320
  :ed_unassigned,
321
321
  # 159 M-^_
322
- :em_copy_prev_word,
323
- # 160 M-SPACE
324
322
  :ed_unassigned,
323
+ # 160 M-SPACE
324
+ :em_set_mark,
325
325
  # 161 M-!
326
326
  :ed_unassigned,
327
327
  # 162 M-"
@@ -415,7 +415,7 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
415
415
  # 206 M-N
416
416
  :vi_search_next,
417
417
  # 207 M-O
418
- :ed_sequence_lead_in,
418
+ :ed_unassigned,
419
419
  # 208 M-P
420
420
  :vi_search_prev,
421
421
  # 209 M-Q
@@ -431,15 +431,15 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
431
431
  # 214 M-V
432
432
  :ed_unassigned,
433
433
  # 215 M-W
434
- :em_copy_region,
434
+ :ed_unassigned,
435
435
  # 216 M-X
436
- :ed_command,
437
- # 217 M-Y
438
436
  :ed_unassigned,
437
+ # 217 M-Y
438
+ :em_yank_pop,
439
439
  # 218 M-Z
440
440
  :ed_unassigned,
441
441
  # 219 M-[
442
- :ed_sequence_lead_in,
442
+ :ed_unassigned,
443
443
  # 220 M-\
444
444
  :ed_unassigned,
445
445
  # 221 M-]
@@ -495,9 +495,9 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
495
495
  # 246 M-v
496
496
  :ed_unassigned,
497
497
  # 247 M-w
498
- :em_copy_region,
498
+ :ed_unassigned,
499
499
  # 248 M-x
500
- :ed_command,
500
+ :ed_unassigned,
501
501
  # 249 M-y
502
502
  :ed_unassigned,
503
503
  # 250 M-z
@@ -17,7 +17,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
17
17
  # 7 ^G
18
18
  :ed_unassigned,
19
19
  # 8 ^H
20
- :ed_unassigned,
20
+ :ed_prev_char,
21
21
  # 9 ^I
22
22
  :ed_unassigned,
23
23
  # 10 ^J
@@ -41,7 +41,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
41
41
  # 19 ^S
42
42
  :ed_ignore,
43
43
  # 20 ^T
44
- :ed_unassigned,
44
+ :ed_transpose_chars,
45
45
  # 21 ^U
46
46
  :vi_kill_line_prev,
47
47
  # 22 ^V
@@ -51,7 +51,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
51
51
  # 24 ^X
52
52
  :ed_unassigned,
53
53
  # 25 ^Y
54
- :ed_unassigned,
54
+ :em_yank,
55
55
  # 26 ^Z
56
56
  :ed_unassigned,
57
57
  # 27 ^[
@@ -75,7 +75,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
75
75
  # 36 $
76
76
  :ed_move_to_end,
77
77
  # 37 %
78
- :vi_match,
78
+ :ed_unassigned,
79
79
  # 38 &
80
80
  :ed_unassigned,
81
81
  # 39 '
@@ -89,11 +89,11 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
89
89
  # 43 +
90
90
  :ed_next_history,
91
91
  # 44 ,
92
- :vi_repeat_prev_char,
92
+ :ed_unassigned,
93
93
  # 45 -
94
94
  :ed_prev_history,
95
95
  # 46 .
96
- :vi_redo,
96
+ :ed_unassigned,
97
97
  # 47 /
98
98
  :vi_search_prev,
99
99
  # 48 0
@@ -117,9 +117,9 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
117
117
  # 57 9
118
118
  :ed_argument_digit,
119
119
  # 58 :
120
- :ed_command,
120
+ :ed_unassigned,
121
121
  # 59 ;
122
- :vi_repeat_next_char,
122
+ :ed_unassigned,
123
123
  # 60 <
124
124
  :ed_unassigned,
125
125
  # 61 =
@@ -157,21 +157,21 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
157
157
  # 77 M
158
158
  :ed_unassigned,
159
159
  # 78 N
160
- :vi_repeat_search_prev,
160
+ :ed_unassigned,
161
161
  # 79 O
162
- :ed_sequence_lead_in,
162
+ :ed_unassigned,
163
163
  # 80 P
164
164
  :vi_paste_prev,
165
165
  # 81 Q
166
166
  :ed_unassigned,
167
167
  # 82 R
168
- :vi_replace_mode,
168
+ :ed_unassigned,
169
169
  # 83 S
170
- :vi_substitute_line,
170
+ :ed_unassigned,
171
171
  # 84 T
172
172
  :vi_to_prev_char,
173
173
  # 85 U
174
- :vi_undo_line,
174
+ :ed_unassigned,
175
175
  # 86 V
176
176
  :ed_unassigned,
177
177
  # 87 W
@@ -179,11 +179,11 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
179
179
  # 88 X
180
180
  :ed_delete_prev_char,
181
181
  # 89 Y
182
- :vi_yank_end,
182
+ :ed_unassigned,
183
183
  # 90 Z
184
184
  :ed_unassigned,
185
185
  # 91 [
186
- :ed_sequence_lead_in,
186
+ :ed_unassigned,
187
187
  # 92 \
188
188
  :ed_unassigned,
189
189
  # 93 ]
@@ -191,7 +191,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
191
191
  # 94 ^
192
192
  :vi_first_print,
193
193
  # 95 _
194
- :vi_history_word,
194
+ :ed_unassigned,
195
195
  # 96 `
196
196
  :ed_unassigned,
197
197
  # 97 a
@@ -221,7 +221,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
221
221
  # 109 m
222
222
  :ed_unassigned,
223
223
  # 110 n
224
- :vi_repeat_search_next,
224
+ :ed_unassigned,
225
225
  # 111 o
226
226
  :ed_unassigned,
227
227
  # 112 p
@@ -231,11 +231,11 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
231
231
  # 114 r
232
232
  :vi_replace_char,
233
233
  # 115 s
234
- :vi_substitute_char,
234
+ :ed_unassigned,
235
235
  # 116 t
236
236
  :vi_to_next_char,
237
237
  # 117 u
238
- :vi_undo,
238
+ :ed_unassigned,
239
239
  # 118 v
240
240
  :vi_histedit,
241
241
  # 119 w
@@ -253,9 +253,9 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
253
253
  # 125 }
254
254
  :ed_unassigned,
255
255
  # 126 ~
256
- :vi_change_case,
257
- # 127 ^?
258
256
  :ed_unassigned,
257
+ # 127 ^?
258
+ :em_delete_prev_char,
259
259
  # 128 M-^@
260
260
  :ed_unassigned,
261
261
  # 129 M-^A
@@ -415,7 +415,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
415
415
  # 206 M-N
416
416
  :ed_unassigned,
417
417
  # 207 M-O
418
- :ed_sequence_lead_in,
418
+ :ed_unassigned,
419
419
  # 208 M-P
420
420
  :ed_unassigned,
421
421
  # 209 M-Q
@@ -439,7 +439,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
439
439
  # 218 M-Z
440
440
  :ed_unassigned,
441
441
  # 219 M-[
442
- :ed_sequence_lead_in,
442
+ :ed_unassigned,
443
443
  # 220 M-\
444
444
  :ed_unassigned,
445
445
  # 221 M-]
@@ -41,7 +41,7 @@ class Reline::KeyActor::ViInsert < Reline::KeyActor::Base
41
41
  # 19 ^S
42
42
  :vi_search_next,
43
43
  # 20 ^T
44
- :ed_insert,
44
+ :ed_transpose_chars,
45
45
  # 21 ^U
46
46
  :vi_kill_line_prev,
47
47
  # 22 ^V
@@ -51,7 +51,7 @@ class Reline::KeyActor::ViInsert < Reline::KeyActor::Base
51
51
  # 24 ^X
52
52
  :ed_insert,
53
53
  # 25 ^Y
54
- :ed_insert,
54
+ :em_yank,
55
55
  # 26 ^Z
56
56
  :ed_insert,
57
57
  # 27 ^[