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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fca2b6f76f8c59a18589d6d730f7f159e25b95e639ae7d6866f772e9bb2655ab
4
- data.tar.gz: 61b69c3d01f74b957c6a2d646e58021cad4b49031d4fdf6437f2303d417d5f36
3
+ metadata.gz: 161818586702ae2834bf5e6490adf5dcec415256925ffd83339ffe6ef3c13012
4
+ data.tar.gz: 3ab65900ed4022e1baa2213d560938339711264e3188597c4eb98bc1891c81a8
5
5
  SHA512:
6
- metadata.gz: 561ffdbf39c095852f0a642178d5328329cea072fdc91c32bd11edfdcecb4846414006961b6fe7adbf63c825022a8634d5a563fdeb574d127088b536967e1f9c
7
- data.tar.gz: 07e62e55ca7a45d3b747724823b26af09d109f9620ba82914cfaf7e6100251bb76bd0de7b01b9829b51e41248a32b028bbbb3617c7d4eedfc2c1d05ab701a236
6
+ metadata.gz: 610c5367d68b627fb7e0a7bef7919d147b5a19539725f9a2d184bbed69b0988c613acf1f001d2f05857fce2490e7309e666a4327f1f15cd0541e3bb7db5089ec
7
+ data.tar.gz: b567f8283fe5637161e21536f500f6824d9a92aadf940e10386d27cf4df29940d3e3d6cb95a7a4fff6e711ac33c73f870ee419b45d44274184160b37354d9d77
@@ -24,6 +24,7 @@ class Reline::GeneralIO
24
24
  end
25
25
 
26
26
  @@buf = []
27
+ @@input = STDIN
27
28
 
28
29
  def self.input=(val)
29
30
  @@input = val
@@ -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
- dialog.width = dialog_render_info.width if dialog_render_info and dialog_render_info.width
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 + -(height + 1)
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
- @output.write "\e[#{bg_color}m%-#{dialog.width}s\e[49m" % Reline::Unicode.take_range(item, 0, dialog.width)
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%-#{dialog.width}s\e[39m\e[49m" % s
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%-#{dialog.width}s\e[39m\e[49m" % s
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%-#{width}s\e[39m\e[49m" % s
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%-#{width}s\e[39m\e[49m" % s
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(0)
791
- @output.write "\e[39m\e[49m%-#{dialog.width}s\e[39m\e[49m" % visual_lines_under_dialog[i]
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
- @line = @completion_journey_data.preposing + completed + @completion_journey_data.postposing
1291
- line_to_pointer = @completion_journey_data.preposing + completed
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
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.2.8.pre.5'
2
+ VERSION = '0.2.8.pre.6'
3
3
  end
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.5
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-08-31 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console