vedeu 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/docs/object_graph.md +14 -0
- data/examples/borders_app.rb +19 -19
- data/lib/vedeu/api.rb +134 -22
- data/lib/vedeu/buffers/buffer.rb +11 -8
- data/lib/vedeu/cursor/cursor.rb +2 -1
- data/lib/vedeu/dsl/shared/colour.rb +1 -1
- data/lib/vedeu/geometry/area.rb +25 -20
- data/lib/vedeu/geometry/canvas.rb +12 -2
- data/lib/vedeu/geometry/dimension.rb +68 -21
- data/lib/vedeu/geometry/geometry.rb +70 -224
- data/lib/vedeu/geometry/position.rb +1 -6
- data/lib/vedeu/models/cell.rb +1 -6
- data/lib/vedeu/models/char.rb +1 -6
- data/lib/vedeu/output/compositor.rb +3 -3
- data/lib/vedeu/output/viewport.rb +6 -0
- data/test/lib/vedeu/distributed/server_test.rb +4 -0
- data/test/lib/vedeu/dsl/components/geometry_test.rb +4 -0
- data/test/lib/vedeu/geometry/area_test.rb +95 -7
- data/test/lib/vedeu/geometry/canvas_test.rb +10 -2
- data/test/lib/vedeu/geometry/dimension_test.rb +112 -33
- data/test/lib/vedeu/geometry/geometry_test.rb +71 -240
- data/test/lib/vedeu/geometry/position_test.rb +5 -9
- data/test/lib/vedeu/models/cell_test.rb +1 -15
- data/test/lib/vedeu/models/char_test.rb +14 -0
- data/test/lib/vedeu/output/colour_test.rb +16 -0
- data/test/lib/vedeu/output/compositor_test.rb +3 -1
- data/vedeu.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f8e55b96180371a74727bb5684f829aea4fb3ae
|
4
|
+
data.tar.gz: d3bbd55216ffff82ebf2007cd7616228be86e155
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52b9ca57b1f4258a516e236a49e42840665bb4f40352e8d7b562de206eb1a23340fe4be40acfe02d41a28618db3e36a8841964d2a1fa2c3108bd841bdb6aa29f
|
7
|
+
data.tar.gz: b5caa9c02529b83537e2894d4fbc287beedef7c1cbcd7de1bc5d2eafb178d225ec9709c14fda5a8872bd2760f04c3df0ed2a95051e8fc1a8ebe1002506ff8b4e
|
data/README.md
CHANGED
@@ -176,7 +176,9 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
|
|
176
176
|
* Update the [README](https://github.com/gavinlaking/vedeu/blob/master/README.md).
|
177
177
|
* Please **do not change** the version number.
|
178
178
|
|
179
|
-
Any branch on the repository that is not `master` is probably experimental; do not rely on anything in these branches.
|
179
|
+
Any branch on the repository that is not `master` is probably experimental; do not rely on anything in these branches. Typically, `twerks` will be merged into `master` before a release,
|
180
|
+
and branches prefixed with `spike/` are me playing with ideas.
|
181
|
+
|
180
182
|
|
181
183
|
### General contribution help
|
182
184
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
## Producing an object graph of Vedeu
|
2
|
+
|
3
|
+
Sometimes I find looking at the project as a graph helps me to understand the
|
4
|
+
relationship between the various objects. To achieve this, I use Yard's graph
|
5
|
+
options. If this sort of thing floats your boat too, and you have the
|
6
|
+
appropriate software installed:
|
7
|
+
|
8
|
+
```shell
|
9
|
+
yard graph --full --dependencies --private --protected --dot --file vedeu.dot
|
10
|
+
|
11
|
+
dot -Tpdf vedeu.dot -o vedeu.pdf
|
12
|
+
```
|
13
|
+
|
14
|
+
Cool stuff.
|
data/examples/borders_app.rb
CHANGED
@@ -28,7 +28,7 @@ class VedeuBordersApp
|
|
28
28
|
|
29
29
|
interface 'border_off' do
|
30
30
|
geometry do
|
31
|
-
x
|
31
|
+
x 14
|
32
32
|
y 2
|
33
33
|
height 4
|
34
34
|
width 10
|
@@ -38,7 +38,7 @@ class VedeuBordersApp
|
|
38
38
|
|
39
39
|
interface 'no_top' do
|
40
40
|
geometry do
|
41
|
-
x
|
41
|
+
x 26
|
42
42
|
y 2
|
43
43
|
height 4
|
44
44
|
width 10
|
@@ -48,7 +48,7 @@ class VedeuBordersApp
|
|
48
48
|
|
49
49
|
interface 'no_bottom' do
|
50
50
|
geometry do
|
51
|
-
x
|
51
|
+
x 38
|
52
52
|
y 2
|
53
53
|
height 4
|
54
54
|
width 10
|
@@ -58,7 +58,7 @@ class VedeuBordersApp
|
|
58
58
|
|
59
59
|
interface 'no_left' do
|
60
60
|
geometry do
|
61
|
-
x
|
61
|
+
x 50
|
62
62
|
y 2
|
63
63
|
height 4
|
64
64
|
width 10
|
@@ -68,7 +68,7 @@ class VedeuBordersApp
|
|
68
68
|
|
69
69
|
interface 'no_right' do
|
70
70
|
geometry do
|
71
|
-
x
|
71
|
+
x 62
|
72
72
|
y 2
|
73
73
|
height 4
|
74
74
|
width 10
|
@@ -79,7 +79,7 @@ class VedeuBordersApp
|
|
79
79
|
interface 'custom_corners' do
|
80
80
|
geometry do
|
81
81
|
x 2
|
82
|
-
y
|
82
|
+
y 8
|
83
83
|
height 4
|
84
84
|
width 10
|
85
85
|
end
|
@@ -88,8 +88,8 @@ class VedeuBordersApp
|
|
88
88
|
|
89
89
|
interface 'custom_sides' do
|
90
90
|
geometry do
|
91
|
-
x
|
92
|
-
y
|
91
|
+
x 14
|
92
|
+
y 8
|
93
93
|
height 4
|
94
94
|
width 10
|
95
95
|
end
|
@@ -98,8 +98,8 @@ class VedeuBordersApp
|
|
98
98
|
|
99
99
|
interface 'only_top' do
|
100
100
|
geometry do
|
101
|
-
x
|
102
|
-
y
|
101
|
+
x 26
|
102
|
+
y 8
|
103
103
|
height 4
|
104
104
|
width 10
|
105
105
|
end
|
@@ -108,8 +108,8 @@ class VedeuBordersApp
|
|
108
108
|
|
109
109
|
interface 'only_bottom' do
|
110
110
|
geometry do
|
111
|
-
x
|
112
|
-
y
|
111
|
+
x 38
|
112
|
+
y 8
|
113
113
|
height 4
|
114
114
|
width 10
|
115
115
|
end
|
@@ -118,8 +118,8 @@ class VedeuBordersApp
|
|
118
118
|
|
119
119
|
interface 'only_left' do
|
120
120
|
geometry do
|
121
|
-
x
|
122
|
-
y
|
121
|
+
x 50
|
122
|
+
y 8
|
123
123
|
height 4
|
124
124
|
width 10
|
125
125
|
end
|
@@ -128,8 +128,8 @@ class VedeuBordersApp
|
|
128
128
|
|
129
129
|
interface 'only_right' do
|
130
130
|
geometry do
|
131
|
-
x
|
132
|
-
y
|
131
|
+
x 62
|
132
|
+
y 8
|
133
133
|
height 4
|
134
134
|
width 10
|
135
135
|
end
|
@@ -139,7 +139,7 @@ class VedeuBordersApp
|
|
139
139
|
interface 'custom_colour' do
|
140
140
|
geometry do
|
141
141
|
x 2
|
142
|
-
y
|
142
|
+
y 14
|
143
143
|
height 4
|
144
144
|
width 10
|
145
145
|
end
|
@@ -148,8 +148,8 @@ class VedeuBordersApp
|
|
148
148
|
|
149
149
|
interface 'negative' do
|
150
150
|
geometry do
|
151
|
-
x
|
152
|
-
y
|
151
|
+
x 14
|
152
|
+
y 14
|
153
153
|
height 4
|
154
154
|
width 10
|
155
155
|
end
|
data/lib/vedeu/api.rb
CHANGED
@@ -14,6 +14,19 @@ module Vedeu
|
|
14
14
|
# Provides the API to Vedeu. Methods therein, and classes belonging to this
|
15
15
|
# module expose Vedeu's core functionality.
|
16
16
|
#
|
17
|
+
# These methods are used in a variety of ways, sometimes in combination:
|
18
|
+
#
|
19
|
+
# # with parameters
|
20
|
+
# Vedeu.method_name(*params)
|
21
|
+
#
|
22
|
+
# # with a block
|
23
|
+
# Vedeu.method_name(*params) do
|
24
|
+
# # ...
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# # with other methods
|
28
|
+
# Vedeu.method_name.other_method
|
29
|
+
#
|
17
30
|
# @api public
|
18
31
|
#
|
19
32
|
module API
|
@@ -21,35 +34,134 @@ module Vedeu
|
|
21
34
|
extend Forwardable
|
22
35
|
extend self
|
23
36
|
|
24
|
-
|
25
|
-
|
26
|
-
def_delegators Vedeu::
|
27
|
-
|
28
|
-
|
37
|
+
# @!method borders
|
38
|
+
# @see Vedeu::Borders.borders
|
39
|
+
def_delegators Vedeu::Borders, :borders
|
40
|
+
|
41
|
+
# @!method buffers
|
42
|
+
# @see Vedeu::Buffers.buffers
|
43
|
+
def_delegators Vedeu::Buffers, :buffers
|
44
|
+
|
45
|
+
# @!method canvas
|
46
|
+
# @see Vedeu::Canvas.canvas
|
47
|
+
def_delegators Vedeu::Canvas, :canvas
|
48
|
+
|
49
|
+
# @!method cursors
|
50
|
+
# @see Vedeu::Cursors.cursors
|
51
|
+
def_delegators Vedeu::Cursors, :cursors
|
52
|
+
|
53
|
+
# @!method cursor
|
54
|
+
# @see Vedeu::Cursors.cursor
|
55
|
+
def_delegators Vedeu::Cursors, :cursor
|
56
|
+
|
57
|
+
# @!method events
|
58
|
+
# @see Vedeu::EventsRepository.events
|
29
59
|
def_delegators Vedeu::EventsRepository, :events
|
30
|
-
|
31
|
-
|
60
|
+
|
61
|
+
# @!method geometries
|
62
|
+
# @see Vedeu::Geometries.geometries
|
63
|
+
def_delegators Vedeu::Geometries, :geometries
|
64
|
+
|
65
|
+
# @!method groups
|
66
|
+
# @see Vedeu::Groups.groups
|
67
|
+
def_delegators Vedeu::Groups, :groups
|
68
|
+
|
69
|
+
# @!method interfaces
|
70
|
+
# @see Vedeu::InterfacesRepository.interfaces
|
32
71
|
def_delegators Vedeu::InterfacesRepository, :interfaces
|
33
72
|
|
34
|
-
|
35
|
-
|
36
|
-
def_delegators Vedeu::
|
73
|
+
# @!method keymaps
|
74
|
+
# @see Vedeu::Keymaps.keymaps
|
75
|
+
def_delegators Vedeu::Keymaps, :keymaps
|
37
76
|
|
38
|
-
|
39
|
-
|
40
|
-
def_delegators Vedeu::
|
77
|
+
# @!method keypress
|
78
|
+
# @see Vedeu::Mapper.keypress
|
79
|
+
def_delegators Vedeu::Mapper, :keypress
|
80
|
+
|
81
|
+
# @!method menus
|
82
|
+
# @see Vedeu::Menus.menus
|
83
|
+
def_delegators Vedeu::Menus, :menus
|
84
|
+
|
85
|
+
# @!method bind
|
86
|
+
# @see Vedeu::Event.bind
|
87
|
+
# @!method trigger
|
88
|
+
# @see Vedeu::Event.trigger
|
89
|
+
# @!method unbind
|
90
|
+
# @see Vedeu::Event.unbind
|
91
|
+
def_delegators Vedeu::Event, :bind,
|
92
|
+
:trigger,
|
93
|
+
:unbind
|
94
|
+
|
95
|
+
# @!method configure
|
96
|
+
# @see Vedeu::Configuration.configure
|
97
|
+
# @!method configuration
|
98
|
+
# @see Vedeu::Configuration.configuration
|
99
|
+
def_delegators Vedeu::Configuration, :configure,
|
100
|
+
:configuration
|
101
|
+
|
102
|
+
# @!method border
|
103
|
+
# @see Vedeu::DSL::Border.border
|
104
|
+
def_delegators Vedeu::DSL::Border, :border
|
105
|
+
|
106
|
+
# @!method geometry
|
107
|
+
# @see Vedeu::DSL::Geometry.geometry
|
41
108
|
def_delegators Vedeu::DSL::Geometry, :geometry
|
42
|
-
def_delegators Vedeu::DSL::Keymap, :keymap
|
43
|
-
def_delegators Vedeu::DSL::Group, :group
|
44
|
-
def_delegators Vedeu::DSL::Use, :use
|
45
|
-
def_delegators Vedeu::DSL::View, :interface, :renders, :views
|
46
109
|
|
47
|
-
|
48
|
-
|
110
|
+
# @!method keymap
|
111
|
+
# @see Vedeu::DSL::Keymap.keymap
|
112
|
+
def_delegators Vedeu::DSL::Keymap, :keymap
|
113
|
+
|
114
|
+
# @!method group
|
115
|
+
# @see Vedeu::DSL::Group.group
|
116
|
+
def_delegators Vedeu::DSL::Group, :group
|
117
|
+
|
118
|
+
# @!method use
|
119
|
+
# @see Vedeu::DSL::Use#use
|
120
|
+
def_delegators Vedeu::DSL::Use, :use
|
121
|
+
|
122
|
+
# @!method interface
|
123
|
+
# @see Vedeu::DSL::View.interface
|
124
|
+
# @!method renders
|
125
|
+
# @see Vedeu::DSL::View.renders
|
126
|
+
# @!method views
|
127
|
+
# @see Vedeu::DSL::View.views
|
128
|
+
def_delegators Vedeu::DSL::View, :interface,
|
129
|
+
:renders,
|
130
|
+
:views
|
131
|
+
|
132
|
+
# @!method focus
|
133
|
+
# @see Vedeu::Focus#focus
|
134
|
+
# @!method focus_by_name
|
135
|
+
# @see Vedeu::Focus#focus_by_name
|
136
|
+
# @!method focussed?
|
137
|
+
# @see Vedeu::Focus#focussed?
|
138
|
+
# @!method focus_next
|
139
|
+
# @see Vedeu::Focus#focus_next
|
140
|
+
# @!method focus_previous
|
141
|
+
# @see Vedeu::Focus#focus_previous
|
142
|
+
def_delegators Vedeu::Focus, :focus,
|
143
|
+
:focus_by_name,
|
144
|
+
:focussed?,
|
145
|
+
:focus_next,
|
146
|
+
:focus_previous
|
147
|
+
|
148
|
+
# @!method log
|
149
|
+
# @see Vedeu::Log.log
|
150
|
+
def_delegators Vedeu::Log, :log
|
151
|
+
|
152
|
+
# @!method menu
|
153
|
+
# @see Vedeu::Menu.menu
|
154
|
+
def_delegators Vedeu::Menu, :menu
|
49
155
|
|
50
|
-
|
51
|
-
|
52
|
-
|
156
|
+
# @!method height
|
157
|
+
# @see Vedeu::Terminal#height
|
158
|
+
# @!method width
|
159
|
+
# @see Vedeu::Terminal#width
|
160
|
+
# @!method resize
|
161
|
+
# @see Vedeu::Terminal#resize
|
162
|
+
def_delegators Vedeu::Terminal, :height,
|
163
|
+
:width,
|
164
|
+
:resize
|
53
165
|
|
54
166
|
end # API
|
55
167
|
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -5,25 +5,27 @@ module Vedeu
|
|
5
5
|
# The Buffer object represents the states of display for an interface. The
|
6
6
|
# states are 'front', 'back' and 'previous'.
|
7
7
|
#
|
8
|
-
# - 'front': The currently displayed buffer; contains the content which was
|
9
|
-
# last output.
|
10
|
-
# - 'back': The next buffer to be displayed; contains the content which
|
11
|
-
# will be shown on next refresh.
|
12
|
-
# - 'previous': The previous buffer which was displayed; contains the content
|
13
|
-
# that was shown before 'front'.
|
14
|
-
#
|
15
8
|
class Buffer
|
16
9
|
|
17
10
|
include Vedeu::Model
|
18
11
|
|
12
|
+
# The next buffer to be displayed; contains the content which will be shown
|
13
|
+
# on next refresh.
|
14
|
+
#
|
19
15
|
# @!attribute [rw] back
|
20
16
|
# @return [Interface]
|
21
17
|
attr_accessor :back
|
22
18
|
|
19
|
+
# The currently displayed buffer, contains the content which was last
|
20
|
+
# output.
|
21
|
+
#
|
23
22
|
# @!attribute [rw] front
|
24
23
|
# @return [Interface]
|
25
24
|
attr_accessor :front
|
26
25
|
|
26
|
+
# The previous buffer which was displayed; contains the content that was
|
27
|
+
# shown before 'front'.
|
28
|
+
#
|
27
29
|
# @!attribute [rw] previous
|
28
30
|
# @return [Interface]
|
29
31
|
attr_accessor :previous
|
@@ -32,7 +34,8 @@ module Vedeu
|
|
32
34
|
# @return [String]
|
33
35
|
attr_reader :name
|
34
36
|
|
35
|
-
# Return a new instance of Buffer.
|
37
|
+
# Return a new instance of Buffer. Generally a Buffer is initialized with
|
38
|
+
# only a 'name' and 'back' parameter.
|
36
39
|
#
|
37
40
|
# @param name [String] The name of the interface for which the buffer
|
38
41
|
# belongs.
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -17,7 +17,7 @@ module Vedeu
|
|
17
17
|
# @note The last defined background colour for a particular interface,
|
18
18
|
# line or stream overrides previously defined entries in the same block.
|
19
19
|
#
|
20
|
-
# @param value [String]
|
20
|
+
# @param value [String] A HTML/CSS value.
|
21
21
|
#
|
22
22
|
# @example
|
23
23
|
# interface 'my_interface' do
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -5,22 +5,22 @@ module Vedeu
|
|
5
5
|
class Area
|
6
6
|
|
7
7
|
# @!attribute [r] y
|
8
|
-
# @return [Fixnum]
|
8
|
+
# @return [Fixnum] Returns the top coordinate of the interface.
|
9
9
|
attr_reader :y
|
10
10
|
alias_method :top, :y
|
11
11
|
|
12
12
|
# @!attribute [r] yn
|
13
|
-
# @return [Fixnum]
|
13
|
+
# @return [Fixnum] Returns the bottom coordinate of the interface.
|
14
14
|
attr_reader :yn
|
15
15
|
alias_method :bottom, :yn
|
16
16
|
|
17
17
|
# @!attribute [r] x
|
18
|
-
# @return [Fixnum]
|
18
|
+
# @return [Fixnum] Returns the left coordinate of the interface.
|
19
19
|
attr_reader :x
|
20
20
|
alias_method :left, :x
|
21
21
|
|
22
22
|
# @!attribute [r] xn
|
23
|
-
# @return [Fixnum]
|
23
|
+
# @return [Fixnum] Returns the right coordinate of the interface.
|
24
24
|
attr_reader :xn
|
25
25
|
alias_method :right, :xn
|
26
26
|
|
@@ -53,12 +53,6 @@ module Vedeu
|
|
53
53
|
@y, @yn, @x, @xn = y, yn, x, xn
|
54
54
|
end
|
55
55
|
|
56
|
-
# @param other [Vedeu::Area]
|
57
|
-
# @return [Boolean]
|
58
|
-
def ==(other)
|
59
|
-
eql?(other)
|
60
|
-
end
|
61
|
-
|
62
56
|
# @param other [Vedeu::Area]
|
63
57
|
# @return [Boolean]
|
64
58
|
def eql?(other)
|
@@ -68,6 +62,7 @@ module Vedeu
|
|
68
62
|
x == other.x &&
|
69
63
|
xn == other.xn
|
70
64
|
end
|
65
|
+
alias_method :==, :eql?
|
71
66
|
|
72
67
|
# @return [Array<Fixnum>]
|
73
68
|
def centre
|
@@ -76,12 +71,22 @@ module Vedeu
|
|
76
71
|
|
77
72
|
# @return [Fixnum]
|
78
73
|
def centre_y
|
79
|
-
(
|
74
|
+
(height / 2) + y
|
80
75
|
end
|
81
76
|
|
82
77
|
# @return [Fixnum]
|
83
78
|
def centre_x
|
84
|
-
(
|
79
|
+
(width / 2) + x
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Fixnum]
|
83
|
+
def height
|
84
|
+
(y..yn).size
|
85
|
+
end
|
86
|
+
|
87
|
+
# @return [Fixnum]
|
88
|
+
def width
|
89
|
+
(x..xn).size
|
85
90
|
end
|
86
91
|
|
87
92
|
# Returns the row above the top by default.
|
@@ -90,8 +95,8 @@ module Vedeu
|
|
90
95
|
# `top` / `y` is 4.
|
91
96
|
#
|
92
97
|
# north # => 3
|
93
|
-
# north(2) # => 2
|
94
|
-
# north(-4) # => 8
|
98
|
+
# north(2) # => 2 (positive goes north)
|
99
|
+
# north(-4) # => 8 (negative goes south)
|
95
100
|
#
|
96
101
|
# @param offset [Fixnum]
|
97
102
|
# @return [Fixnum]
|
@@ -105,8 +110,8 @@ module Vedeu
|
|
105
110
|
# `right` / `xn` is 19.
|
106
111
|
#
|
107
112
|
# east # => 20
|
108
|
-
# east(2) # => 21
|
109
|
-
# east(-4) # => 15
|
113
|
+
# east(2) # => 21 (positive goes east)
|
114
|
+
# east(-4) # => 15 (negative goes west)
|
110
115
|
#
|
111
116
|
# @param offset [Fixnum]
|
112
117
|
# @return [Fixnum]
|
@@ -120,8 +125,8 @@ module Vedeu
|
|
120
125
|
# `bottom` / `yn` is 12.
|
121
126
|
#
|
122
127
|
# south # => 13
|
123
|
-
# south(2) # => 14
|
124
|
-
# south(-4) # => 8
|
128
|
+
# south(2) # => 14 (positive goes south)
|
129
|
+
# south(-4) # => 8 (negative goes north)
|
125
130
|
#
|
126
131
|
# @param offset [Fixnum]
|
127
132
|
# @return [Fixnum]
|
@@ -135,8 +140,8 @@ module Vedeu
|
|
135
140
|
# `left` / `x` is 8.
|
136
141
|
#
|
137
142
|
# west # => 7
|
138
|
-
# west(2) # => 6
|
139
|
-
# west(-4) # => 12
|
143
|
+
# west(2) # => 6 (positive goes west)
|
144
|
+
# west(-4) # => 12 (negative goes east)
|
140
145
|
#
|
141
146
|
# @param offset [Fixnum]
|
142
147
|
# @return [Fixnum]
|