reline 0.2.8.pre.5 → 0.2.8.pre.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/reline/general_io.rb +1 -0
- data/lib/reline/line_editor.rb +43 -32
- data/lib/reline/version.rb +1 -1
- data/lib/reline.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 161818586702ae2834bf5e6490adf5dcec415256925ffd83339ffe6ef3c13012
|
4
|
+
data.tar.gz: 3ab65900ed4022e1baa2213d560938339711264e3188597c4eb98bc1891c81a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 610c5367d68b627fb7e0a7bef7919d147b5a19539725f9a2d184bbed69b0988c613acf1f001d2f05857fce2490e7309e666a4327f1f15cd0541e3bb7db5089ec
|
7
|
+
data.tar.gz: b567f8283fe5637161e21536f500f6824d9a92aadf940e10386d27cf4df29940d3e3d6cb95a7a4fff6e711ac33c73f870ee419b45d44274184160b37354d9d77
|
data/lib/reline/general_io.rb
CHANGED
data/lib/reline/line_editor.rb
CHANGED
@@ -575,13 +575,16 @@ class Reline::LineEditor
|
|
575
575
|
end
|
576
576
|
|
577
577
|
DIALOG_HEIGHT = 20
|
578
|
-
DIALOG_WIDTH = 40
|
579
578
|
private def render_dialog(cursor_column)
|
580
579
|
@dialogs.each do |dialog|
|
581
580
|
render_each_dialog(dialog, cursor_column)
|
582
581
|
end
|
583
582
|
end
|
584
583
|
|
584
|
+
private def padding_space_with_escape_sequences(str, width)
|
585
|
+
str + (' ' * (width - calculate_width(str, true)))
|
586
|
+
end
|
587
|
+
|
585
588
|
private def render_each_dialog(dialog, cursor_column)
|
586
589
|
if @in_pasting
|
587
590
|
dialog.contents = nil
|
@@ -589,26 +592,7 @@ class Reline::LineEditor
|
|
589
592
|
end
|
590
593
|
dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
|
591
594
|
dialog_render_info = dialog.call
|
592
|
-
|
593
|
-
old_dialog = dialog.clone
|
594
|
-
if dialog_render_info and dialog_render_info.contents and not dialog_render_info.contents.empty?
|
595
|
-
height = dialog_render_info.height || DIALOG_HEIGHT
|
596
|
-
pointer = dialog_render_info.pointer
|
597
|
-
dialog.contents = dialog_render_info.contents
|
598
|
-
if dialog.contents.size > height
|
599
|
-
if dialog_render_info.pointer
|
600
|
-
if dialog_render_info.pointer < 0
|
601
|
-
dialog.scroll_top = 0
|
602
|
-
elsif (dialog_render_info.pointer - dialog.scroll_top) >= (height - 1)
|
603
|
-
dialog.scroll_top = dialog_render_info.pointer - (height - 1)
|
604
|
-
elsif (dialog_render_info.pointer - dialog.scroll_top) < 0
|
605
|
-
dialog.scroll_top = dialog_render_info.pointer
|
606
|
-
end
|
607
|
-
pointer = dialog_render_info.pointer - dialog.scroll_top
|
608
|
-
end
|
609
|
-
dialog.contents = dialog.contents[dialog.scroll_top, height]
|
610
|
-
end
|
611
|
-
else
|
595
|
+
if dialog_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty?
|
612
596
|
dialog.lines_backup = {
|
613
597
|
lines: modify_lines(whole_lines),
|
614
598
|
line_index: @line_index,
|
@@ -620,6 +604,25 @@ class Reline::LineEditor
|
|
620
604
|
dialog.contents = nil
|
621
605
|
return
|
622
606
|
end
|
607
|
+
old_dialog = dialog.clone
|
608
|
+
dialog.width = dialog_render_info.width if dialog_render_info.width
|
609
|
+
height = dialog_render_info.height || DIALOG_HEIGHT
|
610
|
+
pointer = dialog_render_info.pointer
|
611
|
+
dialog.contents = dialog_render_info.contents
|
612
|
+
height = dialog.contents.size if dialog.contents.size < height
|
613
|
+
if dialog.contents.size > height
|
614
|
+
if dialog_render_info.pointer
|
615
|
+
if dialog_render_info.pointer < 0
|
616
|
+
dialog.scroll_top = 0
|
617
|
+
elsif (dialog_render_info.pointer - dialog.scroll_top) >= (height - 1)
|
618
|
+
dialog.scroll_top = dialog_render_info.pointer - (height - 1)
|
619
|
+
elsif (dialog_render_info.pointer - dialog.scroll_top) < 0
|
620
|
+
dialog.scroll_top = dialog_render_info.pointer
|
621
|
+
end
|
622
|
+
pointer = dialog_render_info.pointer - dialog.scroll_top
|
623
|
+
end
|
624
|
+
dialog.contents = dialog.contents[dialog.scroll_top, height]
|
625
|
+
end
|
623
626
|
upper_space = @first_line_started_from - @started_from
|
624
627
|
lower_space = @highest_in_all - @first_line_started_from - @started_from - 1
|
625
628
|
dialog.column = dialog_render_info.pos.x
|
@@ -630,7 +633,7 @@ class Reline::LineEditor
|
|
630
633
|
if (lower_space + @rest_height - dialog_render_info.pos.y) >= height
|
631
634
|
dialog.vertical_offset = dialog_render_info.pos.y + 1
|
632
635
|
elsif upper_space >= height
|
633
|
-
dialog.vertical_offset = dialog_render_info.pos.y
|
636
|
+
dialog.vertical_offset = dialog_render_info.pos.y - height
|
634
637
|
else
|
635
638
|
if (lower_space + @rest_height - dialog_render_info.pos.y) < height
|
636
639
|
scroll_down(height + dialog_render_info.pos.y)
|
@@ -652,7 +655,8 @@ class Reline::LineEditor
|
|
652
655
|
bg_color = '46'
|
653
656
|
end
|
654
657
|
end
|
655
|
-
|
658
|
+
str = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, dialog.width), dialog.width)
|
659
|
+
@output.write "\e[#{bg_color}m#{str}\e[49m"
|
656
660
|
Reline::IOGate.move_cursor_column(dialog.column)
|
657
661
|
move_cursor_down(1) if i < (dialog.contents.size - 1)
|
658
662
|
end
|
@@ -696,8 +700,9 @@ class Reline::LineEditor
|
|
696
700
|
s = ' ' * dialog.width
|
697
701
|
else
|
698
702
|
s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, dialog.width)
|
703
|
+
s = padding_space_with_escape_sequences(s, dialog.width)
|
699
704
|
end
|
700
|
-
@output.write "\e[39m\e[49m
|
705
|
+
@output.write "\e[39m\e[49m#{s}\e[39m\e[49m"
|
701
706
|
move_cursor_down(1) if i < (line_num - 1)
|
702
707
|
end
|
703
708
|
move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
|
@@ -713,8 +718,9 @@ class Reline::LineEditor
|
|
713
718
|
s = ' ' * dialog.width
|
714
719
|
else
|
715
720
|
s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, dialog.width)
|
721
|
+
s = padding_space_with_escape_sequences(s, dialog.width)
|
716
722
|
end
|
717
|
-
@output.write "\e[39m\e[49m
|
723
|
+
@output.write "\e[39m\e[49m#{s}\e[39m\e[49m"
|
718
724
|
move_cursor_down(1) if i < (line_num - 1)
|
719
725
|
end
|
720
726
|
move_cursor_up(dialog.vertical_offset + dialog.contents.size + line_num - 1 - y_diff)
|
@@ -731,8 +737,9 @@ class Reline::LineEditor
|
|
731
737
|
s = ' ' * width
|
732
738
|
else
|
733
739
|
s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, width)
|
740
|
+
s = padding_space_with_escape_sequences(s, dialog.width)
|
734
741
|
end
|
735
|
-
@output.write "\e[39m\e[49m
|
742
|
+
@output.write "\e[39m\e[49m#{s}\e[39m\e[49m"
|
736
743
|
move_cursor_down(1) if i < (line_num - 1)
|
737
744
|
end
|
738
745
|
move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
|
@@ -749,9 +756,10 @@ class Reline::LineEditor
|
|
749
756
|
s = ' ' * width
|
750
757
|
else
|
751
758
|
s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column + dialog.width, width)
|
759
|
+
s = padding_space_with_escape_sequences(s, dialog.width)
|
752
760
|
end
|
753
761
|
Reline::IOGate.move_cursor_column(dialog.column + dialog.width)
|
754
|
-
@output.write "\e[39m\e[49m
|
762
|
+
@output.write "\e[39m\e[49m#{s}\e[39m\e[49m"
|
755
763
|
move_cursor_down(1) if i < (line_num - 1)
|
756
764
|
end
|
757
765
|
move_cursor_up(old_dialog.vertical_offset + line_num - 1 + y_diff)
|
@@ -787,13 +795,14 @@ class Reline::LineEditor
|
|
787
795
|
dialog_vertical_size = dialog.contents.size
|
788
796
|
dialog_vertical_size.times do |i|
|
789
797
|
if i < visual_lines_under_dialog.size
|
790
|
-
Reline::IOGate.move_cursor_column(
|
791
|
-
|
798
|
+
Reline::IOGate.move_cursor_column(dialog.column)
|
799
|
+
str = Reline::Unicode.take_range(visual_lines_under_dialog[i], dialog.column, dialog.width)
|
800
|
+
str = padding_space_with_escape_sequences(str, dialog.width)
|
801
|
+
@output.write "\e[39m\e[49m#{str}\e[39m\e[49m"
|
792
802
|
else
|
793
803
|
Reline::IOGate.move_cursor_column(dialog.column)
|
794
804
|
@output.write "\e[39m\e[49m#{' ' * dialog.width}\e[39m\e[49m"
|
795
805
|
end
|
796
|
-
Reline::IOGate.erase_after_cursor
|
797
806
|
move_cursor_down(1) if i < (dialog_vertical_size - 1)
|
798
807
|
end
|
799
808
|
move_cursor_up(dialog_vertical_size - 1 + dialog.vertical_offset)
|
@@ -1287,8 +1296,10 @@ class Reline::LineEditor
|
|
1287
1296
|
end
|
1288
1297
|
end
|
1289
1298
|
completed = @completion_journey_data.list[@completion_journey_data.pointer]
|
1290
|
-
|
1291
|
-
|
1299
|
+
new_line = (@completion_journey_data.preposing + completed + @completion_journey_data.postposing).split("\n")[@line_index]
|
1300
|
+
@line = new_line.nil? ? String.new(encoding: @encoding) : new_line
|
1301
|
+
line_to_pointer = (@completion_journey_data.preposing + completed).split("\n").last
|
1302
|
+
line_to_pointer = String.new(encoding: @encoding) if line_to_pointer.nil?
|
1292
1303
|
@cursor_max = calculate_width(@line)
|
1293
1304
|
@cursor = calculate_width(line_to_pointer)
|
1294
1305
|
@byte_pointer = line_to_pointer.bytesize
|
data/lib/reline/version.rb
CHANGED
data/lib/reline.rb
CHANGED
@@ -194,7 +194,7 @@ module Reline
|
|
194
194
|
# Auto complete starts only when edited
|
195
195
|
return nil
|
196
196
|
end
|
197
|
-
pre, target, post= retrieve_completion_block(true)
|
197
|
+
pre, target, post = retrieve_completion_block(true)
|
198
198
|
if target.nil? or target.empty?# or target.size <= 3
|
199
199
|
return nil
|
200
200
|
end
|
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.2.8.pre.
|
4
|
+
version: 0.2.8.pre.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|