vedeu 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +6 -0
  4. data/bin/vedeu_drb_client +8 -3
  5. data/bin/vedeu_drb_server +113 -0
  6. data/bin/vedeu_test +1 -1
  7. data/docs/events.md +0 -127
  8. data/examples/borders_app.rb +17 -7
  9. data/examples/configuration_app.rb +1 -1
  10. data/examples/cursor_app.rb +4 -2
  11. data/examples/drb_app.rb +113 -0
  12. data/examples/focus_app.rb +1 -1
  13. data/examples/geometry_app.rb +1 -1
  14. data/examples/hello_world.rb +1 -1
  15. data/examples/lines_app.rb +1 -1
  16. data/features/start_stop.feature +1 -1
  17. data/inch.yml +5 -0
  18. data/lib/vedeu/all.rb +2 -0
  19. data/lib/vedeu/api.rb +1 -0
  20. data/lib/vedeu/application.rb +17 -36
  21. data/lib/vedeu/bindings.rb +134 -27
  22. data/lib/vedeu/buffers/display_buffer.rb +1 -4
  23. data/lib/vedeu/configuration/api.rb +15 -14
  24. data/lib/vedeu/configuration/cli.rb +17 -16
  25. data/lib/vedeu/configuration/configuration.rb +3 -1
  26. data/lib/vedeu/cursor/cursor.rb +6 -8
  27. data/lib/vedeu/cursor/move_cursor.rb +1 -0
  28. data/lib/vedeu/cursor/toggle_cursor.rb +1 -0
  29. data/lib/vedeu/debug.rb +23 -0
  30. data/lib/vedeu/distributed/all.rb +1 -1
  31. data/lib/vedeu/distributed/client.rb +55 -13
  32. data/lib/vedeu/distributed/server.rb +207 -0
  33. data/lib/vedeu/distributed/subprocess.rb +22 -21
  34. data/lib/vedeu/distributed/templates/default_application.vedeu +3 -1
  35. data/lib/vedeu/distributed/test_application.rb +2 -1
  36. data/lib/vedeu/distributed/uri.rb +1 -0
  37. data/lib/vedeu/dsl/all.rb +4 -2
  38. data/lib/vedeu/dsl/components/border.rb +11 -10
  39. data/lib/vedeu/dsl/components/geometry.rb +1 -0
  40. data/lib/vedeu/dsl/components/keymap.rb +1 -0
  41. data/lib/vedeu/dsl/components/menu.rb +1 -0
  42. data/lib/vedeu/dsl/interface.rb +1 -0
  43. data/lib/vedeu/dsl/line.rb +3 -1
  44. data/lib/vedeu/dsl/shared/colour.rb +1 -0
  45. data/lib/vedeu/dsl/shared/style.rb +1 -0
  46. data/lib/vedeu/dsl/shared/text.rb +2 -0
  47. data/lib/vedeu/dsl/shared/use.rb +3 -0
  48. data/lib/vedeu/dsl/stream.rb +3 -1
  49. data/lib/vedeu/dsl/view.rb +1 -0
  50. data/lib/vedeu/events/event.rb +9 -6
  51. data/lib/vedeu/events/trigger.rb +18 -7
  52. data/lib/vedeu/exceptions.rb +4 -1
  53. data/lib/vedeu/input/input.rb +1 -0
  54. data/lib/vedeu/input/key.rb +0 -1
  55. data/lib/vedeu/input/keymap.rb +5 -3
  56. data/lib/vedeu/input/keys.rb +1 -0
  57. data/lib/vedeu/input/mapper.rb +1 -0
  58. data/lib/vedeu/launcher.rb +35 -12
  59. data/lib/vedeu/main_loop.rb +53 -0
  60. data/lib/vedeu/models/collection.rb +11 -3
  61. data/lib/vedeu/models/focus.rb +3 -3
  62. data/lib/vedeu/models/geometry.rb +8 -16
  63. data/lib/vedeu/models/group.rb +1 -0
  64. data/lib/vedeu/models/menu.rb +2 -1
  65. data/lib/vedeu/models/model.rb +7 -1
  66. data/lib/vedeu/models/view/char.rb +52 -44
  67. data/lib/vedeu/models/view/chars.rb +1 -0
  68. data/lib/vedeu/models/view/composition.rb +2 -1
  69. data/lib/vedeu/models/view/interface.rb +5 -3
  70. data/lib/vedeu/models/view/interfaces.rb +1 -0
  71. data/lib/vedeu/models/view/line.rb +2 -1
  72. data/lib/vedeu/models/view/stream.rb +2 -1
  73. data/lib/vedeu/models/view/streams.rb +1 -0
  74. data/lib/vedeu/output/all.rb +4 -0
  75. data/lib/vedeu/output/border.rb +75 -206
  76. data/lib/vedeu/output/compositor.rb +1 -0
  77. data/lib/vedeu/output/html_char.rb +119 -0
  78. data/lib/vedeu/output/html_renderer.rb +89 -0
  79. data/lib/vedeu/output/output.rb +48 -44
  80. data/lib/vedeu/output/position_index.rb +12 -1
  81. data/lib/vedeu/output/renderer.rb +28 -0
  82. data/lib/vedeu/output/viewport.rb +14 -14
  83. data/lib/vedeu/output/virtual_buffer.rb +56 -0
  84. data/lib/vedeu/output/virtual_terminal.rb +42 -34
  85. data/lib/vedeu/output/wordwrap.rb +3 -0
  86. data/lib/vedeu/output/writer.rb +13 -1
  87. data/lib/vedeu/presentation/background.rb +1 -0
  88. data/lib/vedeu/presentation/colour.rb +8 -7
  89. data/lib/vedeu/presentation/foreground.rb +1 -0
  90. data/lib/vedeu/presentation/presentation.rb +43 -7
  91. data/lib/vedeu/presentation/translator.rb +12 -0
  92. data/lib/vedeu/repositories/repository.rb +8 -8
  93. data/lib/vedeu/support/bounding_area.rb +2 -0
  94. data/lib/vedeu/support/coercions.rb +2 -1
  95. data/lib/vedeu/support/common.rb +1 -0
  96. data/lib/vedeu/support/console.rb +17 -23
  97. data/lib/vedeu/support/content_geometry.rb +2 -0
  98. data/lib/vedeu/support/coordinate.rb +1 -0
  99. data/lib/vedeu/support/esc.rb +58 -29
  100. data/lib/vedeu/support/grid.rb +1 -0
  101. data/lib/vedeu/support/limit.rb +9 -0
  102. data/lib/vedeu/support/log.rb +31 -9
  103. data/lib/vedeu/support/node.rb +8 -18
  104. data/lib/vedeu/support/position.rb +13 -34
  105. data/lib/vedeu/support/position_validator.rb +3 -0
  106. data/lib/vedeu/support/read.rb +1 -0
  107. data/lib/vedeu/support/refresh.rb +3 -2
  108. data/lib/vedeu/support/terminal.rb +11 -5
  109. data/lib/vedeu/support/trace.rb +16 -1
  110. data/lib/vedeu/support/visible.rb +2 -0
  111. data/lib/vedeu/support/write.rb +1 -0
  112. data/lib/vedeu/traps.rb +1 -0
  113. data/lib/vedeu.rb +2 -0
  114. data/test/integration/distributed_test.rb +10 -8
  115. data/test/lib/vedeu/api_test.rb +3 -7
  116. data/test/lib/vedeu/application_test.rb +2 -5
  117. data/test/lib/vedeu/configuration/api_test.rb +12 -0
  118. data/test/lib/vedeu/cursor/cursor_test.rb +2 -0
  119. data/test/lib/vedeu/distributed/client_test.rb +17 -7
  120. data/test/lib/vedeu/distributed/server_test.rb +56 -0
  121. data/test/lib/vedeu/distributed/test_application_test.rb +7 -3
  122. data/test/lib/vedeu/dsl/components/border_test.rb +10 -2
  123. data/test/lib/vedeu/dsl/interface_test.rb +6 -0
  124. data/test/lib/vedeu/dsl/line_test.rb +19 -0
  125. data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -26
  126. data/test/lib/vedeu/dsl/shared/text_test.rb +8 -1
  127. data/test/lib/vedeu/dsl/stream_test.rb +13 -1
  128. data/test/lib/vedeu/input/input_test.rb +1 -1
  129. data/test/lib/vedeu/input/key_test.rb +3 -16
  130. data/test/lib/vedeu/launcher_test.rb +11 -1
  131. data/test/lib/vedeu/main_loop_test.rb +41 -0
  132. data/test/lib/vedeu/models/geometry_test.rb +15 -34
  133. data/test/lib/vedeu/models/view/char_test.rb +44 -45
  134. data/test/lib/vedeu/models/view/interface_test.rb +6 -0
  135. data/test/lib/vedeu/models/view/line_test.rb +1 -1
  136. data/test/lib/vedeu/models/view/stream_test.rb +1 -1
  137. data/test/lib/vedeu/output/border_test.rb +6 -5
  138. data/test/lib/vedeu/output/compositor_test.rb +2 -20
  139. data/test/lib/vedeu/output/html_char_test.rb +85 -0
  140. data/test/lib/vedeu/output/html_renderer_test.rb +37 -0
  141. data/test/lib/vedeu/output/position_index_test.rb +2 -10
  142. data/test/lib/vedeu/output/renderer_test.rb +24 -0
  143. data/test/lib/vedeu/output/virtual_buffer_test.rb +53 -0
  144. data/test/lib/vedeu/output/virtual_terminal_test.rb +32 -2
  145. data/test/lib/vedeu/presentation/background_test.rb +41 -1
  146. data/test/lib/vedeu/presentation/colour_test.rb +10 -6
  147. data/test/lib/vedeu/presentation/foreground_test.rb +46 -6
  148. data/test/lib/vedeu/presentation/presentation_test.rb +44 -1
  149. data/test/lib/vedeu/presentation/translator_test.rb +34 -0
  150. data/test/lib/vedeu/repositories/repository_test.rb +1 -1
  151. data/test/lib/vedeu/support/bounding_area_test.rb +4 -12
  152. data/test/lib/vedeu/support/console_test.rb +9 -50
  153. data/test/lib/vedeu/support/esc_test.rb +7 -7
  154. data/test/lib/vedeu/support/position_test.rb +42 -0
  155. data/test/lib/vedeu/support/terminal_test.rb +5 -20
  156. data/test/lib/vedeu/support/write_test.rb +42 -18
  157. data/test/support/helpers/all.rb +0 -1
  158. data/test/support/helpers/repository_test_module.rb +1 -0
  159. data/test/test_helper.rb +5 -2
  160. data/vedeu.gemspec +7 -5
  161. metadata +60 -14
  162. data/lib/vedeu/distributed/application.rb +0 -91
  163. data/test/lib/vedeu/distributed/application_test.rb +0 -24
  164. data/test/support/helpers/presentation.rb +0 -16
