vedeu 0.6.42 → 0.6.43

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.
@@ -28,6 +28,11 @@ module Vedeu
28
28
  # @return [Fixnum|Float]
29
29
  attr_accessor :client
30
30
 
31
+ # @!attribute [rw] cursor_visible
32
+ # @return [Boolean]
33
+ attr_accessor :cursor_visible
34
+ alias_method :cursor_visible?, :cursor_visible
35
+
31
36
  # @!attribute [rw] name
32
37
  # @return [String]
33
38
  attr_accessor :name
@@ -49,6 +54,7 @@ module Vedeu
49
54
  # @param attributes [Hash]
50
55
  # @option attributes client [Vedeu::Client]
51
56
  # @option attributes colour [Vedeu::Colours::Colour]
57
+ # @option attributes cursor_visible [Boolean]
52
58
  # @option attributes value [Vedeu::Views::Lines]
53
59
  # @option attributes name [String|Symbol]
54
60
  # @option attributes parent [Vedeu::Views::Composition]
@@ -118,14 +124,14 @@ module Vedeu
118
124
  # @return [Hash]
119
125
  def defaults
120
126
  {
121
- client: nil,
122
- colour: Vedeu::Colours::Colour.coerce(background: :default,
123
- foreground: :default),
124
- name: '',
125
- parent: nil,
126
- style: :normal,
127
- value: [],
128
- zindex: 0,
127
+ client: nil,
128
+ colour: Vedeu::Colours::Colour.default,
129
+ cursor_visible: true,
130
+ name: '',
131
+ parent: nil,
132
+ style: :normal,
133
+ value: [],
134
+ zindex: 0,
129
135
  }
130
136
  end
131
137
 
@@ -28,6 +28,7 @@ module Vedeu
28
28
  def falsy
29
29
  false
30
30
  end
31
+ alias_method :cursor_visible?, :falsy
31
32
  alias_method :enabled?, :falsy
32
33
  alias_method :maximise, :falsy
33
34
  alias_method :maximised?, :falsy
@@ -18,6 +18,9 @@ module Vedeu
18
18
  # @return [Array<void>]
19
19
  def clear
20
20
  threads = storage.map do |renderer|
21
+ Vedeu.log(type: :output,
22
+ message: "Clearing via #{renderer.class.name}")
23
+
21
24
  Thread.new(renderer) do
22
25
  mutex.synchronize do
23
26
  toggle_cursor { renderer.clear }
@@ -49,6 +52,9 @@ module Vedeu
49
52
  # @return [Array<void>]
50
53
  def render(output)
51
54
  threads = storage.map do |renderer|
55
+ Vedeu.log(type: :output,
56
+ message: "Rendering via #{renderer.class.name}")
57
+
52
58
  Thread.new(renderer) do
53
59
  mutex.synchronize do
54
60
  toggle_cursor { renderer.render(output) }
@@ -127,10 +133,7 @@ module Vedeu
127
133
  end # Vedeu
128
134
 
129
135
  require 'vedeu/output/renderers/options'
130
- require 'vedeu/output/renderers/escape_sequence'
131
136
  require 'vedeu/output/renderers/file'
132
137
  require 'vedeu/output/renderers/html'
133
138
  require 'vedeu/output/renderers/json'
134
- require 'vedeu/output/renderers/null'
135
139
  require 'vedeu/output/renderers/terminal'
136
- require 'vedeu/output/renderers/text'
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.42'.freeze
4
+ VERSION = '0.6.43'.freeze
5
5
 
6
6
  end
@@ -71,6 +71,77 @@ module Vedeu
71
71
  end
72
72
  end
73
73
 
