yap-rawline 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rawline/completer.rb +7 -17
- data/lib/rawline/editor.rb +12 -15
- data/lib/rawline/event_loop.rb +6 -3
- data/lib/rawline/history_buffer.rb +210 -82
- data/lib/rawline/keycode_parser.rb +22 -9
- data/lib/rawline/renderer.rb +55 -17
- data/lib/rawline/terminal.rb +0 -4
- data/lib/rawline/version.rb +1 -1
- data/spec/history_buffer_spec.rb +557 -133
- data/spec/keycode_parser_spec.rb +28 -16
- metadata +3 -3
data/spec/keycode_parser_spec.rb
CHANGED
@@ -70,22 +70,34 @@ describe RawLine::KeycodeParser do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
context "given multiple bytes which could map to multiple sequences" do
|
74
|
+
let(:keymap) do
|
75
|
+
{ escape: [?\e.ord] }
|
76
|
+
{ left_arrow: [?\e.ord, ?[.ord, ?D.ord] }
|
77
|
+
end
|
78
|
+
let(:bytes) { ["a".ord, ?\e.ord, ?[.ord, ?D.ord, "C".ord] }
|
74
79
|
|
75
|
-
|
80
|
+
it "returns the longest sequence matching" do
|
81
|
+
expect(parse).to eq ["a", [?\e.ord, ?[.ord, ?D.ord], "C"]
|
82
|
+
end
|
83
|
+
end
|
76
84
|
|
85
|
+
context "given a lot of bytes" do
|
86
|
+
let(:keymap) do
|
87
|
+
{ left_arrow: [?\e.ord, ?[.ord, ?D.ord] }
|
88
|
+
end
|
89
|
+
let(:alphabet_chars) do
|
90
|
+
["a"].tap { |bytes| 256**256.times { bytes << bytes.last.succ } }
|
91
|
+
end
|
92
|
+
let(:bytes) { alphabet_chars.map(&:ord) }
|
93
|
+
|
94
|
+
it "returns the keycodes speedily" do
|
95
|
+
Timeout.timeout(0.5) do
|
96
|
+
parse
|
97
|
+
end
|
98
|
+
end
|
77
99
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
:up_arrow => [?\e.ord, ?[.ord, ?A.ord],
|
83
|
-
:down_arrow => [?\e.ord, ?[.ord, ?B.ord],
|
84
|
-
:right_arrow => [?\e.ord, ?[.ord, ?C.ord],
|
85
|
-
:left_arrow => [?\e.ord, ?[.ord, ?D.ord],
|
86
|
-
:insert => [?\e.ord, ?[, ?2.ord, ?~.ord],
|
87
|
-
:delete => [?\e.ord, ?[, ?3.ord, ?~.ord],
|
88
|
-
:backspace => [?\C-?.ord],
|
89
|
-
:enter => (HighLine::SystemExtensions::CHARACTER_MODE == 'termios' ? [?\n.ord] : [?\r.ord]),
|
90
|
-
|
91
|
-
:ctrl_alt_a => [?\e.ord, ?\C-a.ord],
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yap-rawline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Cevasco
|
@@ -51,14 +51,14 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.4.
|
54
|
+
version: 0.4.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.4.
|
61
|
+
version: 0.4.3
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: term-ansicolor
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|