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 +4 -4
- data/README.md +1 -1
- data/lib/reline/ansi.rb +1 -1
- data/lib/reline/config.rb +9 -8
- data/lib/reline/key_actor/emacs.rb +1 -1
- data/lib/reline/line_editor.rb +30 -17
- data/lib/reline/version.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: bcccc644594f9c2e4b9ae0eb743c2ae293ef084e96a8d9bd032b76825111c01b
|
4
|
+
data.tar.gz: b5ab239a3d20925d4fbd8fb827908fa3e4fa70298a172e32e9b2b4de59dc767e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
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
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 +([^ ]+) +(
|
186
|
-
|
187
|
-
|
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(
|
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(
|
305
|
+
@vi_cmd_mode_string = retrieve_string(raw_value)
|
305
306
|
when 'vi-ins-mode-string'
|
306
|
-
@vi_ins_mode_string = retrieve_string(
|
307
|
+
@vi_ins_mode_string = retrieve_string(raw_value)
|
307
308
|
when 'emacs-mode-string'
|
308
|
-
@emacs_mode_string = retrieve_string(
|
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')
|
data/lib/reline/line_editor.rb
CHANGED
@@ -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
|
-
@
|
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
|
-
|
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
|
1164
|
-
if @old_buffer_of_lines
|
1165
|
-
@
|
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
|
-
|
1170
|
+
trim_input_lines
|
1168
1171
|
end
|
1169
1172
|
|
1170
|
-
|
1171
|
-
def
|
1172
|
-
if @
|
1173
|
-
@
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
@
|
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
|
data/lib/reline/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|