@@ -1,3 +1,4 @@
1
+ require 'vedeu/output/html_char'
1
2
  require 'vedeu/presentation/presentation'
2
3
 
3
4
  module Vedeu
@@ -9,58 +10,34 @@ module Vedeu
9
10
  # character is returned in the escape sequence.
10
11
  #
11
12
  # @api private
13
+ #
12
14
  class Char
13
15
 
14
16
  include Vedeu::Presentation
15
17
 
16
- attr_accessor :parent,
18
+ attr_accessor :border,
19
+ :parent,
17
20
  :position
18
21
 
19
- class << self
20
-
21
- # @param value []
22
- # @param parent []
23
- # @param colour []
24
- # @param style []
25
- # @param position []
26
- # @return [Vedeu::Char]
27
- def coerce(value = nil, parent = nil, colour = nil, style = nil, position = nil)
28
- if value.is_a?(self)
29
- value
30
-
31
- elsif value.is_a?(Array)
32
- if value.first.is_a?(self)
33
- value
34
-
35
- elsif value.first.is_a?(String)
36
- value.map { |char| new(char, parent, colour, style, position) }
37
-
38
- else
39
- # ...
40
-
41
- end
42
- else
43
- # ...
44
-
45
- end
46
- end
47
-
48
- end
49
-
50
22
  # Returns a new instance of Char.
