vedeu 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/dsl/by_method/focus_by_name.md +6 -1
- data/docs/dsl/by_method/focus_next.md +7 -0
- data/docs/dsl/by_method/focus_previous.md +7 -0
- data/docs/events/by_name/mouse_event.md +8 -0
- data/lib/vedeu.rb +12 -0
- data/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/application/controller.rb +2 -6
- data/lib/vedeu/buffers/empty.rb +2 -1
- data/lib/vedeu/cells/borders/vertices/bottom_left.rb +1 -1
- data/lib/vedeu/cells/borders/vertices/bottom_right.rb +1 -1
- data/lib/vedeu/cells/borders/vertices/top_left.rb +1 -1
- data/lib/vedeu/cells/borders/vertices/top_right.rb +1 -1
- data/lib/vedeu/cells/char.rb +2 -6
- data/lib/vedeu/cells/cursor.rb +1 -1
- data/lib/vedeu/cells/support/html.rb +6 -18
- data/lib/vedeu/coercers/all.rb +18 -1
- data/lib/vedeu/coercers/chars.rb +29 -0
- data/lib/vedeu/coercers/coercer.rb +59 -0
- data/lib/vedeu/coercers/colour.rb +15 -33
- data/lib/vedeu/coercers/colour_attributes.rb +8 -3
- data/lib/vedeu/coercers/editor_line.rb +36 -0
- data/lib/vedeu/coercers/editor_lines.rb +36 -0
- data/lib/vedeu/coercers/lines.rb +36 -0
- data/lib/vedeu/coercers/page.rb +52 -0
- data/lib/vedeu/coercers/position.rb +69 -0
- data/lib/vedeu/coercers/row.rb +43 -0
- data/lib/vedeu/coercers/streams.rb +29 -0
- data/lib/vedeu/coercers/style.rb +54 -0
- data/lib/vedeu/configuration/api.rb +10 -0
- data/lib/vedeu/configuration/configuration.rb +11 -0
- data/lib/vedeu/cursors/coordinate.rb +41 -66
- data/lib/vedeu/cursors/cursor.rb +4 -4
- data/lib/vedeu/cursors/reposition.rb +3 -3
- data/lib/vedeu/dsl/border.rb +2 -39
- data/lib/vedeu/dsl/elements.rb +5 -6
- data/lib/vedeu/dsl/geometry.rb +3 -12
- data/lib/vedeu/editor/cropper.rb +2 -1
- data/lib/vedeu/error.rb +4 -0
- data/lib/vedeu/geometries/position.rb +14 -27
- data/lib/vedeu/input/mouse.rb +14 -5
- data/lib/vedeu/input/read.rb +1 -11
- data/lib/vedeu/interfaces/clear.rb +2 -1
- data/lib/vedeu/logging/log.rb +1 -1
- data/lib/vedeu/models/page.rb +5 -23
- data/lib/vedeu/models/row.rb +5 -14
- data/lib/vedeu/models/toggleable.rb +2 -7
- data/lib/vedeu/plugins/plugin.rb +1 -0
- data/lib/vedeu/presentation/style.rb +4 -20
- data/lib/vedeu/renderers/all.rb +24 -10
- data/lib/vedeu/repositories/model.rb +2 -8
- data/lib/vedeu/repositories/registerable.rb +4 -9
- data/lib/vedeu/runtime/application.rb +2 -0
- data/lib/vedeu/runtime/flags.rb +2 -0
- data/lib/vedeu/runtime/router.rb +2 -0
- data/lib/vedeu/support/point.rb +9 -7
- data/lib/vedeu/support/x_coordinate.rb +57 -0
- data/lib/vedeu/support/y_coordinate.rb +57 -0
- data/lib/vedeu/terminal/terminal.rb +2 -0
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/value.rb +3 -12
- data/test/lib/vedeu/coercers/chars_test.rb +33 -0
- data/test/lib/vedeu/coercers/coercer_test.rb +34 -0
- data/test/lib/vedeu/coercers/colour_test.rb +9 -7
- data/test/lib/vedeu/coercers/editor_line_test.rb +40 -0
- data/test/lib/vedeu/coercers/editor_lines_test.rb +40 -0
- data/test/lib/vedeu/coercers/lines_test.rb +40 -0
- data/test/lib/vedeu/coercers/page_test.rb +150 -0
- data/test/lib/vedeu/coercers/position_test.rb +76 -0
- data/test/lib/vedeu/coercers/row_test.rb +64 -0
- data/test/lib/vedeu/coercers/streams_test.rb +33 -0
- data/test/lib/vedeu/coercers/style_test.rb +62 -0
- data/test/lib/vedeu/cursors/coordinate_test.rb +11 -12
- data/test/lib/vedeu/geometries/position_test.rb +10 -54
- data/test/lib/vedeu/input/capture_test.rb +1 -1
- data/test/lib/vedeu/models/page_test.rb +4 -116
- data/test/lib/vedeu/models/row_test.rb +1 -31
- data/test/lib/vedeu/presentation/style_test.rb +4 -38
- data/test/lib/vedeu/renderers/all_test.rb +6 -0
- data/test/lib/vedeu/support/point_test.rb +13 -1
- data/test/lib/vedeu/support/x_coordinate_test.rb +64 -0
- data/test/lib/vedeu/support/y_coordinate_test.rb +64 -0
- data/test/support/examples/material_colours_app.rb +1 -0
- data/vedeu.gemspec +1 -1
- metadata +41 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83b3e4909563317ccf8df15a1f8e0106f27ca00a
|
4
|
+
data.tar.gz: fc3fce16bcc6f5648854b4897b493aaf6b04857e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32aa195136e7b3cbbfa16018dba9c6da366df448e2a4a432c232485808bbad8d0c5dd4f9154d5313ccb9a1867373b607142dad8859a90474c738deca068d2f94
|
7
|
+
data.tar.gz: efdbc099065362fd76ecc407f50915ebad6285b0f36707153fe7a2266f8603be7620aaefb87abb34871730db610527bddfda04783258c51b9bf9051273727019
|
data/lib/vedeu.rb
CHANGED
@@ -44,4 +44,16 @@ module Vedeu
|
|
44
44
|
|
45
45
|
end # Vedeu
|
46
46
|
|
47
|
+
# Define some Yard macros used throughout the project.
|
48
|
+
#
|
49
|
+
# @!macro [new] included_module
|
50
|
+
# Provide additional behaviour to a class or module.
|
51
|
+
#
|
52
|
+
# When a ClassMethods submodule and/or an InstanceMethods submodule
|
53
|
+
# is defined within this module, then provide these methods as
|
54
|
+
# class or instance methods to the including class or module.
|
55
|
+
#
|
56
|
+
# @param klass [Class]
|
57
|
+
# @return [void]
|
58
|
+
|
47
59
|
require 'vedeu/all'
|
data/lib/vedeu/all.rb
CHANGED
@@ -6,7 +6,7 @@ module Vedeu
|
|
6
6
|
#
|
7
7
|
module Controller
|
8
8
|
|
9
|
-
#
|
9
|
+
# Provide additional behaviour as class methods.
|
10
10
|
#
|
11
11
|
module ClassMethods
|
12
12
|
|
@@ -75,11 +75,7 @@ module Vedeu
|
|
75
75
|
|
76
76
|
end # ClassMethods
|
77
77
|
|
78
|
-
#
|
79
|
-
# class methods for the class.
|
80
|
-
#
|
81
|
-
# @param klass [Class]
|
82
|
-
# @return [void]
|
78
|
+
# @macro included_module
|
83
79
|
def self.included(klass)
|
84
80
|
klass.extend(Vedeu::Controller::ClassMethods)
|
85
81
|
end
|
data/lib/vedeu/buffers/empty.rb
CHANGED
@@ -58,7 +58,8 @@ module Vedeu
|
|
58
58
|
def empty
|
59
59
|
Array.new(height) do |h|
|
60
60
|
Array.new(width) do |w|
|
61
|
-
Vedeu::
|
61
|
+
position = Vedeu::Geometries::Position.new((y + h), (x + w))
|
62
|
+
Vedeu::Cells::Empty.new(name: name, position: position)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
data/lib/vedeu/cells/char.rb
CHANGED
data/lib/vedeu/cells/cursor.rb
CHANGED
@@ -39,13 +39,9 @@ module Vedeu
|
|
39
39
|
|
40
40
|
# @return [String]
|
41
41
|
def background
|
42
|
-
|
43
|
-
cell.background.to_html
|
42
|
+
return '' unless cell.respond_to?(:background)
|
44
43
|
|
45
|
-
|
46
|
-
''
|
47
|
-
|
48
|
-
end
|
44
|
+
cell.background.to_html
|
49
45
|
end
|
50
46
|
|
51
47
|
# @return [String]
|
@@ -55,13 +51,9 @@ module Vedeu
|
|
55
51
|
|
56
52
|
# @return [String]
|
57
53
|
def foreground
|
58
|
-
|
59
|
-
cell.foreground.to_html
|
60
|
-
|
61
|
-
else
|
62
|
-
''
|
54
|
+
return '' unless cell.respond_to?(:foreground)
|
63
55
|
|
64
|
-
|
56
|
+
cell.foreground.to_html
|
65
57
|
end
|
66
58
|
|
67
59
|
# @return [String]
|
@@ -71,13 +63,9 @@ module Vedeu
|
|
71
63
|
|
72
64
|
# @return [String]
|
73
65
|
def style_attribute
|
74
|
-
if absent?(background) && absent?(foreground)
|
75
|
-
''
|
76
|
-
|
77
|
-
else
|
78
|
-
" style='#{background}#{foreground}'"
|
66
|
+
return '' if absent?(background) && absent?(foreground)
|
79
67
|
|
80
|
-
|
68
|
+
" style='#{background}#{foreground}'"
|
81
69
|
end
|
82
70
|
|
83
71
|
# @return [String]
|
data/lib/vedeu/coercers/all.rb
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
# Provides a mechanism to coerce values within Vedeu
|
5
|
+
# Provides a mechanism to coerce values within Vedeu in to expected
|
6
|
+
# objects.
|
7
|
+
#
|
8
|
+
# @api private
|
6
9
|
#
|
7
10
|
module Coercers
|
8
11
|
|
@@ -10,9 +13,23 @@ module Vedeu
|
|
10
13
|
|
11
14
|
end # Vedeu
|
12
15
|
|
16
|
+
require 'vedeu/coercers/coercer'
|
17
|
+
|
13
18
|
require 'vedeu/coercers/alignment'
|
14
19
|
require 'vedeu/coercers/horizontal_alignment'
|
15
20
|
require 'vedeu/coercers/vertical_alignment'
|
16
21
|
|
22
|
+
require 'vedeu/coercers/chars'
|
23
|
+
|
17
24
|
require 'vedeu/coercers/colour'
|
18
25
|
require 'vedeu/coercers/colour_attributes'
|
26
|
+
|
27
|
+
require 'vedeu/coercers/editor_line'
|
28
|
+
require 'vedeu/coercers/editor_lines'
|
29
|
+
|
30
|
+
require 'vedeu/coercers/lines'
|
31
|
+
require 'vedeu/coercers/page'
|
32
|
+
require 'vedeu/coercers/position'
|
33
|
+
require 'vedeu/coercers/row'
|
34
|
+
require 'vedeu/coercers/streams'
|
35
|
+
require 'vedeu/coercers/style'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Coercers
|
6
|
+
|
7
|
+
# Provides the mechanism to convert a value into a
|
8
|
+
# {Vedeu::Views::Chars}.
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
#
|
12
|
+
class Chars < Vedeu::Coercers::Coercer
|
13
|
+
|
14
|
+
# @return [void]
|
15
|
+
def coerce
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @return [Class]
|
21
|
+
def klass
|
22
|
+
Vedeu::Views::Chars
|
23
|
+
end
|
24
|
+
|
25
|
+
end # Chars
|
26
|
+
|
27
|
+
end # Coercers
|
28
|
+
|
29
|
+
end # Vedeu
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Coercers
|
6
|
+
|
7
|
+
# Provides the mechanism to convert a value into another value.
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
#
|
11
|
+
class Coercer
|
12
|
+
|
13
|
+
include Vedeu::Common
|
14
|
+
|
15
|
+
# @param (see #initialize)
|
16
|
+
# @return (see #coerce)
|
17
|
+
def self.coerce(value)
|
18
|
+
new(value).coerce
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns a new instance of the Vedeu::Coercers::Coercer
|
22
|
+
# subclass.
|
23
|
+
#
|
24
|
+
# @param value [void]
|
25
|
+
# @return [Vedeu::Coercers::Coercer]
|
26
|
+
def initialize(value)
|
27
|
+
@value = value
|
28
|
+
end
|
29
|
+
|
30
|
+
# @macro raise_not_implemented
|
31
|
+
# @return [void]
|
32
|
+
def coerce
|
33
|
+
fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
# @!attribute [r] value
|
39
|
+
# @return [void]
|
40
|
+
attr_reader :value
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# @return [Boolean]
|
45
|
+
def coerced?
|
46
|
+
value.is_a?(klass)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @macro raise_not_implemented
|
50
|
+
# @return [Class]
|
51
|
+
def klass
|
52
|
+
fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'
|
53
|
+
end
|
54
|
+
|
55
|
+
end # Coercer
|
56
|
+
|
57
|
+
end # Coercers
|
58
|
+
|
59
|
+
end # Vedeu
|
@@ -9,40 +9,28 @@ module Vedeu
|
|
9
9
|
#
|
10
10
|
# @api private
|
11
11
|
#
|
12
|
-
class Colour
|
12
|
+
class Colour < Vedeu::Coercers::Coercer
|
13
13
|
|
14
14
|
include Vedeu::Common
|
15
15
|
|
16
|
-
# @
|
17
|
-
# @return (see #coerce)
|
18
|
-
def self.coerce(value)
|
19
|
-
new(value).coerce
|
20
|
-
end
|
21
|
-
|
22
|
-
# @param value [void]
|
23
|
-
# @return [Vedeu::Coercers::Colour]
|
24
|
-
def initialize(value)
|
25
|
-
@value = value
|
26
|
-
end
|
27
|
-
|
28
|
-
# @raise [Vedeu::Error::Fatal] When the value cannot be coerced.
|
16
|
+
# @macro raise_fatal
|
29
17
|
# @return [void]
|
30
18
|
def coerce
|
31
|
-
if
|
32
|
-
|
19
|
+
if coerced?
|
20
|
+
value
|
33
21
|
|
34
|
-
elsif
|
35
|
-
|
22
|
+
elsif absent?(value)
|
23
|
+
klass.new
|
36
24
|
|
37
|
-
elsif
|
38
|
-
value
|
25
|
+
elsif background?
|
26
|
+
klass.new(background: value)
|
39
27
|
|
40
28
|
elsif foreground?
|
41
|
-
|
29
|
+
klass.new(foreground: value)
|
42
30
|
|
43
31
|
elsif hash?(value)
|
44
32
|
attributes = Vedeu::Coercers::ColourAttributes.coerce(value)
|
45
|
-
|
33
|
+
klass.new(attributes)
|
46
34
|
|
47
35
|
else
|
48
36
|
fail Vedeu::Error::Fatal, 'Vedeu cannot coerce this colour.'
|
@@ -50,12 +38,6 @@ module Vedeu
|
|
50
38
|
end
|
51
39
|
end
|
52
40
|
|
53
|
-
protected
|
54
|
-
|
55
|
-
# @!attribute [r] value
|
56
|
-
# @return [void]
|
57
|
-
attr_reader :value
|
58
|
-
|
59
41
|
private
|
60
42
|
|
61
43
|
# @return [Boolean]
|
@@ -63,16 +45,16 @@ module Vedeu
|
|
63
45
|
value.is_a?(Vedeu::Colours::Background)
|
64
46
|
end
|
65
47
|
|
66
|
-
# @return [Boolean]
|
67
|
-
def colour?
|
68
|
-
value.is_a?(Vedeu::Colours::Colour)
|
69
|
-
end
|
70
|
-
|
71
48
|
# @return [Boolean]
|
72
49
|
def foreground?
|
73
50
|
value.is_a?(Vedeu::Colours::Foreground)
|
74
51
|
end
|
75
52
|
|
53
|
+
# @return [Class]
|
54
|
+
def klass
|
55
|
+
Vedeu::Colours::Colour
|
56
|
+
end
|
57
|
+
|
76
58
|
end # Colour
|
77
59
|
|
78
60
|
end # Coercers
|
@@ -33,7 +33,7 @@ module Vedeu
|
|
33
33
|
if colour? && hash?(colour)
|
34
34
|
Vedeu::Coercers::ColourAttributes.coerce(colour)
|
35
35
|
|
36
|
-
elsif colour? &&
|
36
|
+
elsif colour? && coerced?(colour)
|
37
37
|
colour.attributes
|
38
38
|
|
39
39
|
else
|
@@ -52,8 +52,8 @@ module Vedeu
|
|
52
52
|
|
53
53
|
# @param colour [void]
|
54
54
|
# @return [Boolean]
|
55
|
-
def
|
56
|
-
colour.is_a?(
|
55
|
+
def coerced?(colour)
|
56
|
+
colour.is_a?(klass)
|
57
57
|
end
|
58
58
|
|
59
59
|
# @return [Hash]
|
@@ -104,6 +104,11 @@ module Vedeu
|
|
104
104
|
valid?(foreground)
|
105
105
|
end
|
106
106
|
|
107
|
+
# @return [Class]
|
108
|
+
def klass
|
109
|
+
Vedeu::Colours::Colour
|
110
|
+
end
|
111
|
+
|
107
112
|
# @param colour [void]
|
108
113
|
# @return [Boolean]
|
109
114
|
def valid?(colour)
|