reline 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,8 +84,13 @@ class Reline::Unicode::EastAsianWidth
84
84
  \u{17000}-\u{187F7}
85
85
  \u{18800}-\u{18CD5}
86
86
  \u{18D00}-\u{18D08}
87
- \u{1B000}-\u{1B11E}
87
+ \u{1AFF0}-\u{1AFF3}
88
+ \u{1AFF5}-\u{1AFFB}
89
+ \u{1AFFD}-\u{1AFFE}
90
+ \u{1B000}-\u{1B122}
91
+ \u{1B132}
88
92
  \u{1B150}-\u{1B152}
93
+ \u{1B155}
89
94
  \u{1B164}-\u{1B167}
90
95
  \u{1B170}-\u{1B2FB}
91
96
  \u{1F004}
@@ -119,21 +124,21 @@ class Reline::Unicode::EastAsianWidth
119
124
  \u{1F6CC}
120
125
  \u{1F6D0}-\u{1F6D2}
121
126
  \u{1F6D5}-\u{1F6D7}
127
+ \u{1F6DC}-\u{1F6DF}
122
128
  \u{1F6EB}-\u{1F6EC}
123
129
  \u{1F6F4}-\u{1F6FC}
124
130
  \u{1F7E0}-\u{1F7EB}
131
+ \u{1F7F0}
125
132
  \u{1F90C}-\u{1F93A}
126
133
  \u{1F93C}-\u{1F945}
127
- \u{1F947}-\u{1F978}
128
- \u{1F97A}-\u{1F9CB}
129
- \u{1F9CD}-\u{1F9FF}
130
- \u{1FA70}-\u{1FA74}
131
- \u{1FA78}-\u{1FA7A}
132
- \u{1FA80}-\u{1FA86}
133
- \u{1FA90}-\u{1FAA8}
134
- \u{1FAB0}-\u{1FAB6}
135
- \u{1FAC0}-\u{1FAC2}
136
- \u{1FAD0}-\u{1FAD6}
134
+ \u{1F947}-\u{1F9FF}
135
+ \u{1FA70}-\u{1FA7C}
136
+ \u{1FA80}-\u{1FA88}
137
+ \u{1FA90}-\u{1FABD}
138
+ \u{1FABF}-\u{1FAC5}
139
+ \u{1FACE}-\u{1FADB}
140
+ \u{1FAE0}-\u{1FAE8}
141
+ \u{1FAF0}-\u{1FAF8}
137
142
  \u{20000}-\u{2FFFD}
138
143
  \u{30000}-\u{3FFFD}
139
144
  ).join }]/
@@ -403,8 +408,7 @@ class Reline::Unicode::EastAsianWidth
403
408
  \u{0591}-\u{05C7}
404
409
  \u{05D0}-\u{05EA}
405
410
  \u{05EF}-\u{05F4}
406
- \u{0600}-\u{061C}
407
- \u{061E}-\u{070D}
411
+ \u{0600}-\u{070D}
408
412
  \u{070F}-\u{074A}
409
413
  \u{074D}-\u{07B1}
410
414
  \u{07C0}-\u{07FA}
@@ -413,9 +417,9 @@ class Reline::Unicode::EastAsianWidth
413
417
  \u{0840}-\u{085B}
414
418
  \u{085E}
415
419
  \u{0860}-\u{086A}
416
- \u{08A0}-\u{08B4}
417
- \u{08B6}-\u{08C7}
418
- \u{08D3}-\u{0983}
420
+ \u{0870}-\u{088E}
421
+ \u{0890}-\u{0891}
422
+ \u{0898}-\u{0983}
419
423
  \u{0985}-\u{098C}
420
424
  \u{098F}-\u{0990}
421
425
  \u{0993}-\u{09A8}
@@ -493,11 +497,12 @@ class Reline::Unicode::EastAsianWidth
493
497
  \u{0C0E}-\u{0C10}
494
498
  \u{0C12}-\u{0C28}
495
499
  \u{0C2A}-\u{0C39}
