vedeu 0.6.21 → 0.6.22
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/.rubocop.yml +1 -0
- data/bin/vedeu_drb_server +1 -0
- data/docs/configuration.md +3 -0
- data/docs/events/refresh.md +5 -0
- data/docs/events/visibility.md +6 -0
- data/examples/hello_worlds.rb +79 -0
- data/lib/vedeu/all.rb +2 -2
- data/lib/vedeu/bindings/refresh.rb +8 -0
- data/lib/vedeu/bindings/visibility.rb +8 -0
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/render.rb +13 -10
- data/lib/vedeu/buffers/buffer.rb +5 -49
- data/lib/vedeu/buffers/refresh.rb +33 -15
- data/lib/vedeu/configuration/api.rb +32 -3
- data/lib/vedeu/configuration/configuration.rb +16 -2
- data/lib/vedeu/cursors/refresh.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -0
- data/lib/vedeu/editor/document.rb +1 -3
- data/lib/vedeu/logging/debug.rb +11 -8
- data/lib/vedeu/logging/timer.rb +18 -4
- data/lib/vedeu/models/interface.rb +18 -6
- data/lib/vedeu/models/views/view.rb +2 -9
- data/lib/vedeu/output/clear/interface.rb +93 -9
- data/lib/vedeu/output/direct.rb +0 -2
- data/lib/vedeu/output/viewport.rb +18 -16
- data/lib/vedeu/runtime/launcher.rb +25 -26
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/bindings/refresh_test.rb +1 -0
- data/test/lib/vedeu/bindings/visibility_test.rb +1 -0
- data/test/lib/vedeu/borders/border_test.rb +2 -2
- data/test/lib/vedeu/borders/render_test.rb +12 -69
- data/test/lib/vedeu/buffers/buffer_test.rb +0 -31
- data/test/lib/vedeu/buffers/refresh_test.rb +2 -10
- data/test/lib/vedeu/cursors/refresh_test.rb +2 -2
- data/test/lib/vedeu/editor/document_test.rb +3 -3
- data/test/lib/vedeu/logging/debug_test.rb +3 -3
- data/test/lib/vedeu/logging/timer_test.rb +24 -6
- data/test/lib/vedeu/models/interface_test.rb +4 -8
- data/test/lib/vedeu/models/views/view_test.rb +12 -22
- data/test/lib/vedeu/output/clear/interface_test.rb +7 -1
- data/test/lib/vedeu/output/viewport_test.rb +11 -190
- data/test/lib/vedeu/runtime/launcher_test.rb +2 -1
- data/test/lib/vedeu_test.rb +18 -19
- data/test/support/examples/borders_app.rb +4 -3
- data/test/support/examples/drb_app.rb +4 -3
- data/test/support/examples/editor_app.rb +3 -7
- data/test/support/examples/focus_app.rb +4 -4
- data/test/support/examples/hello_world.rb +5 -2
- data/test/support/examples/material_colours_app.rb +3 -42
- data/test/test_helper.rb +1 -0
- metadata +2 -1
@@ -89,8 +89,8 @@ module Vedeu
|
|
89
89
|
end
|
90
90
|
|
91
91
|
# Returns whether debugging is enabled or disabled. Default is
|
92
|
-
# false; meaning
|
93
|
-
#
|
92
|
+
# false; meaning only the top line of a backtrace from an
|
93
|
+
# exception is shown to the user of the client application.
|
94
94
|
#
|
95
95
|
# @return [Boolean]
|
96
96
|
def debug?
|
@@ -183,6 +183,15 @@ module Vedeu
|
|
183
183
|
end
|
184
184
|
alias_method :once, :once?
|
185
185
|
|
186
|
+
# Returns a boolean indicating whether profiling has been
|
187
|
+
# enabled.
|
188
|
+
#
|
189
|
+
# @return [Boolean]
|
190
|
+
def profile?
|
191
|
+
instance.options[:profile]
|
192
|
+
end
|
193
|
+
alias_method :profile, :profile?
|
194
|
+
|
186
195
|
# Returns the renderers which should receive output.
|
187
196
|
#
|
188
197
|
# @return [Array<Class>]
|
@@ -304,6 +313,7 @@ module Vedeu
|
|
304
313
|
log: nil,
|
305
314
|
log_only: [],
|
306
315
|
once: false,
|
316
|
+
profile: false,
|
307
317
|
renderers: [Vedeu::Renderers::Terminal.new],
|
308
318
|
root: nil,
|
309
319
|
stdin: nil,
|
@@ -335,6 +345,10 @@ module Vedeu
|
|
335
345
|
|
336
346
|
end # Configuration
|
337
347
|
|
348
|
+
require 'vedeu/output/renderers/all'
|
349
|
+
|
350
|
+
Vedeu::Configuration.configure({})
|
351
|
+
|
338
352
|
# @!method configure
|
339
353
|
# @see Vedeu::Configuration.configure
|
340
354
|
# @!method configuration
|
@@ -58,7 +58,7 @@ module Vedeu
|
|
58
58
|
#
|
59
59
|
# @return [void]
|
60
60
|
def clear
|
61
|
-
Vedeu.trigger(:
|
61
|
+
Vedeu.trigger(:_clear_view_content_, name)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Deletes the character from the line where the cursor is
|
@@ -249,8 +249,6 @@ module Vedeu
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
-
out << border.render
|
253
|
-
|
254
252
|
cursor.store
|
255
253
|
|
256
254
|
out.flatten
|
data/lib/vedeu/logging/debug.rb
CHANGED
@@ -10,16 +10,19 @@ module Vedeu
|
|
10
10
|
extend self
|
11
11
|
|
12
12
|
# :nocov:
|
13
|
-
# Helps to
|
13
|
+
# Helps to profile a running application by providing a stack
|
14
14
|
# trace of its execution upon exiting.
|
15
15
|
#
|
16
16
|
# @example
|
17
|
-
# Vedeu.
|
17
|
+
# Vedeu.profile('some_file.html') do
|
18
|
+
# # ... code to profile ...
|
19
|
+
# end
|
18
20
|
#
|
19
|
-
# @param filename [String]
|
21
|
+
# @param filename [String] Optional, and defaults to being
|
22
|
+
# written to the /tmp directory.
|
20
23
|
# @return [void]
|
21
|
-
# @yieldreturn [void] The section of the application to
|
22
|
-
def self.
|
24
|
+
# @yieldreturn [void] The section of the application to profile.
|
25
|
+
def self.profile(filename = 'profile.html')
|
23
26
|
return nil unless block_given?
|
24
27
|
|
25
28
|
require 'ruby-prof'
|
@@ -88,10 +91,10 @@ module Vedeu
|
|
88
91
|
# ruby-prof.
|
89
92
|
#
|
90
93
|
# @example
|
91
|
-
# Vedeu.
|
94
|
+
# Vedeu.profile
|
92
95
|
#
|
93
|
-
# @!method
|
96
|
+
# @!method profile
|
94
97
|
# @return [Vedeu::Logging::Debug]
|
95
|
-
def_delegators Vedeu::Logging::Debug, :
|
98
|
+
def_delegators Vedeu::Logging::Debug, :profile
|
96
99
|
|
97
100
|
end # Vedeu
|
data/lib/vedeu/logging/timer.rb
CHANGED
@@ -3,18 +3,23 @@ module Vedeu
|
|
3
3
|
module Logging
|
4
4
|
|
5
5
|
# Measure the duration. Used for debugging.
|
6
|
+
# The configuration option 'debug' must be set to true to enable
|
7
|
+
# this functionality.
|
6
8
|
#
|
7
9
|
class Timer
|
8
10
|
|
9
11
|
class << self
|
10
12
|
|
11
13
|
# Measure the execution time of the code in the given block.
|
14
|
+
# The message provided will have ' took <time>ms.' appended.
|
12
15
|
#
|
13
16
|
# @example
|
14
|
-
# Vedeu.timer '
|
17
|
+
# Vedeu.timer 'Really complex code' do
|
15
18
|
# # ... code to be measured
|
16
19
|
# end
|
17
20
|
#
|
21
|
+
# # => 'Really complex code took 0.234ms.'
|
22
|
+
#
|
18
23
|
# @param message [String]
|
19
24
|
# @param block [Proc]
|
20
25
|
# @return [void] The return value of the executed block.
|
@@ -36,13 +41,22 @@ module Vedeu
|
|
36
41
|
# Write an entry to the log file stating how long a section of
|
37
42
|
# code took in milliseconds. Useful for debugging performance.
|
38
43
|
#
|
44
|
+
# @raise [Vedeu::Error::RequiresBlock]
|
39
45
|
# @return [void] The return value of the executed block.
|
40
46
|
def measure
|
41
|
-
|
47
|
+
fail Vedeu::Error::RequiresBlock unless block_given?
|
48
|
+
|
49
|
+
if Vedeu::Configuration.debug?
|
50
|
+
work = yield
|
51
|
+
|
52
|
+
Vedeu.log(type: :timer, message: "#{message} took #{elapsed}ms.")
|
42
53
|
|
43
|
-
|
54
|
+
work
|
44
55
|
|
45
|
-
|
56
|
+
else
|
57
|
+
yield
|
58
|
+
|
59
|
+
end
|
46
60
|
end
|
47
61
|
|
48
62
|
protected
|
@@ -61,30 +61,42 @@ module Vedeu
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
# Hide
|
65
|
-
#
|
64
|
+
# Hide the named interface.
|
65
|
+
#
|
66
|
+
# Will hide the named interface. If the interface is currently
|
67
|
+
# visible, it will be cleared- rendered blank. To show the
|
68
|
+
# interface, the ':_show_interface_' event should be triggered.
|
69
|
+
# Triggering the ':_hide_group_' event to which this named
|
70
|
+
# interface belongs will also hide the interface.
|
66
71
|
#
|
67
72
|
# @example
|
73
|
+
# Vedeu.trigger(:_hide_interface_, name)
|
68
74
|
# Vedeu.hide_interface(name)
|
69
75
|
#
|
70
76
|
# @return [void]
|
71
77
|
def hide
|
72
78
|
super
|
73
79
|
|
74
|
-
Vedeu.
|
80
|
+
Vedeu.trigger(:_clear_view_, name)
|
75
81
|
end
|
76
82
|
|
77
|
-
# Show the named interface
|
78
|
-
#
|
83
|
+
# Show the named interface.
|
84
|
+
#
|
85
|
+
# Will hide the named interface. If the interface is currently
|
86
|
+
# visible, it will be cleared- rendered blank. To show the
|
87
|
+
# interface, the ':_show_interface_' event should be triggered.
|
88
|
+
# Triggering the ':_hide_group_' event to which this named
|
89
|
+
# interface belongs will also hide the interface.
|
79
90
|
#
|
80
91
|
# @example
|
92
|
+
# Vedeu.trigger(:_show_interface_, name)
|
81
93
|
# Vedeu.show_interface(name)
|
82
94
|
#
|
83
95
|
# @return [void]
|
84
96
|
def show
|
85
97
|
super
|
86
98
|
|
87
|
-
Vedeu.
|
99
|
+
Vedeu.trigger(:_refresh_view_, name)
|
88
100
|
end
|
89
101
|
|
90
102
|
private
|
@@ -78,16 +78,9 @@ module Vedeu
|
|
78
78
|
|
79
79
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
80
80
|
def render
|
81
|
-
|
81
|
+
Vedeu.trigger(:_clear_view_content_, name)
|
82
82
|
|
83
|
-
Vedeu.
|
84
|
-
|
85
|
-
output = [
|
86
|
-
Vedeu::Output::Viewport.render(self),
|
87
|
-
Vedeu.borders.by_name(name).render,
|
88
|
-
]
|
89
|
-
|
90
|
-
output
|
83
|
+
Vedeu::Output::Viewport.render(self)
|
91
84
|
end
|
92
85
|
|
93
86
|
# Store the view and immediately refresh it; causing to be
|
@@ -11,6 +11,7 @@ module Vedeu
|
|
11
11
|
# Clear the interface with the given name.
|
12
12
|
#
|
13
13
|
# @example
|
14
|
+
# Vedeu.trigger(:_clear_view_, name)
|
14
15
|
# Vedeu.clear_by_name(name)
|
15
16
|
#
|
16
17
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
@@ -21,14 +22,31 @@ module Vedeu
|
|
21
22
|
alias_method :clear_by_name, :render
|
22
23
|
alias_method :by_name, :render
|
23
24
|
|
25
|
+
# Clear the content of the interface with the given name.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# Vedeu.trigger(:_clear_view_content_, name)
|
29
|
+
# Vedeu.clear_content_by_name(name)
|
30
|
+
#
|
31
|
+
# @return [Array<Array<Vedeu::Views::Char>>]
|
32
|
+
# @see #initialize
|
33
|
+
def clear_content_by_name(name)
|
34
|
+
new(name, content_only: true).render
|
35
|
+
end
|
36
|
+
|
24
37
|
end # Eigenclass
|
25
38
|
|
26
39
|
# Return a new instance of Vedeu::Clear::Interface.
|
27
40
|
#
|
28
|
-
# @param name [String|Symbol] The name of the interface to
|
41
|
+
# @param name [String|Symbol] The name of the interface to
|
42
|
+
# clear.
|
43
|
+
# @param options [Hash]
|
44
|
+
# @option options content_only [Boolean] Only clear the content
|
45
|
+
# not the border as well. Defaults to false.
|
29
46
|
# @return [Vedeu::Clear::Interface]
|
30
|
-
def initialize(name)
|
31
|
-
@name
|
47
|
+
def initialize(name, options = {})
|
48
|
+
@name = name
|
49
|
+
@options = options
|
32
50
|
end
|
33
51
|
|
34
52
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
@@ -44,16 +62,50 @@ module Vedeu
|
|
44
62
|
|
45
63
|
private
|
46
64
|
|
65
|
+
# @see Vedeu::Borders::Repository#by_name
|
66
|
+
def border
|
67
|
+
@border ||= Vedeu.borders.by_name(name)
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [Vedeu::Colours::Colour]
|
71
|
+
def colour
|
72
|
+
interface.colour
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [Boolean]
|
76
|
+
def content_only?
|
77
|
+
options[:content_only]
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Hash<Symbol => Boolean>]
|
81
|
+
def defaults
|
82
|
+
{
|
83
|
+
content_only: false,
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
47
87
|
# @see Vedeu::Geometry::Repository#by_name
|
48
88
|
def geometry
|
49
89
|
@geometry ||= Vedeu.geometries.by_name(name)
|
50
90
|
end
|
51
91
|
|
92
|
+
# @return [Fixnum]
|
93
|
+
def height
|
94
|
+
return border.height if content_only?
|
95
|
+
|
96
|
+
geometry.height
|
97
|
+
end
|
98
|
+
|
52
99
|
# @see Vedeu::Models::Interfaces#by_name
|
53
100
|
def interface
|
54
101
|
@interface ||= Vedeu.interfaces.by_name(name)
|
55
102
|
end
|
56
103
|
|
104
|
+
# @return [Hash<Symbol => Boolean>]
|
105
|
+
def options
|
106
|
+
defaults.merge!(@options)
|
107
|
+
end
|
108
|
+
|
57
109
|
# For each visible line of the interface, set the foreground and
|
58
110
|
# background colours to those specified when the interface was
|
59
111
|
# defined, then starting write space characters over the area
|
@@ -61,12 +113,12 @@ module Vedeu
|
|
61
113
|
#
|
62
114
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
63
115
|
def output
|
64
|
-
Vedeu.timer("Clearing: '#{name}'") do
|
65
|
-
@y =
|
66
|
-
@x =
|
67
|
-
@width =
|
68
|
-
@height =
|
69
|
-
@colour =
|
116
|
+
Vedeu.timer("Clearing #{clearing}: '#{name}'") do
|
117
|
+
@y = y
|
118
|
+
@x = x
|
119
|
+
@width = width
|
120
|
+
@height = height
|
121
|
+
@colour = colour
|
70
122
|
|
71
123
|
@clear ||= Array.new(@height) do |iy|
|
72
124
|
Array.new(@width) do |ix|
|
@@ -78,6 +130,34 @@ module Vedeu
|
|
78
130
|
end
|
79
131
|
end
|
80
132
|
|
133
|
+
# @return [String]
|
134
|
+
def clearing
|
135
|
+
return '(content only)' if content_only?
|
136
|
+
|
137
|
+
'(all)'
|
138
|
+
end
|
139
|
+
|
140
|
+
# @return [Fixnum]
|
141
|
+
def width
|
142
|
+
return border.width if content_only?
|
143
|
+
|
144
|
+
geometry.width
|
145
|
+
end
|
146
|
+
|
147
|
+
# @return [Fixnum]
|
148
|
+
def y
|
149
|
+
return border.by if content_only?
|
150
|
+
|
151
|
+
geometry.y
|
152
|
+
end
|
153
|
+
|
154
|
+
# @return [Fixnum]
|
155
|
+
def x
|
156
|
+
return border.bx if content_only?
|
157
|
+
|
158
|
+
geometry.x
|
159
|
+
end
|
160
|
+
|
81
161
|
end # Interface
|
82
162
|
|
83
163
|
end # Clear
|
@@ -86,4 +166,8 @@ module Vedeu
|
|
86
166
|
# @see Vedeu::Clear::Interface.render
|
87
167
|
def_delegators Vedeu::Clear::Interface, :clear_by_name
|
88
168
|
|
169
|
+
# @!method clear_content_by_name
|
170
|
+
# @see Vedeu::Clear::Interface.clear_content_by_name
|
171
|
+
def_delegators Vedeu::Clear::Interface, :clear_content_by_name
|
172
|
+
|
89
173
|
end # Vedeu
|
data/lib/vedeu/output/direct.rb
CHANGED
@@ -42,29 +42,16 @@ module Vedeu
|
|
42
42
|
|
43
43
|
# Returns the content for the view.
|
44
44
|
#
|
45
|
-
# @return [Array<Array<String
|
45
|
+
# @return [Array<Array<String>>|NilClass]
|
46
46
|
def render
|
47
|
-
|
48
|
-
|
49
|
-
Vedeu.timer("Rendering: '#{name}'") do
|
50
|
-
out = []
|
51
|
-
|
52
|
-
show.each_with_index do |line, iy|
|
53
|
-
line.each_with_index do |column, ix|
|
54
|
-
column.position = [by + iy, bx + ix]
|
55
|
-
out << column
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
out
|
60
|
-
end
|
47
|
+
Vedeu::Output::Output.render(output) if visible?
|
61
48
|
end
|
62
49
|
|
63
50
|
# Returns a string representation of the viewport.
|
64
51
|
#
|
65
52
|
# @return [String]
|
66
53
|
def to_s
|
67
|
-
render.map(&:to_s).join("\n")
|
54
|
+
Array(render).map(&:to_s).join("\n")
|
68
55
|
end
|
69
56
|
alias_method :to_str, :to_s
|
70
57
|
|
@@ -76,6 +63,21 @@ module Vedeu
|
|
76
63
|
|
77
64
|
private
|
78
65
|
|
66
|
+
def output
|
67
|
+
Vedeu.timer("Rendering: '#{name}'") do
|
68
|
+
out = []
|
69
|
+
|
70
|
+
show.each_with_index do |line, iy|
|
71
|
+
line.each_with_index do |column, ix|
|
72
|
+
column.position = [by + iy, bx + ix]
|
73
|
+
out << column
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
out
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
79
81
|
# Returns the visible content for the view.
|
80
82
|
#
|
81
83
|
# @note If there are no lines of content, we return an empty
|