vedeu 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/bin/vedeu +0 -3
  3. data/examples/borders_app.rb +0 -3
  4. data/examples/colours_app.rb +0 -3
  5. data/examples/configuration_app.rb +0 -3
  6. data/examples/cursor_app.rb +0 -3
  7. data/examples/focus_app.rb +0 -3
  8. data/examples/geometry_app.rb +0 -3
  9. data/examples/lines_app.rb +0 -3
  10. data/examples/view_templates_app/template.erb +1 -0
  11. data/examples/view_templates_app/view_templates_app.rb +82 -0
  12. data/lib/vedeu/all.rb +0 -1
  13. data/lib/vedeu/application.rb +7 -6
  14. data/lib/vedeu/bindings.rb +8 -8
  15. data/lib/vedeu/buffers/buffer.rb +14 -4
  16. data/lib/vedeu/buffers/display_buffer.rb +2 -2
  17. data/lib/vedeu/configuration/cli.rb +7 -1
  18. data/lib/vedeu/configuration/configuration.rb +4 -2
  19. data/lib/vedeu/cursor/all.rb +1 -1
  20. data/lib/vedeu/cursor/cursor.rb +29 -2
  21. data/lib/vedeu/cursor/move_cursor.rb +20 -6
  22. data/lib/vedeu/cursor/toggle_cursor.rb +2 -0
  23. data/lib/vedeu/distributed/client.rb +2 -0
  24. data/lib/vedeu/distributed/server.rb +3 -1
  25. data/lib/vedeu/distributed/subprocess.rb +6 -1
  26. data/lib/vedeu/distributed/test_application.rb +32 -9
  27. data/lib/vedeu/distributed/uri.rb +7 -1
  28. data/lib/vedeu/dsl/components/border.rb +2 -0
  29. data/lib/vedeu/dsl/components/geometry.rb +2 -0
  30. data/lib/vedeu/dsl/components/keymap.rb +2 -0
  31. data/lib/vedeu/dsl/components/menu.rb +3 -1
  32. data/lib/vedeu/dsl/composition.rb +31 -2
  33. data/lib/vedeu/dsl/group.rb +2 -0
  34. data/lib/vedeu/dsl/interface.rb +3 -1
  35. data/lib/vedeu/dsl/line.rb +2 -0
  36. data/lib/vedeu/dsl/shared/style.rb +1 -1
  37. data/lib/vedeu/dsl/shared/text.rb +1 -2
  38. data/lib/vedeu/dsl/stream.rb +2 -0
  39. data/lib/vedeu/dsl/view.rb +1 -1
  40. data/lib/vedeu/events/all.rb +1 -1
  41. data/lib/vedeu/events/event.rb +26 -10
  42. data/lib/vedeu/events/trigger.rb +11 -3
  43. data/lib/vedeu/geometry/all.rb +2 -0
  44. data/lib/vedeu/geometry/bounding_area.rb +7 -2
  45. data/lib/vedeu/geometry/content_geometry.rb +2 -0
  46. data/lib/vedeu/geometry/coordinate.rb +15 -6
  47. data/lib/vedeu/geometry/grid.rb +3 -1
  48. data/lib/vedeu/geometry/index_position.rb +77 -0
  49. data/lib/vedeu/geometry/limit.rb +15 -1
  50. data/lib/vedeu/geometry/position.rb +7 -2
  51. data/lib/vedeu/{output → geometry}/position_index.rb +12 -2
  52. data/lib/vedeu/geometry/position_validator.rb +9 -1
  53. data/lib/vedeu/input/all.rb +0 -1
  54. data/lib/vedeu/input/input.rb +2 -0
  55. data/lib/vedeu/input/keymap.rb +5 -3
  56. data/lib/vedeu/input/mapper.rb +7 -1
  57. data/lib/vedeu/launcher.rb +1 -1
  58. data/lib/vedeu/models/all.rb +6 -3
  59. data/lib/vedeu/models/char.rb +157 -0
  60. data/lib/vedeu/models/{view/composition.rb → composition.rb} +1 -4
  61. data/lib/vedeu/models/geometry.rb +36 -12
  62. data/lib/vedeu/models/group.rb +7 -3
  63. data/lib/vedeu/models/{view/interface.rb → interface.rb} +26 -10
  64. data/lib/vedeu/models/{view/line.rb → line.rb} +8 -4
  65. data/lib/vedeu/models/menu.rb +11 -3
  66. data/lib/vedeu/models/{view/stream.rb → stream.rb} +9 -4
  67. data/lib/vedeu/output/all.rb +3 -2
  68. data/lib/vedeu/output/background.rb +2 -2
  69. data/lib/vedeu/output/border.rb +65 -22
  70. data/lib/vedeu/output/char_builder.rb +36 -0
  71. data/lib/vedeu/output/clear.rb +62 -0
  72. data/lib/vedeu/output/colour.rb +15 -7
  73. data/lib/vedeu/output/compositor.rb +3 -1
  74. data/lib/vedeu/output/esc.rb +2 -2
  75. data/lib/vedeu/output/foreground.rb +2 -2
  76. data/lib/vedeu/output/html_char.rb +2 -0
  77. data/lib/vedeu/output/html_renderer.rb +6 -3
  78. data/lib/vedeu/output/output.rb +20 -92
  79. data/lib/vedeu/output/presentation.rb +21 -21
  80. data/lib/vedeu/output/renderer.rb +2 -0
  81. data/lib/vedeu/output/style.rb +4 -2
  82. data/lib/vedeu/output/text.rb +7 -1
  83. data/lib/vedeu/output/translator.rb +4 -2
  84. data/lib/vedeu/output/viewport.rb +4 -2
  85. data/lib/vedeu/output/virtual_buffer.rb +11 -1
  86. data/lib/vedeu/output/virtual_terminal.rb +34 -11
  87. data/lib/vedeu/output/wordwrap.rb +31 -20
  88. data/lib/vedeu/repositories/all.rb +3 -0
  89. data/lib/vedeu/repositories/collection.rb +83 -0
  90. data/lib/vedeu/repositories/collections.rb +35 -0
  91. data/lib/vedeu/{models → repositories}/model.rb +2 -0
  92. data/lib/vedeu/repositories/repository.rb +7 -1
  93. data/lib/vedeu/support/log.rb +1 -1
  94. data/lib/vedeu/support/sentence.rb +7 -1
  95. data/lib/vedeu/support/template.rb +14 -2
  96. data/lib/vedeu/support/terminal.rb +6 -6
  97. data/lib/vedeu/support/trace.rb +4 -4
  98. data/lib/vedeu/support/visible.rb +4 -4
  99. data/test/lib/vedeu/dsl/composition_test.rb +23 -0
  100. data/test/lib/vedeu/geometry/index_position_test.rb +121 -0
  101. data/test/lib/vedeu/{output → geometry}/position_index_test.rb +6 -0
  102. data/test/lib/vedeu/input/keymap_test.rb +2 -2
  103. data/test/lib/vedeu/models/{view/char_test.rb → char_test.rb} +31 -15
  104. data/test/lib/vedeu/models/{view/composition_test.rb → composition_test.rb} +0 -0
  105. data/test/lib/vedeu/models/{view/interface_test.rb → interface_test.rb} +0 -0
  106. data/test/lib/vedeu/models/line_test.rb +156 -0
  107. data/test/lib/vedeu/models/{view/stream_test.rb → stream_test.rb} +1 -16
  108. data/test/lib/vedeu/output/char_builder_test.rb +50 -0
  109. data/test/lib/vedeu/output/clear_test.rb +26 -0
  110. data/test/lib/vedeu/output/compositor_test.rb +0 -10
  111. data/test/lib/vedeu/output/html_renderer_test.rb +8 -3
  112. data/test/lib/vedeu/output/output_test.rb +0 -39
  113. data/test/lib/vedeu/output/viewport_test.rb +10 -66
  114. data/test/lib/vedeu/output/virtual_buffer_test.rb +18 -2
  115. data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -14
  116. data/test/lib/vedeu/output/wordwrap_test.rb +8 -15
  117. data/test/lib/vedeu/repositories/collection_test.rb +108 -0
  118. data/test/lib/vedeu/repositories/collections_test.rb +71 -0
  119. data/test/lib/vedeu/{models → repositories}/model_test.rb +0 -0
  120. data/test/lib/vedeu/support/template_test.rb +21 -1
  121. data/test/support/helpers/model_test_class.rb +1 -1
  122. data/test/test_helper.rb +0 -1
  123. data/vedeu.gemspec +1 -1
  124. metadata +40 -44
  125. data/lib/vedeu/events/events.rb +0 -10
  126. data/lib/vedeu/input/keys.rb +0 -10
  127. data/lib/vedeu/models/collection.rb +0 -81
  128. data/lib/vedeu/models/view/all.rb +0 -12
  129. data/lib/vedeu/models/view/char.rb +0 -99
  130. data/lib/vedeu/models/view/chars.rb +0 -10
  131. data/lib/vedeu/models/view/interfaces.rb +0 -10
  132. data/lib/vedeu/models/view/lines.rb +0 -10
  133. data/lib/vedeu/models/view/streams.rb +0 -10
  134. data/lib/vedeu/output/index_position.rb +0 -35
  135. data/test/lib/vedeu/models/collection_test.rb +0 -112
  136. data/test/lib/vedeu/models/view/chars_test.rb +0 -16
  137. data/test/lib/vedeu/models/view/interfaces_test.rb +0 -16
  138. data/test/lib/vedeu/models/view/line_test.rb +0 -214
  139. data/test/lib/vedeu/models/view/lines_test.rb +0 -16
  140. data/test/lib/vedeu/models/view/streams_test.rb +0 -16
  141. data/test/lib/vedeu/output/index_position_test.rb +0 -64