74
+ describe '#cursor_visible?' do
75
+ let(:buffer) {
76
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new],
77
+ cursor_visible: cursor_visible)
78
+ }
79
+ let(:cursor_visible) { false }
80
+
81
+ subject { instance.cursor_visible? }
82
+
83
+ context 'when there is a front buffer' do
84
+ let(:front) { buffer }
85
+
86
+ context 'when the cursor is visible' do
87
+ let(:cursor_visible) { true }
88
+
89
+ it { subject.must_equal(true) }
90
+ end
91
+
92
+ context 'when the cursor is not visible' do
93
+ it { subject.must_equal(false) }
94
+ end
95
+ end
96
+
97
+ context 'when there is a previous buffer' do
98
+ let(:front) {}
99
+ let(:previous) { buffer }
100
+
101
+ context 'when the cursor is visible' do
102
+ let(:cursor_visible) { true }
103
+
104
+ it { subject.must_equal(true) }
105
+ end
106
+
107
+ context 'when the cursor is not visible' do
108
+ it { subject.must_equal(false) }
109
+ end
110
+ end
111
+
112
+ context 'when neither a front or previous buffer exists (yet)' do
113
+ let(:front) {}
114
+ let(:previous) {}
115
+
116
+ context 'when an interface exists' do
117
+ let(:interface) {
118
+ Vedeu::Interfaces::Interface.new(name: _name, cursor_visible: cursor_visible)
119
+ }
120
+ let(:cursor_visible) { false }
121
+
122
+ before do
123
+ Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
124
+ end
125
+
126
+ context 'when the interface cursor_visible is false' do
127
+ it { subject.must_equal(false) }
128
+ end
129
+
130
+ context 'when the interface cursor_visible is true' do
131
+ let(:cursor_visible) { true }
132
+
133
+ it { subject.must_equal(true) }
134
+ end
135
+ end
136
+
137
+ context 'when an interface does not exist' do
138
+ it 'uses the Interface::Null cursor_visible (always false)' do
139
+ subject.must_equal(false)
140
+ end
141
+ end
142
+ end
143
+ end
144
+
74
145
  describe '#front?' do
75
146
  subject { instance.front? }
76
147
 
@@ -167,6 +167,12 @@ module Vedeu
167
167
  end
168
168
  end
169
169
 
170
+ describe '.default' do
171
+ subject { described.default }
172
+
173
+ it { subject.must_be_instance_of(Vedeu::Colours::Colour) }
174
+ end
175
+
170
176
  describe '#background=' do
171
177
  let(:_value) { '#000000' }
172
178
 
@@ -0,0 +1,91 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Cursors
6
+
7
+ describe DSL do
8
+
9
+ let(:described) { Vedeu::Cursors::DSL }
10
+
11
+ # describe '#cursor' do
12
+ # let(:_value) {}
13
+
14
+ # before { Vedeu.cursors.reset }
15
+
16
+ # subject { instance.cursor(_value) }
17
+
18
+ # it {
19
+ # subject
20
+ # Vedeu.cursors.find('actinium').visible?.must_equal(false)
21
+ # }
22
+
23
+ # context 'when the value is false' do
24
+ # let(:_value) { false }
25
+
26
+ # it {
27
+ # subject
28
+ # Vedeu.cursors.find('actinium').visible?.must_equal(false)
29
+ # }
30
+ # end
31
+
32
+ # context 'when the value is nil' do
33
+ # let(:_value) {}
34
+
35
+ # it {
36
+ # subject
37
+ # Vedeu.cursors.find('actinium').visible?.must_equal(false)
38
+ # }
39
+ # end
40
+
41
+ # context 'when the value is :show' do
42
+ # let(:_value) { :show }
43
+
44
+ # it {
45
+ # subject
46
+ # Vedeu.cursors.find('actinium').visible?.must_equal(true)
47
+ # }
48
+ # end
49
+
50
+ # context 'when the value is true' do
51
+ # let(:_value) { true }
52
+
53
+ # it {
54
+ # subject
55
+ # Vedeu.cursors.find('actinium').visible?.must_equal(true)
56
+ # }
57
+ # end
58
+
59
+ # context 'when the value is :yes' do
60
+ # let(:_value) { :yes }
61
+
62
+ # it {
63
+ # subject
64
+ # Vedeu.cursors.find('actinium').visible?.must_equal(true)
65
+ # }
66
+ # end
67
+ # end
68
+
69
+ # describe '#cursor!' do
70
+ # subject { instance.cursor! }
71
+
72
+ # it {
73
+ # subject
74
+ # Vedeu.cursors.find('actinium').visible?.must_equal(true)
75
+ # }
76
+ # end
77
+
78
+ # describe '#no_cursor!' do
79
+ # subject { instance.no_cursor! }
80
+
81
+ # it {
82
+ # subject
83
+ # Vedeu.cursors.find('actinium').visible?.must_equal(false)
84
+ # }
85
+ # end
86
+
87
+ end # DSL
88
+
89
+ end # Cursors
90
+
91
+ end # Vedeu
@@ -14,8 +14,15 @@ module Vedeu
14
14
  let(:instance) { described.new(_name) }