51
23
  #
52
- # @param value [String]
53
- # @param parent [Line]
54
- # @param colour [Colour]
55
- # @param style [Style]
56
- # @param position [Position]
24
+ # @param attributes [Hash]
25
+ # @option attributes value [String]
26
+ # @option attributes parent [Line]
27
+ # @option attributes colour [Colour]
28
+ # @option attributes style [Style]
29
+ # @option attributes position [Position]
30
+ # @option attributes border [Boolean]
57
31
  # @return [Char]
58
- def initialize(value = nil, parent = nil, colour = nil, style = nil, position = nil)
59
- @value = value
60
- @parent = parent
61
- @colour = Vedeu::Colour.coerce(colour)
62
- @style = style
63
- @position = Vedeu::Position.coerce(position)
32
+ def initialize(attributes = {})
33
+ @attributes = defaults.merge(attributes)
34
+
35
+ @border = @attributes[:border]
36
+ @colour = Vedeu::Colour.coerce(@attributes[:colour])
37
+ @parent = @attributes[:parent]
38
+ @position = Vedeu::Position.coerce(@attributes[:position])
39
+ @style = @attributes[:style]
40
+ @value = @attributes[:value]
64
41
  end
65
42
 
66
43
  # Returns log friendly output.
@@ -86,7 +63,38 @@ module Vedeu
86
63
  def value
