vedeu 0.8.16 → 0.8.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO.md +8 -0
- data/examples/dsl_alignment.rb +5 -2
- data/examples/dsl_horizontal_alignment.rb +5 -2
- data/examples/dsl_vertical_alignment.rb +5 -2
- data/integrations/test_runner.sh +2 -3
- data/lib/vedeu.rb +31 -1
- data/lib/vedeu/borders/all.rb +19 -0
- data/lib/vedeu/borders/border.rb +1 -2
- data/lib/vedeu/borders/caption.rb +2 -0
- data/lib/vedeu/borders/refresh.rb +4 -17
- data/lib/vedeu/borders/repository.rb +0 -14
- data/lib/vedeu/borders/title.rb +9 -3
- data/lib/vedeu/buffers/all.rb +25 -0
- data/lib/vedeu/buffers/buffer.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +1 -15
- data/lib/vedeu/buffers/terminal.rb +0 -15
- data/lib/vedeu/buffers/view.rb +2 -2
- data/lib/vedeu/cells/empty.rb +4 -5
- data/lib/vedeu/coercers/all.rb +0 -5
- data/lib/vedeu/cursors/all.rb +88 -0
- data/lib/vedeu/cursors/cursor.rb +7 -92
- data/lib/vedeu/cursors/move.rb +44 -14
- data/lib/vedeu/cursors/refresh.rb +5 -17
- data/lib/vedeu/cursors/reposition.rb +2 -2
- data/lib/vedeu/distributed/all.rb +16 -0
- data/lib/vedeu/distributed/server.rb +0 -16
- data/lib/vedeu/dsl/dsl.rb +2 -2
- data/lib/vedeu/dsl/helpers/align.rb +1 -1
- data/lib/vedeu/dsl/helpers/attributes.rb +1 -1
- data/lib/vedeu/dsl/helpers/truncate.rb +1 -1
- data/lib/vedeu/dsl/helpers/wordwrap.rb +1 -1
- data/lib/vedeu/dsl/view.rb +1 -1
- data/lib/vedeu/dsl/views.rb +22 -6
- data/lib/vedeu/editor/all.rb +54 -0
- data/lib/vedeu/editor/cropper.rb +3 -5
- data/lib/vedeu/editor/cursor.rb +2 -4
- data/lib/vedeu/editor/document.rb +1 -1
- data/lib/vedeu/editor/editor.rb +2 -17
- data/lib/vedeu/editor/repository.rb +0 -45
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/geometries/all.rb +46 -1
- data/lib/vedeu/geometries/area/area.rb +2 -2
- data/lib/vedeu/geometries/dsl/grid.rb +16 -20
- data/lib/vedeu/geometries/geometry.rb +1 -1
- data/lib/vedeu/geometries/move.rb +2 -38
- data/lib/vedeu/geometries/repository.rb +0 -14
- data/lib/vedeu/groups/all.rb +23 -0
- data/lib/vedeu/groups/clear.rb +1 -10
- data/lib/vedeu/groups/group.rb +0 -12
- data/lib/vedeu/groups/refresh.rb +2 -11
- data/lib/vedeu/input/all.rb +35 -0
- data/lib/vedeu/input/capture.rb +2 -2
- data/lib/vedeu/input/mapper.rb +0 -35
- data/lib/vedeu/input/raw.rb +1 -1
- data/lib/vedeu/input/read.rb +1 -1
- data/lib/vedeu/interfaces/all.rb +24 -0
- data/lib/vedeu/interfaces/clear.rb +32 -46
- data/lib/vedeu/interfaces/interface.rb +0 -16
- data/lib/vedeu/menus/all.rb +44 -0
- data/lib/vedeu/menus/menu.rb +13 -8
- data/lib/vedeu/menus/repository.rb +0 -44
- data/lib/vedeu/models/all.rb +13 -0
- data/lib/vedeu/models/focus.rb +0 -13
- data/lib/vedeu/models/toggleable.rb +1 -1
- data/lib/vedeu/null/generic.rb +1 -1
- data/lib/vedeu/output/all.rb +7 -0
- data/lib/vedeu/output/compressor.rb +11 -6
- data/lib/vedeu/output/compressors/character.rb +2 -0
- data/lib/vedeu/output/refresh.rb +0 -7
- data/lib/vedeu/output/viewport.rb +2 -5
- data/lib/vedeu/plugins/plugin.rb +1 -1
- data/lib/vedeu/presentation/colour.rb +6 -1
- data/lib/vedeu/renderers/all.rb +1 -1
- data/lib/vedeu/repositories/repositories.rb +1 -1
- data/lib/vedeu/runtime/all.rb +28 -0
- data/lib/vedeu/runtime/application.rb +0 -18
- data/lib/vedeu/runtime/flags.rb +0 -7
- data/lib/vedeu/runtime/router.rb +0 -11
- data/lib/vedeu/runtime/traps.rb +2 -0
- data/lib/vedeu/templating/view_template.rb +2 -4
- data/lib/vedeu/terminal/all.rb +7 -0
- data/lib/vedeu/terminal/terminal.rb +0 -7
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/view.rb +3 -3
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
- data/test/lib/vedeu/cursors/move_test.rb +2 -2
- data/test/lib/vedeu/presentation/colour_test.rb +26 -0
- data/test/support/colour_support.sh +3 -1
- data/test/support/examples/material_colours_app.rb +2 -28
- data/test/support/stats.sh +1 -1
- data/test/test_helper.rb +0 -1
- data/vedeu.gemspec +1 -1
- metadata +4 -6
- data/test/support/helpers/presentation_colour_test_class.rb +0 -31
data/lib/vedeu/dsl/view.rb
CHANGED
data/lib/vedeu/dsl/views.rb
CHANGED
@@ -102,7 +102,7 @@ module Vedeu
|
|
102
102
|
def renders(&block)
|
103
103
|
raise Vedeu::Error::RequiresBlock unless block_given?
|
104
104
|
|
105
|
-
composition(
|
105
|
+
composition(true, &block)
|
106
106
|
end
|
107
107
|
alias render renders
|
108
108
|
|
@@ -115,23 +115,39 @@ module Vedeu
|
|
115
115
|
def views(&block)
|
116
116
|
raise Vedeu::Error::RequiresBlock unless block_given?
|
117
117
|
|
118
|
-
composition(
|
118
|
+
composition(false, &block)
|
119
119
|
end
|
120
120
|
|
121
121
|
private
|
122
122
|
|
123
|
+
# @param block [Proc] The directives you wish to send to
|
124
|
+
# render. Typically includes `view` with associated
|
125
|
+
# sub-directives. The binding of the block is also accessed
|
126
|
+
# so that we can ascertain the calling client application
|
127
|
+
# class, this is so that if there methods being called
|
128
|
+
# inside your views, Vedeu will redirect that call to the
|
129
|
+
# client class instance instead. (This actually occurs
|
130
|
+
# when Vedeu rescues from method_missing. See {Vedeu::DSL}.)
|
131
|
+
def client_binding(&block)
|
132
|
+
eval('self', block.binding).tap do |client|
|
133
|
+
Vedeu.log(type: :debug,
|
134
|
+
message: "Client binding: #{client.class.name}")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
123
138
|
# Creates a new Vedeu::Views::Composition which may contain
|
124
139
|
# one or more view {Vedeu::Views::View} objects.
|
125
140
|
#
|
126
|
-
# @param client [Object] The client class which called the DSL
|
127
|
-
# object.
|
128
141
|
# @param refresh [Boolean]
|
129
142
|
# @param block [Proc] The directives you wish to send to
|
130
143
|
# render. Typically includes `view` with associated
|
131
144
|
# sub-directives.
|
132
145
|
# # @return [Vedeu::Views::Composition]
|
133
|
-
def composition(
|
134
|
-
attrs = {
|
146
|
+
def composition(refresh = false, &block)
|
147
|
+
attrs = {
|
148
|
+
client: client_binding(&block),
|
149
|
+
colour: Vedeu.config.colour,
|
150
|
+
}
|
135
151
|
|
136
152
|
Vedeu::Views::Composition.build(attrs, &block).update_buffers(refresh)
|
137
153
|
end
|
data/lib/vedeu/editor/all.rb
CHANGED
@@ -8,6 +8,60 @@ module Vedeu
|
|
8
8
|
|
9
9
|
end # Editor
|
10
10
|
|
11
|
+
# :nocov:
|
12
|
+
|
13
|
+
# See {file:docs/events/system.md#\_editor_}
|
14
|
+
Vedeu.bind(:_editor_) do |key|
|
15
|
+
Vedeu.timer('Executing editor keypress') do
|
16
|
+
Vedeu.trigger(:key, key)
|
17
|
+
|
18
|
+
Vedeu::Editor::Editor.keypress(name: Vedeu.focus, input: key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# See {file:docs/events/document.md#\_editor_execute_}
|
23
|
+
Vedeu.bind(:_editor_execute_) do |name|
|
24
|
+
Vedeu.documents.by_name(name).execute
|
25
|
+
end
|
26
|
+
|
27
|
+
# See {file:docs/events/document.md#\_editor_delete_character_}
|
28
|
+
Vedeu.bind(:_editor_delete_character_) do |name|
|
29
|
+
Vedeu.documents.by_name(name).delete_character
|
30
|
+
end
|
31
|
+
|
32
|
+
# See {file:docs/events/document.md#\_editor_delete_line_}
|
33
|
+
Vedeu.bind(:_editor_delete_line_) do |name|
|
34
|
+
Vedeu.documents.by_name(name).delete_line
|
35
|
+
end
|
36
|
+
|
37
|
+
# See {file:docs/events/document.md#\_editor_down_}
|
38
|
+
Vedeu.bind(:_editor_down_) do |name|
|
39
|
+
Vedeu.documents.by_name(name).down
|
40
|
+
end
|
41
|
+
|
42
|
+
# See {file:docs/events/document.md#\_editor_insert_character_}
|
43
|
+
Vedeu.bind(:_editor_insert_character_) do |name, character|
|
44
|
+
Vedeu.documents.by_name(name).insert_character(character)
|
45
|
+
end
|
46
|
+
|
47
|
+
# See {file:docs/events/document.md#\_editor_insert_line_}
|
48
|
+
Vedeu.bind(:_editor_insert_line_) do |name|
|
49
|
+
Vedeu.documents.by_name(name).insert_line
|
50
|
+
end
|
51
|
+
|
52
|
+
# See {file:docs/events/document.md#\_editor_left_}
|
53
|
+
Vedeu.bind(:_editor_left_) { |name| Vedeu.documents.by_name(name).left }
|
54
|
+
|
55
|
+
# See {file:docs/events/document.md#\_editor_right_}
|
56
|
+
Vedeu.bind(:_editor_right_) do |name|
|
57
|
+
Vedeu.documents.by_name(name).right
|
58
|
+
end
|
59
|
+
|
60
|
+
# See {file:docs/events/document.md#\_editor_up_}
|
61
|
+
Vedeu.bind(:_editor_up_) { |name| Vedeu.documents.by_name(name).up }
|
62
|
+
|
63
|
+
# :nocov:
|
64
|
+
|
11
65
|
end # Vedeu
|
12
66
|
|
13
67
|
require 'vedeu/editor/collection'
|
data/lib/vedeu/editor/cropper.rb
CHANGED
@@ -63,7 +63,7 @@ module Vedeu
|
|
63
63
|
protected
|
64
64
|
|
65
65
|
# @!attribute [r] name
|
66
|
-
# @
|
66
|
+
# @macro return_name
|
67
67
|
attr_reader :name
|
68
68
|
|
69
69
|
# @!attribute [r] ox
|
@@ -100,11 +100,9 @@ module Vedeu
|
|
100
100
|
line[ox...(ox + bordered_width)] || ''
|
101
101
|
end
|
102
102
|
|
103
|
-
#
|
104
|
-
#
|
105
|
-
# @return (see Vedeu::Geometries::Repository#by_name)
|
103
|
+
# @macro geometry_by_name
|
106
104
|
def geometry
|
107
|
-
@
|
105
|
+
@_geometry ||= Vedeu.geometries.by_name(name)
|
108
106
|
end
|
109
107
|
|
110
108
|
end # Editor
|
data/lib/vedeu/editor/cursor.rb
CHANGED
@@ -20,7 +20,7 @@ module Vedeu
|
|
20
20
|
:byn
|
21
21
|
|
22
22
|
# @!attribute [r] name
|
23
|
-
# @
|
23
|
+
# @macro return_name
|
24
24
|
attr_reader :name
|
25
25
|
|
26
26
|
# @!attribute [rw] ox
|
@@ -165,9 +165,7 @@ module Vedeu
|
|
165
165
|
|
166
166
|
private
|
167
167
|
|
168
|
-
#
|
169
|
-
#
|
170
|
-
# @return (see Vedeu::Geometries::Repository#by_name)
|
168
|
+
# @macro geometry_by_name
|
171
169
|
def geometry
|
172
170
|
@geometry ||= Vedeu.geometries.by_name(name)
|
173
171
|
end
|
data/lib/vedeu/editor/editor.rb
CHANGED
@@ -72,14 +72,12 @@ module Vedeu
|
|
72
72
|
attr_reader :input
|
73
73
|
|
74
74
|
# @!attribute [r] name
|
75
|
-
# @
|
75
|
+
# @macro return_name
|
76
76
|
attr_reader :name
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
-
#
|
81
|
-
#
|
82
|
-
# @return [Vedeu::Editor::Document]
|
80
|
+
# @macro document_by_name
|
83
81
|
def document
|
84
82
|
@document ||= Vedeu.documents.by_name(name)
|
85
83
|
end
|
@@ -88,17 +86,4 @@ module Vedeu
|
|
88
86
|
|
89
87
|
end # Editor
|
90
88
|
|
91
|
-
# :nocov:
|
92
|
-
|
93
|
-
# See {file:docs/events/system.md#\_editor_}
|
94
|
-
Vedeu.bind(:_editor_) do |key|
|
95
|
-
Vedeu.timer('Executing editor keypress') do
|
96
|
-
Vedeu.trigger(:key, key)
|
97
|
-
|
98
|
-
Vedeu::Editor::Editor.keypress(name: Vedeu.focus, input: key)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# :nocov:
|
103
|
-
|
104
89
|
end # Vedeu
|
@@ -28,49 +28,4 @@ module Vedeu
|
|
28
28
|
def_delegators Vedeu::Editor::Repository,
|
29
29
|
:documents
|
30
30
|
|
31
|
-
# :nocov:
|
32
|
-
|
33
|
-
# See {file:docs/events/document.md#\_editor_execute_}
|
34
|
-
Vedeu.bind(:_editor_execute_) do |name|
|
35
|
-
Vedeu.documents.by_name(name).execute
|
36
|
-
end
|
37
|
-
|
38
|
-
# See {file:docs/events/document.md#\_editor_delete_character_}
|
39
|
-
Vedeu.bind(:_editor_delete_character_) do |name|
|
40
|
-
Vedeu.documents.by_name(name).delete_character
|
41
|
-
end
|
42
|
-
|
43
|
-
# See {file:docs/events/document.md#\_editor_delete_line_}
|
44
|
-
Vedeu.bind(:_editor_delete_line_) do |name|
|
45
|
-
Vedeu.documents.by_name(name).delete_line
|
46
|
-
end
|
47
|
-
|
48
|
-
# See {file:docs/events/document.md#\_editor_down_}
|
49
|
-
Vedeu.bind(:_editor_down_) do |name|
|
50
|
-
Vedeu.documents.by_name(name).down
|
51
|
-
end
|
52
|
-
|
53
|
-
# See {file:docs/events/document.md#\_editor_insert_character_}
|
54
|
-
Vedeu.bind(:_editor_insert_character_) do |name, character|
|
55
|
-
Vedeu.documents.by_name(name).insert_character(character)
|
56
|
-
end
|
57
|
-
|
58
|
-
# See {file:docs/events/document.md#\_editor_insert_line_}
|
59
|
-
Vedeu.bind(:_editor_insert_line_) do |name|
|
60
|
-
Vedeu.documents.by_name(name).insert_line
|
61
|
-
end
|
62
|
-
|
63
|
-
# See {file:docs/events/document.md#\_editor_left_}
|
64
|
-
Vedeu.bind(:_editor_left_) { |name| Vedeu.documents.by_name(name).left }
|
65
|
-
|
66
|
-
# See {file:docs/events/document.md#\_editor_right_}
|
67
|
-
Vedeu.bind(:_editor_right_) do |name|
|
68
|
-
Vedeu.documents.by_name(name).right
|
69
|
-
end
|
70
|
-
|
71
|
-
# See {file:docs/events/document.md#\_editor_up_}
|
72
|
-
Vedeu.bind(:_editor_up_) { |name| Vedeu.documents.by_name(name).up }
|
73
|
-
|
74
|
-
# :nocov:
|
75
|
-
|
76
31
|
end # Vedeu
|
data/lib/vedeu/events/event.rb
CHANGED
data/lib/vedeu/geometries/all.rb
CHANGED
@@ -13,11 +13,56 @@ module Vedeu
|
|
13
13
|
|
14
14
|
end # Geometries
|
15
15
|
|
16
|
+
# :nocov:
|
17
|
+
|
18
|
+
# See {file:docs/events/view.md#\_maximise_}
|
19
|
+
Vedeu.bind(:_maximise_) do |name|
|
20
|
+
Vedeu.geometries.by_name(name).maximise
|
21
|
+
end
|
22
|
+
|
23
|
+
# {include:file:docs/events/by_name/movement_refresh.md}
|
24
|
+
Vedeu.bind(:_movement_refresh_) do |name|
|
25
|
+
Vedeu.trigger(:_clear_)
|
26
|
+
Vedeu.trigger(:_refresh_)
|
27
|
+
Vedeu.trigger(:_clear_view_, name)
|
28
|
+
Vedeu.trigger(:_refresh_view_, name)
|
29
|
+
end
|
30
|
+
|
31
|
+
# See {file:docs/events/view.md#\_unmaximise_}
|
32
|
+
Vedeu.bind(:_unmaximise_) do |name|
|
33
|
+
Vedeu.geometries.by_name(name).unmaximise
|
34
|
+
end
|
35
|
+
|
36
|
+
# {include:file:docs/events/by_name/view_down.md}
|
37
|
+
Vedeu.bind(:_view_down_) do |name, offset|
|
38
|
+
Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :down)
|
39
|
+
end
|
40
|
+
|
41
|
+
# {include:file:docs/events/by_name/view_left.md}
|
42
|
+
Vedeu.bind(:_view_left_) do |name, offset|
|
43
|
+
Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :left)
|
44
|
+
end
|
45
|
+
|
46
|
+
# {include:file:docs/events/by_name/view_right.md}
|
47
|
+
Vedeu.bind(:_view_right_) do |name, offset|
|
48
|
+
Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :right)
|
49
|
+
end
|
50
|
+
|
51
|
+
# {include:file:docs/events/by_name/view_up.md}
|
52
|
+
Vedeu.bind(:_view_up_) do |name, offset|
|
53
|
+
Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :up)
|
54
|
+
end
|
55
|
+
|
56
|
+
[:down, :left, :right, :up].each do |direction|
|
57
|
+
Vedeu.bind_alias(:"_geometry_#{direction}_", :"_view_#{direction}_")
|
58
|
+
end
|
59
|
+
|
60
|
+
# :nocov:
|
61
|
+
|
16
62
|
end # Vedeu
|
17
63
|
|
18
64
|
require 'vedeu/geometries/area/all'
|
19
65
|
require 'vedeu/geometries/dsl/all'
|
20
|
-
|
21
66
|
require 'vedeu/geometries/geometry'
|
22
67
|
require 'vedeu/geometries/move'
|
23
68
|
require 'vedeu/geometries/position'
|
@@ -281,12 +281,12 @@ module Vedeu
|
|
281
281
|
protected
|
282
282
|
|
283
283
|
# @!attribute [r] name
|
284
|
-
# @
|
284
|
+
# @macro return_name
|
285
285
|
attr_reader :name
|
286
286
|
|
287
287
|
private
|
288
288
|
|
289
|
-
# @
|
289
|
+
# @macro border_by_name
|
290
290
|
def border
|
291
291
|
@_border ||= Vedeu.borders.by_name(name)
|
292
292
|
end
|
@@ -33,50 +33,46 @@ module Vedeu
|
|
33
33
|
@value = value
|
34
34
|
end
|
35
35
|
|
36
|
-
# @macro raise_out_of_range
|
37
36
|
# @see Vedeu::Geometries::DSL#columns
|
38
37
|
def columns
|
39
|
-
raise Vedeu::Error::OutOfRange if out_of_range?
|
40
|
-
|
41
38
|
column * value
|
42
39
|
end
|
43
40
|
|
44
|
-
# @macro raise_out_of_range
|
45
41
|
# @see Vedeu::Geometries::DSL#rows
|
46
42
|
def rows
|
47
|
-
raise Vedeu::Error::OutOfRange if out_of_range?
|
48
|
-
|
49
43
|
row * value
|
50
44
|
end
|
51
45
|
|
52
|
-
protected
|
53
|
-
|
54
|
-
# @!attribute [r] value
|
55
|
-
# @return [Fixnum]
|
56
|
-
attr_reader :value
|
57
|
-
|
58
46
|
private
|
59
47
|
|
60
|
-
# Returns the
|
48
|
+
# Returns the width of a single column in characters.
|
61
49
|
#
|
62
50
|
# @return [Fixnum]
|
63
|
-
def
|
64
|
-
Vedeu.
|
51
|
+
def column
|
52
|
+
Vedeu.width / 12
|
65
53
|
end
|
66
54
|
|
67
55
|
# Returns a boolean indicating whether the value is out of
|
68
56
|
# range.
|
69
57
|
#
|
70
58
|
# @return [Boolean]
|
71
|
-
def out_of_range?
|
72
|
-
|
59
|
+
def out_of_range?(v)
|
60
|
+
v < 1 || v > 12
|
73
61
|
end
|
74
62
|
|
75
|
-
# Returns the
|
63
|
+
# Returns the height of a single row in characters.
|
76
64
|
#
|
77
65
|
# @return [Fixnum]
|
78
|
-
def
|
79
|
-
Vedeu.
|
66
|
+
def row
|
67
|
+
Vedeu.height / 12
|
68
|
+
end
|
69
|
+
|
70
|
+
# @macro raise_out_of_range
|
71
|
+
# @return [Fixnum]
|
72
|
+
def value
|
73
|
+
raise Vedeu::Error::OutOfRange if out_of_range?(@value)
|
74
|
+
|
75
|
+
@value
|
80
76
|
end
|
81
77
|
|
82
78
|
end # Grid
|