496
- \u{0C3D}-\u{0C44}
500
+ \u{0C3C}-\u{0C44}
497
501
  \u{0C46}-\u{0C48}
498
502
  \u{0C4A}-\u{0C4D}
499
503
  \u{0C55}-\u{0C56}
500
504
  \u{0C58}-\u{0C5A}
505
+ \u{0C5D}
501
506
  \u{0C60}-\u{0C63}
502
507
  \u{0C66}-\u{0C6F}
503
508
  \u{0C77}-\u{0C8C}
@@ -509,10 +514,10 @@ class Reline::Unicode::EastAsianWidth
509
514
  \u{0CC6}-\u{0CC8}
510
515
  \u{0CCA}-\u{0CCD}
511
516
  \u{0CD5}-\u{0CD6}
512
- \u{0CDE}
517
+ \u{0CDD}-\u{0CDE}
513
518
  \u{0CE0}-\u{0CE3}
514
519
  \u{0CE6}-\u{0CEF}
515
- \u{0CF1}-\u{0CF2}
520
+ \u{0CF1}-\u{0CF3}
516
521
  \u{0D00}-\u{0D0C}
517
522
  \u{0D0E}-\u{0D10}
518
523
  \u{0D12}-\u{0D44}
@@ -542,7 +547,7 @@ class Reline::Unicode::EastAsianWidth
542
547
  \u{0EA7}-\u{0EBD}
543
548
  \u{0EC0}-\u{0EC4}
544
549
  \u{0EC6}
545
- \u{0EC8}-\u{0ECD}
550
+ \u{0EC8}-\u{0ECE}
546
551
  \u{0ED0}-\u{0ED9}
547
552
  \u{0EDC}-\u{0EDF}
548
553
  \u{0F00}-\u{0F47}
@@ -577,9 +582,8 @@ class Reline::Unicode::EastAsianWidth
577
582
  \u{13F8}-\u{13FD}
578
583
  \u{1400}-\u{169C}
579
584
  \u{16A0}-\u{16F8}
580
- \u{1700}-\u{170C}
581
- \u{170E}-\u{1714}
582
- \u{1720}-\u{1736}
585
+ \u{1700}-\u{1715}
586
+ \u{171F}-\u{1736}
583
587
  \u{1740}-\u{1753}
584
588
  \u{1760}-\u{176C}
585
589
  \u{176E}-\u{1770}
@@ -587,8 +591,7 @@ class Reline::Unicode::EastAsianWidth
587
591
  \u{1780}-\u{17DD}
588
592
  \u{17E0}-\u{17E9}
589
593
  \u{17F0}-\u{17F9}
590
- \u{1800}-\u{180E}
591
- \u{1810}-\u{1819}
594
+ \u{1800}-\u{1819}
592
595
  \u{1820}-\u{1878}
593
596
  \u{1880}-\u{18AA}
594
597
  \u{18B0}-\u{18F5}
@@ -607,9 +610,9 @@ class Reline::Unicode::EastAsianWidth
607
610
  \u{1A7F}-\u{1A89}
608
611
  \u{1A90}-\u{1A99}
609
612
  \u{1AA0}-\u{1AAD}
610
- \u{1AB0}-\u{1AC0}
611
- \u{1B00}-\u{1B4B}
612
- \u{1B50}-\u{1B7C}
613
+ \u{1AB0}-\u{1ACE}
614
+ \u{1B00}-\u{1B4C}
615
+ \u{1B50}-\u{1B7E}
613
616
  \u{1B80}-\u{1BF3}
614
617
  \u{1BFC}-\u{1C37}
615
618
  \u{1C3B}-\u{1C49}
@@ -617,8 +620,7 @@ class Reline::Unicode::EastAsianWidth
617
620
  \u{1C90}-\u{1CBA}
618
621
  \u{1CBD}-\u{1CC7}
619
622
  \u{1CD0}-\u{1CFA}
