vedeu 0.6.64 → 0.6.65
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/docs/api.md +8 -0
- data/docs/debugging.md +2 -1
- data/lib/vedeu/application/application_controller.rb +1 -1
- data/lib/vedeu/common.rb +8 -0
- data/lib/vedeu/cursors/reposition.rb +22 -8
- data/lib/vedeu/dsl/dsl.rb +1 -1
- data/lib/vedeu/input/all.rb +1 -0
- data/lib/vedeu/input/capture.rb +3 -3
- data/lib/vedeu/input/mouse.rb +1 -1
- data/lib/vedeu/input/read.rb +133 -0
- data/lib/vedeu/models/page.rb +1 -1
- data/lib/vedeu/models/row.rb +1 -1
- data/lib/vedeu/null/generic.rb +1 -1
- data/lib/vedeu/output/all.rb +1 -0
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/output/write.rb +114 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/common_test.rb +17 -1
- data/test/lib/vedeu/input/read_test.rb +102 -0
- data/test/lib/vedeu/logging/ips_test.rb +1 -1
- data/test/lib/vedeu/output/write_test.rb +92 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7de5e8ce3c945a022377f002d55b636db36d4c4
|
|
4
|
+
data.tar.gz: 304a938cd7a728def2501a2fbb9c56dc47087c69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5319814ddc77d021cc4b9d6c0faeaf0dee1dfbad8fda6aed11999ed3e596ee304dd25c24155aff10968d5a48112ecfff371d8a7b58fd370fc2ee9195444570ba
|
|
7
|
+
data.tar.gz: 51b151afec06d804cbf24e0a7cf490b434e8d0130d5c993a74e80e93734c22ba00cec0908696fd1bb4d2ce36e6e943a487e7742bdc9b21788ad34476662243fa
|
data/docs/api.md
CHANGED
|
@@ -417,6 +417,10 @@ Repository method. Access registered menus.
|
|
|
417
417
|
|
|
418
418
|
@todo Add more documentation.
|
|
419
419
|
|
|
420
|
+
### Vedeu.read
|
|
421
|
+
|
|
422
|
+
@todo Add more documentation.
|
|
423
|
+
|
|
420
424
|
### Vedeu.ready!
|
|
421
425
|
|
|
422
426
|
@todo Add more documentation.
|
|
@@ -506,3 +510,7 @@ Repository method. Access registered renderers.
|
|
|
506
510
|
### Vedeu.width
|
|
507
511
|
|
|
508
512
|
@todo Add more documentation.
|
|
513
|
+
|
|
514
|
+
### Vedeu.write
|
|
515
|
+
|
|
516
|
+
@todo Add more documentation.
|
data/docs/debugging.md
CHANGED
|
@@ -8,8 +8,9 @@ and hopefully be dropped into a Pry debuggging session:
|
|
|
8
8
|
|
|
9
9
|
Vedeu::Terminal.cooked_mode!
|
|
10
10
|
Vedeu::Terminal.open do
|
|
11
|
+
mouse_off = Vedeu::EscapeSequences::Esc.string('mouse_x10_off')
|
|
11
12
|
show_cursor = Vedeu::EscapeSequences::Esc.string('show_cursor')
|
|
12
|
-
Vedeu::Terminal.output(show_cursor)
|
|
13
|
+
Vedeu::Terminal.output(mouse_off + show_cursor)
|
|
13
14
|
|
|
14
15
|
require 'pry'
|
|
15
16
|
binding.pry
|
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
|
8
8
|
|
|
9
9
|
include Vedeu::Controller
|
|
10
10
|
|
|
11
|
-
# Returns
|
|
11
|
+
# Returns a new instance of Vedeu::ApplicationController.
|
|
12
12
|
#
|
|
13
13
|
# @param params [Hash] The named parameters provided to the
|
|
14
14
|
# controller which will be used by the actions within the
|
data/lib/vedeu/common.rb
CHANGED
|
@@ -28,6 +28,14 @@ module Vedeu
|
|
|
28
28
|
klass[(klass.rindex('::') + 2)..-1]
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
# Returns a boolean indicating whether the value is a Fixnum.
|
|
32
|
+
#
|
|
33
|
+
# @param value [Fixnum|void]
|
|
34
|
+
# @return [Boolean]
|
|
35
|
+
def numeric?(value)
|
|
36
|
+
value.is_a?(Fixnum)
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
# Returns a boolean indicating whether a variable has a useful
|
|
32
40
|
# value.
|
|
33
41
|
#
|
|
@@ -48,6 +48,16 @@ module Vedeu
|
|
|
48
48
|
|
|
49
49
|
private
|
|
50
50
|
|
|
51
|
+
# @return [Hash<Symbol => Fixnum>]
|
|
52
|
+
def absolute
|
|
53
|
+
{
|
|
54
|
+
x: coordinate((x - geometry.x), :x).x,
|
|
55
|
+
y: coordinate((y - geometry.y), :y).y,
|
|
56
|
+
ox: 0,
|
|
57
|
+
oy: 0,
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
51
61
|
# @return [Boolean]
|
|
52
62
|
def absolute?
|
|
53
63
|
mode == :absolute
|
|
@@ -116,16 +126,10 @@ module Vedeu
|
|
|
116
126
|
# @return [Hash<Symbol => Fixnum>]
|
|
117
127
|
def new_attributes
|
|
118
128
|
if absolute? && inside_geometry?
|
|
119
|
-
cursor.attributes.merge!(
|
|
120
|
-
y: coordinate((y - geometry.y), :y).y,
|
|
121
|
-
ox: 0,
|
|
122
|
-
oy: 0)
|
|
129
|
+
cursor.attributes.merge!(absolute)
|
|
123
130
|
|
|
124
131
|
elsif relative?
|
|
125
|
-
cursor.attributes.merge!(
|
|
126
|
-
y: coordinate(y, :y).y,
|
|
127
|
-
ox: x,
|
|
128
|
-
oy: y)
|
|
132
|
+
cursor.attributes.merge!(relative)
|
|
129
133
|
|
|
130
134
|
else
|
|
131
135
|
cursor.attributes
|
|
@@ -133,6 +137,16 @@ module Vedeu
|
|
|
133
137
|
end
|
|
134
138
|
end
|
|
135
139
|
|
|
140
|
+
# @return [Hash<Symbol => Fixnum>]
|
|
141
|
+
def relative
|
|
142
|
+
{
|
|
143
|
+
x: coordinate(x, :x).x,
|
|
144
|
+
y: coordinate(y, :y).y,
|
|
145
|
+
ox: x,
|
|
146
|
+
oy: y,
|
|
147
|
+
}
|
|
148
|
+
end
|
|
149
|
+
|
|
136
150
|
# @return [Boolean]
|
|
137
151
|
def relative?
|
|
138
152
|
mode == :relative
|
data/lib/vedeu/dsl/dsl.rb
CHANGED
data/lib/vedeu/input/all.rb
CHANGED
data/lib/vedeu/input/capture.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module Vedeu
|
|
2
2
|
|
|
3
|
+
ESCAPE_KEY_CODE = 27 # \e
|
|
4
|
+
|
|
3
5
|
module Input
|
|
4
6
|
|
|
5
7
|
# Captures input from the user terminal via 'getch' and
|
|
@@ -7,8 +9,6 @@ module Vedeu
|
|
|
7
9
|
#
|
|
8
10
|
class Capture
|
|
9
11
|
|
|
10
|
-
ESCAPE_KEY_CODE = 27 # \e
|
|
11
|
-
|
|
12
12
|
extend Forwardable
|
|
13
13
|
|
|
14
14
|
def_delegators Vedeu::Terminal::Mode,
|
|
@@ -93,7 +93,7 @@ module Vedeu
|
|
|
93
93
|
def input
|
|
94
94
|
keys = console.getch
|
|
95
95
|
|
|
96
|
-
if keys.ord == ESCAPE_KEY_CODE
|
|
96
|
+
if keys.ord == Vedeu::ESCAPE_KEY_CODE
|
|
97
97
|
keys << console.read_nonblock(4) rescue nil
|
|
98
98
|
keys << console.read_nonblock(3) rescue nil
|
|
99
99
|
keys << console.read_nonblock(2) rescue nil
|
data/lib/vedeu/input/mouse.rb
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module Vedeu
|
|
2
|
+
|
|
3
|
+
module Input
|
|
4
|
+
|
|
5
|
+
# Directly read from the terminal.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# Vedeu.read(input, options)
|
|
9
|
+
#
|
|
10
|
+
# @api private
|
|
11
|
+
#
|
|
12
|
+
class Read
|
|
13
|
+
|
|
14
|
+
include Vedeu::Common
|
|
15
|
+
|
|
16
|
+
# @api public
|
|
17
|
+
# @see Vedeu::Input::Read#initialize
|
|
18
|
+
def self.read(input = nil, options = {})
|
|
19
|
+
new(input, options).read
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns a new instance of Vedeu::Input::Read.
|
|
23
|
+
#
|
|
24
|
+
# @param input [NilClass|String]
|
|
25
|
+
# @param options [Hash<Symbol => Symbol]
|
|
26
|
+
# @option mode [Symbol] Either :cooked (default) or :raw
|
|
27
|
+
# @return [Vedeu::Input::Read]
|
|
28
|
+
def initialize(input = nil, options = {})
|
|
29
|
+
@input = input
|
|
30
|
+
@options = options
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [String]
|
|
34
|
+
def read
|
|
35
|
+
if cooked?
|
|
36
|
+
Vedeu.trigger(:_command_, input)
|
|
37
|
+
|
|
38
|
+
else
|
|
39
|
+
Vedeu.trigger(:_keypress_, input)
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
input
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
protected
|
|
47
|
+
|
|
48
|
+
# @!attribute [r] input
|
|
49
|
+
# @return [NilClass|String]
|
|
50
|
+
attr_reader :input
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# @return [IO]
|
|
55
|
+
def console
|
|
56
|
+
@console ||= Vedeu::Terminal.console
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @return [Boolean]
|
|
60
|
+
def cooked?
|
|
61
|
+
mode == :cooked
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @return [Hash<Symbol => Symbol>]
|
|
65
|
+
def defaults
|
|
66
|
+
{
|
|
67
|
+
mode: :cooked
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @return [String]
|
|
72
|
+
def input
|
|
73
|
+
@_input ||= if input?
|
|
74
|
+
@input
|
|
75
|
+
|
|
76
|
+
elsif cooked?
|
|
77
|
+
console.gets.chomp
|
|
78
|
+
|
|
79
|
+
else
|
|
80
|
+
keys = console.getch
|
|
81
|
+
|
|
82
|
+
if keys.ord == Vedeu::ESCAPE_KEY_CODE
|
|
83
|
+
keys << console.read_nonblock(4) rescue nil
|
|
84
|
+
keys << console.read_nonblock(3) rescue nil
|
|
85
|
+
keys << console.read_nonblock(2) rescue nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Vedeu::Input::Translator.translate(keys)
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @return [Boolean]
|
|
94
|
+
def input?
|
|
95
|
+
present?(@input)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @return [Symbol]
|
|
99
|
+
def mode
|
|
100
|
+
fail Vedeu::Error::InvalidSyntax,
|
|
101
|
+
'mode option must be `:raw` or `:cooked`.' unless valid_mode?
|
|
102
|
+
|
|
103
|
+
options[:mode]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# @return [Array<Symbol>]
|
|
107
|
+
def modes
|
|
108
|
+
[
|
|
109
|
+
:cooked,
|
|
110
|
+
:raw,
|
|
111
|
+
]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# @return [Hash<Symbol => Symbol>]
|
|
115
|
+
def options
|
|
116
|
+
defaults.merge!(@options)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @return [Boolean]
|
|
120
|
+
def valid_mode?
|
|
121
|
+
modes.include?(options[:mode])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end # Read
|
|
125
|
+
|
|
126
|
+
end # Input
|
|
127
|
+
|
|
128
|
+
# @!method read
|
|
129
|
+
# @see Vedeu::Input::Read#read
|
|
130
|
+
def_delegators Vedeu::Input::Read,
|
|
131
|
+
:read
|
|
132
|
+
|
|
133
|
+
end # Vedeu
|
data/lib/vedeu/models/page.rb
CHANGED
data/lib/vedeu/models/row.rb
CHANGED
data/lib/vedeu/null/generic.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Vedeu
|
|
|
14
14
|
# @return [String|Symbol]
|
|
15
15
|
attr_reader :name
|
|
16
16
|
|
|
17
|
-
# Returns
|
|
17
|
+
# Returns a new instance of the Vedeu::Null::Generic class.
|
|
18
18
|
#
|
|
19
19
|
# @param attributes [Hash<Symbol => void>]
|
|
20
20
|
# @option attributes name [String|Symbol|NilClass]
|
data/lib/vedeu/output/all.rb
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
module Vedeu
|
|
2
|
+
|
|
3
|
+
module Output
|
|
4
|
+
|
|
5
|
+
# Directly write to the terminal.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# Vedeu.write(output, options)
|
|
9
|
+
#
|
|
10
|
+
# @api private
|
|
11
|
+
#
|
|
12
|
+
class Write
|
|
13
|
+
|
|
14
|
+
include Vedeu::Common
|
|
15
|
+
include Vedeu::Presentation
|
|
16
|
+
|
|
17
|
+
# @api public
|
|
18
|
+
# @see Vedeu::Output::Write#initialize
|
|
19
|
+
def self.write(output = nil, options = {})
|
|
20
|
+
new(output, options).write
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Returns a new instance of Vedeu::Output::Write.
|
|
24
|
+
#
|
|
25
|
+
# @param output [String]
|
|
26
|
+
# @param options [Hash<Symbol => Fixnum>]
|
|
27
|
+
# @option x [Fixnum]
|
|
28
|
+
# @option y [Fixnum]
|
|
29
|
+
# @option colour [Hash<Symbol => String>]
|
|
30
|
+
# @option style [Array<Symbol>|Symbol]
|
|
31
|
+
# @return [Vedeu::Output::Write]
|
|
32
|
+
def initialize(output = nil, options = {})
|
|
33
|
+
@output = output
|
|
34
|
+
@options = options
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @return [NilClass]
|
|
38
|
+
def parent
|
|
39
|
+
nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @return [Vedeu::Geometries::Position]
|
|
43
|
+
def position(pos = position_start)
|
|
44
|
+
Vedeu::Geometries::Position.coerce(pos)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @return [Array<String>]
|
|
48
|
+
def write
|
|
49
|
+
Vedeu.direct_write(to_s)
|
|
50
|
+
|
|
51
|
+
to_s
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
protected
|
|
55
|
+
|
|
56
|
+
# @!attribute [r] output
|
|
57
|
+
# @return [String]
|
|
58
|
+
attr_reader :output
|
|
59
|
+
alias_method :value, :output
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
# @return [Hash<Symbol => Fixnum>]
|
|
64
|
+
def defaults
|
|
65
|
+
{
|
|
66
|
+
x: 1,
|
|
67
|
+
y: 1,
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @return [Hash<Symbol => Fixnum>]
|
|
72
|
+
def options
|
|
73
|
+
defaults.merge!(@options)
|
|
74
|
+
end
|
|
75
|
+
alias_method :attributes, :options
|
|
76
|
+
|
|
77
|
+
# @return [String]
|
|
78
|
+
def output
|
|
79
|
+
@output.to_s
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# @return [Hash<Symbol => Fixnum>]
|
|
83
|
+
def position_start
|
|
84
|
+
{
|
|
85
|
+
x: options[:x],
|
|
86
|
+
y: options[:y],
|
|
87
|
+
}
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# @return [Hash<Symbol => Fixnum>]
|
|
91
|
+
def position_end
|
|
92
|
+
{
|
|
93
|
+
x: options[:x] + output.size,
|
|
94
|
+
y: options[:y],
|
|
95
|
+
}
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @return [String]
|
|
99
|
+
def to_s
|
|
100
|
+
@_to_s ||= super +
|
|
101
|
+
Vedeu::EscapeSequences::Esc.reset +
|
|
102
|
+
position(position_end)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end # Write
|
|
106
|
+
|
|
107
|
+
end # Output
|
|
108
|
+
|
|
109
|
+
# @!method write
|
|
110
|
+
# @see Vedeu::Output::Write#write
|
|
111
|
+
def_delegators Vedeu::Output::Write,
|
|
112
|
+
:write
|
|
113
|
+
|
|
114
|
+
end # Vedeu
|
data/lib/vedeu/version.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Vedeu
|
|
|
19
19
|
describe Common do
|
|
20
20
|
|
|
21
21
|
let(:described) { Vedeu::VedeuCommonClass }
|
|
22
|
-
let(:instance)
|
|
22
|
+
let(:instance) { described.new }
|
|
23
23
|
|
|
24
24
|
describe '#absent?' do
|
|
25
25
|
subject { instance.undefined_value_test(_value) }
|
|
@@ -58,6 +58,22 @@ module Vedeu
|
|
|
58
58
|
it { subject.must_equal('VedeuCommonClass') }
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
describe '#numeric?' do
|
|
62
|
+
let(:_value) {}
|
|
63
|
+
|
|
64
|
+
subject { instance.numeric?(_value) }
|
|
65
|
+
|
|
66
|
+
context 'when the value is numeric' do
|
|
67
|
+
let(:_value) { 16 }
|
|
68
|
+
|
|
69
|
+
it { subject.must_equal(true) }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context 'when the value is not numeric' do
|
|
73
|
+
it { subject.must_equal(false) }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
61
77
|
describe '#present?' do
|
|
62
78
|
subject { instance.defined_value_test(_value) }
|
|
63
79
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Vedeu
|
|
4
|
+
|
|
5
|
+
module Input
|
|
6
|
+
|
|
7
|
+
describe Read do
|
|
8
|
+
|
|
9
|
+
let(:described) { Vedeu::Input::Read }
|
|
10
|
+
let(:instance) { described.new(input, options) }
|
|
11
|
+
let(:input) {}
|
|
12
|
+
let(:options) {
|
|
13
|
+
{
|
|
14
|
+
mode: mode
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let(:mode) { :cooked }
|
|
18
|
+
|
|
19
|
+
describe '#initialize' do
|
|
20
|
+
it { instance.must_be_instance_of(described) }
|
|
21
|
+
it { instance.instance_variable_get('@input').must_equal(input) }
|
|
22
|
+
it { instance.instance_variable_get('@options').must_equal(options) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '.read' do
|
|
26
|
+
subject { described.read(input, options) }
|
|
27
|
+
|
|
28
|
+
context 'when the mode is :cooked' do
|
|
29
|
+
context 'when input was given' do
|
|
30
|
+
let(:input) { 'Some text...' }
|
|
31
|
+
|
|
32
|
+
it {
|
|
33
|
+
Vedeu.expects(:trigger).with(:_command_, input)
|
|
34
|
+
subject.must_equal(input)
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'when input was not given' do
|
|
39
|
+
let(:some_input) { "Some text...\n" }
|
|
40
|
+
let(:chomped) { 'Some text...' }
|
|
41
|
+
|
|
42
|
+
it {
|
|
43
|
+
Vedeu::Terminal.console.expects(:gets).returns(some_input)
|
|
44
|
+
Vedeu.expects(:trigger).with(:_command_, chomped)
|
|
45
|
+
subject.must_equal(chomped)
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'when the mode is :raw' do
|
|
51
|
+
let(:mode) { :raw }
|
|
52
|
+
|
|
53
|
+
context 'when input was given' do
|
|
54
|
+
let(:input) { 'S' }
|
|
55
|
+
|
|
56
|
+
it {
|
|
57
|
+
Vedeu.expects(:trigger).with(:_keypress_, input)
|
|
58
|
+
subject.must_equal(input)
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context 'when input was not given' do
|
|
63
|
+
let(:some_input) { 'T' }
|
|
64
|
+
let(:translated) { 'T' }
|
|
65
|
+
|
|
66
|
+
it {
|
|
67
|
+
Vedeu::Terminal.console.expects(:getch).returns(some_input)
|
|
68
|
+
Vedeu::Input::Translator.expects(:translate).returns(translated)
|
|
69
|
+
Vedeu.expects(:trigger).with(:_keypress_, translated)
|
|
70
|
+
subject.must_equal(translated)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
context 'but a special key is pressed' do
|
|
74
|
+
let(:some_input) { "\e[23;2~" }
|
|
75
|
+
let(:translated) { :shift_f11 }
|
|
76
|
+
|
|
77
|
+
it {
|
|
78
|
+
Vedeu::Terminal.console.expects(:getch).returns(some_input)
|
|
79
|
+
Vedeu::Input::Translator.expects(:translate).returns(translated)
|
|
80
|
+
Vedeu.expects(:trigger).with(:_keypress_, translated)
|
|
81
|
+
subject.must_equal(translated)
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'when the mode is invalid' do
|
|
88
|
+
let(:mode) { :invalid }
|
|
89
|
+
|
|
90
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe '#read' do
|
|
95
|
+
it { instance.must_respond_to(:read) }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end # Read
|
|
99
|
+
|
|
100
|
+
end # Input
|
|
101
|
+
|
|
102
|
+
end # Vedeu
|
|
@@ -13,7 +13,7 @@ module Vedeu
|
|
|
13
13
|
|
|
14
14
|
describe '#initialize' do
|
|
15
15
|
it { instance.must_be_instance_of(described) }
|
|
16
|
-
it { instance.instance_variable_get('@old_stdout').
|
|
16
|
+
it { instance.instance_variable_get('@old_stdout').wont_equal(nil) }
|
|
17
17
|
it { instance.instance_variable_get('@samples').must_equal({}) }
|
|
18
18
|
it { instance.instance_variable_get('@benchmark').must_be_instance_of(Benchmark::IPS::Job) }
|
|
19
19
|
it { instance.instance_variable_get('@count').must_equal(0) }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Vedeu
|
|
4
|
+
|
|
5
|
+
module Output
|
|
6
|
+
|
|
7
|
+
describe Write do
|
|
8
|
+
|
|
9
|
+
let(:described) { Vedeu::Output::Write }
|
|
10
|
+
let(:instance) { described.new(output, options) }
|
|
11
|
+
let(:output) {}
|
|
12
|
+
let(:options) { {} }
|
|
13
|
+
|
|
14
|
+
describe '#initialize' do
|
|
15
|
+
it { instance.must_be_instance_of(described) }
|
|
16
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
|
17
|
+
it { instance.instance_variable_get('@options').must_equal(options) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '.write' do
|
|
21
|
+
before do
|
|
22
|
+
Vedeu::Terminal.stubs(:output)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
subject { described.write(output, options) }
|
|
26
|
+
|
|
27
|
+
context 'when the output is empty' do
|
|
28
|
+
let(:expected) { "\e[1;1H\e[0m\e[1;1H" }
|
|
29
|
+
|
|
30
|
+
it { subject.must_equal(expected) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'when the output is not empty' do
|
|
34
|
+
let(:output) { 'Some text...' }
|
|
35
|
+
let(:expected) { "\e[1;1HSome text...\e[0m\e[1;13H" }
|
|
36
|
+
|
|
37
|
+
it { subject.must_equal(expected) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'when a colour is provided' do
|
|
41
|
+
let(:output) { 'Some text...' }
|
|
42
|
+
let(:options) {
|
|
43
|
+
{
|
|
44
|
+
colour: { background: '#ff0000', foreground: '#ffff00' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let(:expected) {
|
|
48
|
+
"\e[1;1H" \
|
|
49
|
+
"\e[38;2;255;255;0m" \
|
|
50
|
+
"\e[48;2;255;0;0m" \
|
|
51
|
+
"Some text..." \
|
|
52
|
+
"\e[0m" \
|
|
53
|
+
"\e[1;13H" \
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
it { subject.must_equal(expected) }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'when a style is provided' do
|
|
60
|
+
let(:output) { 'Some text...' }
|
|
61
|
+
let(:options) {
|
|
62
|
+
{
|
|
63
|
+
style: :underline,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let(:expected) { "\e[1;1H\e[4mSome text...\e[0m\e[1;13H" }
|
|
67
|
+
|
|
68
|
+
it { subject.must_equal(expected) }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe '#parent' do
|
|
73
|
+
subject { instance.parent }
|
|
74
|
+
|
|
75
|
+
it { subject.must_equal(nil) }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe '#position' do
|
|
79
|
+
subject { instance.position }
|
|
80
|
+
|
|
81
|
+
it { subject.must_be_instance_of(Vedeu::Geometries::Position) }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#write' do
|
|
85
|
+
it { instance.must_respond_to(:write) }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end # Write
|
|
89
|
+
|
|
90
|
+
end # Output
|
|
91
|
+
|
|
92
|
+
end # Vedeu
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vedeu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.65
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gavin Laking
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: guard
|
|
@@ -440,6 +440,7 @@ files:
|
|
|
440
440
|
- lib/vedeu/input/keymap.rb
|
|
441
441
|
- lib/vedeu/input/mapper.rb
|
|
442
442
|
- lib/vedeu/input/mouse.rb
|
|
443
|
+
- lib/vedeu/input/read.rb
|
|
443
444
|
- lib/vedeu/input/repository.rb
|
|
444
445
|
- lib/vedeu/input/store.rb
|
|
445
446
|
- lib/vedeu/input/translator.rb
|
|
@@ -497,6 +498,7 @@ files:
|
|
|
497
498
|
- lib/vedeu/output/text.rb
|
|
498
499
|
- lib/vedeu/output/viewport.rb
|
|
499
500
|
- lib/vedeu/output/wordwrap.rb
|
|
501
|
+
- lib/vedeu/output/write.rb
|
|
500
502
|
- lib/vedeu/plugins/all.rb
|
|
501
503
|
- lib/vedeu/plugins/plugin.rb
|
|
502
504
|
- lib/vedeu/plugins/plugins.rb
|
|
@@ -623,6 +625,7 @@ files:
|
|
|
623
625
|
- test/lib/vedeu/input/keymap_test.rb
|
|
624
626
|
- test/lib/vedeu/input/mapper_test.rb
|
|
625
627
|
- test/lib/vedeu/input/mouse_test.rb
|
|
628
|
+
- test/lib/vedeu/input/read_test.rb
|
|
626
629
|
- test/lib/vedeu/input/repository_test.rb
|
|
627
630
|
- test/lib/vedeu/input/store_test.rb
|
|
628
631
|
- test/lib/vedeu/input/translator_test.rb
|
|
@@ -671,6 +674,7 @@ files:
|
|
|
671
674
|
- test/lib/vedeu/output/text_test.rb
|
|
672
675
|
- test/lib/vedeu/output/viewport_test.rb
|
|
673
676
|
- test/lib/vedeu/output/wordwrap_test.rb
|
|
677
|
+
- test/lib/vedeu/output/write_test.rb
|
|
674
678
|
- test/lib/vedeu/plugins/plugin_test.rb
|
|
675
679
|
- test/lib/vedeu/plugins/plugins_test.rb
|
|
676
680
|
- test/lib/vedeu/repositories/assemblage_test.rb
|
|
@@ -835,6 +839,7 @@ test_files:
|
|
|
835
839
|
- test/lib/vedeu/input/keymap_test.rb
|
|
836
840
|
- test/lib/vedeu/input/mapper_test.rb
|
|
837
841
|
- test/lib/vedeu/input/mouse_test.rb
|
|
842
|
+
- test/lib/vedeu/input/read_test.rb
|
|
838
843
|
- test/lib/vedeu/input/repository_test.rb
|
|
839
844
|
- test/lib/vedeu/input/store_test.rb
|
|
840
845
|
- test/lib/vedeu/input/translator_test.rb
|
|
@@ -883,6 +888,7 @@ test_files:
|
|
|
883
888
|
- test/lib/vedeu/output/text_test.rb
|
|
884
889
|
- test/lib/vedeu/output/viewport_test.rb
|
|
885
890
|
- test/lib/vedeu/output/wordwrap_test.rb
|
|
891
|
+
- test/lib/vedeu/output/write_test.rb
|
|
886
892
|
- test/lib/vedeu/plugins/plugin_test.rb
|
|
887
893
|
- test/lib/vedeu/plugins/plugins_test.rb
|
|
888
894
|
- test/lib/vedeu/repositories/assemblage_test.rb
|