reline 0.3.0 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/lib/reline/ansi.rb +11 -4
- data/lib/reline/config.rb +17 -11
- data/lib/reline/general_io.rb +10 -0
- data/lib/reline/key_actor/emacs.rb +1 -1
- data/lib/reline/key_stroke.rb +50 -7
- data/lib/reline/line_editor.rb +235 -282
- data/lib/reline/terminfo.rb +44 -18
- data/lib/reline/unicode/east_asian_width.rb +88 -56
- data/lib/reline/unicode.rb +30 -53
- data/lib/reline/version.rb +1 -1
- data/lib/reline/windows.rb +7 -3
- data/lib/reline.rb +115 -80
- metadata +4 -5
- data/lib/reline/sibori.rb +0 -170
data/lib/reline/terminfo.rb
CHANGED
@@ -31,21 +31,7 @@ module Reline::Terminfo
|
|
31
31
|
@curses_dl = false
|
32
32
|
def self.curses_dl
|
33
33
|
return @curses_dl unless @curses_dl == false
|
34
|
-
if
|
35
|
-
# Gem module isn't defined in test-all of the Ruby repository, and
|
36
|
-
# Fiddle in Ruby 3.0.0 or later supports Fiddle::TYPE_VARIADIC.
|
37
|
-
fiddle_supports_variadic = true
|
38
|
-
elsif Fiddle.const_defined?(:VERSION) and Gem::Version.create(Fiddle::VERSION) >= Gem::Version.create('1.0.1')
|
39
|
-
# Fiddle::TYPE_VARIADIC is supported from Fiddle 1.0.1.
|
40
|
-
fiddle_supports_variadic = true
|
41
|
-
else
|
42
|
-
fiddle_supports_variadic = false
|
43
|
-
end
|
44
|
-
if fiddle_supports_variadic and not Fiddle.const_defined?(:TYPE_VARIADIC)
|
45
|
-
# If the libffi version is not 3.0.5 or higher, there isn't TYPE_VARIADIC.
|
46
|
-
fiddle_supports_variadic = false
|
47
|
-
end
|
48
|
-
if fiddle_supports_variadic
|
34
|
+
if Fiddle.const_defined?(:TYPE_VARIADIC)
|
49
35
|
curses_dl_files.each do |curses_name|
|
50
36
|
result = Fiddle::Handle.new(curses_name)
|
51
37
|
rescue Fiddle::DLError
|
@@ -74,12 +60,27 @@ module Reline::Terminfo
|
|
74
60
|
#extern 'char *tparm(const char *str, ...)'
|
75
61
|
@tiparm = Fiddle::Function.new(curses_dl['tparm'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VARIADIC], Fiddle::TYPE_VOIDP)
|
76
62
|
end
|
77
|
-
|
63
|
+
begin
|
64
|
+
#extern 'int tigetflag(char *str)'
|
65
|
+
@tigetflag = Fiddle::Function.new(curses_dl['tigetflag'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
|
66
|
+
rescue Fiddle::DLError
|
67
|
+
# OpenBSD lacks tigetflag
|
68
|
+
#extern 'int tgetflag(char *str)'
|
69
|
+
@tigetflag = Fiddle::Function.new(curses_dl['tgetflag'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
|
70
|
+
end
|
71
|
+
begin
|
72
|
+
#extern 'int tigetnum(char *str)'
|
73
|
+
@tigetnum = Fiddle::Function.new(curses_dl['tigetnum'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
|
74
|
+
rescue Fiddle::DLError
|
75
|
+
# OpenBSD lacks tigetnum
|
76
|
+
#extern 'int tgetnum(char *str)'
|
77
|
+
@tigetnum = Fiddle::Function.new(curses_dl['tgetnum'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
|
78
|
+
end
|
78
79
|
|
79
80
|
def self.setupterm(term, fildes)
|
80
|
-
errret_int =
|
81
|
+
errret_int = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
|
81
82
|
ret = @setupterm.(term, fildes, errret_int)
|
82
|
-
errret = errret_int.unpack1('i')
|
83
|
+
errret = errret_int[0, Fiddle::SIZEOF_INT].unpack1('i')
|
83
84
|
case ret
|
84
85
|
when 0 # OK
|
85
86
|
0
|
@@ -106,6 +107,7 @@ module Reline::Terminfo
|
|
106
107
|
end
|
107
108
|
|
108
109
|
def self.tigetstr(capname)
|
110
|
+
raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String)
|
109
111
|
capability = @tigetstr.(capname)
|
110
112
|
case capability.to_i
|
111
113
|
when 0, -1
|
@@ -122,6 +124,30 @@ module Reline::Terminfo
|
|
122
124
|
@tiparm.(str, *new_args).to_s
|
123
125
|
end
|
124
126
|
|
127
|
+
def self.tigetflag(capname)
|
128
|
+
raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String)
|
129
|
+
flag = @tigetflag.(capname).to_i
|
130
|
+
case flag
|
131
|
+
when -1
|
132
|
+
raise TerminfoError, "not boolean capability: #{capname}"
|
133
|
+
when 0
|
134
|
+
raise TerminfoError, "can't find capability: #{capname}"
|
135
|
+
end
|
136
|
+
flag
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.tigetnum(capname)
|
140
|
+
raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String)
|
141
|
+
num = @tigetnum.(capname).to_i
|
142
|
+
case num
|
143
|
+
when -2
|
144
|
+
raise TerminfoError, "not numeric capability: #{capname}"
|
145
|
+
when -1
|
146
|
+
raise TerminfoError, "can't find capability: #{capname}"
|
147
|
+
end
|
148
|
+
num
|
149
|
+
end
|
150
|
+
|
125
151
|
def self.enabled?
|
126
152
|
true
|
127
153
|
end
|
@@ -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{
|
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{
|
128
|
-
\u{
|
129
|
-
\u{
|
130
|
-
\u{
|
131
|
-
\u{
|
132
|
-
\u{
|
133
|
-
\u{
|
134
|
-
\u{
|
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{
|
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{
|
417
|
-
\u{
|
418
|
-
\u{
|
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{
|
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{
|
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{
|
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{
|
581
|
-
\u{
|
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{
|
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{
|
611
|
-
\u{1B00}-\u{
|
612
|
-
\u{1B50}-\u{
|
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{
|
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{
|
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{
|
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{
|
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{
|
793
|
-
\u{
|
794
|
-
\u{
|
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{
|
827
|
-
\u{FBD3}-\u{
|
828
|
-
\u{FD50}-\u{FD8F}
|
828
|
+
\u{FB46}-\u{FBC2}
|
829
|
+
\u{FBD3}-\u{FD8F}
|
829
830
|
\u{FD92}-\u{FDC7}
|
830
|
-
\u{
|
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{
|
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{
|
915
|
-
\u{1107F}-\u{
|
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{
|
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{
|
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{
|
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{
|
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{
|
1006
|
-
\u{
|
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{
|
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{
|
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{
|
1146
|
-
\u{
|
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}
|
data/lib/reline/unicode.rb
CHANGED
@@ -38,33 +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+(?:;[
|
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
|
-
|
49
|
-
def self.get_mbchar_byte_size_by_first_char(c)
|
50
|
-
# Checks UTF-8 character byte size
|
51
|
-
case c.ord
|
52
|
-
# 0b0xxxxxxx
|
53
|
-
when ->(code) { (code ^ 0b10000000).allbits?(0b10000000) } then 1
|
54
|
-
# 0b110xxxxx
|
55
|
-
when ->(code) { (code ^ 0b00100000).allbits?(0b11100000) } then 2
|
56
|
-
# 0b1110xxxx
|
57
|
-
when ->(code) { (code ^ 0b00010000).allbits?(0b11110000) } then 3
|
58
|
-
# 0b11110xxx
|
59
|
-
when ->(code) { (code ^ 0b00001000).allbits?(0b11111000) } then 4
|
60
|
-
# 0b111110xx
|
61
|
-
when ->(code) { (code ^ 0b00000100).allbits?(0b11111100) } then 5
|
62
|
-
# 0b1111110x
|
63
|
-
when ->(code) { (code ^ 0b00000010).allbits?(0b11111110) } then 6
|
64
|
-
# successor of mbchar
|
65
|
-
else 0
|
66
|
-
end
|
67
|
-
end
|
68
43
|
|
69
44
|
def self.escape_for_print(str)
|
70
45
|
str.chars.map! { |gr|
|
@@ -132,15 +107,14 @@ class Reline::Unicode
|
|
132
107
|
width = 0
|
133
108
|
rest = str.encode(Encoding::UTF_8)
|
134
109
|
in_zero_width = false
|
135
|
-
rest.scan(WIDTH_SCANNER) do |gc|
|
110
|
+
rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
|
136
111
|
case
|
137
|
-
when
|
112
|
+
when non_printing_start
|
138
113
|
in_zero_width = true
|
139
|
-
when
|
114
|
+
when non_printing_end
|
140
115
|
in_zero_width = false
|
141
|
-
when
|
142
|
-
when gc
|
143
|
-
gc = gc[GRAPHEME_CLUSTER_INDEX]
|
116
|
+
when csi, osc
|
117
|
+
when gc
|
144
118
|
unless in_zero_width
|
145
119
|
width += get_mbchar_width(gc)
|
146
120
|
end
|
@@ -160,24 +134,28 @@ class Reline::Unicode
|
|
160
134
|
width = 0
|
161
135
|
rest = str.encode(Encoding::UTF_8)
|
162
136
|
in_zero_width = false
|
163
|
-
|
137
|
+
seq = String.new(encoding: encoding)
|
138
|
+
rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
|
164
139
|
case
|
165
|
-
when
|
140
|
+
when non_printing_start
|
166
141
|
in_zero_width = true
|
167
|
-
|
142
|
+
lines.last << NON_PRINTING_START
|
143
|
+
when non_printing_end
|
168
144
|
in_zero_width = false
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
when
|
174
|
-
|
145
|
+
lines.last << NON_PRINTING_END
|
146
|
+
when csi
|
147
|
+
lines.last << csi
|
148
|
+
seq << csi
|
149
|
+
when osc
|
150
|
+
lines.last << osc
|
151
|
+
seq << osc
|
152
|
+
when gc
|
175
153
|
unless in_zero_width
|
176
154
|
mbchar_width = get_mbchar_width(gc)
|
177
155
|
if (width += mbchar_width) > max_width
|
178
156
|
width = mbchar_width
|
179
157
|
lines << nil
|
180
|
-
lines <<
|
158
|
+
lines << seq.dup
|
181
159
|
height += 1
|
182
160
|
end
|
183
161
|
end
|
@@ -194,23 +172,22 @@ class Reline::Unicode
|
|
194
172
|
end
|
195
173
|
|
196
174
|
# Take a chunk of a String cut by width with escape sequences.
|
197
|
-
def self.take_range(str, start_col, max_width
|
198
|
-
chunk = String.new(encoding: encoding)
|
175
|
+
def self.take_range(str, start_col, max_width)
|
176
|
+
chunk = String.new(encoding: str.encoding)
|
199
177
|
total_width = 0
|
200
178
|
rest = str.encode(Encoding::UTF_8)
|
201
179
|
in_zero_width = false
|
202
|
-
rest.scan(WIDTH_SCANNER) do |gc|
|
180
|
+
rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
|
203
181
|
case
|
204
|
-
when
|
182
|
+
when non_printing_start
|
205
183
|
in_zero_width = true
|
206
|
-
when
|
184
|
+
when non_printing_end
|
207
185
|
in_zero_width = false
|
208
|
-
when
|
209
|
-
chunk <<
|
210
|
-
when
|
211
|
-
chunk <<
|
212
|
-
when gc
|
213
|
-
gc = gc[GRAPHEME_CLUSTER_INDEX]
|
186
|
+
when csi
|
187
|
+
chunk << csi
|
188
|
+
when osc
|
189
|
+
chunk << osc
|
190
|
+
when gc
|
214
191
|
if in_zero_width
|
215
192
|
chunk << gc
|
216
193
|
else
|
data/lib/reline/version.rb
CHANGED
data/lib/reline/windows.rb
CHANGED
@@ -95,7 +95,7 @@ class Reline::Windows
|
|
95
95
|
end
|
96
96
|
|
97
97
|
VK_RETURN = 0x0D
|
98
|
-
VK_MENU = 0x12
|
98
|
+
VK_MENU = 0x12 # ALT key
|
99
99
|
VK_LMENU = 0xA4
|
100
100
|
VK_CONTROL = 0x11
|
101
101
|
VK_SHIFT = 0x10
|
@@ -249,7 +249,7 @@ class Reline::Windows
|
|
249
249
|
# no char, only control keys
|
250
250
|
return if key.char_code == 0 and key.control_keys.any?
|
251
251
|
|
252
|
-
@@output_buf.push("\e".ord) if key.control_keys.include?(:ALT)
|
252
|
+
@@output_buf.push("\e".ord) if key.control_keys.include?(:ALT) and !key.control_keys.include?(:CTRL)
|
253
253
|
|
254
254
|
@@output_buf.concat(key.char.bytes)
|
255
255
|
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
|
@@ -386,7 +390,7 @@ class Reline::Windows
|
|
386
390
|
def self.scroll_down(val)
|
387
391
|
return if val < 0
|
388
392
|
return unless csbi = get_console_screen_buffer_info
|
389
|
-
buffer_width, x, y,
|
393
|
+
buffer_width, buffer_lines, x, y, attributes, window_left, window_top, window_bottom = csbi.unpack('ssssSssx2s')
|
390
394
|
screen_height = window_bottom - window_top + 1
|
391
395
|
val = screen_height if val > screen_height
|
392
396
|
|