reline 0.2.8.pre.3 → 0.2.8.pre.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -186,9 +186,9 @@ class Reline::Unicode
186
186
  end
187
187
 
188
188
  # Take a chunk of a String with escape sequences.
189
- def self.take_range(str, col, length, encoding = str.encoding)
189
+ def self.take_range(str, start_col, max_width, encoding = str.encoding)
190
190
  chunk = String.new(encoding: encoding)
191
- width = 0
191
+ total_width = 0
192
192
  rest = str.encode(Encoding::UTF_8)
193
193
  in_zero_width = false
194
194
  rest.scan(WIDTH_SCANNER) do |gc|
@@ -206,9 +206,10 @@ class Reline::Unicode
206
206
  if in_zero_width
207
207
  chunk << gc
208
208
  else
209
- width = get_mbchar_width(gc)
210
- break if (width + length) <= col
211
- chunk << gc if col <= width
209
+ mbchar_width = get_mbchar_width(gc)
210
+ total_width += mbchar_width
211
+ break if (start_col + max_width) < total_width
212
+ chunk << gc if start_col < total_width
212
213
  end
213
214
  end
214
215
  end
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.2.8.pre.3'
2
+ VERSION = '0.2.8.pre.7'
3
3
  end
@@ -226,6 +226,8 @@ class Reline::Windows
226
226
  # no char, only control keys
227
227
  return if key.char_code == 0 and key.control_keys.any?
228
228
 
229
+ @@output_buf.push("\e".ord) if key.control_keys.include?(:ALT)
230
+
229
231
  @@output_buf.concat(key.char.bytes)
230
232
  end
231
233
 
data/lib/reline.rb CHANGED
@@ -16,8 +16,15 @@ module Reline
16
16
 
17
17
  class ConfigEncodingConversionError < StandardError; end
18
18
 
19
- Key = Struct.new('Key', :char, :combined_char, :with_meta)
19
+ Key = Struct.new('Key', :char, :combined_char, :with_meta) do
20
+ def match?(key)
21
+ (key.char.nil? or char.nil? or char == key.char) and
22
+ (key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
23
+ (key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
24
+ end
25
+ end
20
26
  CursorPos = Struct.new(:x, :y)
27
+ DialogRenderInfo = Struct.new(:pos, :contents, :pointer, :bg_color, :width, :height, keyword_init: true)
21
28
 
22
29
  class Core
23
30
  ATTR_READER_NAMES = %i(
@@ -193,8 +200,8 @@ module Reline
193
200
  # Auto complete starts only when edited
194
201
  return nil
195
202
  end
196
- pre, target, post= retrieve_completion_block(true)
197
- if target.nil? or target.empty?# or target.size <= 3
203
+ pre, target, post = retrieve_completion_block(true)
204
+ if target.nil? or target.empty? or target.size <= 3
198
205
  return nil
199
206
  end
200
207
  if completion_journey_data and completion_journey_data.list
@@ -205,7 +212,7 @@ module Reline
205
212
  result = call_completion_proc_with_checking_args(pre, target, post)
206
213
  pointer = nil
207
214
  end
208
- if result and result.size == 1 and result[0] == target
215
+ if result and result.size == 1 and result[0] == target and pointer != 0
209
216
  result = nil
210
217
  end
211
218
  target_width = Reline::Unicode.calculate_width(target)
@@ -219,9 +226,9 @@ module Reline
219
226
  cursor_pos_to_render = Reline::CursorPos.new(x, y)
220
227
  if context and context.is_a?(Array)
221
228
  context.clear
222
- context.push(cursor_pos_to_render, result, pointer)
229
+ context.push(cursor_pos_to_render, result, pointer, dialog)
223
230
  end
224
- [cursor_pos_to_render, result, pointer, nil]
231
+ DialogRenderInfo.new(pos: cursor_pos_to_render, contents: result, pointer: pointer, height: 15)
225
232
  }
226
233
  Reline::DEFAULT_DIALOG_CONTEXT = Array.new
227
234
 
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.3
4
+ version: 0.2.8.pre.7
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-29 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console
@@ -47,6 +47,7 @@ files:
47
47
  - lib/reline/key_stroke.rb
48
48
  - lib/reline/kill_ring.rb
49
49
  - lib/reline/line_editor.rb
50
+ - lib/reline/line_editor.rb.orig
50
51
  - lib/reline/sibori.rb
51
52
  - lib/reline/terminfo.rb
52
53
  - lib/reline/unicode.rb