vedeu 0.6.40 → 0.6.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.yardopts +7 -0
- data/README.md +10 -0
- data/benchmarks/array_vs_range.rb +41 -0
- data/docs/api.md +7 -0
- data/docs/colours_styles.md +4 -0
- data/docs/debugging.md +19 -0
- data/docs/template.md +1 -0
- data/examples/284_slow_rendering.rb +105 -0
- data/lib/vedeu/borders/dsl.rb +2 -1
- data/lib/vedeu/borders/repository.rb +2 -1
- data/lib/vedeu/buffers/repository.rb +2 -1
- data/lib/vedeu/colours/backgrounds.rb +2 -1
- data/lib/vedeu/colours/foregrounds.rb +2 -1
- data/lib/vedeu/configuration/configuration.rb +3 -1
- data/lib/vedeu/cursors/cursor.rb +3 -1
- data/lib/vedeu/cursors/repository.rb +4 -2
- data/lib/vedeu/distributed/server.rb +5 -2
- data/lib/vedeu/dsl/view.rb +4 -1
- data/lib/vedeu/editor/document.rb +13 -12
- data/lib/vedeu/editor/repository.rb +2 -1
- data/lib/vedeu/events/aliases.rb +3 -1
- data/lib/vedeu/events/event.rb +6 -2
- data/lib/vedeu/events/repository.rb +2 -1
- data/lib/vedeu/events/trigger.rb +2 -1
- data/lib/vedeu/geometry/dsl.rb +2 -1
- data/lib/vedeu/geometry/repository.rb +2 -1
- data/lib/vedeu/groups/clear.rb +2 -1
- data/lib/vedeu/groups/dsl.rb +2 -1
- data/lib/vedeu/groups/group.rb +4 -1
- data/lib/vedeu/groups/repository.rb +2 -1
- data/lib/vedeu/input/dsl.rb +2 -1
- data/lib/vedeu/input/keymaps.rb +2 -1
- data/lib/vedeu/input/mapper.rb +2 -1
- data/lib/vedeu/interfaces/dsl.rb +2 -1
- data/lib/vedeu/interfaces/interface.rb +3 -1
- data/lib/vedeu/interfaces/repository.rb +2 -1
- data/lib/vedeu/logging/all.rb +1 -0
- data/lib/vedeu/logging/debug.rb +2 -1
- data/lib/vedeu/logging/ips.rb +57 -0
- data/lib/vedeu/logging/log.rb +4 -1
- data/lib/vedeu/logging/timer.rb +2 -1
- data/lib/vedeu/menus/menu.rb +2 -1
- data/lib/vedeu/menus/repository.rb +2 -1
- data/lib/vedeu/models/focus.rb +6 -2
- data/lib/vedeu/output/clear/interface.rb +46 -4
- data/lib/vedeu/output/compressor.rb +1 -1
- data/lib/vedeu/output/output.rb +36 -3
- data/lib/vedeu/output/renderers/all.rb +3 -1
- data/lib/vedeu/runtime/application.rb +2 -1
- data/lib/vedeu/runtime/flags.rb +3 -1
- data/lib/vedeu/runtime/main_loop.rb +2 -2
- data/lib/vedeu/runtime/router.rb +2 -1
- data/lib/vedeu/terminal/buffer.rb +27 -8
- data/lib/vedeu/terminal/terminal.rb +4 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/editor/document_test.rb +1 -0
- data/test/lib/vedeu/output/clear/interface_test.rb +1 -0
- data/test/lib/vedeu/output/output_test.rb +45 -1
- data/test/lib/vedeu/terminal/buffer_test.rb +11 -0
- data/test/lib/vedeu_test.rb +2 -0
- data/test/test_helper.rb +21 -0
- data/vedeu.gemspec +1 -0
- metadata +20 -2
data/lib/vedeu/events/aliases.rb
CHANGED
@@ -108,6 +108,8 @@ module Vedeu
|
|
108
108
|
# @see Vedeu::Events::Aliases#bind_alias
|
109
109
|
# @!method unbind_alias
|
110
110
|
# @see Vedeu::Events::Aliases#unbind_alias
|
111
|
-
def_delegators Vedeu::Events::Aliases,
|
111
|
+
def_delegators Vedeu::Events::Aliases,
|
112
|
+
:bind_alias,
|
113
|
+
:unbind_alias
|
112
114
|
|
113
115
|
end # Vedeu
|
data/lib/vedeu/events/event.rb
CHANGED
@@ -126,7 +126,8 @@ module Vedeu
|
|
126
126
|
|
127
127
|
extend Forwardable
|
128
128
|
|
129
|
-
def_delegators Vedeu::Events::Trigger,
|
129
|
+
def_delegators Vedeu::Events::Trigger,
|
130
|
+
:trigger
|
130
131
|
|
131
132
|
end # Eigenclass
|
132
133
|
|
@@ -305,6 +306,9 @@ module Vedeu
|
|
305
306
|
# @see Vedeu::Events::Event.bound?
|
306
307
|
# @!method unbind
|
307
308
|
# @see Vedeu::Events::Event.unbind
|
308
|
-
def_delegators Vedeu::Events::Event,
|
309
|
+
def_delegators Vedeu::Events::Event,
|
310
|
+
:bind,
|
311
|
+
:bound?,
|
312
|
+
:unbind
|
309
313
|
|
310
314
|
end # Vedeu
|
data/lib/vedeu/events/trigger.rb
CHANGED
data/lib/vedeu/geometry/dsl.rb
CHANGED
data/lib/vedeu/groups/clear.rb
CHANGED
data/lib/vedeu/groups/dsl.rb
CHANGED
data/lib/vedeu/groups/group.rb
CHANGED
@@ -177,7 +177,10 @@ module Vedeu
|
|
177
177
|
# @see Vedeu::Toggleable::ClassMethods#show
|
178
178
|
# @!method toggle_group
|
179
179
|
# @see Vedeu::Toggleable::ClassMethods#toggle
|
180
|
-
def_delegators Vedeu::Groups::Group,
|
180
|
+
def_delegators Vedeu::Groups::Group,
|
181
|
+
:hide_group,
|
182
|
+
:show_group,
|
183
|
+
:toggle_group
|
181
184
|
|
182
185
|
# :nocov:
|
183
186
|
|
data/lib/vedeu/input/dsl.rb
CHANGED
data/lib/vedeu/input/keymaps.rb
CHANGED
data/lib/vedeu/input/mapper.rb
CHANGED
data/lib/vedeu/interfaces/dsl.rb
CHANGED
@@ -137,7 +137,9 @@ module Vedeu
|
|
137
137
|
# @see Vedeu::Toggleable::ClassMethods#show
|
138
138
|
# @!method toggle_interface
|
139
139
|
# @see Vedeu::Toggleable::ClassMethods#toggle
|
140
|
-
def_delegators Vedeu::Interfaces::Interface,
|
140
|
+
def_delegators Vedeu::Interfaces::Interface,
|
141
|
+
:hide_interface,
|
142
|
+
:show_interface,
|
141
143
|
:toggle_interface
|
142
144
|
|
143
145
|
# :nocov:
|
data/lib/vedeu/logging/all.rb
CHANGED
data/lib/vedeu/logging/debug.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'benchmark/ips'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Logging
|
6
|
+
|
7
|
+
module Debug
|
8
|
+
|
9
|
+
class IPS
|
10
|
+
|
11
|
+
attr_accessor :samples
|
12
|
+
attr_accessor :benchmark
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@old_stdout = $stdout
|
16
|
+
$stdout = StringIO.new
|
17
|
+
@samples = {}
|
18
|
+
@benchmark = Benchmark::IPS::Job.new
|
19
|
+
@count = 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_item(label = '', &blk)
|
23
|
+
samples[label] = blk
|
24
|
+
@count += 1
|
25
|
+
|
26
|
+
benchmark.item(label, &blk)
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute!
|
30
|
+
benchmark.compare!
|
31
|
+
benchmark.run_warmup
|
32
|
+
benchmark.run
|
33
|
+
|
34
|
+
$stdout.sync = true
|
35
|
+
benchmark.run_comparison
|
36
|
+
benchmark.full_report
|
37
|
+
|
38
|
+
Vedeu.log(type: :debug, message: "IPS:\n#{$stdout.string}")
|
39
|
+
$stdout = @old_stdout
|
40
|
+
|
41
|
+
Vedeu.log(type: :debug, message: "Running: #{key}")
|
42
|
+
samples[key].call
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def key
|
48
|
+
@key ||= samples.keys.sample
|
49
|
+
end
|
50
|
+
|
51
|
+
end # IPS
|
52
|
+
|
53
|
+
end # Debug
|
54
|
+
|
55
|
+
end # Logging
|
56
|
+
|
57
|
+
end # Vedeu
|
data/lib/vedeu/logging/log.rb
CHANGED
@@ -191,7 +191,10 @@ module Vedeu
|
|
191
191
|
# @see Vedeu::Logging::Log.log_stdout
|
192
192
|
# @!method log_stderr
|
193
193
|
# @see Vedeu::Logging::Log.log_stderr
|
194
|
-
def_delegators Vedeu::Logging::Log,
|
194
|
+
def_delegators Vedeu::Logging::Log,
|
195
|
+
:log,
|
196
|
+
:log_stdout,
|
197
|
+
:log_stderr
|
195
198
|
|
196
199
|
# :nocov:
|
197
200
|
|
data/lib/vedeu/logging/timer.rb
CHANGED
data/lib/vedeu/menus/menu.rb
CHANGED
data/lib/vedeu/models/focus.rb
CHANGED
@@ -262,8 +262,12 @@ module Vedeu
|
|
262
262
|
# @see Vedeu::Models::Focus#focus_next
|
263
263
|
# @!method focus_previous
|
264
264
|
# @see Vedeu::Models::Focus#focus_previous
|
265
|
-
def_delegators Vedeu::Models::Focus,
|
266
|
-
:
|
265
|
+
def_delegators Vedeu::Models::Focus,
|
266
|
+
:focus,
|
267
|
+
:focus_by_name,
|
268
|
+
:focussed?,
|
269
|
+
:focus_next,
|
270
|
+
:focus_previous
|
267
271
|
|
268
272
|
# :nocov:
|
269
273
|
|
@@ -37,7 +37,7 @@ module Vedeu
|
|
37
37
|
def clear_content_by_name(name = Vedeu.focus)
|
38
38
|
name || Vedeu.focus
|
39
39
|
|
40
|
-
new(name, content_only: true).render
|
40
|
+
new(name, content_only: true, direct: true).render
|
41
41
|
end
|
42
42
|
|
43
43
|
end # Eigenclass
|
@@ -49,6 +49,11 @@ module Vedeu
|
|
49
49
|
# @param options [Hash]
|
50
50
|
# @option options content_only [Boolean] Only clear the content
|
51
51
|
# not the border as well. Defaults to false.
|
52
|
+
# @option options direct [Boolean] Write the content directly
|
53
|
+
# to the terminal using a faster mechanism. The virtual buffer
|
54
|
+
# will still be updated. This improves the refresh time for
|
55
|
+
# Vedeu as we will not be building a grid of
|
56
|
+
# {Vedeu::Views::Char} objects.
|
52
57
|
# @return [Vedeu::Clear::Interface]
|
53
58
|
def initialize(name, options = {})
|
54
59
|
@name = present?(name) ? name : Vedeu.focus
|
@@ -57,7 +62,15 @@ module Vedeu
|
|
57
62
|
|
58
63
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
59
64
|
def render
|
60
|
-
|
65
|
+
if direct?
|
66
|
+
Vedeu.direct_write(optimised_output)
|
67
|
+
|
68
|
+
Vedeu::Terminal::Buffer.update(output)
|
69
|
+
|
70
|
+
else
|
71
|
+
Vedeu.render_output(output)
|
72
|
+
|
73
|
+
end
|
61
74
|
end
|
62
75
|
|
63
76
|
protected
|
@@ -87,9 +100,15 @@ module Vedeu
|
|
87
100
|
def defaults
|
88
101
|
{
|
89
102
|
content_only: false,
|
103
|
+
direct: false,
|
90
104
|
}
|
91
105
|
end
|
92
106
|
|
107
|
+
# @return [Boolean]
|
108
|
+
def direct?
|
109
|
+
options[:direct]
|
110
|
+
end
|
111
|
+
|
93
112
|
# @see Vedeu::Geometry::Repository#by_name
|
94
113
|
def geometry
|
95
114
|
@geometry ||= Vedeu.geometries.by_name(name)
|
@@ -112,6 +131,27 @@ module Vedeu
|
|
112
131
|
defaults.merge!(@options)
|
113
132
|
end
|
114
133
|
|
134
|
+
# @return [String]
|
135
|
+
def optimised_output
|
136
|
+
Vedeu.timer("Optimised clearing #{clearing}: '#{name}'".freeze) do
|
137
|
+
output = ''
|
138
|
+
|
139
|
+
@y = y
|
140
|
+
@x = x
|
141
|
+
@colour = colour.to_s
|
142
|
+
@chars = (' ' * width).freeze
|
143
|
+
|
144
|
+
height.times do |iy|
|
145
|
+
output << Vedeu::Geometry::Position.new(@y + iy, @x).to_s
|
146
|
+
output << @colour
|
147
|
+
output << @chars
|
148
|
+
end
|
149
|
+
|
150
|
+
output << Vedeu::Geometry::Position.new(@y, @x).to_s
|
151
|
+
output
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
115
155
|
# For each visible line of the interface, set the foreground and
|
116
156
|
# background colours to those specified when the interface was
|
117
157
|
# defined, then starting write space characters over the area
|
@@ -170,11 +210,13 @@ module Vedeu
|
|
170
210
|
|
171
211
|
# @!method clear_by_name
|
172
212
|
# @see Vedeu::Clear::Interface.render
|
173
|
-
def_delegators Vedeu::Clear::Interface,
|
213
|
+
def_delegators Vedeu::Clear::Interface,
|
214
|
+
:clear_by_name
|
174
215
|
|
175
216
|
# @!method clear_content_by_name
|
176
217
|
# @see Vedeu::Clear::Interface.clear_content_by_name
|
177
|
-
def_delegators Vedeu::Clear::Interface,
|
218
|
+
def_delegators Vedeu::Clear::Interface,
|
219
|
+
:clear_content_by_name
|
178
220
|
|
179
221
|
# :nocov:
|
180
222
|
|
data/lib/vedeu/output/output.rb
CHANGED
@@ -9,10 +9,29 @@ module Vedeu
|
|
9
9
|
#
|
10
10
|
class Output
|
11
11
|
|
12
|
+
# @param output [Array<Array<Vedeu::Views::Char>>|
|
13
|
+
# NilClass|Vedeu::Models::Escape]
|
14
|
+
# @return [Array]
|
15
|
+
def self.buffer_write(output)
|
16
|
+
return nil if output.nil?
|
17
|
+
|
18
|
+
new(output).buffer_write
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param output [Array<Array<Vedeu::Views::Char>>|
|
22
|
+
# NilClass|Vedeu::Models::Escape]
|
23
|
+
# @return [Array<String>]
|
24
|
+
def self.direct_write(output)
|
25
|
+
return nil if output.nil?
|
26
|
+
|
27
|
+
new(output).direct_write
|
28
|
+
end
|
29
|
+
|
12
30
|
# Writes output to the defined renderers.
|
13
31
|
#
|
32
|
+
# @param output [Array<Array<Vedeu::Views::Char>>|
|
33
|
+
# NilClass|Vedeu::Models::Escape]
|
14
34
|
# @return [Array|NilClass|String]
|
15
|
-
# @see #initialize
|
16
35
|
def self.render_output(output)
|
17
36
|
return nil if output.nil?
|
18
37
|
|
@@ -21,12 +40,23 @@ module Vedeu
|
|
21
40
|
|
22
41
|
# Return a new instance of Vedeu::Output::Output.
|
23
42
|
#
|
24
|
-
# @param output [Array<Array<Vedeu::Views::Char
|
43
|
+
# @param output [Array<Array<Vedeu::Views::Char>>|
|
44
|
+
# NilClass|Vedeu::Models::Escape]
|
25
45
|
# @return [Vedeu::Output::Output]
|
26
46
|
def initialize(output)
|
27
47
|
@output = output
|
28
48
|
end
|
29
49
|
|
50
|
+
# @return [Array]
|
51
|
+
def buffer_write
|
52
|
+
buffer_write!
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Array<String>]
|
56
|
+
def direct_write
|
57
|
+
direct_write!
|
58
|
+
end
|
59
|
+
|
30
60
|
# Send the view to the renderers. If the output is a
|
31
61
|
# {Vedeu::Models::Escape} object (typical when showing or
|
32
62
|
# hiding the cursor) then we bypass the
|
@@ -80,6 +110,9 @@ module Vedeu
|
|
80
110
|
#
|
81
111
|
# @!method render_output
|
82
112
|
# @return [Array|NilClass]
|
83
|
-
def_delegators Vedeu::Output::Output,
|
113
|
+
def_delegators Vedeu::Output::Output,
|
114
|
+
:render_output,
|
115
|
+
:buffer_write,
|
116
|
+
:direct_write
|
84
117
|
|
85
118
|
end # Vedeu
|