reline 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06a566ff8fc4daaf8ecee47eb28dac9e3e1a1d94fe05be5b9b9e1eb3a58228cc
4
- data.tar.gz: 70b3aa5a4bcbf7fd7e564d47857f18717e49e2163ee5e5789d81f0bc246a2e17
3
+ metadata.gz: bcccc644594f9c2e4b9ae0eb743c2ae293ef084e96a8d9bd032b76825111c01b
4
+ data.tar.gz: b5ab239a3d20925d4fbd8fb827908fa3e4fa70298a172e32e9b2b4de59dc767e
5
5
  SHA512:
6
- metadata.gz: e1eaf728bdb9be12e3d6fdba67a00651641426f7f70b6248360d47b7101d638d17b9ddbc70e20ad6fbd428dfcd69a6cb75e01bf4f9b20ebde16c3c5e2216231d
7
- data.tar.gz: 28645bd429b1210b50875109c1fad90a5cd759e0411e99292ef1d785341b28ae851d144c3e1faeae994e42eaed735a71f8a94d5c74423085f1ac7d5ce72bdb72
6
+ metadata.gz: 9bce894711da0253bf9b3f0eb192ff64947d591edd00f9094430431eb470fade4d02f3f8b529d364cdd7124d7f5a5203ea755be41dbfda890e37654aca430706
7
+ data.tar.gz: eed500ad148a1f83e3de03e6d7daaf5d250ba3ea25d47d24070e749dfd44a7d900b83474dd0b427faee74bad883dab97b7af1984a7fb7209e1819fd416d4381b
data/README.md CHANGED
@@ -15,7 +15,7 @@ Reline is compatible with the API of Ruby's stdlib 'readline', GNU Readline and
15
15
 
16
16
  It's compatible with the readline standard library.
17
17
 
