reline 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reline/ansi.rb +9 -2
- data/lib/reline/config.rb +1 -1
- data/lib/reline/general_io.rb +4 -0
- data/lib/reline/line_editor.rb +50 -61
- data/lib/reline/unicode/east_asian_width.rb +88 -56
- data/lib/reline/unicode.rb +6 -1
- data/lib/reline/version.rb +1 -1
- data/lib/reline/windows.rb +4 -0
- data/lib/reline.rb +14 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0fe224245c6f66bdfa42b7fd6b0dc4c30f9645f0c1498fd7780ff17db642eec
|
4
|
+
data.tar.gz: af1b5a53e09f4b2c60ae20e153a4b3043ea3a19a38c58be697067c58f63feec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb456e06f2cef817fe3ae8fa27e9666587f2b3175cdbc97714ab3638d5b11bf606595d772c4e100fc21d9f50ed6e55fb6b833c28bad6b4ae3c8838d2418e75f5
|
7
|
+
data.tar.gz: 6f3eb2f3feee78d7b4754c069a7d6c0d5d29af100bcb493bab2696c9b610c86de4fb3b201d624b6d00f218f1257a526d0c29bf95c79a1ed3daf117f0c95a2768
|
data/lib/reline/ansi.rb
CHANGED
@@ -7,6 +7,9 @@ class Reline::ANSI
|
|
7
7
|
CAPNAME_KEY_BINDINGS = {
|
8
8
|
'khome' => :ed_move_to_beg,
|
9
9
|
'kend' => :ed_move_to_end,
|
10
|
+
'kdch1' => :key_delete,
|
11
|
+
'kpp' => :ed_search_prev_history,
|
12
|
+
'knp' => :ed_search_next_history,
|
10
13
|
'kcuu1' => :ed_prev_history,
|
11
14
|
'kcud1' => :ed_next_history,
|
12
15
|
'kcuf1' => :ed_next_char,
|
@@ -29,8 +32,8 @@ class Reline::ANSI
|
|
29
32
|
false
|
30
33
|
end
|
31
34
|
|
32
|
-
def self.set_default_key_bindings(config)
|
33
|
-
if Reline::Terminfo.enabled?
|
35
|
+
def self.set_default_key_bindings(config, allow_terminfo: true)
|
36
|
+
if allow_terminfo && Reline::Terminfo.enabled?
|
34
37
|
set_default_key_bindings_terminfo(config)
|
35
38
|
else
|
36
39
|
set_default_key_bindings_comprehensive_list(config)
|
@@ -142,6 +145,10 @@ class Reline::ANSI
|
|
142
145
|
@@output = val
|
143
146
|
end
|
144
147
|
|
148
|
+
def self.with_raw_input
|
149
|
+
@@input.raw { yield }
|
150
|
+
end
|
151
|
+
|
145
152
|
@@buf = []
|
146
153
|
def self.inner_getc
|
147
154
|
unless @@buf.empty?
|
data/lib/reline/config.rb
CHANGED
data/lib/reline/general_io.rb
CHANGED
data/lib/reline/line_editor.rb
CHANGED
@@ -52,6 +52,7 @@ class Reline::LineEditor
|
|
52
52
|
MenuInfo = Struct.new('MenuInfo', :target, :list)
|
53
53
|
|
54
54
|
PROMPT_LIST_CACHE_TIMEOUT = 0.5
|
55
|
+
MINIMUM_SCROLLBAR_HEIGHT = 1
|
55
56
|
|
56
57
|
def initialize(config, encoding)
|
57
58
|
@config = config
|
@@ -449,14 +450,10 @@ class Reline::LineEditor
|
|
449
450
|
Reline::IOGate.move_cursor_up(@first_line_started_from + @started_from - @scroll_partial_screen)
|
450
451
|
Reline::IOGate.move_cursor_column(0)
|
451
452
|
@scroll_partial_screen = nil
|
452
|
-
|
453
|
-
|
454
|
-
new_lines = whole_lines(index: @previous_line_index, line: @line)
|
455
|
-
else
|
456
|
-
new_lines = whole_lines
|
457
|
-
end
|
453
|
+
new_lines = whole_lines
|
454
|
+
prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
|
458
455
|
modify_lines(new_lines).each_with_index do |line, index|
|
459
|
-
@output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\n"
|
456
|
+
@output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\r\n"
|
460
457
|
Reline::IOGate.erase_after_cursor
|
461
458
|
end
|
462
459
|
@output.flush
|
@@ -467,7 +464,7 @@ class Reline::LineEditor
|
|
467
464
|
rendered = false
|
468
465
|
if @add_newline_to_end_of_buffer
|
469
466
|
clear_dialog_with_content
|
470
|
-
rerender_added_newline(prompt, prompt_width)
|
467
|
+
rerender_added_newline(prompt, prompt_width, prompt_list)
|
471
468
|
@add_newline_to_end_of_buffer = false
|
472
469
|
else
|
473
470
|
if @just_cursor_moving and not @rerender_all
|
@@ -490,11 +487,7 @@ class Reline::LineEditor
|
|
490
487
|
if @is_multiline
|
491
488
|
if finished?
|
492
489
|
# Always rerender on finish because output_modifier_proc may return a different output.
|
493
|
-
|
494
|
-
new_lines = whole_lines(index: @previous_line_index, line: @line)
|
495
|
-
else
|
496
|
-
new_lines = whole_lines
|
497
|
-
end
|
490
|
+
new_lines = whole_lines
|
498
491
|
line = modify_lines(new_lines)[@line_index]
|
499
492
|
clear_dialog
|
500
493
|
prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
|
@@ -671,8 +664,10 @@ class Reline::LineEditor
|
|
671
664
|
dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
|
672
665
|
dialog_render_info = dialog.call(@last_key)
|
673
666
|
if dialog_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty?
|
667
|
+
lines = whole_lines
|
674
668
|
dialog.lines_backup = {
|
675
|
-
|
669
|
+
unmodified_lines: lines,
|
670
|
+
lines: modify_lines(lines),
|
676
671
|
line_index: @line_index,
|
677
672
|
first_line_started_from: @first_line_started_from,
|
678
673
|
started_from: @started_from,
|
@@ -703,17 +698,17 @@ class Reline::LineEditor
|
|
703
698
|
dialog.scroll_top = dialog.pointer
|
704
699
|
end
|
705
700
|
pointer = dialog.pointer - dialog.scroll_top
|
701
|
+
else
|
702
|
+
dialog.scroll_top = 0
|
706
703
|
end
|
707
704
|
dialog.contents = dialog.contents[dialog.scroll_top, height]
|
708
705
|
end
|
709
|
-
if dialog.contents and dialog.scroll_top >= dialog.contents.size
|
710
|
-
dialog.scroll_top = dialog.contents.size - height
|
711
|
-
end
|
712
706
|
if dialog_render_info.scrollbar and dialog_render_info.contents.size > height
|
713
707
|
bar_max_height = height * 2
|
714
708
|
moving_distance = (dialog_render_info.contents.size - height) * 2
|
715
709
|
position_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance)
|
716
710
|
bar_height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i
|
711
|
+
bar_height = MINIMUM_SCROLLBAR_HEIGHT if bar_height < MINIMUM_SCROLLBAR_HEIGHT
|
717
712
|
dialog.scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i
|
718
713
|
else
|
719
714
|
dialog.scrollbar_pos = nil
|
@@ -755,7 +750,7 @@ class Reline::LineEditor
|
|
755
750
|
str_width = dialog.width - (dialog.scrollbar_pos.nil? ? 0 : @block_elem_width)
|
756
751
|
str = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, str_width), str_width)
|
757
752
|
@output.write "\e[#{bg_color}m\e[#{fg_color}m#{str}"
|
758
|
-
if dialog.scrollbar_pos
|
753
|
+
if dialog.scrollbar_pos
|
759
754
|
@output.write "\e[37m"
|
760
755
|
if dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height)
|
761
756
|
@output.write @full_block
|
@@ -774,8 +769,10 @@ class Reline::LineEditor
|
|
774
769
|
Reline::IOGate.move_cursor_column(cursor_column)
|
775
770
|
move_cursor_up(dialog.vertical_offset + dialog.contents.size - 1)
|
776
771
|
Reline::IOGate.show_cursor
|
772
|
+
lines = whole_lines
|
777
773
|
dialog.lines_backup = {
|
778
|
-
|
774
|
+
unmodified_lines: lines,
|
775
|
+
lines: modify_lines(lines),
|
779
776
|
line_index: @line_index,
|
780
777
|
first_line_started_from: @first_line_started_from,
|
781
778
|
started_from: @started_from,
|
@@ -785,7 +782,7 @@ class Reline::LineEditor
|
|
785
782
|
|
786
783
|
private def reset_dialog(dialog, old_dialog)
|
787
784
|
return if dialog.lines_backup.nil? or old_dialog.contents.nil?
|
788
|
-
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:
|
785
|
+
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
|
789
786
|
visual_lines = []
|
790
787
|
visual_start = nil
|
791
788
|
dialog.lines_backup[:lines].each_with_index { |l, i|
|
@@ -896,7 +893,7 @@ class Reline::LineEditor
|
|
896
893
|
private def clear_each_dialog(dialog)
|
897
894
|
dialog.trap_key = nil
|
898
895
|
return unless dialog.contents
|
899
|
-
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:
|
896
|
+
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
|
900
897
|
visual_lines = []
|
901
898
|
visual_lines_under_dialog = []
|
902
899
|
visual_start = nil
|
@@ -964,11 +961,20 @@ class Reline::LineEditor
|
|
964
961
|
end
|
965
962
|
end
|
966
963
|
|
967
|
-
private def rerender_added_newline(prompt, prompt_width)
|
968
|
-
scroll_down(1)
|
964
|
+
private def rerender_added_newline(prompt, prompt_width, prompt_list)
|
969
965
|
@buffer_of_lines[@previous_line_index] = @line
|
970
966
|
@line = @buffer_of_lines[@line_index]
|
971
|
-
|
967
|
+
@previous_line_index = nil
|
968
|
+
if @in_pasting
|
969
|
+
scroll_down(1)
|
970
|
+
else
|
971
|
+
lines = whole_lines
|
972
|
+
prev_line_prompt = @prompt_proc ? prompt_list[@line_index - 1] : prompt
|
973
|
+
prev_line_prompt_width = @prompt_proc ? calculate_width(prev_line_prompt, true) : prompt_width
|
974
|
+
prev_line = modify_lines(lines)[@line_index - 1]
|
975
|
+
move_cursor_up(@started_from)
|
976
|
+
render_partial(prev_line_prompt, prev_line_prompt_width, prev_line, @first_line_started_from + @started_from, with_control: false)
|
977
|
+
scroll_down(1)
|
972
978
|
render_partial(prompt, prompt_width, @line, @first_line_started_from + @started_from + 1, with_control: false)
|
973
979
|
end
|
974
980
|
@cursor = @cursor_max = calculate_width(@line)
|
@@ -977,7 +983,6 @@ class Reline::LineEditor
|
|
977
983
|
@highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
|
978
984
|
@first_line_started_from += @started_from + 1
|
979
985
|
@started_from = calculate_height_by_width(prompt_width + @cursor) - 1
|
980
|
-
@previous_line_index = nil
|
981
986
|
end
|
982
987
|
|
983
988
|
def just_move_cursor
|
@@ -990,22 +995,18 @@ class Reline::LineEditor
|
|
990
995
|
calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt)
|
991
996
|
end
|
992
997
|
first_line_diff = new_first_line_started_from - @first_line_started_from
|
993
|
-
|
994
|
-
new_started_from = calculate_height_by_width(prompt_width +
|
998
|
+
@cursor, @cursor_max, _, @byte_pointer = calculate_nearest_cursor(@buffer_of_lines[@line_index], @cursor, @started_from, @byte_pointer, false)
|
999
|
+
new_started_from = calculate_height_by_width(prompt_width + @cursor) - 1
|
995
1000
|
calculate_scroll_partial_screen(@highest_in_all, new_first_line_started_from + new_started_from)
|
996
1001
|
@previous_line_index = nil
|
1002
|
+
@line = @buffer_of_lines[@line_index]
|
997
1003
|
if @rerender_all
|
998
|
-
@line = @buffer_of_lines[@line_index]
|
999
1004
|
rerender_all_lines
|
1000
1005
|
@rerender_all = false
|
1001
1006
|
true
|
1002
1007
|
else
|
1003
|
-
@line = @buffer_of_lines[@line_index]
|
1004
1008
|
@first_line_started_from = new_first_line_started_from
|
1005
1009
|
@started_from = new_started_from
|
1006
|
-
@cursor = new_cursor
|
1007
|
-
@cursor_max = new_cursor_max
|
1008
|
-
@byte_pointer = new_byte_pointer
|
1009
1010
|
move_cursor_down(first_line_diff + @started_from)
|
1010
1011
|
Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
|
1011
1012
|
false
|
@@ -1013,11 +1014,7 @@ class Reline::LineEditor
|
|
1013
1014
|
end
|
1014
1015
|
|
1015
1016
|
private def rerender_changed_current_line
|
1016
|
-
|
1017
|
-
new_lines = whole_lines(index: @previous_line_index, line: @line)
|
1018
|
-
else
|
1019
|
-
new_lines = whole_lines
|
1020
|
-
end
|
1017
|
+
new_lines = whole_lines
|
1021
1018
|
prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
|
1022
1019
|
all_height = calculate_height_by_lines(new_lines, prompt_list || prompt)
|
1023
1020
|
diff = all_height - @highest_in_all
|
@@ -1371,8 +1368,8 @@ class Reline::LineEditor
|
|
1371
1368
|
@completion_state = CompletionState::MENU
|
1372
1369
|
end
|
1373
1370
|
if not just_show_list and target < completed
|
1374
|
-
@line = preposing + completed + completion_append_character.to_s + postposing
|
1375
|
-
line_to_pointer = preposing + completed + completion_append_character.to_s
|
1371
|
+
@line = (preposing + completed + completion_append_character.to_s + postposing).split("\n")[@line_index] || String.new(encoding: @encoding)
|
1372
|
+
line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n").last || String.new(encoding: @encoding)
|
1376
1373
|
@cursor_max = calculate_width(@line)
|
1377
1374
|
@cursor = calculate_width(line_to_pointer)
|
1378
1375
|
@byte_pointer = line_to_pointer.bytesize
|
@@ -1698,7 +1695,7 @@ class Reline::LineEditor
|
|
1698
1695
|
return if not @check_new_auto_indent and @previous_line_index # move cursor up or down
|
1699
1696
|
if @check_new_auto_indent and @previous_line_index and @previous_line_index > 0 and @line_index > @previous_line_index
|
1700
1697
|
# Fix indent of a line when a newline is inserted to the next
|
1701
|
-
new_lines = whole_lines
|
1698
|
+
new_lines = whole_lines
|
1702
1699
|
new_indent = @auto_indent_proc.(new_lines[0..-3].push(''), @line_index - 1, 0, true)
|
1703
1700
|
md = @line.match(/\A */)
|
1704
1701
|
prev_indent = md[0].count(' ')
|
@@ -1713,23 +1710,20 @@ class Reline::LineEditor
|
|
1713
1710
|
@line = ' ' * new_indent + @line.lstrip
|
1714
1711
|
end
|
1715
1712
|
end
|
1716
|
-
|
1717
|
-
new_lines = whole_lines(index: @previous_line_index, line: @line)
|
1718
|
-
else
|
1719
|
-
new_lines = whole_lines
|
1720
|
-
end
|
1713
|
+
new_lines = whole_lines
|
1721
1714
|
new_indent = @auto_indent_proc.(new_lines, @line_index, @byte_pointer, @check_new_auto_indent)
|
1722
|
-
new_indent = @cursor_max if new_indent&.> @cursor_max
|
1723
1715
|
if new_indent&.>= 0
|
1724
1716
|
md = new_lines[@line_index].match(/\A */)
|
1725
1717
|
prev_indent = md[0].count(' ')
|
1726
1718
|
if @check_new_auto_indent
|
1727
|
-
@buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
|
1719
|
+
line = @buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
|
1728
1720
|
@cursor = new_indent
|
1721
|
+
@cursor_max = calculate_width(line)
|
1729
1722
|
@byte_pointer = new_indent
|
1730
1723
|
else
|
1731
1724
|
@line = ' ' * new_indent + @line.lstrip
|
1732
1725
|
@cursor += new_indent - prev_indent
|
1726
|
+
@cursor_max = calculate_width(@line)
|
1733
1727
|
@byte_pointer += new_indent - prev_indent
|
1734
1728
|
end
|
1735
1729
|
end
|
@@ -1803,11 +1797,7 @@ class Reline::LineEditor
|
|
1803
1797
|
target = before
|
1804
1798
|
end
|
1805
1799
|
if @is_multiline
|
1806
|
-
|
1807
|
-
lines = whole_lines(index: @previous_line_index, line: @line)
|
1808
|
-
else
|
1809
|
-
lines = whole_lines
|
1810
|
-
end
|
1800
|
+
lines = whole_lines
|
1811
1801
|
if @line_index > 0
|
1812
1802
|
preposing = lines[0..(@line_index - 1)].join("\n") + "\n" + preposing
|
1813
1803
|
end
|
@@ -1907,9 +1897,10 @@ class Reline::LineEditor
|
|
1907
1897
|
@cursor_max = calculate_width(@line)
|
1908
1898
|
end
|
1909
1899
|
|
1910
|
-
def whole_lines
|
1900
|
+
def whole_lines
|
1901
|
+
index = @previous_line_index || @line_index
|
1911
1902
|
temp_lines = @buffer_of_lines.dup
|
1912
|
-
temp_lines[index] = line
|
1903
|
+
temp_lines[index] = @line
|
1913
1904
|
temp_lines
|
1914
1905
|
end
|
1915
1906
|
|
@@ -1917,11 +1908,7 @@ class Reline::LineEditor
|
|
1917
1908
|
if @buffer_of_lines.size == 1 and @line.nil?
|
1918
1909
|
nil
|
1919
1910
|
else
|
1920
|
-
|
1921
|
-
whole_lines(index: @previous_line_index, line: @line).join("\n")
|
1922
|
-
else
|
1923
|
-
whole_lines.join("\n")
|
1924
|
-
end
|
1911
|
+
whole_lines.join("\n")
|
1925
1912
|
end
|
1926
1913
|
end
|
1927
1914
|
|
@@ -1953,8 +1940,10 @@ class Reline::LineEditor
|
|
1953
1940
|
end
|
1954
1941
|
|
1955
1942
|
private def key_delete(key)
|
1956
|
-
if @config.editing_mode_is?(:vi_insert
|
1943
|
+
if @config.editing_mode_is?(:vi_insert)
|
1957
1944
|
ed_delete_next_char(key)
|
1945
|
+
elsif @config.editing_mode_is?(:emacs)
|
1946
|
+
em_delete(key)
|
1958
1947
|
end
|
1959
1948
|
end
|
1960
1949
|
|
@@ -2660,7 +2649,7 @@ class Reline::LineEditor
|
|
2660
2649
|
alias_method :kill_whole_line, :em_kill_line
|
2661
2650
|
|
2662
2651
|
private def em_delete(key)
|
2663
|
-
if
|
2652
|
+
if @line.empty? and (not @is_multiline or @buffer_of_lines.size == 1) and key == "\C-d".ord
|
2664
2653
|
@line = nil
|
2665
2654
|
if @buffer_of_lines.size > 1
|
2666
2655
|
scroll_down(@highest_in_all - @first_line_started_from)
|
@@ -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
@@ -160,16 +160,21 @@ class Reline::Unicode
|
|
160
160
|
width = 0
|
161
161
|
rest = str.encode(Encoding::UTF_8)
|
162
162
|
in_zero_width = false
|
163
|
+
seq = String.new(encoding: encoding)
|
163
164
|
rest.scan(WIDTH_SCANNER) do |gc|
|
164
165
|
case
|
165
166
|
when gc[NON_PRINTING_START_INDEX]
|
166
167
|
in_zero_width = true
|
168
|
+
lines.last << NON_PRINTING_START
|
167
169
|
when gc[NON_PRINTING_END_INDEX]
|
168
170
|
in_zero_width = false
|
171
|
+
lines.last << NON_PRINTING_END
|
169
172
|
when gc[CSI_REGEXP_INDEX]
|
170
173
|
lines.last << gc[CSI_REGEXP_INDEX]
|
174
|
+
seq << gc[CSI_REGEXP_INDEX]
|
171
175
|
when gc[OSC_REGEXP_INDEX]
|
172
176
|
lines.last << gc[OSC_REGEXP_INDEX]
|
177
|
+
seq << gc[OSC_REGEXP_INDEX]
|
173
178
|
when gc[GRAPHEME_CLUSTER_INDEX]
|
174
179
|
gc = gc[GRAPHEME_CLUSTER_INDEX]
|
175
180
|
unless in_zero_width
|
@@ -177,7 +182,7 @@ class Reline::Unicode
|
|
177
182
|
if (width += mbchar_width) > max_width
|
178
183
|
width = mbchar_width
|
179
184
|
lines << nil
|
180
|
-
lines <<
|
185
|
+
lines << seq.dup
|
181
186
|
height += 1
|
182
187
|
end
|
183
188
|
end
|
data/lib/reline/version.rb
CHANGED
data/lib/reline/windows.rb
CHANGED
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
|
|
@@ -265,19 +266,21 @@ module Reline
|
|
265
266
|
Reline::DEFAULT_DIALOG_CONTEXT = Array.new
|
266
267
|
|
267
268
|
def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
269
|
+
Reline::IOGate.with_raw_input do
|
270
|
+
unless confirm_multiline_termination
|
271
|
+
raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
|
272
|
+
end
|
273
|
+
inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
|
272
274
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
275
|
+
whole_buffer = line_editor.whole_buffer.dup
|
276
|
+
whole_buffer.taint if RUBY_VERSION < '2.7'
|
277
|
+
if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
|
278
|
+
Reline::HISTORY << whole_buffer
|
279
|
+
end
|
278
280
|
|
279
|
-
|
280
|
-
|
281
|
+
line_editor.reset_line if line_editor.whole_buffer.nil?
|
282
|
+
whole_buffer
|
283
|
+
end
|
281
284
|
end
|
282
285
|
|
283
286
|
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.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-27 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.
|
75
|
+
rubygems_version: 3.4.8
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Alternative GNU Readline or Editline implementation by pure Ruby.
|