reline 0.2.8.pre.10 → 0.2.8.pre.11

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: cdcb3b1edc046520bc5be9cbddb21a4ba498fd1111319c90b05f76b066155eaa
4
- data.tar.gz: f5a5af7fb221dc0fb21aac67baa20af7c159f22ee792b5f9264badb1ff8b6ba4
3
+ metadata.gz: 5d16269b004e83a04194509a08f401942324ca51a216897f84a7c79bf0c1e0a4
4
+ data.tar.gz: dc7fe8a18875d588b45f6e5ef37bba5495e40d30ab0268d7895f4dfb36b6e3bc
5
5
  SHA512:
6
- metadata.gz: a40a42eb7fe33b39dbf8d56eae76708caee116462bbe35b537e36b39e0edb8263cd5854f48b8c7ef440b686c5dabb7e34c72ec844c2ab79661797c23a28a9f0f
7
- data.tar.gz: 9937033c4b7509a3ef39522bc82e574cd6049cfa6204463625bf89ad427ff7c21e36ca3e0a94b11e3b36dfb1cacb2b3a357a3a115e80b13e94eb9512697aea1e
6
+ metadata.gz: 59c0d2c3361faedafaa0266b8951d9dd5b2776aac5b37cb139b2e1a28b2c4a10b825aa79f90054d79eb5f8c5aa1d0969ee63d8e105605c66ec991e4527d2e35f
7
+ data.tar.gz: 43fbf984721138fe3c52c3ddda17d06f8a2d5f95a0216120d2b62134c3f99d7c8798e23bac06d7d6cef7748360e5ad35cca5804cd81d31e11c429a24e0d087f7
@@ -181,7 +181,27 @@ class Reline::LineEditor
181
181
  Reline::IOGate.set_winch_handler do
182
182
  @resized = true
183
183
  end
184
- @block_elem_width = Reline::Unicode.calculate_width('')
184
+ if ENV.key?('RELINE_ALT_SCROLLBAR')
185
+ @full_block = '::'
186
+ @upper_half_block = "''"
187
+ @lower_half_block = '..'
188
+ @block_elem_width = 2
189
+ elsif Reline::IOGate.win?
190
+ @full_block = '█'
191
+ @upper_half_block = '▀'
192
+ @lower_half_block = '▄'
193
+ @block_elem_width = 1
194
+ elsif @encoding == Encoding::UTF_8
195
+ @full_block = '█'
196
+ @upper_half_block = '▀'
197
+ @lower_half_block = '▄'
198
+ @block_elem_width = Reline::Unicode.calculate_width('█')
199
+ else
200
+ @full_block = '::'
201
+ @upper_half_block = "''"
202
+ @lower_half_block = '..'
203
+ @block_elem_width = 2
204
+ end
185
205
  end
186
206
 
187
207
  def resize
@@ -618,7 +638,7 @@ class Reline::LineEditor
618
638
  @dialogs << Dialog.new(name, @config, DialogProcScope.new(self, @config, p, context))
619
639
  end
620
640
 
621
- DIALOG_HEIGHT = 20
641
+ DIALOG_DEFAULT_HEIGHT = 20
622
642
  private def render_dialog(cursor_column)
623
643
  @dialogs.each do |dialog|
624
644
  render_each_dialog(dialog, cursor_column)
@@ -658,7 +678,7 @@ class Reline::LineEditor
658
678
  else
659
679
  dialog.width = dialog.contents.map { |l| calculate_width(l, true) }.max
660
680
  end
661
- height = dialog_render_info.height || DIALOG_HEIGHT
681
+ height = dialog_render_info.height || DIALOG_DEFAULT_HEIGHT
662
682
  height = dialog.contents.size if dialog.contents.size < height
663
683
  if dialog.contents.size > height
664
684
  if dialog.pointer
@@ -673,6 +693,9 @@ class Reline::LineEditor
673
693
  end
674
694
  dialog.contents = dialog.contents[dialog.scroll_top, height]
675
695
  end
696
+ if dialog.contents and dialog.scroll_top >= dialog.contents.size
697
+ dialog.scroll_top = dialog.contents.size - height
698
+ end
676
699
  if dialog_render_info.scrollbar and dialog_render_info.contents.size > height
677
700
  bar_max_height = height * 2
678
701
  moving_distance = (dialog_render_info.contents.size - height) * 2
@@ -685,7 +708,8 @@ class Reline::LineEditor
685
708
  upper_space = @first_line_started_from - @started_from
686
709
  lower_space = @highest_in_all - @first_line_started_from - @started_from - 1
687
710
  dialog.column = dialog_render_info.pos.x
688
- diff = (dialog.column + dialog.width) - (@screen_size.last - 1)
711
+ dialog.width += @block_elem_width if dialog.scrollbar_pos
712
+ diff = (dialog.column + dialog.width) - (@screen_size.last)
689
713
  if diff > 0
690
714
  dialog.column -= diff
691
715
  end
@@ -701,7 +725,10 @@ class Reline::LineEditor
701
725
  dialog.vertical_offset = dialog_render_info.pos.y + 1
702
726
  end
703
727
  Reline::IOGate.hide_cursor
704
- dialog.width += @block_elem_width if dialog.scrollbar_pos
728
+ if dialog.column < 0
729
+ dialog.column = 0
730
+ dialog.width = @screen_size.last
731
+ end
705
732
  reset_dialog(dialog, old_dialog)
706
733
  move_cursor_down(dialog.vertical_offset)
707
734
  Reline::IOGate.move_cursor_column(dialog.column)
@@ -721,12 +748,12 @@ class Reline::LineEditor
721
748
  if dialog.scrollbar_pos and (dialog.scrollbar_pos != old_dialog.scrollbar_pos or dialog.column != old_dialog.column)
722
749
  @output.write "\e[37m"
723
750
  if dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height)
724
- @output.write '█'
751
+ @output.write @full_block
725
752
  elsif dialog.scrollbar_pos <= (i * 2) and (i * 2) < (dialog.scrollbar_pos + bar_height)
726
- @output.write '▀'
753
+ @output.write @upper_half_block
727
754
  str += ''
728
755
  elsif dialog.scrollbar_pos <= (i * 2 + 1) and (i * 2) < (dialog.scrollbar_pos + bar_height)
729
- @output.write '▄'
756
+ @output.write @lower_half_block
730
757
  else
731
758
  @output.write ' ' * @block_elem_width
732
759
  end
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.2.8.pre.10'
2
+ VERSION = '0.2.8.pre.11'
3
3
  end
@@ -323,12 +323,13 @@ class Reline::Windows
323
323
  end
324
324
 
325
325
  def self.erase_after_cursor
326
- csbi = 0.chr * 24
326
+ csbi = 0.chr * 22
327
327
  @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi)
328
+ attributes = csbi[8, 2].unpack1('S')
328
329
  cursor = csbi[4, 4].unpack1('L')
329
330
  written = 0.chr * 4
330
331
  @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, get_screen_size.last - cursor_pos.x, cursor, written)
331
- @@FillConsoleOutputAttribute.call(@@hConsoleHandle, 0, get_screen_size.last - cursor_pos.x, cursor, written)
332
+ @@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, get_screen_size.last - cursor_pos.x, cursor, written)
332
333
  end
333
334
 
334
335
  def self.scroll_down(val)
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.10
4
+ version: 0.2.8.pre.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-03 00:00:00.000000000 Z
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.3.1
75
75
  requirements: []
76
- rubygems_version: 3.2.22
76
+ rubygems_version: 3.1.6
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Alternative GNU Readline or Editline implementation by pure Ruby.