vedeu 0.4.31 → 0.4.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/borders_app.rb +1 -1
- data/examples/colours_app.rb +1 -1
- data/examples/configuration_app.rb +1 -1
- data/examples/drb_app.rb +1 -1
- data/examples/focus_app.rb +1 -1
- data/examples/geometry_app.rb +1 -1
- data/examples/hello_world.rb +1 -1
- data/examples/material_colours_app.rb +1 -1
- data/examples/panel_app.rb +1 -1
- data/lib/vedeu/application.rb +0 -2
- data/lib/vedeu/bindings.rb +0 -3
- data/lib/vedeu/configuration/configuration.rb +1 -1
- data/lib/vedeu/dsl/presentation.rb +0 -3
- data/lib/vedeu/geometry/area.rb +10 -14
- data/lib/vedeu/geometry/coordinate.rb +2 -0
- data/lib/vedeu/main_loop.rb +32 -34
- data/lib/vedeu/support/log.rb +17 -18
- data/lib/vedeu/support/terminal.rb +6 -13
- data/lib/vedeu/support/timer.rb +2 -2
- data/lib/vedeu/version.rb +3 -1
- data/test/lib/vedeu/bindings_test.rb +0 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +0 -10
- data/test/lib/vedeu/main_loop_test.rb +0 -4
- data/test/lib/vedeu/support/timer_test.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2db54587f464686863ae7a86653c4e690522f778
|
4
|
+
data.tar.gz: 8d0f17548d624a09022312fd9704632090a73b4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a817ae692b688d3a6f67b70c3f88a2fc2775c2b754fa227e5e7b0610705c4c52a266a631fe4efc169b9c26867141cbf48a1ca2e73acbe3d1a047b451dfa75f2
|
7
|
+
data.tar.gz: 5a2423e352bc179911a180df68addaf8b194786dff67ebece988897e4756d5386c71fb8dc97281b47c92665058daeee8d5476ee7445a8e59ed28fa5d1108d23f
|
data/examples/borders_app.rb
CHANGED
data/examples/colours_app.rb
CHANGED
data/examples/drb_app.rb
CHANGED
data/examples/focus_app.rb
CHANGED
data/examples/geometry_app.rb
CHANGED
data/examples/hello_world.rb
CHANGED
data/examples/panel_app.rb
CHANGED
data/lib/vedeu/application.rb
CHANGED
data/lib/vedeu/bindings.rb
CHANGED
@@ -74,9 +74,6 @@ module Vedeu
|
|
74
74
|
# events. Please see those events for their behaviour.
|
75
75
|
Vedeu.bind(:_resize_, delay: 0.15) { Vedeu.resize }
|
76
76
|
|
77
|
-
Vedeu.bind(:tick) { |t| Vedeu.log(type: :debug, message: "Tick: #{t}") }
|
78
|
-
Vedeu.bind(:tock) { |t| Vedeu.log(type: :debug, message: "Tock: #{t}") }
|
79
|
-
|
80
77
|
# Hide the cursor of the named interface or interface currently in focus.
|
81
78
|
Vedeu.bind(:_cursor_hide_) do |name|
|
82
79
|
Vedeu::Visibility.for_cursor(name).hide
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -35,20 +35,16 @@ module Vedeu
|
|
35
35
|
# @return [Vedeu::Area]
|
36
36
|
def self.from_attributes(y:, yn:, y_yn:, y_default:,
|
37
37
|
x:, xn:, x_xn:, x_default:, options:)
|
38
|
-
y_yn = Vedeu::Dimension.pair(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
d_dn: x_xn,
|
49
|
-
default: x_default,
|
50
|
-
options: options,
|
51
|
-
})
|
38
|
+
y_yn = Vedeu::Dimension.pair(d: y,
|
39
|
+
dn: yn,
|
40
|
+
d_dn: y_yn,
|
41
|
+
default: y_default,
|
42
|
+
options: options)
|
43
|
+
x_xn = Vedeu::Dimension.pair(d: x,
|
44
|
+
dn: xn,
|
45
|
+
d_dn: x_xn,
|
46
|
+
default: x_default,
|
47
|
+
options: options)
|
52
48
|
|
53
49
|
from_dimensions(y_yn: y_yn, x_xn: x_xn)
|
54
50
|
end
|
data/lib/vedeu/main_loop.rb
CHANGED
@@ -2,53 +2,51 @@ module Vedeu
|
|
2
2
|
|
3
3
|
# Provides the main loop for a Vedeu application.
|
4
4
|
#
|
5
|
-
# Each time Vedeu starts one cycle in the application loop, it triggers the
|
6
|
-
# `:tick` event. A completion of that cycle will trigger `:tock`. This can be
|
7
|
-
# used by the client application for timing amongst other things.
|
8
5
|
class MainLoop
|
9
6
|
|
10
7
|
trap('SIGTERM') { stop! }
|
11
8
|
trap('TERM') { stop! }
|
12
9
|
trap('INT') { stop! }
|
13
10
|
|
14
|
-
|
15
|
-
# Start the main loop.
|
16
|
-
#
|
17
|
-
# @return [void]
|
18
|
-
# @yieldreturn [void] The client application.
|
19
|
-
def self.start!
|
20
|
-
@started = true
|
21
|
-
@loop = true
|
11
|
+
class << self
|
22
12
|
|
23
|
-
|
24
|
-
|
13
|
+
# :nocov:
|
14
|
+
# Start the main loop.
|
15
|
+
#
|
16
|
+
# @return [void]
|
17
|
+
# @yieldreturn [void] The client application.
|
18
|
+
def start!
|
19
|
+
@started = true
|
20
|
+
@loop = true
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
rescue VedeuInterrupt
|
29
|
-
Vedeu.log(type: :debug, message: 'Vedeu execution interrupted, exiting.')
|
30
|
-
end
|
31
|
-
# :nocov:
|
22
|
+
while @loop
|
23
|
+
yield
|
32
24
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
25
|
+
safe_exit_point!
|
26
|
+
end
|
27
|
+
rescue VedeuInterrupt
|
28
|
+
Vedeu.log(type: :debug,
|
29
|
+
message: 'Vedeu execution interrupted, exiting.')
|
39
30
|
|
40
|
-
|
41
|
-
|
42
|
-
# @raise [VedeuInterrupt] When we wish to terminate the running application.
|
43
|
-
# @return [void]
|
44
|
-
def self.safe_exit_point!
|
45
|
-
if @started && !@loop
|
46
|
-
fail VedeuInterrupt
|
31
|
+
end
|
32
|
+
# :nocov:
|
47
33
|
|
48
|
-
|
49
|
-
|
34
|
+
# Signal that we wish to terminate the running application.
|
35
|
+
#
|
36
|
+
# @return [void]
|
37
|
+
def stop!
|
38
|
+
@loop = false
|
39
|
+
end
|
50
40
|
|
41
|
+
# Check the application has started and we wish to continue running.
|
42
|
+
#
|
43
|
+
# @raise [VedeuInterrupt] When we wish to terminate the running
|
44
|
+
# application.
|
45
|
+
# @return [void]
|
46
|
+
def safe_exit_point!
|
47
|
+
fail VedeuInterrupt if @started && !@loop
|
51
48
|
end
|
49
|
+
|
52
50
|
end
|
53
51
|
|
54
52
|
end # MainLoop
|
data/lib/vedeu/support/log.rb
CHANGED
@@ -101,8 +101,8 @@ module Vedeu
|
|
101
101
|
# @return [TrueClass]
|
102
102
|
def logger
|
103
103
|
MonoLogger.new(log_file).tap do |log|
|
104
|
-
log.formatter = proc do |_,
|
105
|
-
formatted_message(message
|
104
|
+
log.formatter = proc do |_, _, _, message|
|
105
|
+
formatted_message(message)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
@@ -110,21 +110,16 @@ module Vedeu
|
|
110
110
|
private
|
111
111
|
|
112
112
|
# @param message [String]
|
113
|
-
# @param time [Time]
|
114
113
|
# @return [String]
|
115
|
-
def formatted_message(message
|
116
|
-
[timestamp
|
117
|
-
end
|
118
|
-
|
119
|
-
# @return [Boolean]
|
120
|
-
def enabled?
|
121
|
-
Vedeu::Configuration.debug?
|
114
|
+
def formatted_message(message)
|
115
|
+
[timestamp, message, "\n"].join
|
122
116
|
end
|
123
117
|
|
124
118
|
# @return [String]
|
125
119
|
def log_file
|
126
120
|
Vedeu::Configuration.log
|
127
121
|
end
|
122
|
+
alias_method :enabled?, :log_file
|
128
123
|
|
129
124
|
# @param type [Symbol] The type of log message.
|
130
125
|
# @param body [String] The log message itself.
|
@@ -161,17 +156,21 @@ module Vedeu
|
|
161
156
|
}
|
162
157
|
end
|
163
158
|
|
164
|
-
# Returns a formatted
|
165
|
-
# eg.
|
159
|
+
# Returns a formatted timestamp.
|
160
|
+
# eg. [137.7824]
|
166
161
|
#
|
167
|
-
# @param utc_time [String]
|
168
162
|
# @return [String]
|
169
|
-
def timestamp
|
170
|
-
|
171
|
-
|
172
|
-
@
|
163
|
+
def timestamp
|
164
|
+
@now = Time.now.to_f
|
165
|
+
@time = 0.0 unless @time
|
166
|
+
@last = @now unless @last
|
167
|
+
|
168
|
+
unless @last == @time
|
169
|
+
@time += (@now - @last).round(4)
|
170
|
+
@last = @now
|
171
|
+
end
|
173
172
|
|
174
|
-
"
|
173
|
+
"[#{'%7.4f' % @time.to_s}] ".rjust(7)
|
175
174
|
end
|
176
175
|
|
177
176
|
end # Log eigenclass
|
@@ -18,14 +18,10 @@ module Vedeu
|
|
18
18
|
fail InvalidSyntax, 'block not given' unless block_given?
|
19
19
|
|
20
20
|
if raw_mode?
|
21
|
-
|
22
|
-
|
23
|
-
console.raw { initialize_screen { yield } }
|
21
|
+
console.raw { initialize_screen(mode) { yield } }
|
24
22
|
|
25
23
|
else
|
26
|
-
|
27
|
-
|
28
|
-
console.cooked { initialize_screen { yield } }
|
24
|
+
console.cooked { initialize_screen(mode) { yield } }
|
29
25
|
|
30
26
|
end
|
31
27
|
ensure
|
@@ -53,8 +49,6 @@ module Vedeu
|
|
53
49
|
|
54
50
|
end
|
55
51
|
|
56
|
-
Vedeu.trigger(:tick, Time.now.to_f)
|
57
|
-
|
58
52
|
keys_or_cmd
|
59
53
|
end
|
60
54
|
alias_method :read, :input
|
@@ -90,8 +84,11 @@ module Vedeu
|
|
90
84
|
true
|
91
85
|
end
|
92
86
|
|
87
|
+
# @param mode [Symbol]
|
93
88
|
# @return [void]
|
94
|
-
def initialize_screen
|
89
|
+
def initialize_screen(mode)
|
90
|
+
Vedeu.log(type: :info, message: "Terminal entering '#{mode}' mode")
|
91
|
+
|
95
92
|
output(Esc.string('screen_init'))
|
96
93
|
|
97
94
|
yield if block_given?
|
@@ -136,8 +133,6 @@ module Vedeu
|
|
136
133
|
#
|
137
134
|
# @return [Symbol]
|
138
135
|
def cooked_mode!
|
139
|
-
Vedeu.log(type: :info, message: "Terminal switching to 'cooked' mode")
|
140
|
-
|
141
136
|
@mode = :cooked
|
142
137
|
end
|
143
138
|
|
@@ -153,8 +148,6 @@ module Vedeu
|
|
153
148
|
#
|
154
149
|
# @return [Symbol]
|
155
150
|
def raw_mode!
|
156
|
-
Vedeu.log(type: :info, message: "Terminal switching to 'raw' mode")
|
157
|
-
|
158
151
|
@mode = :raw
|
159
152
|
end
|
160
153
|
|
data/lib/vedeu/support/timer.rb
CHANGED
@@ -23,10 +23,10 @@ module Vedeu
|
|
23
23
|
|
24
24
|
# @param block [Proc]
|
25
25
|
# @return [void]
|
26
|
-
def measure
|
26
|
+
def measure
|
27
27
|
work = yield
|
28
28
|
|
29
|
-
elapsed = ((Time.now.to_f - started) * 1000).
|
29
|
+
elapsed = ((Time.now.to_f - started) * 1000).round(3)
|
30
30
|
|
31
31
|
Vedeu.log(type: :timer, message: "#{message} took #{elapsed}ms.")
|
32
32
|
|
data/lib/vedeu/version.rb
CHANGED
@@ -20,8 +20,6 @@ module Vedeu
|
|
20
20
|
it { Vedeu.events.registered?(:_refresh_group_).must_equal(true) }
|
21
21
|
it { Vedeu.events.registered?(:_resize_).must_equal(true) }
|
22
22
|
it { Vedeu.events.registered?(:_show_group_).must_equal(true) }
|
23
|
-
it { Vedeu.events.registered?(:tick).must_equal(true) }
|
24
|
-
it { Vedeu.events.registered?(:tock).must_equal(true) }
|
25
23
|
end
|
26
24
|
|
27
25
|
context 'the cursor specific events are defined' do
|
@@ -50,16 +50,6 @@ module Vedeu
|
|
50
50
|
|
51
51
|
it { subject.must_be_instance_of(Vedeu::Colour) }
|
52
52
|
|
53
|
-
context 'with an invalid attribute' do
|
54
|
-
let(:attributes) { { invalid: background, foreground: foreground } }
|
55
|
-
|
56
|
-
it 'sets only the valid attributes' do
|
57
|
-
subject.attributes.must_equal(
|
58
|
-
background: '', foreground: '#ff00ff'
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
53
|
context 'with an empty value' do
|
64
54
|
let(:attributes) { { background: background, foreground: '' } }
|
65
55
|
|