@@ -0,0 +1,157 @@
1
+ require 'vedeu/geometry/position'
2
+ require 'vedeu/output/esc'
3
+ require 'vedeu/output/html_char'
4
+ require 'vedeu/output/presentation'
5
+
6
+ module Vedeu
7
+
8
+ # A Char represents a single character of the terminal. It is a container for
9
+ # the a single character in a {Vedeu::Stream}.
10
+ #
11
+ # Though a multi-character String can be passed as a value, only the first
12
+ # character is returned in the escape sequence.
13
+ #
14
+ class Char
15
+
16
+ include Vedeu::Presentation
17
+
18
+ # @!attribute [rw] border
19
+ # @return [NilClass|Symbol]
20
+ attr_accessor :border
21
+
22
+ # @!attribute [rw] parent
23
+ # @return [Vedeu::Line]
24
+ attr_accessor :parent
25
+
26
+ # @!attribute [r] value
27
+ # @return [String]
28
+ attr_reader :value
29
+
30
+ # Returns a new instance of Vedeu::Char.
31
+ #
32
+ # @param attributes [Hash]
33
+ # @option attributes value [String]
34
+ # @option attributes parent [Vedeu::Line]
35
+ # @option attributes colour [Vedeu::Colour]
36
+ # @option attributes style [Vedeu::Style]
37
+ # @option attributes position [Vedeu::Position]
38
+ # @option attributes border [NilClass|Symbol] A symbol representing the
39
+ # border 'piece' this Char represents.
40
+ # @return [Char]
41
+ def initialize(attributes = {})
42
+ @attributes = defaults.merge!(attributes)
43
+
44
+ @border = @attributes[:border]
45
+ @colour = @attributes[:colour]
46
+ @parent = @attributes[:parent]
47
+ @style = @attributes[:style]
48
+ @value = @attributes[:value]
49
+ end
50
+
51
+ # @param other [Vedeu::Char]
52
+ # @return [Boolean]
53
+ def ==(other)
54
+ eql?(other)
55
+ end
56
+
57
+ # When {Vedeu::Viewport#padded_lines} has less lines that required to fill
58
+ # the visible area of the interface, it creates a line that contains a
59
+ # single {Vedeu::Char} containing a space (0x20); later,
60
+ # {Vedeu::Viewport#padded_columns} will attempts to call `#chars` on an
61
+ # expected {Vedeu::Line} and fail; this method fixes that.
62
+ #
63
+ # @return [Array]
64
+ def chars
65
+ []
66
+ end
67
+
68
+ # @param other [Vedeu::Char]
69
+ # @return [Boolean]
70
+ def eql?(other)
71
+ self.class == other.class && value == other.value
72
+ end
73
+
74
+ # @return [String]
75
+ def inspect
76
+ "<Vedeu::Char '#{Vedeu::Esc.escape(self.to_s)}'>"
77
+ end
78
+
79
+ # @return [Vedeu::Position]
80
+ def position
81
+ @position ||= Vedeu::Position.coerce(attributes[:position])
82
+ end
83
+
84
+ # Sets the position of the Char.
85
+ #
86
+ # @param value [Vedeu::Position]
87
+ # @return [Vedeu::Position]
88
+ def position=(value)
89
+ @position = Vedeu::Position.coerce(value)
90
+ end
91
+
92
+ # Returns the x position for the Char if set.
93
+ #
94
+ # @return [Fixnum|NilClass]
95
+ def x
96
+ position.x if position
97
+ end
98
+
99
+ # Returns the y position for the Char if set.
100
+ #
101
+ # @return [Fixnum|NilClass]
102
+ def y
103
+ position.y if position
104
+ end
105
+
106
+ # Returns a Hash of all the values before coercion.
107
+ #
108
+ # @note
109
+ # From this hash we should be able to construct a new instance of
110
+ # Vedeu::Char, however, at the moment, `:parent` cannot be coerced.
111
+ #
112
+ # @return [Hash]
113
+ def to_hash
114
+ {
115
+ parent: {
116
+ background: parent_background,
117
+ foreground: parent_foreground,
118
+ style: parent_style,
119
+ },
120
+ background: '',
121
+ border: '',
122
+ foreground: '',
123
+ style: '',
124
+ value: value,
125
+ x: x,
126
+ y: y,
127
+ }
128
+ end
129
+
130
+ # @return [String]
131
+ def to_html
132
+ @to_html ||= Vedeu::HTMLChar.render(self)
133
+ end
134
+
135
+ private
136
+
137
+ # @!attribute [r] attributes
138
+ # @return [Hash]
139
+ attr_reader :attributes
140
+
141
+ # The default values for a new instance of this class.
142
+ #
143
+ # @return [Hash]
144
+ def defaults
145
+ {
146
+ border: nil,
147
+ colour: nil,
148
+ parent: nil,
149
+ position: nil,
150
+ style: nil,
151
+ value: '',
152
+ }
153
+ end
154
+
155
+ end # Char
156
+
157
+ end # Vedeu
@@ -1,11 +1,8 @@
1
1
  require 'vedeu/dsl/composition'
