reline 0.5.12 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reline/io/ansi.rb +36 -21
- data/lib/reline/io/dumb.rb +11 -0
- data/lib/reline/io/windows.rb +11 -1
- data/lib/reline/io.rb +14 -0
- data/lib/reline/key_actor/base.rb +10 -4
- data/lib/reline/key_actor/emacs.rb +96 -96
- data/lib/reline/key_actor/vi_command.rb +182 -182
- data/lib/reline/key_actor/vi_insert.rb +137 -137
- data/lib/reline/key_stroke.rb +10 -11
- data/lib/reline/line_editor.rb +95 -164
- data/lib/reline/unicode.rb +100 -346
- data/lib/reline/version.rb +1 -1
- data/lib/reline.rb +12 -12
- metadata +6 -4
data/lib/reline/unicode.rb
CHANGED
@@ -262,375 +262,126 @@ class Reline::Unicode
|
|
262
262
|
end
|
263
263
|
|
264
264
|
def self.em_forward_word(line, byte_pointer)
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
270
|
-
byte_size += size
|
271
|
-
end
|
272
|
-
while line.bytesize > (byte_pointer + byte_size)
|
273
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
274
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
275
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
276
|
-
byte_size += size
|
277
|
-
end
|
278
|
-
byte_size
|
265
|
+
gcs = line.byteslice(byte_pointer..).grapheme_clusters
|
266
|
+
nonwords = gcs.take_while { |c| !word_character?(c) }
|
267
|
+
words = gcs.drop(nonwords.size).take_while { |c| word_character?(c) }
|
268
|
+
nonwords.sum(&:bytesize) + words.sum(&:bytesize)
|
279
269
|
end
|
280
270
|
|
281
271
|
def self.em_forward_word_with_capitalization(line, byte_pointer)
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
287
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
288
|
-
new_str += mbchar
|
289
|
-
byte_size += size
|
290
|
-
end
|
291
|
-
first = true
|
292
|
-
while line.bytesize > (byte_pointer + byte_size)
|
293
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
294
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
295
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
296
|
-
if first
|
297
|
-
new_str += mbchar.upcase
|
298
|
-
first = false
|
299
|
-
else
|
300
|
-
new_str += mbchar.downcase
|
301
|
-
end
|
302
|
-
byte_size += size
|
303
|
-
end
|
304
|
-
[byte_size, new_str]
|
272
|
+
gcs = line.byteslice(byte_pointer..).grapheme_clusters
|
273
|
+
nonwords = gcs.take_while { |c| !word_character?(c) }
|
274
|
+
words = gcs.drop(nonwords.size).take_while { |c| word_character?(c) }
|
275
|
+
[nonwords.sum(&:bytesize) + words.sum(&:bytesize), nonwords.join + words.join.capitalize]
|
305
276
|
end
|
306
277
|
|
307
278
|
def self.em_backward_word(line, byte_pointer)
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
313
|
-
byte_size += size
|
314
|
-
end
|
315
|
-
while 0 < (byte_pointer - byte_size)
|
316
|
-
size = get_prev_mbchar_size(line, byte_pointer - byte_size)
|
317
|
-
mbchar = line.byteslice(byte_pointer - byte_size - size, size)
|
318
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
319
|
-
byte_size += size
|
320
|
-
end
|
321
|
-
byte_size
|
279
|
+
gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
|
280
|
+
nonwords = gcs.take_while { |c| !word_character?(c) }
|
281
|
+
words = gcs.drop(nonwords.size).take_while { |c| word_character?(c) }
|
282
|
+
nonwords.sum(&:bytesize) + words.sum(&:bytesize)
|
322
283
|
end
|
323
284
|
|
324
285
|
def self.em_big_backward_word(line, byte_pointer)
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
break if mbchar =~ /\S/
|
330
|
-
byte_size += size
|
331
|
-
end
|
332
|
-
while 0 < (byte_pointer - byte_size)
|
333
|
-
size = get_prev_mbchar_size(line, byte_pointer - byte_size)
|
334
|
-
mbchar = line.byteslice(byte_pointer - byte_size - size, size)
|
335
|
-
break if mbchar =~ /\s/
|
336
|
-
byte_size += size
|
337
|
-
end
|
338
|
-
byte_size
|
286
|
+
gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
|
287
|
+
spaces = gcs.take_while { |c| space_character?(c) }
|
288
|
+
nonspaces = gcs.drop(spaces.size).take_while { |c| !space_character?(c) }
|
289
|
+
spaces.sum(&:bytesize) + nonspaces.sum(&:bytesize)
|
339
290
|
end
|
340
291
|
|
341
292
|
def self.ed_transpose_words(line, byte_pointer)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
while line.bytesize > (byte_pointer + byte_size)
|
363
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
364
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
365
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
366
|
-
byte_size += size
|
367
|
-
end
|
368
|
-
after_start = byte_pointer + byte_size
|
369
|
-
elsif mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
370
|
-
# ' aaa bb[cursor]b'
|
371
|
-
byte_size = 0
|
372
|
-
while 0 < (byte_pointer + byte_size)
|
373
|
-
size = get_prev_mbchar_size(line, byte_pointer + byte_size)
|
374
|
-
mbchar = line.byteslice(byte_pointer + byte_size - size, size)
|
375
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
376
|
-
byte_size -= size
|
377
|
-
end
|
378
|
-
right_word_start = byte_pointer + byte_size
|
379
|
-
byte_size = 0
|
380
|
-
while line.bytesize > (byte_pointer + byte_size)
|
381
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
382
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
383
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
384
|
-
byte_size += size
|
385
|
-
end
|
386
|
-
after_start = byte_pointer + byte_size
|
387
|
-
else
|
388
|
-
byte_size = 0
|
389
|
-
while (line.bytesize - 1) > (byte_pointer + byte_size)
|
390
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
391
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
392
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
393
|
-
byte_size += size
|
394
|
-
end
|
395
|
-
if (byte_pointer + byte_size) == (line.bytesize - 1)
|
396
|
-
# ' aaa bbb [cursor] '
|
397
|
-
after_start = line.bytesize
|
398
|
-
while 0 < (byte_pointer + byte_size)
|
399
|
-
size = get_prev_mbchar_size(line, byte_pointer + byte_size)
|
400
|
-
mbchar = line.byteslice(byte_pointer + byte_size - size, size)
|
401
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
402
|
-
byte_size -= size
|
403
|
-
end
|
404
|
-
while 0 < (byte_pointer + byte_size)
|
405
|
-
size = get_prev_mbchar_size(line, byte_pointer + byte_size)
|
406
|
-
mbchar = line.byteslice(byte_pointer + byte_size - size, size)
|
407
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
408
|
-
byte_size -= size
|
409
|
-
end
|
410
|
-
right_word_start = byte_pointer + byte_size
|
411
|
-
else
|
412
|
-
# ' aaa [cursor] bbb '
|
413
|
-
right_word_start = byte_pointer + byte_size
|
414
|
-
while line.bytesize > (byte_pointer + byte_size)
|
415
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
416
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
417
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
418
|
-
byte_size += size
|
419
|
-
end
|
420
|
-
after_start = byte_pointer + byte_size
|
421
|
-
end
|
422
|
-
end
|
423
|
-
byte_size = right_word_start - byte_pointer
|
424
|
-
while 0 < (byte_pointer + byte_size)
|
425
|
-
size = get_prev_mbchar_size(line, byte_pointer + byte_size)
|
426
|
-
mbchar = line.byteslice(byte_pointer + byte_size - size, size)
|
427
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
|
428
|
-
byte_size -= size
|
429
|
-
end
|
430
|
-
middle_start = byte_pointer + byte_size
|
431
|
-
byte_size = middle_start - byte_pointer
|
432
|
-
while 0 < (byte_pointer + byte_size)
|
433
|
-
size = get_prev_mbchar_size(line, byte_pointer + byte_size)
|
434
|
-
mbchar = line.byteslice(byte_pointer + byte_size - size, size)
|
435
|
-
break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
|
436
|
-
byte_size -= size
|
293
|
+
gcs = line.byteslice(0, byte_pointer).grapheme_clusters
|
294
|
+
pos = gcs.size
|
295
|
+
gcs += line.byteslice(byte_pointer..).grapheme_clusters
|
296
|
+
pos += 1 while pos < gcs.size && !word_character?(gcs[pos])
|
297
|
+
if pos == gcs.size # 'aaa bbb [cursor] '
|
298
|
+
pos -= 1 while pos > 0 && !word_character?(gcs[pos - 1])
|
299
|
+
second_word_end = gcs.size
|
300
|
+
else # 'aaa [cursor]bbb'
|
301
|
+
pos += 1 while pos < gcs.size && word_character?(gcs[pos])
|
302
|
+
second_word_end = pos
|
303
|
+
end
|
304
|
+
pos -= 1 while pos > 0 && word_character?(gcs[pos - 1])
|
305
|
+
second_word_start = pos
|
306
|
+
pos -= 1 while pos > 0 && !word_character?(gcs[pos - 1])
|
307
|
+
first_word_end = pos
|
308
|
+
pos -= 1 while pos > 0 && word_character?(gcs[pos - 1])
|
309
|
+
first_word_start = pos
|
310
|
+
|
311
|
+
[first_word_start, first_word_end, second_word_start, second_word_end].map do |idx|
|
312
|
+
gcs.take(idx).sum(&:bytesize)
|
437
313
|
end
|
438
|
-
left_word_start = byte_pointer + byte_size
|
439
|
-
[left_word_start, middle_start, right_word_start, after_start]
|
440
314
|
end
|
441
315
|
|
442
316
|
def self.vi_big_forward_word(line, byte_pointer)
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
break if mbchar =~ /\s/
|
448
|
-
byte_size += size
|
449
|
-
end
|
450
|
-
while (line.bytesize - 1) > (byte_pointer + byte_size)
|
451
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
452
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
453
|
-
break if mbchar =~ /\S/
|
454
|
-
byte_size += size
|
455
|
-
end
|
456
|
-
byte_size
|
317
|
+
gcs = line.byteslice(byte_pointer..).grapheme_clusters
|
318
|
+
nonspaces = gcs.take_while { |c| !space_character?(c) }
|
319
|
+
spaces = gcs.drop(nonspaces.size).take_while { |c| space_character?(c) }
|
320
|
+
nonspaces.sum(&:bytesize) + spaces.sum(&:bytesize)
|
457
321
|
end
|
458
322
|
|
459
323
|
def self.vi_big_forward_end_word(line, byte_pointer)
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
468
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
469
|
-
break if mbchar =~ /\S/
|
470
|
-
byte_size += size
|
471
|
-
end
|
472
|
-
prev_byte_size = byte_size
|
473
|
-
while line.bytesize > (byte_pointer + byte_size)
|
474
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
475
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
476
|
-
break if mbchar =~ /\s/
|
477
|
-
prev_byte_size = byte_size
|
478
|
-
byte_size += size
|
479
|
-
end
|
480
|
-
prev_byte_size
|
324
|
+
gcs = line.byteslice(byte_pointer..).grapheme_clusters
|
325
|
+
first = gcs.shift(1)
|
326
|
+
spaces = gcs.take_while { |c| space_character?(c) }
|
327
|
+
nonspaces = gcs.drop(spaces.size).take_while { |c| !space_character?(c) }
|
328
|
+
matched = spaces + nonspaces
|
329
|
+
matched.pop
|
330
|
+
first.sum(&:bytesize) + matched.sum(&:bytesize)
|
481
331
|
end
|
482
332
|
|
483
333
|
def self.vi_big_backward_word(line, byte_pointer)
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
break if mbchar =~ /\S/
|
489
|
-
byte_size += size
|
490
|
-
end
|
491
|
-
while 0 < (byte_pointer - byte_size)
|
492
|
-
size = get_prev_mbchar_size(line, byte_pointer - byte_size)
|
493
|
-
mbchar = line.byteslice(byte_pointer - byte_size - size, size)
|
494
|
-
break if mbchar =~ /\s/
|
495
|
-
byte_size += size
|
496
|
-
end
|
497
|
-
byte_size
|
334
|
+
gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
|
335
|
+
spaces = gcs.take_while { |c| space_character?(c) }
|
336
|
+
nonspaces = gcs.drop(spaces.size).take_while { |c| !space_character?(c) }
|
337
|
+
spaces.sum(&:bytesize) + nonspaces.sum(&:bytesize)
|
498
338
|
end
|
499
339
|
|
500
340
|
def self.vi_forward_word(line, byte_pointer, drop_terminate_spaces = false)
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
341
|
+
gcs = line.byteslice(byte_pointer..).grapheme_clusters
|
342
|
+
return 0 if gcs.empty?
|
343
|
+
|
344
|
+
c = gcs.first
|
345
|
+
matched =
|
346
|
+
if word_character?(c)
|
347
|
+
gcs.take_while { |c| word_character?(c) }
|
348
|
+
elsif space_character?(c)
|
349
|
+
gcs.take_while { |c| space_character?(c) }
|
508
350
|
else
|
509
|
-
|
510
|
-
end
|
511
|
-
byte_size = size
|
512
|
-
else
|
513
|
-
return 0
|
514
|
-
end
|
515
|
-
while line.bytesize > (byte_pointer + byte_size)
|
516
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
517
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
518
|
-
case started_by
|
519
|
-
when :word
|
520
|
-
break if mbchar =~ /\W/
|
521
|
-
when :space
|
522
|
-
break if mbchar =~ /\S/
|
523
|
-
when :non_word_printable
|
524
|
-
break if mbchar =~ /\w|\s/
|
351
|
+
gcs.take_while { |c| !word_character?(c) && !space_character?(c) }
|
525
352
|
end
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
532
|
-
break if mbchar =~ /\S/
|
533
|
-
byte_size += size
|
534
|
-
end
|
535
|
-
byte_size
|
353
|
+
|
354
|
+
return matched.sum(&:bytesize) if drop_terminate_spaces
|
355
|
+
|
356
|
+
spaces = gcs.drop(matched.size).take_while { |c| space_character?(c) }
|
357
|
+
matched.sum(&:bytesize) + spaces.sum(&:bytesize)
|
536
358
|
end
|
537
359
|
|
538
360
|
def self.vi_forward_end_word(line, byte_pointer)
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
555
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
556
|
-
if mbchar =~ /\w/
|
557
|
-
second = :word
|
558
|
-
elsif mbchar =~ /\s/
|
559
|
-
second = :space
|
560
|
-
else
|
561
|
-
second = :non_word_printable
|
562
|
-
end
|
563
|
-
second_byte_size = size
|
564
|
-
else
|
565
|
-
return byte_size
|
566
|
-
end
|
567
|
-
if second == :space
|
568
|
-
byte_size += second_byte_size
|
569
|
-
while (line.bytesize - 1) > (byte_pointer + byte_size)
|
570
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
571
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
572
|
-
if mbchar =~ /\S/
|
573
|
-
if mbchar =~ /\w/
|
574
|
-
started_by = :word
|
575
|
-
else
|
576
|
-
started_by = :non_word_printable
|
577
|
-
end
|
578
|
-
break
|
579
|
-
end
|
580
|
-
byte_size += size
|
581
|
-
end
|
582
|
-
else
|
583
|
-
case [started_by, second]
|
584
|
-
when [:word, :non_word_printable], [:non_word_printable, :word]
|
585
|
-
started_by = second
|
586
|
-
else
|
587
|
-
byte_size += second_byte_size
|
588
|
-
started_by = second
|
589
|
-
end
|
590
|
-
end
|
591
|
-
prev_byte_size = byte_size
|
592
|
-
while line.bytesize > (byte_pointer + byte_size)
|
593
|
-
size = get_next_mbchar_size(line, byte_pointer + byte_size)
|
594
|
-
mbchar = line.byteslice(byte_pointer + byte_size, size)
|
595
|
-
case started_by
|
596
|
-
when :word
|
597
|
-
break if mbchar =~ /\W/
|
598
|
-
when :non_word_printable
|
599
|
-
break if mbchar =~ /[\w\s]/
|
600
|
-
end
|
601
|
-
prev_byte_size = byte_size
|
602
|
-
byte_size += size
|
603
|
-
end
|
604
|
-
prev_byte_size
|
361
|
+
gcs = line.byteslice(byte_pointer..).grapheme_clusters
|
362
|
+
return 0 if gcs.empty?
|
363
|
+
return gcs.first.bytesize if gcs.size == 1
|
364
|
+
|
365
|
+
start = gcs.shift
|
366
|
+
skips = [start]
|
367
|
+
if space_character?(start) || space_character?(gcs.first)
|
368
|
+
spaces = gcs.take_while { |c| space_character?(c) }
|
369
|
+
skips += spaces
|
370
|
+
gcs.shift(spaces.size)
|
371
|
+
end
|
372
|
+
start_with_word = word_character?(gcs.first)
|
373
|
+
matched = gcs.take_while { |c| start_with_word ? word_character?(c) : !word_character?(c) && !space_character?(c) }
|
374
|
+
matched.pop
|
375
|
+
skips.sum(&:bytesize) + matched.sum(&:bytesize)
|
605
376
|
end
|
606
377
|
|
607
378
|
def self.vi_backward_word(line, byte_pointer)
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
started_by = :word
|
615
|
-
else
|
616
|
-
started_by = :non_word_printable
|
617
|
-
end
|
618
|
-
break
|
619
|
-
end
|
620
|
-
byte_size += size
|
621
|
-
end
|
622
|
-
while 0 < (byte_pointer - byte_size)
|
623
|
-
size = get_prev_mbchar_size(line, byte_pointer - byte_size)
|
624
|
-
mbchar = line.byteslice(byte_pointer - byte_size - size, size)
|
625
|
-
case started_by
|
626
|
-
when :word
|
627
|
-
break if mbchar =~ /\W/
|
628
|
-
when :non_word_printable
|
629
|
-
break if mbchar =~ /[\w\s]/
|
630
|
-
end
|
631
|
-
byte_size += size
|
632
|
-
end
|
633
|
-
byte_size
|
379
|
+
gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
|
380
|
+
spaces = gcs.take_while { |c| space_character?(c) }
|
381
|
+
gcs.shift(spaces.size)
|
382
|
+
start_with_word = word_character?(gcs.first)
|
383
|
+
matched = gcs.take_while { |c| start_with_word ? word_character?(c) : !word_character?(c) && !space_character?(c) }
|
384
|
+
spaces.sum(&:bytesize) + matched.sum(&:bytesize)
|
634
385
|
end
|
635
386
|
|
636
387
|
def self.common_prefix(list, ignore_case: false)
|
@@ -647,15 +398,18 @@ class Reline::Unicode
|
|
647
398
|
end
|
648
399
|
|
649
400
|
def self.vi_first_print(line)
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
401
|
+
gcs = line.grapheme_clusters
|
402
|
+
spaces = gcs.take_while { |c| space_character?(c) }
|
403
|
+
spaces.sum(&:bytesize)
|
404
|
+
end
|
405
|
+
|
406
|
+
def self.word_character?(s)
|
407
|
+
s.encode(Encoding::UTF_8).match?(/\p{Word}/) if s
|
408
|
+
rescue Encoding::UndefinedConversionError
|
409
|
+
false
|
410
|
+
end
|
411
|
+
|
412
|
+
def self.space_character?(s)
|
413
|
+
s.match?(/\s/) if s
|
660
414
|
end
|
661
415
|
end
|
data/lib/reline/version.rb
CHANGED
data/lib/reline.rb
CHANGED
@@ -17,10 +17,12 @@ module Reline
|
|
17
17
|
|
18
18
|
class ConfigEncodingConversionError < StandardError; end
|
19
19
|
|
20
|
-
|
20
|
+
# EOF key: { char: nil, method_symbol: nil }
|
21
|
+
# Other key: { char: String, method_symbol: Symbol }
|
22
|
+
Key = Struct.new(:char, :method_symbol, :unused_boolean) do
|
21
23
|
# For dialog_proc `key.match?(dialog.name)`
|
22
24
|
def match?(sym)
|
23
|
-
|
25
|
+
method_symbol && method_symbol == sym
|
24
26
|
end
|
25
27
|
end
|
26
28
|
CursorPos = Struct.new(:x, :y)
|
@@ -181,9 +183,7 @@ module Reline
|
|
181
183
|
def output=(val)
|
182
184
|
raise TypeError unless val.respond_to?(:write) or val.nil?
|
183
185
|
@output = val
|
184
|
-
|
185
|
-
io_gate.output = val
|
186
|
-
end
|
186
|
+
io_gate.output = val
|
187
187
|
end
|
188
188
|
|
189
189
|
def vi_editing_mode
|
@@ -317,7 +317,6 @@ module Reline
|
|
317
317
|
else
|
318
318
|
line_editor.multiline_off
|
319
319
|
end
|
320
|
-
line_editor.output = output
|
321
320
|
line_editor.completion_proc = completion_proc
|
322
321
|
line_editor.completion_append_character = completion_append_character
|
323
322
|
line_editor.output_modifier_proc = output_modifier_proc
|
@@ -344,13 +343,14 @@ module Reline
|
|
344
343
|
read_io(config.keyseq_timeout) { |inputs|
|
345
344
|
line_editor.set_pasting_state(io_gate.in_pasting?)
|
346
345
|
inputs.each do |key|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
346
|
+
case key.method_symbol
|
347
|
+
when :bracketed_paste_start
|
348
|
+
# io_gate is Reline::ANSI because the key :bracketed_paste_start is only assigned in Reline::ANSI
|
349
|
+
key = Reline::Key.new(io_gate.read_bracketed_paste, :insert_multiline_text)
|
350
|
+
when :quoted_insert, :ed_quoted_insert
|
351
|
+
key = Reline::Key.new(io_gate.read_single_char(config.keyseq_timeout), :insert_raw_char)
|
353
352
|
end
|
353
|
+
line_editor.update(key)
|
354
354
|
end
|
355
355
|
}
|
356
356
|
if line_editor.finished?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
|
-
original_platform: ''
|
7
6
|
authors:
|
8
7
|
- aycabta
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|
@@ -62,6 +62,7 @@ metadata:
|
|
62
62
|
bug_tracker_uri: https://github.com/ruby/reline/issues
|
63
63
|
changelog_uri: https://github.com/ruby/reline/releases
|
64
64
|
source_code_uri: https://github.com/ruby/reline
|
65
|
+
post_install_message:
|
65
66
|
rdoc_options: []
|
66
67
|
require_paths:
|
67
68
|
- lib
|
@@ -76,7 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
77
|
- !ruby/object:Gem::Version
|
77
78
|
version: '0'
|
78
79
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
80
|
+
rubygems_version: 3.5.22
|
81
|
+
signing_key:
|
80
82
|
specification_version: 4
|
81
83
|
summary: Alternative GNU Readline or Editline implementation by pure Ruby.
|
82
84
|
test_files: []
|