15
15
  let(:_name) { 'refresh_cursor' }
16
16
  let(:expected) {}
17
+ let(:cursor) {
18
+ Vedeu::Cursors::Cursor.store(name: _name,
19
+ ox: ox,
20
+ oy: oy,
21
+ visible: visible)
22
+ }
17
23
  let(:ox) { 0 }
18
24
  let(:oy) { 0 }
25
+ let(:visible) { false }
19
26
 
20
27
  describe '#initialize' do
21
28
  it { instance.must_be_instance_of(described) }
@@ -31,38 +38,41 @@ module Vedeu
31
38
  y 1
32
39
  yn 3
33
40
  end
34
- Vedeu::Cursors::Cursor.store(name: 'refresh_cursor',
35
- ox: ox,
36
- oy: oy)
37
-
41
+ Vedeu.cursors.stubs(:by_name).with(_name).returns(cursor)
38
42
  Vedeu::Terminal.stubs(:output).returns(expected)
39
-
40
- Vedeu.stubs(:trigger)
41
43
  end
42
44
 
43
45
  subject { described.by_name(_name) }
44
46
 
45
- it 'renders the cursor in the terminal' do
46
- Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
47
- subject
48
- end
49
-
50
- context 'when the cursors offset position is outside the viewable area' do
51
- let(:ox) { 3 }
52
- let(:oy) { 3 }
47
+ context 'when the cursor is visible' do
48
+ let(:visible) { true }
53
49
 
54
- it 'refreshes the view' do
55
- Vedeu.expects(:trigger).with(:_refresh_view_content_, _name)
50
+ it 'renders the cursor in the terminal' do
51
+ cursor.expects(:render)
56
52
  subject
57
53
  end
58
- end
59
54
 
60
- context 'when the cursors offset position is inside the viewable area' do
61
- it 'does not refresh the view' do
62
- Vedeu.expects(:trigger).with(:_refresh_view_content_, _name).never
63
- subject
55
+ context 'when the cursors offset position is outside the viewable area' do
56
+ let(:ox) { 3 }
57
+ let(:oy) { 3 }
58
+
59
+ it 'refreshes the view' do
60
+ Vedeu.expects(:trigger).with(:_refresh_view_content_, _name)
61
+ subject
62
+ end
63
+ end
64
+
65
+ context 'when the cursors offset position is inside the viewable area' do
66
+ it 'does not refresh the view' do
67
+ Vedeu.expects(:trigger).with(:_refresh_view_content_, _name).never
68
+ subject
69
+ end
64
70
  end
65
71
  end
72
+
73
+ context 'when the cursor is not visible' do
74
+ it { subject.must_equal(nil) }
75
+ end
66
76
  end
67
77
 
68
78
  describe '#by_name' do
@@ -42,73 +42,6 @@ module Vedeu
42
42
  end
43
43
  end
44
44
 