2
- require 'vedeu/models/collection'
2
+ require 'vedeu/repositories/all'
3
3
  require 'vedeu/output/presentation'
4
4
  require 'vedeu/support/common'
5
5
 
6
- require 'vedeu/models/view/interfaces'
7
- require 'vedeu/models/view/interface'
8
-
9
6
  module Vedeu
10
7
 
11
8
  # A composition is a collection of interfaces.
@@ -1,5 +1,5 @@
1
1
  require 'vedeu/dsl/components/all'
2
- require 'vedeu/models/model'
2
+ require 'vedeu/repositories/model'
3
3
 
4
4
  require 'vedeu/geometry/limit'
5
5
  require 'vedeu/geometry/position'
@@ -31,9 +31,33 @@ module Vedeu
31
31
 
32
32
  include Vedeu::Model
33
33
 
34
- attr_accessor :centred, :height, :name, :width
35
- attr_reader :attributes
36
- attr_writer :x, :y
34
+ # @!attribute [rw] centred
35
+ # @return [Boolean]
36
+ attr_accessor :centred
37
+
38
+ # @!attribute [rw] height
39
+ # @return [Fixnum]
40
+ attr_accessor :height
41
+
42
+ # @!attribute [rw] name
43
+ # @return [String]
44
+ attr_accessor :name
45
+
46
+ # @!attribute [rw] width
47
+ # @return [Fixnum]
48
+ attr_accessor :width
49
+
50
+ # @!attribute [r] attributes
51
+ # @return [Hash]
52
+ attr_reader :attributes
53
+
54
+ # @!attribute [w] x
55
+ # @return [Fixnum]
56
+ attr_writer :x
57
+
58
+ # @!attribute [w] y
59
+ # @return [Fixnum]
60
+ attr_writer :y
37
61
 