87
64
  return '' unless @value
88
65
 
89
- @value[0]
66
+ @value
67
+ end
68
+
69
+ # @return [Fixnum|NilClass]
70
+ def x
71
+ position.x if position
72
+ end
73
+
74
+ # @return [Fixnum|NilClass]
75
+ def y
76
+ position.y if position
77
+ end
78
+
79
+ # @return [String]
80
+ def to_html
81
+ @to_html ||= HTMLChar.render(self)
82
+ end
83
+
84
+ private
85
+
86
+ # The default values for a new instance of this class.
87
+ #
88
+ # @return [Hash]
89
+ def defaults
90
+ {
91
+ border: nil,
92
+ colour: nil,
93
+ parent: nil,
94
+ position: nil,
95
+ style: nil,
96
+ value: nil,
97
+ }
90
98
  end
91
99
 
92
100
  end # Char
@@ -3,6 +3,7 @@ require 'vedeu/models/collection'
3
3
  module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Char} instances.
6
+ #
6
7
  class Chars < Vedeu::Model::Collection
7
8
  end # Chars
8
9
 
@@ -11,6 +11,7 @@ module Vedeu
11
11
  # A composition is a collection of interfaces.
12
12
  #
13
13
  # @api private
14
+ #
14
15
  class Composition
15
16
 
16
17
  include Vedeu::Presentation
@@ -37,7 +38,7 @@ module Vedeu
37
38
  end
38
39
 
39
40
  # @param child [Vedeu::Interface]
40
- # @return []
41
+ # @return [void]
41
42
  def add(child)
42
43
  @interfaces = interfaces.add(child)
43
44
  end
@@ -45,8 +45,7 @@ module Vedeu
45
45
  :left,
46
46
  :width,
47
47
  :height,
48
- :origin,
49
- :raw_origin
48
+ :origin
50
49
 
51
50
  # Return a new instance of Interface.
52
51
  #
@@ -73,11 +72,14 @@ module Vedeu
73
72
  end
74
73
 
75
74
  # @param child []
76
- # @return []
75
+ # @return [void]
77
76
  def add(child)
78
77
  @lines = lines.add(child)
79
78
  end
80
79
 
80
+ # @note
81
+ # This may be unused. (GL 2015-02-20)
82
+ #
81
83
  # @return [Hash]
82
84
  def attributes
83
85
  {
@@ -3,6 +3,7 @@ require 'vedeu/models/collection'
3
3
  module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Interface} instances.
6
+ #
6
7
  class Interfaces < Vedeu::Model::Collection
7
8
  end # Interfaces
8
9
 
@@ -10,6 +10,7 @@ module Vedeu
10
10
  # {Vedeu::Interface} it belongs to.
11
11
  #
12
12
  # @api private
