vedeu 0.6.21 → 0.6.22
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/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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 962d118b37be3f266143bd483c590ea61fcb045b
|
4
|
+
data.tar.gz: a10a95a4e722f747a4faa9b07653d1a74ba98ccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 658eae376a443bde02be432fd0c91c46f972c59da102ea7f198198831b0dc2371776566cb74545829ba4b2a7c3a3f0e8196993be1faadaa3ec195f87db24cbf8
|
7
|
+
data.tar.gz: 3950ca1569a8e8ebf80fe8b14692fcf0796fa61d5eb9d9267ed7606a654ecde8519ac79c4f6d591166f988aad10e8fbee74bbb22ee29c2a3eff23353e28cd2db
|
data/.rubocop.yml
CHANGED
data/bin/vedeu_drb_server
CHANGED
data/docs/configuration.md
CHANGED
data/docs/events/refresh.md
CHANGED
@@ -29,3 +29,8 @@ Will cause all interfaces in the named group to refresh.
|
|
29
29
|
Will cause the named view to refresh.
|
30
30
|
|
31
31
|
Vedeu.trigger(:_refresh_view_, name)
|
32
|
+
|
33
|
+
### :_refresh_view_content_
|
34
|
+
Will cause only the content of the named view to refresh.
|
35
|
+
|
36
|
+
Vedeu.trigger(:_refresh_view_content_, name)
|
data/docs/events/visibility.md
CHANGED
@@ -23,6 +23,12 @@ Clears the named view/interface area.
|
|
23
23
|
Vedeu.trigger(:_clear_view_, name)
|
24
24
|
Vedeu.clear_by_name(name)
|
25
25
|
|
26
|
+
### :_clear_view_content_
|
27
|
+
Clears only the content of the named view/interface area.
|
28
|
+
|
29
|
+
Vedeu.trigger(:_clear_view_content_, name)
|
30
|
+
Vedeu.clear_content_by_name(name)
|
31
|
+
|
26
32
|
### :_hide_cursor_
|
27
33
|
Hide the cursor of the named interface or when a name is not given,
|
28
34
|
the interface currently in focus.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'vedeu'
|
5
|
+
|
6
|
+
# An example application to demonstrate 'Hello World' and a minimum of
|
7
|
+
# interactivity. It uses the DSL-style of vedeu (not the full-flegded
|
8
|
+
# MVC-approach).
|
9
|
+
#
|
10
|
+
# If you have cloned this repository from GitHub, you can run this example:
|
11
|
+
#
|
12
|
+
# bundle exec ./examples/hello_worlds.rb
|
13
|
+
#
|
14
|
+
class HelloWorldsApp
|
15
|
+
|
16
|
+
Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
|
17
|
+
|
18
|
+
Vedeu.configure do
|
19
|
+
# Empty configure block is needed.
|
20
|
+
end
|
21
|
+
|
22
|
+
Vedeu.interface :hello do
|
23
|
+
# Define all of the interface in one place.
|
24
|
+
background '#000000'
|
25
|
+
foreground '#00ff00'
|
26
|
+
geometry do
|
27
|
+
centred!
|
28
|
+
height 5
|
29
|
+
width 24
|
30
|
+
end
|
31
|
+
# (You usually specify the views outside the interface block).
|
32
|
+
Vedeu.views do
|
33
|
+
view :hello do
|
34
|
+
lines do
|
35
|
+
line { centre 'Hello Worlds!', width: 24 }
|
36
|
+
line
|
37
|
+
line { centre "Press 'q' to exit,", width: 24 }
|
38
|
+
line { centre " 'w' to switch worlds.", width: 24 }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
keymap do
|
43
|
+
key('q') { Vedeu.exit }
|
44
|
+
key('w') { HelloWorldsApp.render_world }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.start(argv = ARGV)
|
49
|
+
Vedeu::Launcher.execute!(argv)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def self.render_world
|
55
|
+
# Immediately render this to screen.
|
56
|
+
Vedeu.render do
|
57
|
+
view :hello do
|
58
|
+
geometry do
|
59
|
+
centred!
|
60
|
+
height 5 + 2
|
61
|
+
width 24 + 2
|
62
|
+
end
|
63
|
+
border do
|
64
|
+
colour foreground: ["#00ff00", "#000033", "#cddc39", "#03a9f4"].sample
|
65
|
+
title ["atlantis", "oceania", "utopia", "midgard", "middle-earth"].sample
|
66
|
+
end
|
67
|
+
lines do
|
68
|
+
line { centre 'Hello Worlds!', width: 24 }
|
69
|
+
line
|
70
|
+
line { centre "Press 'q' to exit,", width: 24 }
|
71
|
+
line { centre " 'w' to switch worlds.", width: 24 }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end # HelloWorldsApp
|
78
|
+
|
79
|
+
HelloWorldsApp.start(ARGV)
|
data/lib/vedeu/all.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'vedeu/logging/all'
|
2
1
|
require 'vedeu/version'
|
2
|
+
|
3
|
+
require 'vedeu/logging/all'
|
3
4
|
require 'vedeu/options'
|
4
5
|
|
5
6
|
require 'vedeu/error'
|
6
7
|
require 'vedeu/common'
|
7
|
-
require 'vedeu/logging/all'
|
8
8
|
require 'vedeu/runtime/all'
|
9
9
|
|
10
10
|
require 'vedeu/configuration/api'
|
@@ -17,6 +17,7 @@ module Vedeu
|
|
17
17
|
refresh_cursor!
|
18
18
|
refresh_group!
|
19
19
|
refresh_view!
|
20
|
+
refresh_view_content!
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -49,6 +50,13 @@ module Vedeu
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
53
|
+
# See {file:docs/events/refresh.md#\_refresh_view_content_}
|
54
|
+
def refresh_view_content!
|
55
|
+
Vedeu.bind(:_refresh_view_content_) do |name|
|
56
|
+
Vedeu::Buffers::Refresh.refresh_content_by_name(name)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
52
60
|
# :nocov:
|
53
61
|
|
54
62
|
end # Refresh
|
@@ -17,6 +17,7 @@ module Vedeu
|
|
17
17
|
clear!
|
18
18
|
clear_group!
|
19
19
|
clear_view!
|
20
|
+
clear_view_content!
|
20
21
|
hide_cursor!
|
21
22
|
hide_group!
|
22
23
|
hide_interface!
|
@@ -54,6 +55,13 @@ module Vedeu
|
|
54
55
|
Vedeu.bind(:_clear_view_) { |name| Vedeu.clear_by_name(name) }
|
55
56
|
end
|
56
57
|
|
58
|
+
# See {file:docs/events/visibility.md#\_clear_view_content_}
|
59
|
+
def clear_view_content!
|
60
|
+
Vedeu.bind(:_clear_view_content_) do |name|
|
61
|
+
Vedeu.clear_content_by_name(name)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
57
65
|
# See {file:docs/events/visibility.md#\_hide_cursor_}
|
58
66
|
def hide_cursor!
|
59
67
|
Vedeu.bind(:_hide_cursor_) { |name| Vedeu.hide_cursor(name) }
|
data/lib/vedeu/borders/border.rb
CHANGED
data/lib/vedeu/borders/render.rb
CHANGED
@@ -41,7 +41,7 @@ module Vedeu
|
|
41
41
|
|
42
42
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
43
43
|
# @param (see #initialize)
|
44
|
-
def self.
|
44
|
+
def self.render(border)
|
45
45
|
new(border).render
|
46
46
|
end
|
47
47
|
|
@@ -55,15 +55,7 @@ module Vedeu
|
|
55
55
|
|
56
56
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
57
57
|
def render
|
58
|
-
|
59
|
-
|
60
|
-
Vedeu.timer("Bordering: '#{name}'") do
|
61
|
-
out = [top, bottom]
|
62
|
-
|
63
|
-
height.times { |y| out << [left(y), right(y)] }
|
64
|
-
|
65
|
-
out.flatten
|
66
|
-
end
|
58
|
+
Vedeu::Output::Output.render(output) if enabled?
|
67
59
|
end
|
68
60
|
|
69
61
|
protected
|
@@ -74,6 +66,17 @@ module Vedeu
|
|
74
66
|
|
75
67
|
private
|
76
68
|
|
69
|
+
# @return [Array<Array<Vedeu::Views::Char>>]
|
70
|
+
def output
|
71
|
+
Vedeu.timer("Bordering: '#{name}'") do
|
72
|
+
out = [top, bottom]
|
73
|
+
|
74
|
+
height.times { |y| out << [left(y), right(y)] }
|
75
|
+
|
76
|
+
out.flatten
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
77
80
|
# @param value [String]
|
78
81
|
# @param type [Symbol|NilClass]
|
79
82
|
# @param iy [Fixnum]
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -94,24 +94,7 @@ module Vedeu
|
|
94
94
|
true
|
95
95
|
end
|
96
96
|
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# @example
|
100
|
-
# Vedeu.trigger(:_hide_interface_, name)
|
101
|
-
# Vedeu.hide_interface(name)
|
102
|
-
#
|
103
|
-
# Will hide the named interface. If the interface is currently
|
104
|
-
# visible, it will be cleared- rendered blank. To show the
|
105
|
-
# interface, the ':_show_interface_' event should be triggered.
|
106
|
-
# Triggering the ':_hide_group_' event to which this named
|
107
|
-
# interface belongs will also hide the interface.
|
108
|
-
#
|
109
|
-
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
110
|
-
def hide
|
111
|
-
Vedeu.trigger(:_clear_view_, name)
|
112
|
-
end
|
113
|
-
|
114
|
-
# Return the content for this buffer.
|
97
|
+
# Retrieve the latest content from the buffer.
|
115
98
|
#
|
116
99
|
# - If we have new content (i.e. content on 'back') to be shown,
|
117
100
|
# we first clear the area occupied by the previous content,
|
@@ -126,46 +109,19 @@ module Vedeu
|
|
126
109
|
#
|
127
110
|
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
128
111
|
def render
|
129
|
-
Vedeu::Output::Output.render(buffer)
|
130
|
-
end
|
131
|
-
|
132
|
-
# Show this buffer.
|
133
|
-
#
|
134
|
-
# @example
|
135
|
-
# Vedeu.trigger(:_show_interface_, name)
|
136
|
-
# Vedeu.show_interface(name)
|
137
|
-
#
|
138
|
-
# Will show the named interface. If the interface is currently
|
139
|
-
# invisible, it will be shown- rendered with its latest content.
|
140
|
-
# To hide the interface, the ':_hide_interface_' event should be
|
141
|
-
# triggered. Triggering the ':_show_group_' event to which this
|
142
|
-
# named interface belongs will also show the interface.
|
143
|
-
#
|
144
|
-
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
145
|
-
def show
|
146
|
-
Vedeu::Output::Output.render(buffer)
|
147
|
-
end
|
148
|
-
|
149
|
-
private
|
150
|
-
|
151
|
-
# Retrieve the latest content from the buffer.
|
152
|
-
#
|
153
|
-
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
154
|
-
def buffer
|
155
112
|
swap if back?
|
156
113
|
|
157
114
|
if front?
|
158
|
-
|
115
|
+
front.render
|
159
116
|
|
160
117
|
elsif previous?
|
161
|
-
|
162
|
-
|
163
|
-
else
|
164
|
-
[]
|
118
|
+
previous.render
|
165
119
|
|
166
120
|
end
|
167
121
|
end
|
168
122
|
|
123
|
+
private
|
124
|
+
|
169
125
|
# Returns the default options/attributes for this class.
|
170
126
|
#
|
171
127
|
# @return [Hash<Symbol => NilClass, String>]
|
@@ -4,32 +4,45 @@ module Vedeu
|
|
4
4
|
|
5
5
|
# Refreshes the given named interface.
|
6
6
|
#
|
7
|
-
# @example
|
8
|
-
# Vedeu.trigger(:_refresh_view_, name)
|
9
|
-
#
|
10
7
|
class Refresh
|
11
8
|
|
12
9
|
include Vedeu::Common
|
13
10
|
|
11
|
+
# @example
|
12
|
+
# Vedeu.trigger(:_refresh_view_, name)
|
13
|
+
#
|
14
14
|
# @param (see #initialize)
|
15
15
|
# @return (see #by_name)
|
16
16
|
def self.by_name(name)
|
17
17
|
new(name).by_name
|
18
18
|
end
|
19
19
|
|
20
|
+
# @example
|
21
|
+
# Vedeu.trigger(:_refresh_view_content_, name)
|
22
|
+
#
|
23
|
+
# @param (see #initialize)
|
24
|
+
# @return (see #by_name)
|
25
|
+
def self.refresh_content_by_name(name)
|
26
|
+
new(name, content_only: true).by_name
|
27
|
+
end
|
28
|
+
|
20
29
|
# Return a new instance of Vedeu::Buffers::Refresh.
|
21
30
|
#
|
22
31
|
# @param name [String|Symbol] The name of the interface to be refreshed
|
23
32
|
# using the named buffer.
|
33
|
+
# @param options [Hash]
|
34
|
+
# @option options content_only [Boolean]
|
24
35
|
# @return [Vedeu::Buffers::Refresh]
|
25
|
-
def initialize(name)
|
26
|
-
@name
|
36
|
+
def initialize(name, options = {})
|
37
|
+
@name = name
|
38
|
+
@options = options
|
27
39
|
end
|
28
40
|
|
29
41
|
# @return [Array|Vedeu::Error::ModelNotFound]
|
30
42
|
def by_name
|
31
|
-
Vedeu.timer("Refresh Buffer: '#{
|
32
|
-
Vedeu.buffers.by_name(
|
43
|
+
Vedeu.timer("Refresh Buffer: '#{name}'") do
|
44
|
+
Vedeu.buffers.by_name(name).render
|
45
|
+
Vedeu.borders.by_name(name).render unless content_only?
|
33
46
|
end if Vedeu.ready?
|
34
47
|
end
|
35
48
|
|
@@ -39,16 +52,21 @@ module Vedeu
|
|
39
52
|
# @return [String|Symbol]
|
40
53
|
attr_reader :name
|
41
54
|
|
42
|
-
|
55
|
+
# @return [Boolean]
|
56
|
+
def content_only?
|
57
|
+
options[:content_only] == true
|
58
|
+
end
|
43
59
|
|
44
|
-
# @
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
return name if present?(name)
|
60
|
+
# @return [Hash<Symbol => Boolean>]
|
61
|
+
def options
|
62
|
+
defaults.merge!(@options)
|
63
|
+
end
|
49
64
|
|
50
|
-
|
51
|
-
|
65
|
+
# @return [Hash<Symbol => Boolean>]
|
66
|
+
def defaults
|
67
|
+
{
|
68
|
+
content_only: false,
|
69
|
+
}
|
52
70
|
end
|
53
71
|
|
54
72
|
end # Refresh
|
@@ -221,9 +221,8 @@ module Vedeu
|
|
221
221
|
# setting is for debugging to be disabled. Using `debug!` or
|
222
222
|
# setting `debug` to true will enable debugging.
|
223
223
|
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
# will affect performance.
|
224
|
+
# At this time, debugging only toggles between viewing a full
|
225
|
+
# backtrace (true) upon exception or only its top line (false).
|
227
226
|
#
|
228
227
|
# Vedeu.configure do
|
229
228
|
# debug!
|
@@ -310,6 +309,36 @@ module Vedeu
|
|
310
309
|
options[:log_only] = types
|
311
310
|
end
|
312
311
|
|
312
|
+
# Sets boolean to enable/disable profiling. Vedeu's default
|
313
|
+
# setting is for profiling to be disabled. Using `profile!` or
|
314
|
+
# setting `profile` to true will enable profiling.
|
315
|
+
#
|
316
|
+
# Profile uses 'ruby-prof' to write a 'profile.html' file to
|
317
|
+
# the /tmp directory which contains a call trace of the running
|
318
|
+
# application. Upon exit, this file can be examined to ascertain
|
319
|
+
# certain behaviours of Vedeu.
|
320
|
+
#
|
321
|
+
# @note
|
322
|
+
# Be aware that running an application with profiling enabled
|
323
|
+
# will affect performance.
|
324
|
+
#
|
325
|
+
# Vedeu.configure do
|
326
|
+
# profile!
|
327
|
+
# # ...
|
328
|
+
# end
|
329
|
+
#
|
330
|
+
# Vedeu.configure do
|
331
|
+
# profile false
|
332
|
+
# # ...
|
333
|
+
# end
|
334
|
+
#
|
335
|
+
# @param value [Boolean]
|
336
|
+
# @return [Boolean]
|
337
|
+
def profile!(value = true)
|
338
|
+
options[:profile] = value
|
339
|
+
end
|
340
|
+
alias_method :profile, :profile!
|
341
|
+
|
313
342
|
# Sets the renderers for Vedeu. Each renderer added must have
|
314
343
|
# the class method '.render' defined as this will be called when
|
315
344
|
# rendering content.
|