38
62
  # Returns a new instance of Geometry.
39
63
  #
@@ -124,12 +148,12 @@ module Vedeu
124
148
  #
125
149
  # @return [Fixnum]
126
150
  def width
127
- Vedeu::Limit.apply(x, @width, Terminal.width, Terminal.origin)
151
+ Vedeu::Limit.apply(x, @width, Vedeu::Terminal.width, Vedeu::Terminal.origin)
128
152
  end
129
153
 
130
154
  # @see Vedeu::Geometry#width
131
155
  def height
132
- Vedeu::Limit.apply(y, @height, Terminal.height, Terminal.origin)
156
+ Vedeu::Limit.apply(y, @height, Vedeu::Terminal.height, Vedeu::Terminal.origin)
133
157
  end
134
158
 
135
159
  # Returns the top coordinate of the interface, a fixed or dynamic value
@@ -141,7 +165,7 @@ module Vedeu
141
165
  # @return [Fixnum]
142
166
  def top
143
167
  if centred
144
- Terminal.centre_y - (height / 2)
168
+ Vedeu::Terminal.centre_y - (height / 2)
145
169
 
146
170
  else
147
171
  y
@@ -173,7 +197,7 @@ module Vedeu
173
197
  # @return [Fixnum]
174
198
  def left
175
199
  if centred