13
+ #
13
14
  class Line
14
15
 
15
16
  include Vedeu::Model
@@ -39,7 +40,7 @@ module Vedeu
39
40
  end
40
41
 
41
42
  # @param child []
42
- # @return []
43
+ # @return [void]
43
44
  def add(child)
44
45
  @streams = streams.add(child)
45
46
  end
@@ -8,6 +8,7 @@ module Vedeu
8
8
  # characters in that line.
9
9
  #
10
10
  # @api private
11
+ #
11
12
  class Stream
12
13
 
13
14
  include Vedeu::Model
@@ -56,7 +57,7 @@ module Vedeu
56
57
  return [] if value.empty?
57
58
 
58
59
  value.chars.map do |char|
59
- member.new(char, parent, colour, style, nil).to_s
60
+ member.new({ value: char, parent: parent, colour: colour, style: style, position: nil }).to_s
60
61
  end
61
62
  end
62
63
 
@@ -3,6 +3,7 @@ require 'vedeu/models/collection'
3
3
  module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Stream} instances.
6
+ #
6
7
  class Streams < Vedeu::Model::Collection
7
8
  end # Streams
8
9
 
@@ -1,6 +1,10 @@
1
1
  require 'vedeu/output/border'
2
2
  require 'vedeu/output/compositor'
3
3
  require 'vedeu/output/position_index'
4
+ require 'vedeu/output/virtual_buffer'
5
+ require 'vedeu/output/html_char'
6
+ require 'vedeu/output/html_renderer'
7
+ require 'vedeu/output/renderer'
4
8
  require 'vedeu/output/output'
5
9
  require 'vedeu/output/viewport'
6
10
  require 'vedeu/output/virtual_terminal'
@@ -14,29 +14,67 @@ module Vedeu
14
14
 
15
15
  include Vedeu::Model
16
16
 
17
- attr_accessor :attributes
18
- attr_reader :name
17
+ attr_accessor :attributes,
18
+ :bottom_left,
19
+ :bottom_right,
20
+ :horizontal,
21
+ :show_bottom,
22
+ :show_left,
23
+ :show_right,
24
+ :show_top,
25
+ :top_left,
26
+ :top_right,
27
+ :vertical
28
+
29
+ attr_reader :name,
30
+ :colour,
31
+ :enabled,
32
+ :style
33
+
34
+ alias_method :enabled?, :enabled
35
+ alias_method :bottom?, :show_bottom
36
+ alias_method :left?, :show_left
37
+ alias_method :right?, :show_right
38
+ alias_method :top?, :show_top
19
39
 
20
40
  # Returns a new instance of Border.
21
41
  #
22
42
  # @param attributes [Hash]
23
- # @option attributes bottom_left [String]
24
- # @option attributes bottom_right [String]
43
+ # @option attributes bottom_left [String] The bottom left border character.
44
+ # @option attributes bottom_right [String] The bottom right border
45
+ # character.
25
46
  # @option attributes colour
26
- # @option attributes enabled [Boolean]
27
- # @option attributes horizontal [String]
47
+ # @option attributes enabled [Boolean] Indicate whether the border is to be
48
+ # shown for this interface.
49
+ # @option attributes horizontal [String] The horizontal border character.
28
50
  # @option attributes name [String]
29
51
  # @option attributes style
30
- # @option attributes show_bottom [Boolean]
31
- # @option attributes show_left [Boolean]
32
- # @option attributes show_right [Boolean]
33
- # @option attributes show_top [Boolean]
34
- # @option attributes top_left [String]
35
- # @option attributes top_right [String]
36
- # @option attributes vertical [String]
52
+ # @option attributes show_bottom [Boolean] Indicate whether the bottom
53
+ # border is to be shown.
54
+ # @option attributes show_left [Boolean] Indicate whether the left border
55
+ # is to be shown.
56
+ # @option attributes show_right [Boolean] Indicate whether the right border
57
+ # is to be shown.
58
+ # @option attributes show_top [Boolean] Indicate whether the top border is
59
+ # to be shown.
60
+ # @option attributes top_left [String] The top left border character.
61
+ # @option attributes top_right [String] The top right border character.
62
+ # @option attributes vertical [String] The vertical border character.
37
63
  # @return [Border]