620
- \u{1D00}-\u{1DF9}
621
- \u{1DFB}-\u{1F15}
623
+ \u{1D00}-\u{1F15}
622
624
  \u{1F18}-\u{1F1D}
623
625
  \u{1F20}-\u{1F45}
624
626
  \u{1F48}-\u{1F4D}
@@ -653,7 +655,7 @@ class Reline::Unicode::EastAsianWidth
653
655
  \u{2090}-\u{209C}
654
656
  \u{20A0}-\u{20A8}
655
657
  \u{20AA}-\u{20AB}
656
- \u{20AD}-\u{20BF}
658
+ \u{20AD}-\u{20C0}
657
659
  \u{20D0}-\u{20F0}
658
660
  \u{2100}-\u{2102}
659
661
  \u{2104}
@@ -767,9 +769,7 @@ class Reline::Unicode::EastAsianWidth
767
769
  \u{2B51}-\u{2B54}
768
770
  \u{2B5A}-\u{2B73}
769
771
  \u{2B76}-\u{2B95}
770
- \u{2B97}-\u{2C2E}
771
- \u{2C30}-\u{2C5E}
772
- \u{2C60}-\u{2CF3}
772
+ \u{2B97}-\u{2CF3}
773
773
  \u{2CF9}-\u{2D25}
774
774
  \u{2D27}
775
775
  \u{2D2D}
@@ -784,14 +784,16 @@ class Reline::Unicode::EastAsianWidth
784
784
  \u{2DC8}-\u{2DCE}
785
785
  \u{2DD0}-\u{2DD6}
786
786
  \u{2DD8}-\u{2DDE}
787
- \u{2DE0}-\u{2E52}
787
+ \u{2DE0}-\u{2E5D}
788
788
  \u{303F}
789
789
  \u{4DC0}-\u{4DFF}
790
790
  \u{A4D0}-\u{A62B}
791
791
  \u{A640}-\u{A6F7}
792
- \u{A700}-\u{A7BF}
793
- \u{A7C2}-\u{A7CA}
794
- \u{A7F5}-\u{A82C}
792
+ \u{A700}-\u{A7CA}
793
+ \u{A7D0}-\u{A7D1}
794
+ \u{A7D3}
795
+ \u{A7D5}-\u{A7D9}
796
+ \u{A7F2}-\u{A82C}
795
797
  \u{A830}-\u{A839}
796
798
  \u{A840}-\u{A877}
797
799
  \u{A880}-\u{A8C5}
@@ -823,11 +825,11 @@ class Reline::Unicode::EastAsianWidth
823
825
  \u{FB3E}
824
826
  \u{FB40}-\u{FB41}
825
827
  \u{FB43}-\u{FB44}
826
- \u{FB46}-\u{FBC1}
827
- \u{FBD3}-\u{FD3F}
828
- \u{FD50}-\u{FD8F}
828
+ \u{FB46}-\u{FBC2}
829
+ \u{FBD3}-\u{FD8F}
829
830
  \u{FD92}-\u{FDC7}
830
- \u{FDF0}-\u{FDFD}
831
+ \u{FDCF}
832
+ \u{FDF0}-\u{FDFF}
831
833
  \u{FE20}-\u{FE2F}
832
834
  \u{FE70}-\u{FE74}
833
835
  \u{FE76}-\u{FEFC}
@@ -861,10 +863,20 @@ class Reline::Unicode::EastAsianWidth
861
863
  \u{104D8}-\u{104FB}
862
864
  \u{10500}-\u{10527}
863
865
  \u{10530}-\u{10563}
864
- \u{1056F}
866
+ \u{1056F}-\u{1057A}
867
+ \u{1057C}-\u{1058A}
868
+ \u{1058C}-\u{10592}
869
+ \u{10594}-\u{10595}
870
+ \u{10597}-\u{105A1}
871
+ \u{105A3}-\u{105B1}
872
+ \u{105B3}-\u{105B9}
873
+ \u{105BB}-\u{105BC}
865
874
  \u{10600}-\u{10736}
866
875
  \u{10740}-\u{10755}