176
- Terminal.centre_x - (width / 2)
200
+ Vedeu::Terminal.centre_x - (width / 2)
177
201
 
178
202
  else
179
203
  x
@@ -251,13 +275,13 @@ module Vedeu
251
275
  {
252
276
  centred: false,
253
277
  client: nil,
254
- height: Terminal.height,
278
+ height: Vedeu::Terminal.height,
255
279
  name: '',
256
- width: Terminal.width,
280
+ width: Vedeu::Terminal.width,
257
281
  x: 1,
258
- xn: Terminal.width,
282
+ xn: Vedeu::Terminal.width,
259
283
  y: 1,
260
- yn: Terminal.height,
284
+ yn: Vedeu::Terminal.height,
261
285
  }
262
286
  end
263
287
 
@@ -1,3 +1,5 @@
1
+ require 'vedeu/repositories/model'
2
+
1
3
  module Vedeu
2
4
 
3
5
  # Interfaces can be associated with one another by being members of the same
@@ -7,6 +9,8 @@ module Vedeu
7
9
 
8
10
  include Vedeu::Model
9
11
 
12
+ # @!attribute [rw] name
13
+ # @return [String]
10
14
  attr_accessor :name
11
15
 
12
16
  # Return a new instance of Group.
@@ -33,7 +37,7 @@ module Vedeu
33
37
  def add(member)
34
38
  @members = members.add(member)
35
39
 
36
- Group.new({ name: name, members: @members }).store
40
+ Vedeu::Group.new({ name: name, members: @members }).store
37
41
  end
38
42
 
39
43
  # Return the members as a Set.
@@ -50,14 +54,14 @@ module Vedeu
50
54
  def remove(member)
51
55
  @members = members.delete(member)
52
56
 
53
- Group.new({ name: name, members: @members }).store
57
+ Vedeu::Group.new({ name: name, members: @members }).store
54
58
  end