38
64
  def initialize(attributes = {})
39
65
  @attributes = defaults.merge(attributes)
66
+
67
+ @enabled = @attributes[:enabled]
68
+ @bottom_left = @attributes[:bottom_left]
69
+ @bottom_right = @attributes[:bottom_right]
70
+ @show_bottom = @attributes[:show_bottom]
71
+ @show_left = @attributes[:show_left]
72
+ @show_right = @attributes[:show_right]
73
+ @show_top = @attributes[:show_top]
74
+ @top_left = @attributes[:top_left]
75
+ @top_right = @attributes[:top_right]
76
+ @horizontal = @attributes[:horizontal]
77
+ @vertical = @attributes[:vertical]
40
78
  @name = @attributes[:name]
41
79
  @colour = Colour.coerce(@attributes[:colour])
42
80
  @repository = Vedeu.borders
@@ -81,24 +119,6 @@ module Vedeu
81
119
  end
82
120
  end
83
121
 
84
- # Returns the interface with border (if enabled) and the content for the
85
- # interface.
86
- #
87
- # @return [Array<Array<String>>]
88
- def render
89
- out = []
90
-
91
- out << top if top?
92
-
93
- interface.viewport[0...height].each do |line|
94
- out << [left, line[0...width], right].flatten
95
- end
96
-
97
- out << bottom if bottom?
98
-
99
- out
100
- end
101
-
102
122
  # Set the border colour.
103
123
  #
104
124
  # @return [Vedeu::Colour]
@@ -113,42 +133,6 @@ module Vedeu
113
133
  @style = Style.coerce(value)
114
134
  end
115
135
 
116
- # Returns a boolean indicating whether the border is to be shown for this
117
- # interface.
118
- #
119
- # @return [Boolean]
120
- def enabled?
121
- attributes[:enabled]
122
- end
123
-
124
- # Returns a boolean indicating whether the bottom border is to be shown.
125
- #
126
- # @return [Boolean]
127
- def bottom?
128
- attributes[:show_bottom]
129
- end
130
-
131
- # Returns a boolean indicating whether the left border is to be shown.
132
- #
133
- # @return [Boolean]
134
- def left?
135
- attributes[:show_left]
136
- end
137
-
138
- # Returns a boolean indicating whether the right border is to be shown.
139
- #
140
- # @return [Boolean]
141
- def right?
142
- attributes[:show_right]
143
- end
144
-
145
- # Returns a boolean indicating whether the top border is to be shown.
146
- #
147
- # @return [Boolean]
148
- def top?
149
- attributes[:show_top]
150
- end
151
-
152
136
  # Returns a string representation of the border for the interface without
153
137
  # content.
154
138
  #
@@ -166,31 +150,31 @@ module Vedeu
166
150
 
167
151
  out = []
168
152
 
169
- out << bottom_left
170
- horizontal_border.each do |border|
171
- out << border
153
+ out << border(bottom_left, :bottom_left) if left?
154
+ width.times do
155
+ out << border(horizontal, :bottom_horizontal)
172
156
  end
173
- out << bottom_right
157
+ out << border(bottom_right, :bottom_right) if right?
174
158
 
175
- out
159
+ out.flatten
176
160
  end
177
161
 
178
162
  # Renders the left border for the interface.
179
163
  #
180
164
  # @return [String]
181
165
  def left
182
- return '' unless left?
166
+ return [] unless left?
183
167
 
184
- vertical_border
168
+ border(vertical, :left_vertical)
185
169
  end
186
170
 
187
171
  # Renders the right border for the interface.
188
172
  #
189
173
  # @return [String]
190
174
  def right
191
- return '' unless right?
175
+ return [] unless right?
192
176
 
193
- vertical_border
177
+ border(vertical, :right_vertical)
194
178
  end
195
179
 
196
180
  # Renders the top border for the interface.
@@ -200,142 +184,27 @@ module Vedeu
200
184
  return [] unless top?
201
185
 
202
186
  out = []
