reline 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reline/line_editor.rb +57 -24
- data/lib/reline/line_editor.rb.orig +2384 -0
- data/lib/reline/line_editor.rb.rej +81 -0
- data/lib/reline/sibori.rb +14 -0
- data/lib/reline/unicode.rb +25 -15
- data/lib/reline/unicode/east_asian_width.rb +13 -13
- data/lib/reline/version.rb +1 -1
- metadata +4 -2
@@ -0,0 +1,81 @@
|
|
1
|
+
--- lib/reline/line_editor.rb
|
2
|
+
+++ lib/reline/line_editor.rb
|
3
|
+
@@ -1092,60 +1053,38 @@ class Reline::LineEditor
|
4
|
+
|
5
|
+
private def ed_unassigned(key) end # do nothing
|
6
|
+
|
7
|
+
- private def process_insert(force: false)
|
8
|
+
- return if @continuous_insertion_buffer.empty? or (Reline::IOGate.in_pasting? and not force)
|
9
|
+
- #$stderr.puts 'process!!!!!!!'
|
10
|
+
- width = Reline::Unicode.calculate_width(@continuous_insertion_buffer)
|
11
|
+
- bytesize = @continuous_insertion_buffer.bytesize
|
12
|
+
- if @cursor == @cursor_max
|
13
|
+
- @line += @continuous_insertion_buffer
|
14
|
+
- else
|
15
|
+
- @line = byteinsert(@line, @byte_pointer, @continuous_insertion_buffer)
|
16
|
+
- end
|
17
|
+
- #$stderr.puts "#### #{@continuous_insertion_buffer.inspect} => #{@line.inspect}"
|
18
|
+
- #$stderr.puts "width #{width.inspect} bytesize #{bytesize.inspect}"
|
19
|
+
- @byte_pointer += bytesize
|
20
|
+
- @cursor += width
|
21
|
+
- @cursor_max += width
|
22
|
+
- @continuous_insertion_buffer.clear
|
23
|
+
- @rerender_all = true
|
24
|
+
- end
|
25
|
+
-
|
26
|
+
private def ed_insert(key)
|
27
|
+
- str = nil
|
28
|
+
- width = nil
|
29
|
+
- bytesize = nil
|
30
|
+
if key.instance_of?(String)
|
31
|
+
begin
|
32
|
+
key.encode(Encoding::UTF_8)
|
33
|
+
rescue Encoding::UndefinedConversionError
|
34
|
+
return
|
35
|
+
end
|
36
|
+
- str = key
|
37
|
+
- bytesize = key.bytesize
|
38
|
+
+ width = Reline::Unicode.get_mbchar_width(key)
|
39
|
+
+ if @cursor == @cursor_max
|
40
|
+
+ @line += key
|
41
|
+
+ else
|
42
|
+
+ @line = byteinsert(@line, @byte_pointer, key)
|
43
|
+
+ end
|
44
|
+
+ @byte_pointer += key.bytesize
|
45
|
+
+ @cursor += width
|
46
|
+
+ @cursor_max += width
|
47
|
+
else
|
48
|
+
begin
|
49
|
+
key.chr.encode(Encoding::UTF_8)
|
50
|
+
rescue Encoding::UndefinedConversionError
|
51
|
+
return
|
52
|
+
end
|
53
|
+
- str = key.chr
|
54
|
+
- bytesize = 1
|
55
|
+
+ if @cursor == @cursor_max
|
56
|
+
+ @line += key.chr
|
57
|
+
+ else
|
58
|
+
+ @line = byteinsert(@line, @byte_pointer, key.chr)
|
59
|
+
+ end
|
60
|
+
+ width = Reline::Unicode.get_mbchar_width(key.chr)
|
61
|
+
+ @byte_pointer += 1
|
62
|
+
+ @cursor += width
|
63
|
+
+ @cursor_max += width
|
64
|
+
end
|
65
|
+
- if Reline::IOGate.in_pasting?
|
66
|
+
- #$stderr.puts 'pasting!!!!!!'
|
67
|
+
- @continuous_insertion_buffer << str
|
68
|
+
- return
|
69
|
+
- end
|
70
|
+
- width = Reline::Unicode.get_mbchar_width(str)
|
71
|
+
- if @cursor == @cursor_max
|
72
|
+
- @line += str
|
73
|
+
- else
|
74
|
+
- @line = byteinsert(@line, @byte_pointer, str)
|
75
|
+
- end
|
76
|
+
- @byte_pointer += bytesize
|
77
|
+
- @cursor += width
|
78
|
+
- @cursor_max += width
|
79
|
+
end
|
80
|
+
alias_method :ed_digit, :ed_insert
|
81
|
+
alias_method :self_insert, :ed_insert
|
data/lib/reline/sibori.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
require 'reline/unicode'
|
2
2
|
|
3
|
+
=begin
|
4
|
+
|
5
|
+
\ |
|
6
|
+
\ | <--- whipped cream
|
7
|
+
\ |
|
8
|
+
\ |
|
9
|
+
\-~~|
|
10
|
+
\ | <--- shibori kutigane (piping nozzle in Japanese)
|
11
|
+
\Ml
|
12
|
+
(\ __ __
|
13
|
+
( \--( ) )
|
14
|
+
(__(__)__) <--- compressed whipped cream
|
15
|
+
=end
|
16
|
+
|
3
17
|
class Sibori
|
4
18
|
attr_writer :output
|
5
19
|
|
data/lib/reline/unicode.rb
CHANGED
@@ -72,20 +72,32 @@ class Reline::Unicode
|
|
72
72
|
}.join
|
73
73
|
end
|
74
74
|
|
75
|
+
require 'reline/unicode/east_asian_width'
|
76
|
+
|
77
|
+
MBCharWidthRE = /
|
78
|
+
(?<width_2_1>
|
79
|
+
[#{ EscapedChars.map {|c| "\\x%02x" % c.ord }.join }] (?# ^ + char, such as ^M, ^H, ^[, ...)
|
80
|
+
)
|
81
|
+
| (?<width_3>^\u{2E3B}) (?# THREE-EM DASH)
|
82
|
+
| (?<width_0>^\p{M})
|
83
|
+
| (?<width_2_2>
|
84
|
+
#{ EastAsianWidth::TYPE_F }
|
85
|
+
| #{ EastAsianWidth::TYPE_W }
|
86
|
+
)
|
87
|
+
| (?<width_1>
|
88
|
+
#{ EastAsianWidth::TYPE_H }
|
89
|
+
| #{ EastAsianWidth::TYPE_NA }
|
90
|
+
| #{ EastAsianWidth::TYPE_N }
|
91
|
+
)
|
92
|
+
/x
|
93
|
+
|
75
94
|
def self.get_mbchar_width(mbchar)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
when
|
80
|
-
|
81
|
-
when
|
82
|
-
0
|
83
|
-
when EastAsianWidth::TYPE_A
|
84
|
-
Reline.ambiguous_width
|
85
|
-
when EastAsianWidth::TYPE_F, EastAsianWidth::TYPE_W
|
86
|
-
2
|
87
|
-
when EastAsianWidth::TYPE_H, EastAsianWidth::TYPE_NA, EastAsianWidth::TYPE_N
|
88
|
-
1
|
95
|
+
m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE)
|
96
|
+
case
|
97
|
+
when m[:width_2_1], m[:width_2_2] then 2
|
98
|
+
when m[:width_3] then 3
|
99
|
+
when m[:width_0] then 0
|
100
|
+
when m[:width_1] then 1
|
89
101
|
else
|
90
102
|
nil
|
91
103
|
end
|
@@ -591,5 +603,3 @@ class Reline::Unicode
|
|
591
603
|
[byte_size, width]
|
592
604
|
end
|
593
605
|
end
|
594
|
-
|
595
|
-
require 'reline/unicode/east_asian_width'
|
@@ -1,16 +1,16 @@
|
|
1
1
|
class Reline::Unicode::EastAsianWidth
|
2
2
|
# This is based on EastAsianWidth.txt
|
3
|
-
#
|
3
|
+
# EastAsianWidth.txt
|
4
4
|
|
5
5
|
# Fullwidth
|
6
|
-
TYPE_F = /^
|
6
|
+
TYPE_F = /^[#{ %W(
|
7
7
|
\u{3000}
|
8
8
|
\u{FF01}-\u{FF60}
|
9
9
|
\u{FFE0}-\u{FFE6}
|
10
|
-
).join }]
|
10
|
+
).join }]/
|
11
11
|
|
12
12
|
# Halfwidth
|
13
|
-
TYPE_H = /^
|
13
|
+
TYPE_H = /^[#{ %W(
|
14
14
|
\u{20A9}
|
15
15
|
\u{FF61}-\u{FFBE}
|
16
16
|
\u{FFC2}-\u{FFC7}
|
@@ -18,10 +18,10 @@ class Reline::Unicode::EastAsianWidth
|
|
18
18
|
\u{FFD2}-\u{FFD7}
|
19
19
|
\u{FFDA}-\u{FFDC}
|
20
20
|
\u{FFE8}-\u{FFEE}
|
21
|
-
).join }]
|
21
|
+
).join }]/
|
22
22
|
|
23
23
|
# Wide
|
24
|
-
TYPE_W = /^
|
24
|
+
TYPE_W = /^[#{ %W(
|
25
25
|
\u{1100}-\u{115F}
|
26
26
|
\u{231A}-\u{231B}
|
27
27
|
\u{2329}-\u{232A}
|
@@ -136,10 +136,10 @@ class Reline::Unicode::EastAsianWidth
|
|
136
136
|
\u{1FAD0}-\u{1FAD6}
|
137
137
|
\u{20000}-\u{2FFFD}
|
138
138
|
\u{30000}-\u{3FFFD}
|
139
|
-
).join }]
|
139
|
+
).join }]/
|
140
140
|
|
141
141
|
# Narrow
|
142
|
-
TYPE_NA = /^
|
142
|
+
TYPE_NA = /^[#{ %W(
|
143
143
|
\u{0020}-\u{007E}
|
144
144
|
\u{00A2}-\u{00A3}
|
145
145
|
\u{00A5}-\u{00A6}
|
@@ -147,10 +147,10 @@ class Reline::Unicode::EastAsianWidth
|
|
147
147
|
\u{00AF}
|
148
148
|
\u{27E6}-\u{27ED}
|
149
149
|
\u{2985}-\u{2986}
|
150
|
-
).join }]
|
150
|
+
).join }]/
|
151
151
|
|
152
152
|
# Ambiguous
|
153
|
-
TYPE_A = /^
|
153
|
+
TYPE_A = /^[#{ %W(
|
154
154
|
\u{00A1}
|
155
155
|
\u{00A4}
|
156
156
|
\u{00A7}-\u{00A8}
|
@@ -330,10 +330,10 @@ class Reline::Unicode::EastAsianWidth
|
|
330
330
|
\u{E0100}-\u{E01EF}
|
331
331
|
\u{F0000}-\u{FFFFD}
|
332
332
|
\u{100000}-\u{10FFFD}
|
333
|
-
).join }]
|
333
|
+
).join }]/
|
334
334
|
|
335
335
|
# Neutral
|
336
|
-
TYPE_N = /^
|
336
|
+
TYPE_N = /^[#{ %W(
|
337
337
|
\u{0000}-\u{001F}
|
338
338
|
\u{007F}-\u{00A0}
|
339
339
|
\u{00A9}
|
@@ -1160,5 +1160,5 @@ class Reline::Unicode::EastAsianWidth
|
|
1160
1160
|
\u{1FBF0}-\u{1FBF9}
|
1161
1161
|
\u{E0001}
|
1162
1162
|
\u{E0020}-\u{E007F}
|
1163
|
-
).join }]
|
1163
|
+
).join }]/
|
1164
1164
|
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.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|
@@ -103,6 +103,8 @@ files:
|
|
103
103
|
- lib/reline/key_stroke.rb
|
104
104
|
- lib/reline/kill_ring.rb
|
105
105
|
- lib/reline/line_editor.rb
|
106
|
+
- lib/reline/line_editor.rb.orig
|
107
|
+
- lib/reline/line_editor.rb.rej
|
106
108
|
- lib/reline/sibori.rb
|
107
109
|
- lib/reline/unicode.rb
|
108
110
|
- lib/reline/unicode/east_asian_width.rb
|