55
59
 
56
60
  # Remove all members from the group.
57
61
  #
58
62
  # @return [Group]
59
63
  def reset
60
- Group.new(defaults.merge!({ name: name })).store
64
+ Vedeu::Group.new(defaults.merge!({ name: name })).store
61
65
  end
62
66
 
63
67
  private
@@ -1,12 +1,9 @@
1
1
  require 'vedeu/geometry/content_geometry'
2
- require 'vedeu/models/model'
2
+ require 'vedeu/models/all'
3
3
  require 'vedeu/output/presentation'
4
4
  require 'vedeu/buffers/display_buffer'
5
5
  require 'vedeu/buffers/buffer'
6
6
 
7
- require 'vedeu/models/view/lines'
8
- require 'vedeu/models/view/line'
9
-
10
7
  module Vedeu
11
8
 
12
9
  # An Interface represents a portion of the terminal defined by
@@ -24,13 +21,32 @@ module Vedeu
24
21
  collection Vedeu::Lines
25
22
  member Vedeu::Line
26
23
 
27
- attr_accessor :colour,
28
- :delay,
29
- :group,
30
- :name,
31
- :parent,
32
- :style
24
+ # @!attribute [rw] colour
25
+ # @return [void]
26
+ attr_accessor :colour
27
+
28
+ # @!attribute [rw] delay
29
+ # @return [Fixnum|Float]
30
+ attr_accessor :delay
31
+
32
+ # @!attribute [rw] group
33
+ # @return [void]
34
+ attr_accessor :group
35
+
36
+ # @!attribute [rw] name
37
+ # @return [String]
38
+ attr_accessor :name
39
+
40
+ # @!attribute [rw] parent
41
+ # @return [Vedeu::Composition]
42
+ attr_accessor :parent
43
+
44
+ # @!attribute [rw] style
45
+ # @return [String|Symbol]
46
+ attr_accessor :style
33
47
 
48
+ # @!attribute [w] lines
49
+ # @return [Array<Vedeu::Line>]
34
50
  attr_writer :lines
35
51
 
36
52
  def_delegators :geometry,
@@ -1,6 +1,5 @@
1
1
  require 'vedeu/output/presentation'
2
- require 'vedeu/models/view/streams'
3
- require 'vedeu/models/view/stream'
2
+ require 'vedeu/models/all'
4
3
 
5
4
  module Vedeu
6
5
 
@@ -16,8 +15,13 @@ module Vedeu
16
15
  collection Vedeu::Streams
17
16
  member Vedeu::Stream
18
17
 
19
- attr_accessor :parent,
20
- :streams
18
+ # @!attribute [rw] parent
19
+ # @return [Interface]
20
+ attr_accessor :parent
21
+
22
+ # @!attribute [rw] streams
23
+ # @return [Streams]
24
+ attr_accessor :streams
21
25
 
22
26
  alias_method :value, :streams
23
27
 
@@ -1,4 +1,4 @@
1
- require 'vedeu/models/model'
1
+ require 'vedeu/repositories/model'
2
2
 
3
3
  module Vedeu
4
4
 
@@ -9,25 +9,33 @@ module Vedeu
9
9
 
10
10
  include Vedeu::Model
11
11
 
12
+ # @!attribute [rw] collection
13
+ # @return [Array]
12
14
  attr_accessor :collection
13
15
 
14
16
  # Returns the index of the value in the collection which is current.
15
17
  #
18
+ # @!attribute [rw] current
16
19
  # @return [Fixnum]
17
20
  attr_accessor :current
18
21
 
22
+ # The name of the menu. Used to reference the menu throughout the
23
+ # application's execution lifetime.
24
+ #
25
+ # @!attribute [rw] name
26
+ # @return [String]
19
27
  attr_accessor :name
20
28
 
21
29
  # Returns the index of the value in the collection which is selected.
22
30
  #
31
+ # @!attribute [rw] selected
23
32
  # @return [Fixnum]
