vedeu 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/docs/events.md +4 -0
- data/examples/borders_app.rb +43 -39
- data/examples/focus_app.rb +4 -0
- data/examples/hello_world.rb +10 -3
- data/lib/vedeu/all.rb +1 -2
- data/lib/vedeu/api.rb +4 -1
- data/lib/vedeu/application/application_controller.rb +24 -0
- data/lib/vedeu/application/application_view.rb +9 -9
- data/lib/vedeu/bindings.rb +2 -0
- data/lib/vedeu/bindings/movement.rb +9 -9
- data/lib/vedeu/bindings/system.rb +3 -3
- data/lib/vedeu/buffers/buffer.rb +4 -9
- data/lib/vedeu/buffers/display_buffer.rb +2 -48
- data/lib/vedeu/cli/generator/application.rb +6 -0
- data/lib/vedeu/cli/generator/templates/application/.ruby-version +1 -0
- data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +2 -11
- data/lib/vedeu/configuration/api.rb +6 -0
- data/lib/vedeu/configuration/configuration.rb +6 -0
- data/lib/vedeu/cursor/cursor.rb +49 -15
- data/lib/vedeu/cursor/move.rb +2 -2
- data/lib/vedeu/cursor/refresh_cursor.rb +2 -7
- data/lib/vedeu/distributed/server.rb +7 -21
- data/lib/vedeu/dsl/view.rb +31 -6
- data/lib/vedeu/internal_api.rb +7 -0
- data/lib/vedeu/log/log.rb +5 -2
- data/lib/vedeu/models/escape.rb +24 -6
- data/lib/vedeu/models/interface.rb +2 -14
- data/lib/vedeu/null/buffer.rb +7 -21
- data/lib/vedeu/null/generic.rb +5 -16
- data/lib/vedeu/null/interface.rb +6 -18
- data/lib/vedeu/runtime/bootstrap.rb +1 -1
- data/lib/vedeu/runtime/flags.rb +57 -0
- data/lib/vedeu/runtime/router.rb +2 -2
- data/lib/vedeu/version.rb +2 -1
- data/test/lib/vedeu/api_test.rb +1 -0
- data/test/lib/vedeu/application/application_controller_test.rb +26 -2
- data/test/lib/vedeu/application/application_view_test.rb +9 -4
- data/test/lib/vedeu/bindings_test.rb +9 -0
- data/test/lib/vedeu/borders/border_test.rb +25 -42
- data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -10
- data/test/lib/vedeu/configuration/api_test.rb +7 -1
- data/test/lib/vedeu/configuration/cli_test.rb +0 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +16 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +122 -4
- data/test/lib/vedeu/dsl/view_test.rb +2 -2
- data/test/lib/vedeu/internal_api_test.rb +2 -0
- data/test/lib/vedeu/models/escape_test.rb +16 -6
- data/test/lib/vedeu/models/focus_test.rb +2 -1
- data/test/lib/vedeu/models/interface_test.rb +9 -5
- data/test/lib/vedeu/null/buffer_test.rb +7 -25
- data/test/lib/vedeu/null/generic_test.rb +6 -20
- data/test/lib/vedeu/null/interface_test.rb +8 -14
- data/test/lib/vedeu/output/compressor_test.rb +4 -4
- data/test/lib/vedeu/output/renderers_test.rb +1 -1
- data/test/lib/vedeu/runtime/flags_test.rb +47 -0
- data/test/lib/vedeu/runtime/router_test.rb +4 -4
- data/test/test_helper.rb +2 -0
- metadata +6 -10
- data/examples/geometry_app.rb +0 -147
- data/examples/panel_app.rb +0 -71
- data/lib/vedeu/geometry/index_position.rb +0 -85
- data/lib/vedeu/geometry/position_validator.rb +0 -69
- data/test/lib/vedeu/geometry/index_position_test.rb +0 -130
- data/test/lib/vedeu/geometry/position_validator_test.rb +0 -149
data/lib/vedeu/bindings.rb
CHANGED
@@ -35,11 +35,11 @@ module Vedeu
|
|
35
35
|
# @see Vedeu::Move
|
36
36
|
def down!
|
37
37
|
Vedeu.bind(:_cursor_down_) do |name|
|
38
|
-
Vedeu::Move.
|
38
|
+
Vedeu::Move.down(Vedeu::Cursor, name)
|
39
39
|
end
|
40
40
|
|
41
41
|
Vedeu.bind(:_view_down_) do |name|
|
42
|
-
Vedeu::Move.
|
42
|
+
Vedeu::Move.down(Vedeu::Geometry, name)
|
43
43
|
end
|
44
44
|
|
45
45
|
Vedeu.bind_alias(:_geometry_down_, :_view_down_)
|
@@ -56,11 +56,11 @@ module Vedeu
|
|
56
56
|
# @see Vedeu::Move
|
57
57
|
def left!
|
58
58
|
Vedeu.bind(:_cursor_left_) do |name|
|
59
|
-
Vedeu::Move.
|
59
|
+
Vedeu::Move.left(Vedeu::Cursor, name)
|
60
60
|
end
|
61
61
|
|
62
62
|
Vedeu.bind(:_view_left_) do |name|
|
63
|
-
Vedeu::Move.
|
63
|
+
Vedeu::Move.left(Vedeu::Geometry, name)
|
64
64
|
end
|
65
65
|
|
66
66
|
Vedeu.bind_alias(:_geometry_left_, :_view_left_)
|
@@ -77,7 +77,7 @@ module Vedeu
|
|
77
77
|
# @see Vedeu::Move
|
78
78
|
def cursor_origin!
|
79
79
|
Vedeu.bind(:_cursor_origin_) do |name|
|
80
|
-
Vedeu::Move.
|
80
|
+
Vedeu::Move.origin(Vedeu::Cursor, name)
|
81
81
|
end
|
82
82
|
|
83
83
|
Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
|
@@ -122,11 +122,11 @@ module Vedeu
|
|
122
122
|
# @see Vedeu::Move
|
123
123
|
def right!
|
124
124
|
Vedeu.bind(:_cursor_right_) do |name|
|
125
|
-
Vedeu::Move.
|
125
|
+
Vedeu::Move.right(Vedeu::Cursor, name)
|
126
126
|
end
|
127
127
|
|
128
128
|
Vedeu.bind(:_view_right_) do |name|
|
129
|
-
Vedeu::Move.
|
129
|
+
Vedeu::Move.right(Vedeu::Geometry, name)
|
130
130
|
end
|
131
131
|
|
132
132
|
Vedeu.bind_alias(:_geometry_right_, :_view_right_)
|
@@ -143,11 +143,11 @@ module Vedeu
|
|
143
143
|
# @see Vedeu::Move
|
144
144
|
def up!
|
145
145
|
Vedeu.bind(:_cursor_up_) do |name|
|
146
|
-
Vedeu::Move.
|
146
|
+
Vedeu::Move.up(Vedeu::Cursor, name)
|
147
147
|
end
|
148
148
|
|
149
149
|
Vedeu.bind(:_view_up_) do |name|
|
150
|
-
Vedeu::Move.
|
150
|
+
Vedeu::Move.up(Vedeu::Geometry, name)
|
151
151
|
end
|
152
152
|
|
153
153
|
Vedeu.bind_alias(:_geometry_up_, :_view_up_)
|
@@ -135,12 +135,12 @@ module Vedeu
|
|
135
135
|
# Vedeu triggers this event when it is ready to enter the main loop.
|
136
136
|
# Client applications can listen for this event and perform some
|
137
137
|
# action(s), like render the first screen, interface or make a sound.
|
138
|
-
# When Vedeu triggers this event, the :_refresh_ event is also triggered
|
139
|
-
# automatically.
|
140
138
|
#
|
141
139
|
# @return [TrueClass]
|
142
140
|
def initialize!
|
143
|
-
Vedeu.bind(:_initialize_)
|
141
|
+
Vedeu.bind(:_initialize_) do
|
142
|
+
Vedeu.ready!
|
143
|
+
end
|
144
144
|
end
|
145
145
|
|
146
146
|
# Will cause the triggering of the `:key` event; which you should define
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -110,7 +110,7 @@ module Vedeu
|
|
110
110
|
#
|
111
111
|
# @return [void]
|
112
112
|
def hide
|
113
|
-
Vedeu::Output.render(clear_buffer)
|
113
|
+
Vedeu::Output.render(clear_buffer) if Vedeu.ready?
|
114
114
|
end
|
115
115
|
|
116
116
|
# Return the content for this buffer.
|
@@ -126,7 +126,7 @@ module Vedeu
|
|
126
126
|
#
|
127
127
|
# @return [Array<Array<Array<Vedeu::Char>>>]
|
128
128
|
def render
|
129
|
-
Vedeu::Output.render(buffer)
|
129
|
+
Vedeu::Output.render(buffer) if Vedeu.ready?
|
130
130
|
end
|
131
131
|
|
132
132
|
# Show this buffer.
|
@@ -143,7 +143,7 @@ module Vedeu
|
|
143
143
|
#
|
144
144
|
# @return [void]
|
145
145
|
def show
|
146
|
-
Vedeu::Output.render(buffer)
|
146
|
+
Vedeu::Output.render(buffer) if Vedeu.ready?
|
147
147
|
end
|
148
148
|
|
149
149
|
private
|
@@ -160,7 +160,7 @@ module Vedeu
|
|
160
160
|
elsif previous?
|
161
161
|
[previous.render]
|
162
162
|
|
163
|
-
elsif visible?
|
163
|
+
elsif interface.visible?
|
164
164
|
[interface.render]
|
165
165
|
|
166
166
|
else
|
@@ -211,11 +211,6 @@ module Vedeu
|
|
211
211
|
Vedeu.interfaces.by_name(name)
|
212
212
|
end
|
213
213
|
|
214
|
-
# @see Vedeu::Interface#visible
|
215
|
-
def visible?
|
216
|
-
interface.visible?
|
217
|
-
end
|
218
|
-
|
219
214
|
end # Buffer
|
220
215
|
|
221
216
|
end # Vedeu
|
@@ -7,7 +7,7 @@ module Vedeu
|
|
7
7
|
|
8
8
|
include Vedeu::Common
|
9
9
|
|
10
|
-
# Store the view and
|
10
|
+
# Store the view and immediately refresh it; causing to be pushed to the
|
11
11
|
# Terminal.
|
12
12
|
#
|
13
13
|
# @return [Vedeu::Interface]
|
@@ -29,53 +29,7 @@ module Vedeu
|
|
29
29
|
fail Vedeu::InvalidSyntax, 'Cannot store an interface without a name.'
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# Registers a set of buffers for the interface unless already registered,
|
40
|
-
# and also adds interface's name to list of focussable interfaces.
|
41
|
-
#
|
42
|
-
# @see Vedeu::Buffer
|
43
|
-
# @return [Vedeu::Interface]
|
44
|
-
def store_new_buffer
|
45
|
-
if Vedeu.buffers.registered?(name)
|
46
|
-
Vedeu.buffers.find(name).add(self)
|
47
|
-
|
48
|
-
else
|
49
|
-
Vedeu::Buffer.new(name: name, back: self).store
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
self
|
54
|
-
end
|
55
|
-
|
56
|
-
# Registers interface name in focus list unless already registered.
|
57
|
-
#
|
58
|
-
# @return [Vedeu::Interface]
|
59
|
-
def store_focusable
|
60
|
-
Vedeu.focusable.add(name) unless Vedeu.focusable.registered?(name)
|
61
|
-
|
62
|
-
self
|
63
|
-
end
|
64
|
-
|
65
|
-
# Registers a new cursor for the interface unless already registered.
|
66
|
-
#
|
67
|
-
# @return [Vedeu::Interface]
|
68
|
-
def store_cursor
|
69
|
-
Vedeu.cursors.by_name(name)
|
70
|
-
|
71
|
-
self
|
72
|
-
end
|
73
|
-
|
74
|
-
# Registers a new group for the interface unless already registered.
|
75
|
-
#
|
76
|
-
# @return [Vedeu::Interface]
|
77
|
-
def store_group
|
78
|
-
Vedeu.groups.by_name(group).add(name) if group?
|
32
|
+
Vedeu.buffers.by_name(name).add(self)
|
79
33
|
|
80
34
|
self
|
81
35
|
end
|
@@ -36,6 +36,7 @@ module Vedeu
|
|
36
36
|
copy_gitignore
|
37
37
|
copy_license
|
38
38
|
copy_readme
|
39
|
+
copy_ruby_version
|
39
40
|
copy_application_bootstrapper
|
40
41
|
copy_application_controller
|
41
42
|
copy_application_helper
|
@@ -107,6 +108,11 @@ module Vedeu
|
|
107
108
|
copy_file(source + '/README.md', "#{name}/README.md")
|
108
109
|
end
|
109
110
|
|
111
|
+
# @return [void]
|
112
|
+
def copy_ruby_version
|
113
|
+
copy_file(source + '/.ruby-version', "#{name}/.ruby-version")
|
114
|
+
end
|
115
|
+
|
110
116
|
# @return [void]
|
111
117
|
def make_application_executable
|
112
118
|
FileUtils.chmod(0755, "#{name}/bin/#{name}")
|
@@ -0,0 +1 @@
|
|
1
|
+
2.2.2
|
@@ -10,20 +10,11 @@ module <%= object.app_name %>
|
|
10
10
|
action :show
|
11
11
|
# add more actions and implement or remove existing actions
|
12
12
|
|
13
|
-
def initialize
|
14
|
-
end
|
15
|
-
|
16
13
|
def list
|
17
14
|
end
|
18
15
|
|
19
|
-
def show
|
20
|
-
<%= object.app_name %>::<%= object.name_as_class %>View.render(
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def object
|
26
|
-
nil
|
16
|
+
def show
|
17
|
+
<%= object.app_name %>::<%= object.name_as_class %>View.render(params)
|
27
18
|
end
|
28
19
|
|
29
20
|
end
|
@@ -270,6 +270,12 @@ module Vedeu
|
|
270
270
|
options[:log] = filename
|
271
271
|
end
|
272
272
|
|
273
|
+
# @param types [Array<Symbol>] The message types which should be logged.
|
274
|
+
# @return [Array<Symbol>]
|
275
|
+
def log_only(*types)
|
276
|
+
options[:log_only] = types
|
277
|
+
end
|
278
|
+
|
273
279
|
# Sets the renderers for Vedeu. Each renderer added must have the class
|
274
280
|
# method '.render' defined as this will be called when rendering content.
|
275
281
|
#
|
@@ -158,6 +158,11 @@ module Vedeu
|
|
158
158
|
log != nil
|
159
159
|
end
|
160
160
|
|
161
|
+
# @return [Array<Symbol>]
|
162
|
+
def log_only
|
163
|
+
instance.options[:log_only] || []
|
164
|
+
end
|
165
|
+
|
161
166
|
# Returns whether the application will run through its main loop once or
|
162
167
|
# not. Default is false; meaning the application will loop forever or
|
163
168
|
# until terminated by the user.
|
@@ -281,6 +286,7 @@ module Vedeu
|
|
281
286
|
drb_width: 80,
|
282
287
|
interactive: true,
|
283
288
|
log: nil,
|
289
|
+
log_only: [],
|
284
290
|
once: false,
|
285
291
|
renderers: [Vedeu::Renderers::Terminal.new],
|
286
292
|
root: nil,
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -7,6 +7,13 @@ module Vedeu
|
|
7
7
|
|
8
8
|
include Vedeu::Model
|
9
9
|
include Vedeu::Toggleable
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
def_delegators :border,
|
13
|
+
:bx,
|
14
|
+
:bxn,
|
15
|
+
:by,
|
16
|
+
:byn
|
10
17
|
|
11
18
|
# @!attribute [r] attributes
|
12
19
|
# @return [Hash]
|
@@ -28,13 +35,13 @@ module Vedeu
|
|
28
35
|
# @return [Boolean|Symbol]
|
29
36
|
attr_reader :state
|
30
37
|
|
31
|
-
# @!attribute [
|
38
|
+
# @!attribute [w] x
|
32
39
|
# @return [Fixnum]
|
33
|
-
|
40
|
+
attr_writer :x
|
34
41
|
|
35
|
-
# @!attribute [
|
42
|
+
# @!attribute [sw] y
|
36
43
|
# @return [Fixnum]
|
37
|
-
|
44
|
+
attr_writer :y
|
38
45
|
|
39
46
|
# Returns a new instance of Vedeu::Cursor.
|
40
47
|
#
|
@@ -50,15 +57,13 @@ module Vedeu
|
|
50
57
|
#
|
51
58
|
# @return [Vedeu::Cursor]
|
52
59
|
def initialize(attributes = {})
|
53
|
-
# Hack because Repository#by_name creates Cursor objects with just a
|
54
|
-
#
|
60
|
+
# @todo Hack because Repository#by_name creates Cursor objects with just a
|
61
|
+
# name. Intend to remove this.
|
55
62
|
attributes = { name: attributes } if attributes.is_a?(String)
|
56
63
|
|
57
64
|
@attributes = defaults.merge!(attributes)
|
58
65
|
|
59
66
|
@attributes.each { |key, value| instance_variable_set("@#{key}", value) }
|
60
|
-
|
61
|
-
@position = Vedeu::Position[@y, @x]
|
62
67
|
end
|
63
68
|
|
64
69
|
# Override Ruby's Object#inspect method to provide a more helpful output.
|
@@ -80,10 +85,10 @@ module Vedeu
|
|
80
85
|
# @return [String]
|
81
86
|
def to_s
|
82
87
|
if block_given?
|
83
|
-
"#{position}#{yield}#{
|
88
|
+
"#{position}#{yield}#{visibility}"
|
84
89
|
|
85
90
|
else
|
86
|
-
"#{
|
91
|
+
"#{visibility}"
|
87
92
|
|
88
93
|
end
|
89
94
|
end
|
@@ -99,14 +104,14 @@ module Vedeu
|
|
99
104
|
def hide
|
100
105
|
super
|
101
106
|
|
102
|
-
Vedeu::Output.render(visibility)
|
107
|
+
Vedeu::Output.render(visibility) if Vedeu.ready?
|
103
108
|
end
|
104
109
|
|
105
110
|
# Return the position of this cursor.
|
106
111
|
#
|
107
112
|
# @return [Vedeu::Position]
|
108
113
|
def position
|
109
|
-
@position
|
114
|
+
@position = Vedeu::Position[y, x]
|
110
115
|
end
|
111
116
|
|
112
117
|
# Show a named cursor, or without a name, the cursor of the currently
|
@@ -119,11 +124,36 @@ module Vedeu
|
|
119
124
|
def show
|
120
125
|
super
|
121
126
|
|
122
|
-
Vedeu::Output.render(visibility)
|
127
|
+
Vedeu::Output.render(visibility) if Vedeu.ready?
|
128
|
+
end
|
129
|
+
|
130
|
+
# @return [Fixnum] The column/character coordinate.
|
131
|
+
def x
|
132
|
+
@x = bx if @x < bx
|
133
|
+
@x = bxn if @x > bxn
|
134
|
+
|
135
|
+
@attributes[:x] = @x
|
136
|
+
|
137
|
+
@x
|
138
|
+
end
|
139
|
+
|
140
|
+
# @return [Fixnum] The row/line coordinate.
|
141
|
+
def y
|
142
|
+
@y = by if @y < by
|
143
|
+
@y = byn if @y > byn
|
144
|
+
|
145
|
+
@attributes[:y] = @y
|
146
|
+
|
147
|
+
@y
|
123
148
|
end
|
124
149
|
|
125
150
|
private
|
126
151
|
|
152
|
+
# @see Vedeu::Borders#by_name
|
153
|
+
def border
|
154
|
+
@border ||= Vedeu.borders.by_name(name)
|
155
|
+
end
|
156
|
+
|
127
157
|
# The default values for a new instance of this class.
|
128
158
|
#
|
129
159
|
# @return [Hash]
|
@@ -143,9 +173,13 @@ module Vedeu
|
|
143
173
|
#
|
144
174
|
# @return [String]
|
145
175
|
def visibility
|
146
|
-
|
176
|
+
if visible?
|
177
|
+
Vedeu::Escape.new(position: position, value: Vedeu::Esc.show_cursor)
|
147
178
|
|
148
|
-
|
179
|
+
else
|
180
|
+
Vedeu::Escape.new(position: position, value: Vedeu::Esc.hide_cursor)
|
181
|
+
|
182
|
+
end
|
149
183
|
end
|
150
184
|
|
151
185
|
end # Cursor
|
data/lib/vedeu/cursor/move.rb
CHANGED
@@ -114,9 +114,9 @@ module Vedeu
|
|
114
114
|
# @param dy [Fixnum] Move up (-1), or down (1), or no action (0).
|
115
115
|
# @param dx [Fixnum] Move left (-1), or right (1), or no action (0).
|
116
116
|
# @return [Vedeu::Move]
|
117
|
-
def initialize(entity, name, dy = 0, dx = 0)
|
117
|
+
def initialize(entity, name = nil, dy = 0, dx = 0)
|
118
118
|
@entity = entity
|
119
|
-
@name = name
|
119
|
+
@name = name ? name : Vedeu.focus
|
120
120
|
@dy = dy
|
121
121
|
@dx = dx
|
122
122
|
end
|
@@ -62,16 +62,11 @@ module Vedeu
|
|
62
62
|
# @return [Hash<Symbol => Fixnum>]
|
63
63
|
def position
|
64
64
|
{
|
65
|
-
x:
|
66
|
-
y:
|
65
|
+
x: cursor.x,
|
66
|
+
y: cursor.y,
|
67
67
|
}
|
68
68
|
end
|
69
69
|
|
70
|
-
# @return [Vedeu::PositionValidator]
|
71
|
-
def validated_position
|
72
|
-
@position ||= Vedeu::PositionValidator.validate(name, cursor.x, cursor.y)
|
73
|
-
end
|
74
|
-
|
75
70
|
# @return [Vedeu::Cursor]
|
76
71
|
def cursor
|
77
72
|
@cursor ||= Vedeu.cursors.by_name(name)
|