867
876
  \u{10760}-\u{10767}
877
+ \u{10780}-\u{10785}
878
+ \u{10787}-\u{107B0}
879
+ \u{107B2}-\u{107BA}
868
880
  \u{10800}-\u{10805}
869
881
  \u{10808}
870
882
  \u{1080A}-\u{10835}
@@ -906,13 +918,14 @@ class Reline::Unicode::EastAsianWidth
906
918
  \u{10E80}-\u{10EA9}
907
919
  \u{10EAB}-\u{10EAD}
908
920
  \u{10EB0}-\u{10EB1}
909
- \u{10F00}-\u{10F27}
921
+ \u{10EFD}-\u{10F27}
910
922
  \u{10F30}-\u{10F59}
923
+ \u{10F70}-\u{10F89}
911
924
  \u{10FB0}-\u{10FCB}
912
925
  \u{10FE0}-\u{10FF6}
913
926
  \u{11000}-\u{1104D}
914
- \u{11052}-\u{1106F}
915
- \u{1107F}-\u{110C1}
927
+ \u{11052}-\u{11075}
928
+ \u{1107F}-\u{110C2}
916
929
  \u{110CD}
917
930
  \u{110D0}-\u{110E8}
918
931
  \u{110F0}-\u{110F9}
@@ -922,7 +935,7 @@ class Reline::Unicode::EastAsianWidth
922
935
  \u{11180}-\u{111DF}
923
936
  \u{111E1}-\u{111F4}
924
937
  \u{11200}-\u{11211}
925
- \u{11213}-\u{1123E}
938
+ \u{11213}-\u{11241}
926
939
  \u{11280}-\u{11286}
927
940
  \u{11288}
928
941
  \u{1128A}-\u{1128D}
@@ -954,11 +967,11 @@ class Reline::Unicode::EastAsianWidth
954
967
  \u{11600}-\u{11644}
955
968
  \u{11650}-\u{11659}
956
969
  \u{11660}-\u{1166C}
957
- \u{11680}-\u{116B8}
970
+ \u{11680}-\u{116B9}
958
971
  \u{116C0}-\u{116C9}
959
972
  \u{11700}-\u{1171A}
960
973
  \u{1171D}-\u{1172B}
961
- \u{11730}-\u{1173F}
974
+ \u{11730}-\u{11746}
962
975
  \u{11800}-\u{1183B}
963
976
  \u{118A0}-\u{118F2}
964
977
  \u{118FF}-\u{11906}
@@ -974,7 +987,8 @@ class Reline::Unicode::EastAsianWidth
974
987
  \u{119DA}-\u{119E4}
975
988
  \u{11A00}-\u{11A47}
976
989
  \u{11A50}-\u{11AA2}
977
- \u{11AC0}-\u{11AF8}
990
+ \u{11AB0}-\u{11AF8}
991
+ \u{11B00}-\u{11B09}
978
992
  \u{11C00}-\u{11C08}
979
993
  \u{11C0A}-\u{11C36}
980
994
  \u{11C38}-\u{11C45}
@@ -996,19 +1010,23 @@ class Reline::Unicode::EastAsianWidth
996
1010
  \u{11D93}-\u{11D98}
997
1011
  \u{11DA0}-\u{11DA9}
998
1012
  \u{11EE0}-\u{11EF8}
1013
+ \u{11F00}-\u{11F10}
1014
+ \u{11F12}-\u{11F3A}
1015
+ \u{11F3E}-\u{11F59}
999
1016
  \u{11FB0}
1000
1017
  \u{11FC0}-\u{11FF1}
1001
1018
  \u{11FFF}-\u{12399}
1002
1019
  \u{12400}-\u{1246E}
1003
1020
  \u{12470}-\u{12474}
1004
1021
  \u{12480}-\u{12543}
1005
- \u{13000}-\u{1342E}
1006
- \u{13430}-\u{13438}
1022
+ \u{12F90}-\u{12FF2}
1023
+ \u{13000}-\u{13455}
1007
1024
  \u{14400}-\u{14646}