24
33
  attr_accessor :selected
25
34
 
26
35
  # Register a menu by name which will display a collection of items for
27
36
  # your users to select; and provide interactivity within your application.
28
37
  #
29
- # @param name [String] The name of the menu. Used to reference the
30
- # menu throughout your application's execution lifetime.
38
+ # @param name [String]
31
39
  # @param block [Proc] A set of attributes which define the features of the
32
40
  # menu. See {Vedeu::DSL::Menu#items} and {Vedeu::DSL::Menu#name}.
33
41
  #
@@ -1,5 +1,5 @@
1
1
  require 'vedeu/output/presentation'
2
- require 'vedeu/models/view/char'
2
+ require 'vedeu/models/all'
3
3
 
4
4
  module Vedeu
5
5
 
@@ -15,8 +15,13 @@ module Vedeu
15
15
  collection Vedeu::Chars
16
16
  member Vedeu::Char
17
17
 
18
- attr_accessor :parent,
19
- :value
18
+ # @!attribute [rw] parent
19
+ # @return [Line]
20
+ attr_accessor :parent
21
+
22
+ # @!attribute [rw] value
23
+ # @return [String]
24
+ attr_accessor :value
20
25
 
21
26
  alias_method :content, :value
22
27
  alias_method :data, :value
@@ -58,7 +63,7 @@ module Vedeu
58
63
  parent: parent,
59
64
  colour: colour,
60
65
  style: style,
61
- position: nil }).to_s
66
+ position: nil })
62
67
  end
63
68
  end
64
69
 
@@ -8,11 +8,12 @@ require 'vedeu/output/border'
8
8
  require 'vedeu/output/colour'
9
9
  require 'vedeu/output/compositor'
10
10
 
11
+ require 'vedeu/output/char_builder'
12
+ require 'vedeu/output/clear'
13
+
11
14
  require 'vedeu/output/presentation'
12
15
  require 'vedeu/output/style'
13
16
  require 'vedeu/output/text'
14
- require 'vedeu/output/position_index'
15
- require 'vedeu/output/index_position'
16
17
  require 'vedeu/output/virtual_buffer'
17
18
  require 'vedeu/output/html_char'
18
19
  require 'vedeu/output/html_renderer'
@@ -3,13 +3,13 @@ module Vedeu
3
3
  # The class represents one half (the other, can be found at
4
4
  # {Vedeu::Foreground}) of a terminal colour escape sequence.
5
5
  #
6
- class Background < Translator
6
+ class Background < Vedeu::Translator
7
7
 
8
8
  private
9
9
 
10
10
  # @return [String]
11
11
  def named_codes
12
- Esc.background_codes[colour]
12
+ Vedeu::Esc.background_codes[colour]
13
13
  end
14
14
 
15
15
  # @return [String]
@@ -14,22 +14,65 @@ module Vedeu
14
14
 
15
15
  include Vedeu::Model
16
16
 
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
17
+ # @!attribute [rw] attributes
18
+ # @return [Hash]
19
+ attr_accessor :attributes
20
+
21
+ # @!attribute [rw] bottom_left
22
+ # @return [String]
23
+ attr_accessor :bottom_left
24
+
25
+ # @!attribute [rw] bottom_right
26
+ # @return [String]
27
+ attr_accessor :bottom_right
28
+
29
+ # @!attribute [rw] horizontal
30
+ # @return [String]
31
+ attr_accessor :horizontal
32
+
33
+ # @!attribute [rw] show_bottom
34
+ # @return [Boolean]
35
+ attr_accessor :show_bottom
36
+
37
+ # @!attribute [rw] show_left
38
+ # @return [Boolean]
39
+ attr_accessor :show_left
40
+
41
+ # @!attribute [rw] show_right
42
+ # @return [Boolean]
43
+ attr_accessor :show_right
44
+
45
+ # @!attribute [rw] show_top
46
+ # @return [Boolean]
47
+ attr_accessor :show_top
48
+
49
+ # @!attribute [rw] top_left
50
+ # @return [String]
51
+ attr_accessor :top_left
52
+
53
+ # @!attribute [rw] top_right
54
+ # @return [String]
55
+ attr_accessor :top_right
56
+
57
+ # @!attribute [rw] vertical
58
+ # @return [String]
59
+ attr_accessor :vertical
60
+
61
+ # @!attribute [r] name
62
+ # @return [String]
63
+ attr_reader :name
64
+
65
+ # @!attribute [r] colour
66
+ # @return [Vedeu::Colour]
67
+ attr_reader :colour
68
+
69
+ # @!attribute [r] enabled
70
+ # @return [Boolean]
71
+ attr_reader :enabled
72
+
73
+ # @!attribute [r] style
74
+ # @return [Style]
75
+ attr_reader :style
33
76
 
