vedeu 0.6.33 → 0.6.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/vedeu.rb +0 -7
- data/lib/vedeu/geometry/area.rb +27 -12
- data/lib/vedeu/geometry/geometry.rb +44 -82
- data/lib/vedeu/geometry/repository.rb +8 -4
- data/lib/vedeu/interfaces/dsl.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/buffers/refresh_test.rb +44 -23
- data/vedeu.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12cdb96715e44a6ed789be72c594f11a2fca50c4
|
4
|
+
data.tar.gz: 5fb1b73c0e64a16bfaa3c227169fec1ad8d69475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcce80eac99efd8c58394bf7bc595ce26ec4534288357894afbbbb7ac7abe76dd4b4f1f80f5500b6208dbfe0be58882ad7c455a4e6f669d937a0b866ab2958df
|
7
|
+
data.tar.gz: e55fbfa42ce9f608f0f28dffa9584f763a5f6ae8126e03de8c841fde5377612d67d7437a33b5962c63119a14eccce43b1cf4e0933982b65e1751ba7372080638
|
data/.rubocop.yml
CHANGED
data/lib/vedeu.rb
CHANGED
@@ -23,13 +23,6 @@ module Vedeu
|
|
23
23
|
extend Forwardable
|
24
24
|
extend self
|
25
25
|
|
26
|
-
# Return the name of currently focussed interface.
|
27
|
-
#
|
28
|
-
# @return [Vedeu::Models::Focus]
|
29
|
-
def self.focusable
|
30
|
-
@focusable ||= Vedeu::Models::Focus
|
31
|
-
end
|
32
|
-
|
33
26
|
end # Vedeu
|
34
27
|
|
35
28
|
require 'vedeu/all'
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -7,24 +7,26 @@ module Vedeu
|
|
7
7
|
class Area
|
8
8
|
|
9
9
|
# @!attribute [r] y
|
10
|
-
# @return [Fixnum] Returns the top coordinate
|
10
|
+
# @return [Fixnum] Returns the top coordinate (row/line start
|
11
|
+
# position) of the interface.
|
11
12
|
attr_reader :y
|
12
13
|
alias_method :top, :y
|
13
14
|
|
14
15
|
# @!attribute [r] yn
|
15
|
-
# @return [Fixnum] Returns the bottom coordinate
|
16
|
-
# interface.
|
16
|
+
# @return [Fixnum] Returns the bottom coordinate (row/line end
|
17
|
+
# position) of the interface.
|
17
18
|
attr_reader :yn
|
18
19
|
alias_method :bottom, :yn
|
19
20
|
|
20
21
|
# @!attribute [r] x
|
21
|
-
# @return [Fixnum] Returns the left coordinate
|
22
|
+
# @return [Fixnum] Returns the left coordinate (column/character
|
23
|
+
# start position) of the interface.
|
22
24
|
attr_reader :x
|
23
25
|
alias_method :left, :x
|
24
26
|
|
25
27
|
# @!attribute [r] xn
|
26
|
-
# @return [Fixnum] Returns the right coordinate
|
27
|
-
# interface.
|
28
|
+
# @return [Fixnum] Returns the right coordinate (column/
|
29
|
+
# character end position) of the interface.
|
28
30
|
attr_reader :xn
|
29
31
|
alias_method :right, :xn
|
30
32
|
|
@@ -44,7 +46,7 @@ module Vedeu
|
|
44
46
|
d: attributes[:y],
|
45
47
|
dn: attributes[:yn],
|
46
48
|
d_dn: attributes[:y_yn],
|
47
|
-
default:
|
49
|
+
default: Vedeu.height,
|
48
50
|
maximised: attributes[:maximised],
|
49
51
|
centred: attributes[:centred],
|
50
52
|
}
|
@@ -52,7 +54,7 @@ module Vedeu
|
|
52
54
|
d: attributes[:x],
|
53
55
|
dn: attributes[:xn],
|
54
56
|
d_dn: attributes[:x_xn],
|
55
|
-
default:
|
57
|
+
default: Vedeu.width,
|
56
58
|
maximised: attributes[:maximised],
|
57
59
|
centred: attributes[:centred],
|
58
60
|
}
|
@@ -86,26 +88,39 @@ module Vedeu
|
|
86
88
|
end
|
87
89
|
alias_method :==, :eql?
|
88
90
|
|
91
|
+
# Returns an array containing the centred y and x coordinates of
|
92
|
+
# the interface.
|
93
|
+
#
|
89
94
|
# @return [Array<Fixnum>]
|
90
95
|
def centre
|
91
96
|
[centre_y, centre_x]
|
92
97
|
end
|
93
98
|
|
99
|
+
# Returns the centred y coordinate (the vertical centre row) of
|
100
|
+
# the interface.
|
101
|
+
#
|
94
102
|
# @return [Fixnum]
|
95
103
|
def centre_y
|
96
104
|
(height / 2) + y
|
97
105
|
end
|
98
106
|
|
107
|
+
# Returns the centred x coordinate (the horizontal centre
|
108
|
+
# character) of the interface.
|
109
|
+
#
|
99
110
|
# @return [Fixnum]
|
100
111
|
def centre_x
|
101
112
|
(width / 2) + x
|
102
113
|
end
|
103
114
|
|
115
|
+
# Returns the height of the interface.
|
116
|
+
#
|
104
117
|
# @return [Fixnum]
|
105
118
|
def height
|
106
119
|
(y..yn).size
|
107
120
|
end
|
108
121
|
|
122
|
+
# Returns the width of the interface.
|
123
|
+
#
|
109
124
|
# @return [Fixnum]
|
110
125
|
def width
|
111
126
|
(x..xn).size
|
@@ -117,7 +132,7 @@ module Vedeu
|
|
117
132
|
# `top` or `y` is 4.
|
118
133
|
#
|
119
134
|
# north # => 3
|
120
|
-
# north(2) # => 2 (positive goes north)
|
135
|
+
# north(2) # => 2 (positive goes 'more' north)
|
121
136
|
# north(-4) # => 8 (negative goes south)
|
122
137
|
#
|
123
138
|
# @param offset [Fixnum]
|
@@ -132,7 +147,7 @@ module Vedeu
|
|
132
147
|
# `right` or `xn` is 19.
|
133
148
|
#
|
134
149
|
# east # => 20
|
135
|
-
# east(2) # => 21 (positive goes east)
|
150
|
+
# east(2) # => 21 (positive goes 'more' east)
|
136
151
|
# east(-4) # => 15 (negative goes west)
|
137
152
|
#
|
138
153
|
# @param offset [Fixnum]
|
@@ -147,7 +162,7 @@ module Vedeu
|
|
147
162
|
# `bottom` or `yn` is 12.
|
148
163
|
#
|
149
164
|
# south # => 13
|
150
|
-
# south(2) # => 14 (positive goes south)
|
165
|
+
# south(2) # => 14 (positive goes 'more' south)
|
151
166
|
# south(-4) # => 8 (negative goes north)
|
152
167
|
#
|
153
168
|
# @param offset [Fixnum]
|
@@ -162,7 +177,7 @@ module Vedeu
|
|
162
177
|
# `left` or `x` is 8.
|
163
178
|
#
|
164
179
|
# west # => 7
|
165
|
-
# west(2) # => 6 (positive goes west)
|
180
|
+
# west(2) # => 6 (positive goes 'more' west)
|
166
181
|
# west(-4) # => 12 (negative goes east)
|
167
182
|
#
|
168
183
|
# @param offset [Fixnum]
|
@@ -103,15 +103,15 @@ module Vedeu
|
|
103
103
|
{
|
104
104
|
client: @client,
|
105
105
|
centred: @centred,
|
106
|
-
height:
|
106
|
+
height: height,
|
107
107
|
maximised: @maximised,
|
108
108
|
name: @name,
|
109
109
|
repository: @repository,
|
110
|
-
width:
|
111
|
-
x:
|
112
|
-
xn:
|
113
|
-
y:
|
114
|
-
yn:
|
110
|
+
width: width,
|
111
|
+
x: x,
|
112
|
+
xn: xn,
|
113
|
+
y: y,
|
114
|
+
yn: yn,
|
115
115
|
}
|
116
116
|
end
|
117
117
|
|
@@ -144,51 +144,50 @@ module Vedeu
|
|
144
144
|
|
145
145
|
# Moves the geometry down by one row.
|
146
146
|
#
|
147
|
-
#
|
147
|
+
# @todo Move cursor also.
|
148
148
|
# @return [Vedeu::Geometry::Geometry]
|
149
149
|
def move_down
|
150
150
|
return self if yn + 1 > Vedeu.height
|
151
151
|
|
152
|
-
|
152
|
+
move(y: y + 1, yn: yn + 1)
|
153
153
|
end
|
154
154
|
|
155
155
|
# Moves the geometry left by one column.
|
156
156
|
#
|
157
|
-
#
|
157
|
+
# @todo Move cursor also.
|
158
158
|
# @return [Vedeu::Geometry::Geometry]
|
159
159
|
def move_left
|
160
160
|
return self if x - 1 < 1
|
161
161
|
|
162
|
-
|
162
|
+
move(x: x - 1, xn: xn - 1)
|
163
163
|
end
|
164
164
|
|
165
165
|
# Moves the geometry to the top left of the terminal.
|
166
166
|
#
|
167
|
-
#
|
167
|
+
# @todo Move cursor also.
|
168
168
|
# @return [Vedeu::Geometry::Geometry]
|
169
169
|
def move_origin
|
170
|
-
|
171
|
-
move_attributes(x: 1, xn: (xn - x + 1), y: 1, yn: (yn - y + 1)))
|
170
|
+
move(x: 1, xn: (xn - x + 1), y: 1, yn: (yn - y + 1))
|
172
171
|
end
|
173
172
|
|
174
173
|
# Moves the geometry right by one column.
|
175
174
|
#
|
176
|
-
#
|
175
|
+
# @todo Move cursor also.
|
177
176
|
# @return [Vedeu::Geometry::Geometry]
|
178
177
|
def move_right
|
179
178
|
return self if xn + 1 > Vedeu.width
|
180
179
|
|
181
|
-
|
180
|
+
move(x: x + 1, xn: xn + 1)
|
182
181
|
end
|
183
182
|
|
184
183
|
# Moves the geometry up by one column.
|
185
184
|
#
|
186
|
-
#
|
185
|
+
# @todo Move cursor also.
|
187
186
|
# @return [Vedeu::Geometry::Geometry]
|
188
187
|
def move_up
|
189
188
|
return self if y - 1 < 1
|
190
189
|
|
191
|
-
|
190
|
+
move(y: y - 1, yn: yn - 1)
|
192
191
|
end
|
193
192
|
|
194
193
|
# Will unmaximise the named interface geometry. Previously, when
|
@@ -223,75 +222,38 @@ module Vedeu
|
|
223
222
|
# @return [Hash<Symbol => Boolean, Fixnum>]
|
224
223
|
def area_attributes
|
225
224
|
{
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
centred: centred,
|
235
|
-
maximised: maximised,
|
225
|
+
centred: @centred,
|
226
|
+
maximised: @maximised,
|
227
|
+
x: @x.is_a?(Proc) ? @x.call : @x,
|
228
|
+
xn: @xn.is_a?(Proc) ? @xn.call : @xn,
|
229
|
+
x_xn: @width.is_a?(Proc) ? @width.call : @width,
|
230
|
+
y: @y.is_a?(Proc) ? @y.call : @y,
|
231
|
+
yn: @yn.is_a?(Proc) ? @yn.call : @yn,
|
232
|
+
y_yn: @height.is_a?(Proc) ? @height.call : @height,
|
236
233
|
}
|
237
234
|
end
|
238
235
|
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
|
246
|
-
attributes.merge!(
|
247
|
-
centred: false,
|
248
|
-
maximised: false,
|
249
|
-
x: x,
|
250
|
-
xn: xn,
|
251
|
-
y: y,
|
252
|
-
yn: yn).merge!(attrs)
|
253
|
-
end
|
254
|
-
|
255
|
-
# Returns the row/line start position for the interface.
|
256
|
-
#
|
257
|
-
# @return [Fixnum]
|
258
|
-
def _y
|
259
|
-
@y.is_a?(Proc) ? @y.call : @y
|
260
|
-
end
|
261
|
-
|
262
|
-
# Returns the row/line end position for the interface.
|
263
|
-
#
|
264
|
-
# @return [Fixnum]
|
265
|
-
def _yn
|
266
|
-
@yn.is_a?(Proc) ? @yn.call : @yn
|
267
|
-
end
|
268
|
-
|
269
|
-
# Returns the column/character start position for the interface.
|
270
|
-
#
|
271
|
-
# @return [Fixnum]
|
272
|
-
def _x
|
273
|
-
@x.is_a?(Proc) ? @x.call : @x
|
274
|
-
end
|
275
|
-
|
276
|
-
# Returns the column/character end position for the interface.
|
277
|
-
#
|
278
|
-
# @return [Fixnum]
|
279
|
-
def _xn
|
280
|
-
@xn.is_a?(Proc) ? @xn.call : @xn
|
281
|
-
end
|
282
|
-
|
283
|
-
# Returns the width of the interface.
|
236
|
+
# When moving an interface;
|
237
|
+
# 1) Reset the centred and maximised states to false; it wont be
|
238
|
+
# centred if moved, and cannot be moved if maximised.
|
239
|
+
# 2) Get the current coordinates of the interface, then:
|
240
|
+
# 3) Override the attributes with the new coordinates for
|
241
|
+
# desired movement; these are usually +/- 1 of the current
|
242
|
+
# state, depending on direction.
|
284
243
|
#
|
285
|
-
# @
|
286
|
-
|
287
|
-
|
288
|
-
|
244
|
+
# @param coordinates [Hash<Symbol => Fixnum>]
|
245
|
+
# @option coordinates x [Fixnum] The starting column/character
|
246
|
+
# position.
|
247
|
+
# @option coordinates xn [Fixnum] The ending column/character
|
248
|
+
# position.
|
249
|
+
# @option coordinates y [Fixnum] The starting row/line position.
|
250
|
+
# @option coordinates yn [Fixnum] The ending row/line position.
|
251
|
+
# @return [Hash<Symbol => Boolean, Fixnum>]
|
252
|
+
def move(coordinates = {})
|
253
|
+
attrs = attributes.merge!(centred: false, maximised: false)
|
254
|
+
.merge!(coordinates)
|
289
255
|
|
290
|
-
|
291
|
-
#
|
292
|
-
# @return [Fixnum]
|
293
|
-
def _height
|
294
|
-
@height.is_a?(Proc) ? @height.call : @height
|
256
|
+
Vedeu::Geometry::Geometry.store(attrs)
|
295
257
|
end
|
296
258
|
|
297
259
|
# Returns the default options/attributes for this class.
|
@@ -300,7 +262,7 @@ module Vedeu
|
|
300
262
|
def defaults
|
301
263
|
{
|
302
264
|
client: nil,
|
303
|
-
centred:
|
265
|
+
centred: false,
|
304
266
|
height: nil,
|
305
267
|
maximised: false,
|
306
268
|
name: nil,
|
@@ -32,6 +32,13 @@ module Vedeu
|
|
32
32
|
Vedeu.geometries.by_name(name).maximise
|
33
33
|
end
|
34
34
|
|
35
|
+
Vedeu.bind(:_movement_refresh_) do |name|
|
36
|
+
Vedeu.trigger(:_clear_)
|
37
|
+
Vedeu.trigger(:_refresh_)
|
38
|
+
Vedeu.trigger(:_clear_view_, name)
|
39
|
+
Vedeu.trigger(:_refresh_view_, name)
|
40
|
+
end
|
41
|
+
|
35
42
|
# See {file:docs/events/view.md#\_unmaximise_}
|
36
43
|
Vedeu.bind(:_unmaximise_) do |name|
|
37
44
|
Vedeu.geometries.by_name(name).unmaximise
|
@@ -41,10 +48,7 @@ module Vedeu
|
|
41
48
|
Vedeu.bind(:"_view_#{direction}_") do |name|
|
42
49
|
Vedeu.geometries.by_name(name).send("move_#{direction}")
|
43
50
|
|
44
|
-
Vedeu.trigger(:
|
45
|
-
Vedeu.trigger(:_refresh_)
|
46
|
-
Vedeu.trigger(:_clear_view_, name)
|
47
|
-
Vedeu.trigger(:_refresh_view_, name)
|
51
|
+
Vedeu.trigger(:_movement_refresh_, name)
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
data/lib/vedeu/interfaces/dsl.rb
CHANGED
@@ -76,7 +76,7 @@ module Vedeu
|
|
76
76
|
# @param name [String|Symbol]
|
77
77
|
# @return [void]
|
78
78
|
def add_focusable!(name)
|
79
|
-
Vedeu.
|
79
|
+
Vedeu::Models::Focus.add(name)
|
80
80
|
end
|
81
81
|
|
82
82
|
# Returns the client object which called the DSL method.
|
data/lib/vedeu/version.rb
CHANGED
@@ -12,48 +12,69 @@ module Vedeu
|
|
12
12
|
describe Refresh do
|
13
13
|
|
14
14
|
let(:described) { Vedeu::Buffers::Refresh }
|
15
|
-
let(:instance) { described.new(_name) }
|
15
|
+
let(:instance) { described.new(_name, options) }
|
16
16
|
let(:_name) { 'Vedeu::Buffers::Refresh' }
|
17
|
-
let(:
|
17
|
+
let(:options) {
|
18
|
+
{
|
19
|
+
content_only: content_only,
|
20
|
+
}
|
21
|
+
}
|
22
|
+
let(:content_only) { false }
|
23
|
+
let(:ready) { true }
|
24
|
+
let(:buffer) { mock('Vedeu::Buffers::Buffer', render: nil) }
|
18
25
|
|
19
26
|
before do
|
20
|
-
Vedeu.stubs(:
|
27
|
+
Vedeu.stubs(:trigger).with(:_clear_view_content_, _name)
|
28
|
+
Vedeu.stubs(:trigger).with(:_refresh_border_, _name)
|
21
29
|
end
|
22
30
|
|
23
31
|
describe '#initialize' do
|
24
32
|
it { instance.must_be_instance_of(described) }
|
25
33
|
it { instance.instance_variable_get('@name').must_equal(_name) }
|
34
|
+
it { instance.instance_variable_get('@options').must_equal(options) }
|
26
35
|
end
|
27
36
|
|
28
37
|
describe '.by_name' do
|
38
|
+
before do
|
39
|
+
Vedeu.buffers.stubs(:by_name).with(_name).returns(buffer)
|
40
|
+
end
|
41
|
+
|
29
42
|
subject { described.by_name(_name) }
|
30
43
|
|
31
|
-
|
32
|
-
|
44
|
+
it {
|
45
|
+
Vedeu.expects(:trigger).with(:_clear_view_content_, _name)
|
46
|
+
subject
|
47
|
+
}
|
33
48
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
49
|
+
it {
|
50
|
+
Vedeu.buffers.expects(:by_name).with(_name).returns(buffer)
|
51
|
+
subject
|
52
|
+
}
|
39
53
|
|
40
|
-
|
54
|
+
it {
|
55
|
+
Vedeu.expects(:trigger).with(:_refresh_border_, _name)
|
56
|
+
subject
|
57
|
+
}
|
58
|
+
end
|
41
59
|
|
42
|
-
|
43
|
-
|
44
|
-
subject
|
45
|
-
}
|
60
|
+
describe '.refresh_content_by_name' do
|
61
|
+
let(:content_only) { true }
|
46
62
|
|
47
|
-
|
48
|
-
|
49
|
-
subject
|
50
|
-
}
|
63
|
+
before do
|
64
|
+
Vedeu.buffers.stubs(:by_name).with(_name).returns(buffer)
|
51
65
|
end
|
52
66
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
67
|
+
subject { described.refresh_content_by_name(_name) }
|
68
|
+
|
69
|
+
it {
|
70
|
+
Vedeu.expects(:trigger).with(:_clear_view_content_, _name)
|
71
|
+
subject
|
72
|
+
}
|
73
|
+
|
74
|
+
it {
|
75
|
+
Vedeu.buffers.expects(:by_name).with(_name).returns(buffer)
|
76
|
+
subject
|
77
|
+
}
|
57
78
|
end
|
58
79
|
|
59
80
|
describe '#by_name' do
|
data/vedeu.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'minitest', '5.8.1'
|
27
27
|
spec.add_development_dependency 'minitest-reporters', '1.1.3'
|
28
28
|
spec.add_development_dependency 'mocha', '1.1.0'
|
29
|
-
spec.add_development_dependency 'pry', '0.10.
|
29
|
+
spec.add_development_dependency 'pry', '0.10.3'
|
30
30
|
spec.add_development_dependency 'rubocop', '0.34.2'
|
31
31
|
spec.add_development_dependency 'simplecov', '0.10.0'
|
32
32
|
spec.add_development_dependency 'simplecov-console', '0.2.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.10.
|
103
|
+
version: 0.10.3
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.10.
|
110
|
+
version: 0.10.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|