203
- out << top_left
204
- horizontal_border.each do |border|
205
- out << border
187
+ out << border(top_left, :top_left) if left?
188
+ width.times do
189
+ out << border(horizontal, :top_horizontal)
206
190
  end
207
- out << top_right
191
+ out << border(top_right, :top_right) if right?
208
192
 
209
- out
193
+ out.flatten
210
194
  end
211
195
 
212
196
  private
213
197
 
214
- attr_reader :colour, :style
215
-
216
- # Renders the bottom left border character with escape codes for colour and
217
- # style for the interface.
218
- #
219
- # @return [String]
220
- def bottom_left
221
- return '' unless left?
222
-
223
- [*presentation, on, bl, off, *reset].join
224
- end
225
-
226
- # Renders the bottom right border character with escape codes for colour and
227
- # style for the interface.
228
- #
229
- # @return [String]
230
- def bottom_right
231
- return '' unless right?
232
-
233
- [*presentation, on, br, off, *reset].join
234
- end
235
-
236
- # Renders the top left border character with escape codes for colour and
237
- # style for the interface.
238
- #
239
- # @return [String]
240
- def top_left
241
- return '' unless left?
242
-
243
- [*presentation, on, tl, off, *reset].join
244
- end
245
-
246
- # Renders the top right border character with escape codes for colour and
247
- # style for the interface.
248
- #
249
- # @return [String]
250
- def top_right
251
- return '' unless right?
252
-
253
- [*presentation, on, tr, off, *reset].join
254
- end
255
-
256
- # Returns the horizontal border characters with colours and styles.
257
- #
258
- # @return [Array<String>]
259
- def horizontal_border
260
- [[*presentation, on, h, off, *reset].join] * width
261
- end
262
-
263
- # Returns the vertical border characters with colours and styles.
264
- #
265
- # @return [String]
266
- def vertical_border
267
- [*presentation, on, v, off, *reset].join
268
- end
269
-
270
- # Returns the horizontal border character.
271
- #
272
- # @return [String]
273
- def h
274
- attributes[:horizontal]
275
- end
276
-
277
- # Returns the vertical border character.
278
- #
279
- # @return [String]
280
- def v
281
- attributes[:vertical]
282
- end
283
-
284
- # Returns the top right border character.
285
- #
286
- # @return [String]
287
- def tr
288
- attributes[:top_right]
289
- end
290
-
291
- # Returns the top left border character.
292
- #
293
- # @return [String]
294
- def tl
295
- attributes[:top_left]
296
- end
297
-
298
- # Returns the bottom right border character.
299
- #
300
- # @return [String]
301
- def br
302
- attributes[:bottom_right]
303
- end
304
-
305
- # Returns the bottom left border character.
306
- #
307
- # @return [String]
308
- def bl
309
- attributes[:bottom_left]
310
- end
311
-
312
- # Returns the escape sequence to start a border.
313
- #
314
- # @return [String]
315
- def on
316
- "\e(0"
317
- end
318
-
319
- # Returns the escape sequence to end a border.
320
- #
321
- # @return [String]
322
- def off
323
- "\e(B"
324
- end
325
-
326
- # Returns the colour and styles for the border.
327
- #
328
- # @return [Array]
329
- def presentation
330
- [colour, style]
331
- end
332
-
333
- # Returns the colour and styles for the interface; effectively turning off
334
- # the colours and styles for the border.
335
- #
336
- # @return [Array]
337
- def reset
338
- [interface.colour, interface.style]
198
+ # @param value [String]
199
+ # @param type [Symbol|NilClass]
200
+ # @return [Vedeu::Char]
201
+ def border(value, type = :border)
202
+ Vedeu::Char.new({ value: value,
203
+ parent: interface,
204
+ colour: colour,
205
+ style: style,
206
+ position: nil,
207
+ border: type })
339
208
  end
340
209
 
341
210
  # @return [Vedeu::Interface]
@@ -10,6 +10,7 @@ module Vedeu
10
10
  # to create a single view to be sent to the terminal for output.
11
11
  #
12
12
  # @api private
13
+ #
13
14
  class Compositor
14
15
 
15
16
  # Convenience method to initialize a new Compositor and call its {#compose}