1008
1025
  \u{16800}-\u{16A38}
1009
1026
  \u{16A40}-\u{16A5E}
1010
1027
  \u{16A60}-\u{16A69}
1011
- \u{16A6E}-\u{16A6F}
1028
+ \u{16A6E}-\u{16ABE}
1029
+ \u{16AC0}-\u{16AC9}
1012
1030
  \u{16AD0}-\u{16AED}
1013
1031
  \u{16AF0}-\u{16AF5}
1014
1032
  \u{16B00}-\u{16B45}
@@ -1025,10 +1043,14 @@ class Reline::Unicode::EastAsianWidth
1025
1043
  \u{1BC80}-\u{1BC88}
1026
1044
  \u{1BC90}-\u{1BC99}
1027
1045
  \u{1BC9C}-\u{1BCA3}
1046
+ \u{1CF00}-\u{1CF2D}
1047
+ \u{1CF30}-\u{1CF46}
1048
+ \u{1CF50}-\u{1CFC3}
1028
1049
  \u{1D000}-\u{1D0F5}
1029
1050
  \u{1D100}-\u{1D126}
1030
- \u{1D129}-\u{1D1E8}
1051
+ \u{1D129}-\u{1D1EA}
1031
1052
  \u{1D200}-\u{1D245}
1053
+ \u{1D2C0}-\u{1D2D3}
1032
1054
  \u{1D2E0}-\u{1D2F3}
1033
1055
  \u{1D300}-\u{1D356}
1034
1056
  \u{1D360}-\u{1D378}
@@ -1055,17 +1077,27 @@ class Reline::Unicode::EastAsianWidth
1055
1077
  \u{1D7CE}-\u{1DA8B}
1056
1078
  \u{1DA9B}-\u{1DA9F}
1057
1079
  \u{1DAA1}-\u{1DAAF}
1080
+ \u{1DF00}-\u{1DF1E}
1081
+ \u{1DF25}-\u{1DF2A}
1058
1082
  \u{1E000}-\u{1E006}
1059
1083
  \u{1E008}-\u{1E018}
1060
1084
  \u{1E01B}-\u{1E021}
1061
1085
  \u{1E023}-\u{1E024}
1062
1086
  \u{1E026}-\u{1E02A}
1087
+ \u{1E030}-\u{1E06D}
1088
+ \u{1E08F}
1063
1089
  \u{1E100}-\u{1E12C}
1064
1090
  \u{1E130}-\u{1E13D}
1065
1091
  \u{1E140}-\u{1E149}
1066
1092
  \u{1E14E}-\u{1E14F}
1093
+ \u{1E290}-\u{1E2AE}
1067
1094
  \u{1E2C0}-\u{1E2F9}
1068
1095
  \u{1E2FF}
1096
+ \u{1E4D0}-\u{1E4F9}
1097
+ \u{1E7E0}-\u{1E7E6}
1098
+ \u{1E7E8}-\u{1E7EB}
1099
+ \u{1E7ED}-\u{1E7EE}
1100
+ \u{1E7F0}-\u{1E7FE}
1069
1101
  \u{1E800}-\u{1E8C4}
1070
1102
  \u{1E8C7}-\u{1E8D6}
1071
1103
  \u{1E900}-\u{1E94B}
@@ -1142,8 +1174,8 @@ class Reline::Unicode::EastAsianWidth
1142
1174
  \u{1F6D3}-\u{1F6D4}
1143
1175
  \u{1F6E0}-\u{1F6EA}
1144
1176
  \u{1F6F0}-\u{1F6F3}
1145
- \u{1F700}-\u{1F773}
1146
- \u{1F780}-\u{1F7D8}
1177
+ \u{1F700}-\u{1F776}
1178
+ \u{1F77B}-\u{1F7D9}
1147
1179
  \u{1F800}-\u{1F80B}
1148
1180
  \u{1F810}-\u{1F847}
1149
1181
  \u{1F850}-\u{1F859}