45
- describe '#cursor' do
46
- let(:_value) {}
47
-
48
- before { Vedeu.cursors.reset }
49
-
50
- subject { instance.cursor(_value) }
51
-
52
- it {
53
- subject
54
- Vedeu.cursors.find('actinium').visible?.must_equal(false)
55
- }
56
-
57
- context 'when the value is false' do
58
- let(:_value) { false }
59
-
60
- it {
61
- subject
62
- Vedeu.cursors.find('actinium').visible?.must_equal(false)
63
- }
64
- end
65
-
66
- context 'when the value is nil' do
67
- let(:_value) {}
68
-
69
- it {
70
- subject
71
- Vedeu.cursors.find('actinium').visible?.must_equal(false)
72
- }
73
- end
74
-
75
- context 'when the value is :show' do
76
- let(:_value) { :show }
77
-
78
- it {
79
- subject
80
- Vedeu.cursors.find('actinium').visible?.must_equal(true)
81
- }
82
- end
83
-
84
- context 'when the value is true' do
85
- let(:_value) { true }
86
-
87
- it {
88
- subject
89
- Vedeu.cursors.find('actinium').visible?.must_equal(true)
90
- }
91
- end
92
-
93
- context 'when the value is :yes' do
94
- let(:_value) { :yes }
95
-
96
- it {
97
- subject
98
- Vedeu.cursors.find('actinium').visible?.must_equal(true)
99
- }
100
- end
101
- end
102
-
103
- describe '#cursor!' do
104
- subject { instance.cursor! }
105
-
106
- it {
107
- subject
108
- Vedeu.cursors.find('actinium').visible?.must_equal(true)
109
- }
110
- end
111
-
112
45
  describe '#delay' do
113
46
  subject { instance.delay(0.25) }
114
47
 
@@ -219,15 +152,6 @@ module Vedeu
219
152
  }
220
153
  end
221
154
 
222
- describe '#no_cursor!' do
223
- subject { instance.no_cursor! }
224
-
225
- it {
226
- subject
227
- Vedeu.cursors.find('actinium').visible?.must_equal(false)
228
- }
229
- end
230
-
231
155
  describe '#show!' do
232
156
  subject {
233
157
  Vedeu.interface 'xenon' do
@@ -10,35 +10,38 @@ module Vedeu
10
10
  let(:instance) { described.new(attributes) }
11
11
  let(:attributes) {
12
12
  {
13
- client: client,
14
- colour: colour,
15
- delay: delay,
16
- editable: editable,
17
- group: group,
18
- name: _name,
19
- parent: parent,
20
- style: style,
21
- visible: visible,
22
- zindex: zindex,
13
+ client: client,
14
+ colour: colour,
15
+ cursor_visible: cursor_visible,
16
+ delay: delay,
17
+ editable: editable,
18
+ group: group,
19
+ name: _name,
20
+ parent: parent,
21
+ style: style,
22
+ visible: visible,
23
+ zindex: zindex,
23
24
  }
24
25
  }
25
- let(:client) {}
26
- let(:colour) {}
27
- let(:delay) { 0.0 }
28
- let(:editable) { false }
29
- let(:group) { '' }
30
- let(:_name) { 'hydrogen' }
31
- let(:parent) {}
32
- let(:repository) { Vedeu.interfaces }
33
- let(:style) {}
34
- let(:visible) { true }
35
- let(:zindex) { 1 }
26
+ let(:client) {}
27
+ let(:colour) {}
28
+ let(:cursor_visible) { true }
29
+ let(:delay) { 0.0 }
30
+ let(:editable) { false }
31
+ let(:group) { '' }
32
+ let(:_name) { 'hydrogen' }
33
+ let(:parent) {}
34
+ let(:repository) { Vedeu.interfaces }
35
+ let(:style) {}
36
+ let(:visible) { true }
37
+ let(:zindex) { 1 }
36
38
 
37
39
  describe '#initialize' do
38
40
  subject { instance }
39
41
 
40
42
  it { subject.must_be_instance_of(described) }
41
43
  it { subject.instance_variable_get('@client').must_equal(client) }
44
+ it { subject.instance_variable_get('@cursor_visible').must_equal(cursor_visible) }
42
45
  it { subject.instance_variable_get('@delay').must_equal(delay) }
43
46
  it { subject.instance_variable_get('@editable').must_equal(editable) }
44
47
  it { subject.instance_variable_get('@group').must_equal(group) }
@@ -55,6 +58,8 @@ module Vedeu
55
58
  it {
56
59
  instance.must_respond_to(:client)
57
60
  instance.must_respond_to(:client=)
61
+ instance.must_respond_to(:cursor_visible)
62
+ instance.must_respond_to(:cursor_visible=)
58
63
  instance.must_respond_to(:delay)
59
64
  instance.must_respond_to(:delay=)
60
65
  instance.must_respond_to(:editable)