reline 0.3.7 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reline/ansi.rb +17 -18
- data/lib/reline/config.rb +1 -1
- data/lib/reline/general_io.rb +6 -3
- data/lib/reline/line_editor.rb +2 -0
- data/lib/reline/unicode/east_asian_width.rb +3 -3
- data/lib/reline/version.rb +1 -1
- data/lib/reline/windows.rb +1 -1
- data/lib/reline.rb +14 -26
- 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: 7f903d3b8f902335117d484007dcfbef5e8846061a8eb3c8820f9975c4c85ea5
|
4
|
+
data.tar.gz: 2ccb2d104c5c52b4e4f8ab1dd8a48ceb738fa03826ab62a7b38483d0f4f1288a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8edd5b7d31464fbc150518f94d45d84466837fe78374dbc127f2226005eb73f2c238f274d685ed42c97db56e906fb90b5e6369dd03dbaeac4b6f2019f36cd68
|
7
|
+
data.tar.gz: 317225a1374e59f3dbb654b67a732fd3daf669fd13cab0673d73e0b952cc8d6fad554c4318366479d162890d0c538ca09cc902a1ad2fad0e42e4684b54f81c3e
|
data/lib/reline/ansi.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'io/console'
|
2
2
|
require 'io/wait'
|
3
|
-
require 'timeout'
|
4
3
|
require_relative 'terminfo'
|
5
4
|
|
6
5
|
class Reline::ANSI
|
@@ -154,11 +153,13 @@ class Reline::ANSI
|
|
154
153
|
end
|
155
154
|
|
156
155
|
@@buf = []
|
157
|
-
def self.inner_getc
|
156
|
+
def self.inner_getc(timeout_second)
|
158
157
|
unless @@buf.empty?
|
159
158
|
return @@buf.shift
|
160
159
|
end
|
161
160
|
until c = @@input.raw(intr: true) { @@input.wait_readable(0.1) && @@input.getbyte }
|
161
|
+
timeout_second -= 0.1
|
162
|
+
return nil if timeout_second <= 0
|
162
163
|
Reline.core.line_editor.resize
|
163
164
|
end
|
164
165
|
(c == 0x16 && @@input.raw(min: 0, time: 0, &:getbyte)) || c
|
@@ -172,40 +173,38 @@ class Reline::ANSI
|
|
172
173
|
@@in_bracketed_paste_mode = false
|
173
174
|
START_BRACKETED_PASTE = String.new("\e[200~,", encoding: Encoding::ASCII_8BIT)
|
174
175
|
END_BRACKETED_PASTE = String.new("\e[200~.", encoding: Encoding::ASCII_8BIT)
|
175
|
-
def self.getc_with_bracketed_paste
|
176
|
+
def self.getc_with_bracketed_paste(timeout_second)
|
176
177
|
buffer = String.new(encoding: Encoding::ASCII_8BIT)
|
177
|
-
buffer << inner_getc
|
178
|
+
buffer << inner_getc(timeout_second)
|
178
179
|
while START_BRACKETED_PASTE.start_with?(buffer) or END_BRACKETED_PASTE.start_with?(buffer) do
|
179
180
|
if START_BRACKETED_PASTE == buffer
|
180
181
|
@@in_bracketed_paste_mode = true
|
181
|
-
return inner_getc
|
182
|
+
return inner_getc(timeout_second)
|
182
183
|
elsif END_BRACKETED_PASTE == buffer
|
183
184
|
@@in_bracketed_paste_mode = false
|
184
185
|
ungetc(-1)
|
185
|
-
return inner_getc
|
186
|
+
return inner_getc(timeout_second)
|
186
187
|
end
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
succ_c = inner_getc
|
191
|
-
}
|
192
|
-
rescue Timeout::Error
|
193
|
-
break
|
194
|
-
else
|
188
|
+
succ_c = inner_getc(Reline.core.config.keyseq_timeout)
|
189
|
+
|
190
|
+
if succ_c
|
195
191
|
buffer << succ_c
|
192
|
+
else
|
193
|
+
break
|
196
194
|
end
|
197
195
|
end
|
198
196
|
buffer.bytes.reverse_each do |ch|
|
199
197
|
ungetc ch
|
200
198
|
end
|
201
|
-
inner_getc
|
199
|
+
inner_getc(timeout_second)
|
202
200
|
end
|
203
201
|
|
204
|
-
|
202
|
+
# if the usage expects to wait indefinitely, use Float::INFINITY for timeout_second
|
203
|
+
def self.getc(timeout_second)
|
205
204
|
if Reline.core.config.enable_bracketed_paste
|
206
|
-
getc_with_bracketed_paste
|
205
|
+
getc_with_bracketed_paste(timeout_second)
|
207
206
|
else
|
208
|
-
inner_getc
|
207
|
+
inner_getc(timeout_second)
|
209
208
|
end
|
210
209
|
end
|
211
210
|
|
data/lib/reline/config.rb
CHANGED
data/lib/reline/general_io.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
require 'timeout'
|
2
1
|
require 'io/wait'
|
3
2
|
|
4
3
|
class Reline::GeneralIO
|
5
4
|
def self.reset(encoding: nil)
|
6
5
|
@@pasting = false
|
7
|
-
|
6
|
+
if encoding
|
7
|
+
@@encoding = encoding
|
8
|
+
elsif defined?(@@encoding)
|
9
|
+
remove_class_variable(:@@encoding)
|
10
|
+
end
|
8
11
|
end
|
9
12
|
|
10
13
|
def self.encoding
|
@@ -35,7 +38,7 @@ class Reline::GeneralIO
|
|
35
38
|
yield
|
36
39
|
end
|
37
40
|
|
38
|
-
def self.getc
|
41
|
+
def self.getc(_timeout_second)
|
39
42
|
unless @@buf.empty?
|
40
43
|
return @@buf.shift
|
41
44
|
end
|
data/lib/reline/line_editor.rb
CHANGED
@@ -2696,6 +2696,7 @@ class Reline::LineEditor
|
|
2696
2696
|
@cursor_max -= width
|
2697
2697
|
end
|
2698
2698
|
end
|
2699
|
+
alias_method :kill_word, :em_delete_next_word
|
2699
2700
|
|
2700
2701
|
private def ed_delete_prev_word(key)
|
2701
2702
|
if @byte_pointer > 0
|
@@ -2707,6 +2708,7 @@ class Reline::LineEditor
|
|
2707
2708
|
@cursor_max -= width
|
2708
2709
|
end
|
2709
2710
|
end
|
2711
|
+
alias_method :backward_kill_word, :ed_delete_prev_word
|
2710
2712
|
|
2711
2713
|
private def ed_transpose_chars(key)
|
2712
2714
|
if @byte_pointer > 0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Reline::Unicode::EastAsianWidth
|
2
2
|
# This is based on EastAsianWidth.txt
|
3
|
-
#
|
3
|
+
# UNICODE_VERSION = '15.1.0'
|
4
4
|
|
5
5
|
# Fullwidth
|
6
6
|
TYPE_F = /^[#{ %W(
|
@@ -60,14 +60,14 @@ class Reline::Unicode::EastAsianWidth
|
|
60
60
|
\u{2E80}-\u{2E99}
|
61
61
|
\u{2E9B}-\u{2EF3}
|
62
62
|
\u{2F00}-\u{2FD5}
|
63
|
-
\u{2FF0}-\u{
|
63
|
+
\u{2FF0}-\u{2FFF}
|
64
64
|
\u{3001}-\u{303E}
|
65
65
|
\u{3041}-\u{3096}
|
66
66
|
\u{3099}-\u{30FF}
|
67
67
|
\u{3105}-\u{312F}
|
68
68
|
\u{3131}-\u{318E}
|
69
69
|
\u{3190}-\u{31E3}
|
70
|
-
\u{
|
70
|
+
\u{31EF}-\u{321E}
|
71
71
|
\u{3220}-\u{3247}
|
72
72
|
\u{3250}-\u{4DBF}
|
73
73
|
\u{4E00}-\u{A48C}
|
data/lib/reline/version.rb
CHANGED
data/lib/reline/windows.rb
CHANGED
data/lib/reline.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'io/console'
|
2
|
-
require 'timeout'
|
3
2
|
require 'forwardable'
|
4
3
|
require 'reline/version'
|
5
4
|
require 'reline/config'
|
@@ -397,7 +396,7 @@ module Reline
|
|
397
396
|
private def read_io(keyseq_timeout, &block)
|
398
397
|
buffer = []
|
399
398
|
loop do
|
400
|
-
c = io_gate.getc
|
399
|
+
c = io_gate.getc(Float::INFINITY)
|
401
400
|
if c == -1
|
402
401
|
result = :unmatched
|
403
402
|
@bracketed_paste_finished = true
|
@@ -434,15 +433,8 @@ module Reline
|
|
434
433
|
end
|
435
434
|
|
436
435
|
private def read_2nd_character_of_key_sequence(keyseq_timeout, buffer, c, block)
|
437
|
-
|
438
|
-
|
439
|
-
Timeout.timeout(keyseq_timeout / 1000.0) {
|
440
|
-
succ_c = io_gate.getc
|
441
|
-
}
|
442
|
-
rescue Timeout::Error # cancel matching only when first byte
|
443
|
-
block.([Reline::Key.new(c, c, false)])
|
444
|
-
return :break
|
445
|
-
else
|
436
|
+
succ_c = io_gate.getc(keyseq_timeout.fdiv(1000))
|
437
|
+
if succ_c
|
446
438
|
case key_stroke.match_status(buffer.dup.push(succ_c))
|
447
439
|
when :unmatched
|
448
440
|
if c == "\e".ord
|
@@ -462,27 +454,23 @@ module Reline
|
|
462
454
|
block.(expanded)
|
463
455
|
return :break
|
464
456
|
end
|
457
|
+
else
|
458
|
+
block.([Reline::Key.new(c, c, false)])
|
459
|
+
return :break
|
465
460
|
end
|
466
461
|
end
|
467
462
|
|
468
463
|
private def read_escaped_key(keyseq_timeout, c, block)
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
escaped_c = io_gate.getc
|
473
|
-
}
|
474
|
-
rescue Timeout::Error # independent ESC
|
464
|
+
escaped_c = io_gate.getc(keyseq_timeout.fdiv(1000))
|
465
|
+
|
466
|
+
if escaped_c.nil?
|
475
467
|
block.([Reline::Key.new(c, c, false)])
|
468
|
+
elsif escaped_c >= 128 # maybe, first byte of multi byte
|
469
|
+
block.([Reline::Key.new(c, c, false), Reline::Key.new(escaped_c, escaped_c, false)])
|
470
|
+
elsif escaped_c == "\e".ord # escape twice
|
471
|
+
block.([Reline::Key.new(c, c, false), Reline::Key.new(c, c, false)])
|
476
472
|
else
|
477
|
-
|
478
|
-
block.([Reline::Key.new(c, c, false)])
|
479
|
-
elsif escaped_c >= 128 # maybe, first byte of multi byte
|
480
|
-
block.([Reline::Key.new(c, c, false), Reline::Key.new(escaped_c, escaped_c, false)])
|
481
|
-
elsif escaped_c == "\e".ord # escape twice
|
482
|
-
block.([Reline::Key.new(c, c, false), Reline::Key.new(c, c, false)])
|
483
|
-
else
|
484
|
-
block.([Reline::Key.new(escaped_c, escaped_c | 0b10000000, true)])
|
485
|
-
end
|
473
|
+
block.([Reline::Key.new(escaped_c, escaped_c | 0b10000000, true)])
|
486
474
|
end
|
487
475
|
end
|
488
476
|
|
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.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|