@@ -38,13 +38,8 @@ class Reline::Unicode
38
38
  NON_PRINTING_START = "\1"
39
39
  NON_PRINTING_END = "\2"
40
40
  CSI_REGEXP = /\e\[[\d;]*[ABCDEFGHJKSTfminsuhl]/
41
- OSC_REGEXP = /\e\]\d+(?:;[^;]+)*\a/
41
+ OSC_REGEXP = /\e\]\d+(?:;[^;\a\e]+)*(?:\a|\e\\)/
42
42
  WIDTH_SCANNER = /\G(?:(#{NON_PRINTING_START})|(#{NON_PRINTING_END})|(#{CSI_REGEXP})|(#{OSC_REGEXP})|(\X))/o
43
- NON_PRINTING_START_INDEX = 0
44
- NON_PRINTING_END_INDEX = 1
45
- CSI_REGEXP_INDEX = 2
46
- OSC_REGEXP_INDEX = 3
47
- GRAPHEME_CLUSTER_INDEX = 4
48
43
 
49
44
  def self.get_mbchar_byte_size_by_first_char(c)
50
45
  # Checks UTF-8 character byte size
@@ -132,15 +127,14 @@ class Reline::Unicode
132
127
  width = 0
133
128
  rest = str.encode(Encoding::UTF_8)
134
129
  in_zero_width = false
135
- rest.scan(WIDTH_SCANNER) do |gc|
130
+ rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
136
131
  case
137
- when gc[NON_PRINTING_START_INDEX]
132
+ when non_printing_start
138
133
  in_zero_width = true
139
- when gc[NON_PRINTING_END_INDEX]
134
+ when non_printing_end
140
135
  in_zero_width = false
141
- when gc[CSI_REGEXP_INDEX], gc[OSC_REGEXP_INDEX]
142
- when gc[GRAPHEME_CLUSTER_INDEX]
143
- gc = gc[GRAPHEME_CLUSTER_INDEX]
136
+ when csi, osc
137
+ when gc
144
138
  unless in_zero_width
145
139
  width += get_mbchar_width(gc)
146
140
  end
@@ -160,24 +154,28 @@ class Reline::Unicode
160
154
  width = 0
161
155
  rest = str.encode(Encoding::UTF_8)
162
156
  in_zero_width = false
163
- rest.scan(WIDTH_SCANNER) do |gc|
157
+ seq = String.new(encoding: encoding)
158
+ rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
164
159
  case
165
- when gc[NON_PRINTING_START_INDEX]
160
+ when non_printing_start
166
161
  in_zero_width = true
167
- when gc[NON_PRINTING_END_INDEX]
162
+ lines.last << NON_PRINTING_START
163
+ when non_printing_end
168
164
  in_zero_width = false
169
- when gc[CSI_REGEXP_INDEX]
170
- lines.last << gc[CSI_REGEXP_INDEX]
171
- when gc[OSC_REGEXP_INDEX]
172
- lines.last << gc[OSC_REGEXP_INDEX]
173
- when gc[GRAPHEME_CLUSTER_INDEX]
174
- gc = gc[GRAPHEME_CLUSTER_INDEX]
165
+ lines.last << NON_PRINTING_END
166
+ when csi
167
+ lines.last << csi
168
+ seq << csi
169
+ when osc
170
+ lines.last << osc
171
+ seq << osc
172
+ when gc
175
173
  unless in_zero_width
176
174
  mbchar_width = get_mbchar_width(gc)
177
175
  if (width += mbchar_width) > max_width
178
176
  width = mbchar_width
179
177
  lines << nil
180
- lines << String.new(encoding: encoding)
178
+ lines << seq.dup
181
179
  height += 1
182
180
  end
183
181
  end
@@ -194,23 +192,22 @@ class Reline::Unicode
194
192
  end
195
193
 
196
194
  # Take a chunk of a String cut by width with escape sequences.
197
- def self.take_range(str, start_col, max_width, encoding = str.encoding)
198
- chunk = String.new(encoding: encoding)
195
+ def self.take_range(str, start_col, max_width)
196
+ chunk = String.new(encoding: str.encoding)
199
197
  total_width = 0
200
198
  rest = str.encode(Encoding::UTF_8)
201
199
  in_zero_width = false
202
- rest.scan(WIDTH_SCANNER) do |gc|
200
+ rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
203
201
  case
204
- when gc[NON_PRINTING_START_INDEX]
202
+ when non_printing_start
205
203
  in_zero_width = true
206
- when gc[NON_PRINTING_END_INDEX]
204
+ when non_printing_end
207
205
  in_zero_width = false
208
- when gc[CSI_REGEXP_INDEX]
209
- chunk << gc[CSI_REGEXP_INDEX]
210
- when gc[OSC_REGEXP_INDEX]
211
- chunk << gc[OSC_REGEXP_INDEX]
212
- when gc[GRAPHEME_CLUSTER_INDEX]
213
- gc = gc[GRAPHEME_CLUSTER_INDEX]
206
+ when csi
207
+ chunk << csi
208
+ when osc
209
+ chunk << osc
210
+ when gc
214
211
  if in_zero_width
215
212
  chunk << gc
216
213
  else
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.4'
3
3
  end
@@ -291,6 +291,10 @@ class Reline::Windows
291
291
  end
292
292
  end
293
293
 
294
+ def self.with_raw_input
295
+ yield
296
+ end
297
+
294
298
  def self.getc
295
299
  check_input_event
296
300
  @@output_buf.shift
data/lib/reline.rb CHANGED
@@ -11,6 +11,7 @@ require 'reline/terminfo'
11
11
  require 'rbconfig'
12
12
 
13
13
  module Reline
14
+ # NOTE: For making compatible with the rb-readline gem
14
15
  FILENAME_COMPLETION_PROC = nil
15
16
  USERNAME_COMPLETION_PROC = nil
16
17
 
@@ -165,9 +166,13 @@ module Reline
165
166
 
166
167
  DialogProc = Struct.new(:dialog_proc, :context)
167
168
  def add_dialog_proc(name_sym, p, context = nil)
168
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
169
169
  raise ArgumentError unless name_sym.instance_of?(Symbol)
170
- @dialog_proc_list[name_sym] = DialogProc.new(p, context)
170
+ if p.nil?
171
+ @dialog_proc_list.delete(name_sym)
172
+ else
173
+ raise ArgumentError unless p.respond_to?(:call)
174
+ @dialog_proc_list[name_sym] = DialogProc.new(p, context)
175
+ end
171
176
  end
172
177
 
173
178
  def dialog_proc(name_sym)
@@ -265,19 +270,21 @@ module Reline
265
270
  Reline::DEFAULT_DIALOG_CONTEXT = Array.new
266
271
 
267
272
  def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
268
- unless confirm_multiline_termination
269
- raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
270
- end
271
- inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
273
+ Reline::IOGate.with_raw_input do
274
+ unless confirm_multiline_termination
275
+ raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
276
+ end
277
+ inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
272
278
 
273
- whole_buffer = line_editor.whole_buffer.dup
274
- whole_buffer.taint if RUBY_VERSION < '2.7'
275
- if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
276
- Reline::HISTORY << whole_buffer
277
- end
279
+ whole_buffer = line_editor.whole_buffer.dup
280
+ whole_buffer.taint if RUBY_VERSION < '2.7'
281
+ if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
282
+ Reline::HISTORY << whole_buffer
283
+ end
278
284
 
279
- line_editor.reset_line if line_editor.whole_buffer.nil?
280
- whole_buffer
285
+ line_editor.reset_line if line_editor.whole_buffer.nil?
286
+ whole_buffer
287
+ end
281
288
  end
282
289
 
283
290
  def readline(prompt = '', add_hist = false)
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.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-14 00:00:00.000000000 Z
11
+ date: 2023-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.4.0.dev
75
+ rubygems_version: 3.4.13
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Alternative GNU Readline or Editline implementation by pure Ruby.