34
77
  alias_method :enabled?, :enabled
35
78
  alias_method :bottom?, :show_bottom
@@ -43,12 +86,12 @@ module Vedeu
43
86
  # @option attributes bottom_left [String] The bottom left border character.
44
87
  # @option attributes bottom_right [String] The bottom right border
45
88
  # character.
46
- # @option attributes colour
89
+ # @option attributes colour []
47
90
  # @option attributes enabled [Boolean] Indicate whether the border is to be
48
91
  # shown for this interface.
49
92
  # @option attributes horizontal [String] The horizontal border character.
50
93
  # @option attributes name [String]
51
- # @option attributes style
94
+ # @option attributes style []
52
95
  # @option attributes show_bottom [Boolean] Indicate whether the bottom
53
96
  # border is to be shown.
54
97
  # @option attributes show_left [Boolean] Indicate whether the left border
@@ -120,26 +163,26 @@ module Vedeu
120
163
 
121
164
  # @return [Vedeu::Colour]
122
165
  def colour
123
- Colour.coerce(@colour)
166
+ Vedeu::Colour.coerce(@colour)
124
167
  end
125
168
 
126
169
  # Set the border colour.
127
170
  #
128
171
  # @return [Vedeu::Colour]
129
172
  def colour=(value)
130
- @colour = Colour.coerce(value)
173
+ @colour = Vedeu::Colour.coerce(value)
131
174
  end
132
175
 
133
176
  # @return [Vedeu::Style]
134
177
  def style
135
- Style.coerce(@style)
178
+ Vedeu::Style.coerce(@style)
136
179
  end
137
180
 
138
181
  # Set the border style.
139
182
  #
140
183
  # @return [Vedeu::Style]
141
184
  def style=(value)
142
- @style = Style.coerce(value)
185
+ @style = Vedeu::Style.coerce(value)
143
186
  end
144
187
 
145
188
  # Returns a string representation of the border for the interface without
@@ -0,0 +1,36 @@
1
+ module Vedeu
2
+
3
+ # Included in {Vedeu::Clear} and {Vedeu::Output}, this module builds
4
+ # {Vedeu::Char} objects.
5
+ #
6
+ module CharBuilder
7
+
8
+ # Builds a new Vedeu::Char object.
9
+ #
10
+ # @param value [String]
11
+ # @param iy [Fixnum]
12
+ # @param ix [Fixnum]
13
+ # @return [Vedeu::Char]
14
+ def char_builder(value, iy, ix)
15
+ Vedeu::Char.new({ value: value,
16
+ colour: interface.colour,
17
+ style: interface.style,
18
+ position: origin(iy, ix) })
19
+ end
20
+
21
+ # Returns the position of the cursor at the top-left coordinate, relative to
22
+ # the interface's position.
23
+ #
24
+ # @param y_index [Fixnum]
25
+ # @param x_index [Fixnum]
26
+ # @return [Vedeu::Position]
27
+ def origin(y_index = 0, x_index = 0)
28
+ Vedeu::IndexPosition.new(y_index,
29
+ x_index,
30
+ interface.top,
31
+ interface.left).to_position
32
+ end
33
+
34
+ end # CharBuilder
35
+
36
+ end # Vedeu