reline 0.6.2 → 0.6.3
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 +4 -4
- data/lib/reline/io/ansi.rb +0 -12
- data/lib/reline/line_editor.rb +36 -36
- data/lib/reline/unicode.rb +1 -1
- data/lib/reline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cac4dc95dc3a9106a6f332d3503a62502f09205161a21157222e2dcd985ab706
|
|
4
|
+
data.tar.gz: 586f28ad1d6e68eefe7e5b4a15a4ee69f9d55d5469c144b686b72084b0abebe8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f2e8fc8a404e1e8a0491c083e5ce524c5a5e465fceebcfa6eb7c0a5df20b98e07d337bb2c8703806f54e055efbeeba9c5d1f3171bd8e0faf6a611e30bbbf5da
|
|
7
|
+
data.tar.gz: a73fe51d441f70a4bb84ecfac2172251e6db0abf9f3007cbadf4f0374e5772b3ee62f71c753f10e88aa460278d1c0611b32ebca2e6f59fc6e42894377b56eb34
|
data/lib/reline/io/ansi.rb
CHANGED
|
@@ -167,17 +167,6 @@ class Reline::ANSI < Reline::IO
|
|
|
167
167
|
@buf.unshift(c)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
-
def retrieve_keybuffer
|
|
171
|
-
begin
|
|
172
|
-
return unless @input.wait_readable(0.001)
|
|
173
|
-
str = @input.read_nonblock(1024)
|
|
174
|
-
str.bytes.each do |c|
|
|
175
|
-
@buf.push(c)
|
|
176
|
-
end
|
|
177
|
-
rescue EOFError
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
170
|
def get_screen_size
|
|
182
171
|
s = @input.winsize
|
|
183
172
|
return s if s[0] > 0 && s[1] > 0
|
|
@@ -309,7 +298,6 @@ class Reline::ANSI < Reline::IO
|
|
|
309
298
|
def prep
|
|
310
299
|
# Enable bracketed paste
|
|
311
300
|
write "\e[?2004h" if Reline.core.config.enable_bracketed_paste && both_tty?
|
|
312
|
-
retrieve_keybuffer
|
|
313
301
|
nil
|
|
314
302
|
end
|
|
315
303
|
|
data/lib/reline/line_editor.rb
CHANGED
|
@@ -948,7 +948,7 @@ class Reline::LineEditor
|
|
|
948
948
|
|
|
949
949
|
def wrap_method_call(method_symbol, key, with_operator)
|
|
950
950
|
if @waiting_proc
|
|
951
|
-
@waiting_proc.call(key)
|
|
951
|
+
@waiting_proc.call(key, method_symbol)
|
|
952
952
|
return
|
|
953
953
|
end
|
|
954
954
|
|
|
@@ -1434,21 +1434,24 @@ class Reline::LineEditor
|
|
|
1434
1434
|
end
|
|
1435
1435
|
alias_method :end_of_line, :ed_move_to_end
|
|
1436
1436
|
|
|
1437
|
-
private def generate_searcher(
|
|
1437
|
+
private def generate_searcher(direction)
|
|
1438
1438
|
search_word = String.new(encoding: encoding)
|
|
1439
1439
|
hit_pointer = nil
|
|
1440
|
-
lambda do |key|
|
|
1440
|
+
lambda do |key, key_symbol|
|
|
1441
1441
|
search_again = false
|
|
1442
|
-
case
|
|
1443
|
-
when
|
|
1442
|
+
case key_symbol
|
|
1443
|
+
when :em_delete_prev_char, :backward_delete_char
|
|
1444
1444
|
grapheme_clusters = search_word.grapheme_clusters
|
|
1445
1445
|
if grapheme_clusters.size > 0
|
|
1446
1446
|
grapheme_clusters.pop
|
|
1447
1447
|
search_word = grapheme_clusters.join
|
|
1448
1448
|
end
|
|
1449
|
-
when
|
|
1450
|
-
search_again =
|
|
1451
|
-
|
|
1449
|
+
when :reverse_search_history, :vi_search_prev
|
|
1450
|
+
search_again = direction == :reverse
|
|
1451
|
+
direction = :reverse
|
|
1452
|
+
when :forward_search_history, :vi_search_next
|
|
1453
|
+
search_again = direction == :forward
|
|
1454
|
+
direction = :forward
|
|
1452
1455
|
else
|
|
1453
1456
|
search_word << key
|
|
1454
1457
|
end
|
|
@@ -1462,11 +1465,11 @@ class Reline::LineEditor
|
|
|
1462
1465
|
search_word = Reline.last_incremental_search
|
|
1463
1466
|
end
|
|
1464
1467
|
if @history_pointer
|
|
1465
|
-
case
|
|
1466
|
-
when
|
|
1468
|
+
case direction
|
|
1469
|
+
when :reverse
|
|
1467
1470
|
history_pointer_base = 0
|
|
1468
1471
|
history = Reline::HISTORY[0..(@history_pointer - 1)]
|
|
1469
|
-
when
|
|
1472
|
+
when :forward
|
|
1470
1473
|
history_pointer_base = @history_pointer + 1
|
|
1471
1474
|
history = Reline::HISTORY[(@history_pointer + 1)..-1]
|
|
1472
1475
|
end
|
|
@@ -1475,11 +1478,11 @@ class Reline::LineEditor
|
|
|
1475
1478
|
history = Reline::HISTORY
|
|
1476
1479
|
end
|
|
1477
1480
|
elsif @history_pointer
|
|
1478
|
-
case
|
|
1479
|
-
when
|
|
1481
|
+
case direction
|
|
1482
|
+
when :reverse
|
|
1480
1483
|
history_pointer_base = 0
|
|
1481
1484
|
history = Reline::HISTORY[0..@history_pointer]
|
|
1482
|
-
when
|
|
1485
|
+
when :forward
|
|
1483
1486
|
history_pointer_base = @history_pointer
|
|
1484
1487
|
history = Reline::HISTORY[@history_pointer..-1]
|
|
1485
1488
|
end
|
|
@@ -1487,12 +1490,12 @@ class Reline::LineEditor
|
|
|
1487
1490
|
history_pointer_base = 0
|
|
1488
1491
|
history = Reline::HISTORY
|
|
1489
1492
|
end
|
|
1490
|
-
case
|
|
1491
|
-
when
|
|
1493
|
+
case direction
|
|
1494
|
+
when :reverse
|
|
1492
1495
|
hit_index = history.rindex { |item|
|
|
1493
1496
|
item.include?(search_word)
|
|
1494
1497
|
}
|
|
1495
|
-
when
|
|
1498
|
+
when :forward
|
|
1496
1499
|
hit_index = history.index { |item|
|
|
1497
1500
|
item.include?(search_word)
|
|
1498
1501
|
}
|
|
@@ -1502,31 +1505,28 @@ class Reline::LineEditor
|
|
|
1502
1505
|
hit = Reline::HISTORY[hit_pointer]
|
|
1503
1506
|
end
|
|
1504
1507
|
end
|
|
1505
|
-
|
|
1506
|
-
when "\C-r"
|
|
1507
|
-
prompt_name = 'reverse-i-search'
|
|
1508
|
-
when "\C-s"
|
|
1509
|
-
prompt_name = 'i-search'
|
|
1510
|
-
end
|
|
1508
|
+
prompt_name = direction == :forward ? 'i-search' : 'reverse-i-search'
|
|
1511
1509
|
prompt_name = "failed #{prompt_name}" unless hit
|
|
1512
1510
|
[search_word, prompt_name, hit_pointer]
|
|
1513
1511
|
end
|
|
1514
1512
|
end
|
|
1515
1513
|
|
|
1516
|
-
private def incremental_search_history(
|
|
1514
|
+
private def incremental_search_history(direction)
|
|
1517
1515
|
backup = @buffer_of_lines.dup, @line_index, @byte_pointer, @history_pointer, @line_backup_in_history
|
|
1518
|
-
searcher = generate_searcher(
|
|
1519
|
-
|
|
1516
|
+
searcher = generate_searcher(direction)
|
|
1517
|
+
prompt_name = direction == :forward ? 'i-search' : 'reverse-i-search'
|
|
1518
|
+
@searching_prompt = "(#{prompt_name})`': "
|
|
1520
1519
|
termination_keys = ["\C-j"]
|
|
1521
1520
|
termination_keys.concat(@config.isearch_terminators.chars) if @config.isearch_terminators
|
|
1522
|
-
|
|
1521
|
+
accept_key_syms = [:em_delete_prev_char, :backward_delete_char, :vi_search_prev, :vi_search_next, :reverse_search_history, :forward_search_history]
|
|
1522
|
+
@waiting_proc = ->(k, key_symbol) {
|
|
1523
1523
|
if k == "\C-g"
|
|
1524
1524
|
# cancel search and restore buffer
|
|
1525
1525
|
@buffer_of_lines, @line_index, @byte_pointer, @history_pointer, @line_backup_in_history = backup
|
|
1526
1526
|
@searching_prompt = nil
|
|
1527
1527
|
@waiting_proc = nil
|
|
1528
|
-
elsif !termination_keys.include?(k) && (k.match?(/[[:print:]]/) ||
|
|
1529
|
-
search_word, prompt_name, hit_pointer = searcher.call(k)
|
|
1528
|
+
elsif !termination_keys.include?(k) && (k.match?(/[[:print:]]/) || accept_key_syms.include?(key_symbol))
|
|
1529
|
+
search_word, prompt_name, hit_pointer = searcher.call(k, key_symbol)
|
|
1530
1530
|
Reline.last_incremental_search = search_word
|
|
1531
1531
|
@searching_prompt = "(%s)`%s'" % [prompt_name, search_word]
|
|
1532
1532
|
@searching_prompt += ': ' unless @is_multiline
|
|
@@ -1541,12 +1541,12 @@ class Reline::LineEditor
|
|
|
1541
1541
|
end
|
|
1542
1542
|
|
|
1543
1543
|
private def vi_search_prev(key)
|
|
1544
|
-
incremental_search_history(
|
|
1544
|
+
incremental_search_history(:reverse)
|
|
1545
1545
|
end
|
|
1546
1546
|
alias_method :reverse_search_history, :vi_search_prev
|
|
1547
1547
|
|
|
1548
1548
|
private def vi_search_next(key)
|
|
1549
|
-
incremental_search_history(
|
|
1549
|
+
incremental_search_history(:forward)
|
|
1550
1550
|
end
|
|
1551
1551
|
alias_method :forward_search_history, :vi_search_next
|
|
1552
1552
|
|
|
@@ -2182,7 +2182,7 @@ class Reline::LineEditor
|
|
|
2182
2182
|
end
|
|
2183
2183
|
|
|
2184
2184
|
private def vi_replace_char(key, arg: 1)
|
|
2185
|
-
@waiting_proc = ->(k) {
|
|
2185
|
+
@waiting_proc = ->(k, _sym) {
|
|
2186
2186
|
if arg == 1
|
|
2187
2187
|
byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
|
|
2188
2188
|
before = current_line.byteslice(0, @byte_pointer)
|
|
@@ -2206,11 +2206,11 @@ class Reline::LineEditor
|
|
|
2206
2206
|
end
|
|
2207
2207
|
|
|
2208
2208
|
private def vi_next_char(key, arg: 1, inclusive: false)
|
|
2209
|
-
@waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, inclusive: inclusive) }
|
|
2209
|
+
@waiting_proc = ->(key_for_proc, _sym) { search_next_char(key_for_proc, arg, inclusive: inclusive) }
|
|
2210
2210
|
end
|
|
2211
2211
|
|
|
2212
2212
|
private def vi_to_next_char(key, arg: 1, inclusive: false)
|
|
2213
|
-
@waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, need_prev_char: true, inclusive: inclusive) }
|
|
2213
|
+
@waiting_proc = ->(key_for_proc, _sym) { search_next_char(key_for_proc, arg, need_prev_char: true, inclusive: inclusive) }
|
|
2214
2214
|
end
|
|
2215
2215
|
|
|
2216
2216
|
private def search_next_char(key, arg, need_prev_char: false, inclusive: false)
|
|
@@ -2253,11 +2253,11 @@ class Reline::LineEditor
|
|
|
2253
2253
|
end
|
|
2254
2254
|
|
|
2255
2255
|
private def vi_prev_char(key, arg: 1)
|
|
2256
|
-
@waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg) }
|
|
2256
|
+
@waiting_proc = ->(key_for_proc, _sym) { search_prev_char(key_for_proc, arg) }
|
|
2257
2257
|
end
|
|
2258
2258
|
|
|
2259
2259
|
private def vi_to_prev_char(key, arg: 1)
|
|
2260
|
-
@waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg, true) }
|
|
2260
|
+
@waiting_proc = ->(key_for_proc, _sym) { search_prev_char(key_for_proc, arg, true) }
|
|
2261
2261
|
end
|
|
2262
2262
|
|
|
2263
2263
|
private def search_prev_char(key, arg, need_next_char = false)
|
data/lib/reline/unicode.rb
CHANGED
|
@@ -37,7 +37,7 @@ class Reline::Unicode
|
|
|
37
37
|
|
|
38
38
|
NON_PRINTING_START = "\1"
|
|
39
39
|
NON_PRINTING_END = "\2"
|
|
40
|
-
CSI_REGEXP = /\e\[[\
|
|
40
|
+
CSI_REGEXP = /\e\[[\x30-\x3f]*[\x20-\x2f]*[a-zA-Z]/
|
|
41
41
|
OSC_REGEXP = /\e\]\d+(?:;[^;\a\e]+)*(?:\a|\e\\)/
|
|
42
42
|
WIDTH_SCANNER = /\G(?:(#{NON_PRINTING_START})|(#{NON_PRINTING_END})|(#{CSI_REGEXP})|(#{OSC_REGEXP})|(\X))/o
|
|
43
43
|
|
data/lib/reline/version.rb
CHANGED