18
- See [the document of readline stdlib](https://ruby-doc.org/stdlib/libdoc/readline/rdoc/Readline.html) or [bin/example](https://github.com/ruby/reline/blob/master/bin/example).
18
+ See [the document of readline stdlib](https://ruby-doc.org/stdlib/exts/readline/Readline.html) or [bin/example](https://github.com/ruby/reline/blob/master/bin/example).
19
19
 
20
20
  ### Multi-line editing mode
21
21
 
data/lib/reline/ansi.rb CHANGED
@@ -235,7 +235,7 @@ class Reline::ANSI
235
235
  s = [ENV["LINES"].to_i, ENV["COLUMNS"].to_i]
236
236
  return s if s[0] > 0 && s[1] > 0
237
237
  [24, 80]
238
- rescue Errno::ENOTTY
238
+ rescue Errno::ENOTTY, Errno::ENODEV
239
239
  [24, 80]
240
240
  end
241
241
 
data/lib/reline/config.rb CHANGED
@@ -182,9 +182,10 @@ class Reline::Config
182
182
  next if if_stack.any? { |_no, skip| skip }
183
183
 
184
184
  case line
185
- when /^set +([^ ]+) +([^ ]+)/i
186
- var, value = $1.downcase, $2
187
- bind_variable(var, value)
185
+ when /^set +([^ ]+) +(.+)/i
186
+ # value ignores everything after a space, raw_value does not.
187
+ var, value, raw_value = $1.downcase, $2.partition(' ').first, $2
188
+ bind_variable(var, value, raw_value)
188
189
  next
189
190
  when /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/o
190
191
  key, func_name = $1, $2
@@ -234,7 +235,7 @@ class Reline::Config
234
235
  end
235
236
  end
236
237
 
237
- def bind_variable(name, value)
238
+ def bind_variable(name, value, raw_value)
238
239
  case name
239
240
  when 'history-size'
240
241
  begin
@@ -259,7 +260,7 @@ class Reline::Config
259
260
  when 'completion-query-items'
260
261
  @completion_query_items = value.to_i
261
262
  when 'isearch-terminators'
262
- @isearch_terminators = retrieve_string(value)
263
+ @isearch_terminators = retrieve_string(raw_value)
263
264
  when 'editing-mode'
264
265
  case value
265
266
  when 'emacs'
@@ -301,11 +302,11 @@ class Reline::Config
301
302
  @show_mode_in_prompt = false
302
303
  end
303
304
  when 'vi-cmd-mode-string'
304
- @vi_cmd_mode_string = retrieve_string(value)
305
+ @vi_cmd_mode_string = retrieve_string(raw_value)
305
306
  when 'vi-ins-mode-string'
306
- @vi_ins_mode_string = retrieve_string(value)
307
+ @vi_ins_mode_string = retrieve_string(raw_value)
307
308
  when 'emacs-mode-string'
308
- @emacs_mode_string = retrieve_string(value)
309
+ @emacs_mode_string = retrieve_string(raw_value)
309
310
  when *VARIABLE_NAMES then
310
311
  variable_name = :"@#{name.tr(?-, ?_)}"
311
312
  instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on')
@@ -319,7 +319,7 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
319
319
  # 158 M-^^
320
320
  :ed_unassigned,
321
321
  # 159 M-^_
322
- :ed_unassigned,
322
+ :redo,
323
323
  # 160 M-SPACE
324
324
  :em_set_mark,
325
325
  # 161 M-!
@@ -250,7 +250,8 @@ class Reline::LineEditor
250
250
  @resized = false
251
251
  @cache = {}
252
252
  @rendered_screen = RenderedScreen.new(base_y: 0, lines: [], cursor_y: 0)
253
- @past_lines = []
253
+ @input_lines = [[[""], 0, 0]]
254
+ @input_lines_position = 0
254
255
  @undoing = false
255
256
  reset_line
256
257
  end
@@ -1137,7 +1138,7 @@ class Reline::LineEditor
1137
1138
  @completion_journey_state = nil
1138
1139
  end
1139
1140
 
1140
- push_past_lines unless @undoing
1141
+ push_input_lines unless @undoing
1141
1142
  @undoing = false
1142
1143
 
1143
1144
  if @in_pasting
@@ -1156,21 +1157,24 @@ class Reline::LineEditor
1156
1157
 
1157
1158
  def save_old_buffer
1158
1159
  @old_buffer_of_lines = @buffer_of_lines.dup
1159
- @old_byte_pointer = @byte_pointer.dup
1160
- @old_line_index = @line_index.dup
1161
1160
  end
1162
1161
 
1163
- def push_past_lines
1164
- if @old_buffer_of_lines != @buffer_of_lines
1165
- @past_lines.push([@old_buffer_of_lines, @old_byte_pointer, @old_line_index])
1162
+ def push_input_lines
1163
+ if @old_buffer_of_lines == @buffer_of_lines
1164
+ @input_lines[@input_lines_position] = [@buffer_of_lines.dup, @byte_pointer, @line_index]
1165
+ else
1166
+ @input_lines = @input_lines[0..@input_lines_position]
1167
+ @input_lines_position += 1
1168
+ @input_lines.push([@buffer_of_lines.dup, @byte_pointer, @line_index])
1166
1169
  end
1167
- trim_past_lines
1170
+ trim_input_lines
1168
1171
  end
1169
1172
 
1170
- MAX_PAST_LINES = 100
1171
- def trim_past_lines
1172
- if @past_lines.size > MAX_PAST_LINES
1173
- @past_lines.shift
1173
+ MAX_INPUT_LINES = 100
1174
+ def trim_input_lines
1175
+ if @input_lines.size > MAX_INPUT_LINES
1176
+ @input_lines.shift
1177
+ @input_lines_position -= 1
1174
1178
  end
1175
1179
  end
1176
1180
 
@@ -1352,7 +1356,7 @@ class Reline::LineEditor
1352
1356
  @buffer_of_lines[@line_index, 1] = lines
1353
1357
  @line_index += lines.size - 1
1354
1358
  @byte_pointer = @buffer_of_lines[@line_index].bytesize - post.bytesize
1355
- push_past_lines
1359
+ push_input_lines
1356
1360
  end
1357
1361
 
1358
1362
  def insert_text(text)
@@ -2529,13 +2533,22 @@ class Reline::LineEditor
2529
2533
  end
2530
2534
 
2531
2535
  private def undo(_key)
2532
- return if @past_lines.empty?
2536
+ @undoing = true
2537
+
2538
+ return if @input_lines_position <= 0
2539
+
2540
+ @input_lines_position -= 1
2541
+ target_lines, target_cursor_x, target_cursor_y = @input_lines[@input_lines_position]
2542
+ set_current_lines(target_lines.dup, target_cursor_x, target_cursor_y)
2543
+ end
2533
2544
 
2545
+ private def redo(_key)
2534
2546
  @undoing = true
2535
2547
 
2536
- target_lines, target_cursor_x, target_cursor_y = @past_lines.last
2537
- set_current_lines(target_lines, target_cursor_x, target_cursor_y)
2548
+ return if @input_lines_position >= @input_lines.size - 1
2538
2549
 
2539
- @past_lines.pop
2550
+ @input_lines_position += 1
2551
+ target_lines, target_cursor_x, target_cursor_y = @input_lines[@input_lines_position]
2552
+ set_current_lines(target_lines.dup, target_cursor_x, target_cursor_y)
2540
2553
  end
2541
2554
  end
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.5.7'
2
+ VERSION = '0.5.8'
3
3
  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.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-14 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console