vedeu 0.6.71 → 0.7.0

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/docs/api.md +1 -1
  3. data/lib/vedeu/all.rb +1 -0
  4. data/lib/vedeu/borders/border.rb +66 -55
  5. data/lib/vedeu/borders/caption.rb +10 -20
  6. data/lib/vedeu/borders/dsl.rb +57 -13
  7. data/lib/vedeu/borders/refresh.rb +123 -64
  8. data/lib/vedeu/borders/set_attribute.rb +1 -3
  9. data/lib/vedeu/borders/title.rb +68 -25
  10. data/lib/vedeu/cells/all.rb +23 -0
  11. data/lib/vedeu/cells/border.rb +72 -0
  12. data/lib/vedeu/cells/borders/all.rb +18 -0
  13. data/lib/vedeu/cells/borders/bottom_horizontal.rb +28 -0
  14. data/lib/vedeu/cells/borders/bottom_left.rb +34 -0
  15. data/lib/vedeu/cells/borders/bottom_right.rb +34 -0
  16. data/lib/vedeu/cells/borders/horizontal.rb +28 -0
  17. data/lib/vedeu/cells/borders/left_vertical.rb +28 -0
  18. data/lib/vedeu/cells/borders/right_vertical.rb +28 -0
  19. data/lib/vedeu/cells/borders/top_horizontal.rb +28 -0
  20. data/lib/vedeu/cells/borders/top_left.rb +34 -0
  21. data/lib/vedeu/cells/borders/top_right.rb +34 -0
  22. data/lib/vedeu/cells/borders/vertical.rb +28 -0
  23. data/lib/vedeu/cells/char.rb +24 -0
  24. data/lib/vedeu/cells/clear.rb +29 -0
  25. data/lib/vedeu/cells/empty.rb +78 -0
  26. data/lib/vedeu/cells/escape.rb +24 -0
  27. data/lib/vedeu/cells/html.rb +19 -0
  28. data/lib/vedeu/cells/json.rb +19 -0
  29. data/lib/vedeu/colours/colour.rb +6 -6
  30. data/lib/vedeu/common.rb +9 -0
  31. data/lib/vedeu/cursors/move.rb +2 -3
  32. data/lib/vedeu/editor/insert.rb +1 -1
  33. data/lib/vedeu/editor/item.rb +2 -3
  34. data/lib/vedeu/input/mouse.rb +1 -1
  35. data/lib/vedeu/interfaces/clear.rb +3 -4
  36. data/lib/vedeu/output/compressor.rb +1 -0
  37. data/lib/vedeu/presentation/colour.rb +3 -0
  38. data/lib/vedeu/repositories/defaults.rb +10 -1
  39. data/lib/vedeu/templating/decoder.rb +1 -1
  40. data/lib/vedeu/templating/encoder.rb +1 -1
  41. data/lib/vedeu/templating/template.rb +2 -2
  42. data/lib/vedeu/templating/view_template.rb +1 -1
  43. data/lib/vedeu/terminal/terminal.rb +9 -0
  44. data/lib/vedeu/version.rb +1 -1
  45. data/lib/vedeu/views/html_char.rb +1 -1
  46. data/test/lib/vedeu/application/application_controller_test.rb +2 -2
  47. data/test/lib/vedeu/application/controller_test.rb +4 -4
  48. data/test/lib/vedeu/borders/border_test.rb +10 -2
  49. data/test/lib/vedeu/borders/caption_test.rb +29 -13
  50. data/test/lib/vedeu/borders/dsl_test.rb +44 -25
  51. data/test/lib/vedeu/borders/refresh_test.rb +2 -2
  52. data/test/lib/vedeu/borders/title_test.rb +17 -15
  53. data/test/lib/vedeu/buffers/buffer_test.rb +8 -8
  54. data/test/lib/vedeu/buffers/refresh_test.rb +10 -10
  55. data/test/lib/vedeu/buffers/terminal_test.rb +6 -6
  56. data/test/lib/vedeu/cells/border_test.rb +72 -0
  57. data/test/lib/vedeu/cells/borders/bottom_horizontal_test.rb +22 -0
  58. data/test/lib/vedeu/cells/borders/bottom_left_test.rb +36 -0
  59. data/test/lib/vedeu/cells/borders/bottom_right_test.rb +36 -0
  60. data/test/lib/vedeu/cells/borders/horizontal_test.rb +22 -0
  61. data/test/lib/vedeu/cells/borders/left_vertical_test.rb +22 -0
  62. data/test/lib/vedeu/cells/borders/right_vertical_test.rb +22 -0
  63. data/test/lib/vedeu/cells/borders/top_horizontal_test.rb +22 -0
  64. data/test/lib/vedeu/cells/borders/top_left_test.rb +36 -0
  65. data/test/lib/vedeu/cells/borders/top_right_test.rb +36 -0
  66. data/test/lib/vedeu/cells/borders/vertical_test.rb +22 -0
  67. data/test/lib/vedeu/cells/char_test.rb +22 -0
  68. data/test/lib/vedeu/cells/clear_test.rb +34 -0
  69. data/test/lib/vedeu/cells/empty_test.rb +55 -0
  70. data/test/lib/vedeu/cells/escape_test.rb +13 -0
  71. data/test/lib/vedeu/cells/html_test.rb +13 -0
  72. data/test/lib/vedeu/cells/json_test.rb +13 -0
  73. data/test/lib/vedeu/colours/colour_test.rb +2 -6
  74. data/test/lib/vedeu/colours/translator_test.rb +4 -4
  75. data/test/lib/vedeu/common_test.rb +10 -0
  76. data/test/lib/vedeu/configuration/api_test.rb +24 -24
  77. data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
  78. data/test/lib/vedeu/cursors/dsl_test.rb +16 -16
  79. data/test/lib/vedeu/cursors/reposition_test.rb +2 -2
  80. data/test/lib/vedeu/cursors/repository_test.rb +2 -2
  81. data/test/lib/vedeu/distributed/client_test.rb +2 -2
  82. data/test/lib/vedeu/distributed/server_test.rb +8 -8
  83. data/test/lib/vedeu/distributed/subprocess_test.rb +2 -2
  84. data/test/lib/vedeu/distributed/test_application_test.rb +2 -2
  85. data/test/lib/vedeu/dsl/line_test.rb +2 -2
  86. data/test/lib/vedeu/dsl/presentation_test.rb +4 -4
  87. data/test/lib/vedeu/editor/cursor_test.rb +2 -2
  88. data/test/lib/vedeu/editor/document_test.rb +4 -4
  89. data/test/lib/vedeu/editor/editor_test.rb +20 -20
  90. data/test/lib/vedeu/events/aliases_test.rb +2 -2
  91. data/test/lib/vedeu/events/repository_test.rb +2 -2
  92. data/test/lib/vedeu/geometries/area/area_test.rb +2 -2
  93. data/test/lib/vedeu/geometries/geometry_test.rb +2 -2
  94. data/test/lib/vedeu/geometries/move_test.rb +2 -2
  95. data/test/lib/vedeu/geometries/position_test.rb +2 -2
  96. data/test/lib/vedeu/groups/clear_test.rb +2 -2
  97. data/test/lib/vedeu/groups/group_test.rb +4 -4
  98. data/test/lib/vedeu/groups/refresh_test.rb +2 -2
  99. data/test/lib/vedeu/input/capture_test.rb +42 -40
  100. data/test/lib/vedeu/input/mouse_test.rb +13 -11
  101. data/test/lib/vedeu/input/read_test.rb +10 -10
  102. data/test/lib/vedeu/interfaces/clear_test.rb +15 -6
  103. data/test/lib/vedeu/interfaces/dsl_test.rb +14 -14
  104. data/test/lib/vedeu/interfaces/interface_test.rb +12 -9
  105. data/test/lib/vedeu/logging/debug_test.rb +2 -2
  106. data/test/lib/vedeu/logging/lockless_log_device_test.rb +2 -2
  107. data/test/lib/vedeu/logging/log_test.rb +4 -4
  108. data/test/lib/vedeu/logging/mono_logger_test.rb +8 -8
  109. data/test/lib/vedeu/logging/timer_test.rb +2 -2
  110. data/test/lib/vedeu/menus/menu_test.rb +4 -4
  111. data/test/lib/vedeu/models/cell_test.rb +2 -2
  112. data/test/lib/vedeu/models/focus_test.rb +6 -6
  113. data/test/lib/vedeu/models/toggleable_test.rb +10 -10
  114. data/test/lib/vedeu/null/generic_test.rb +2 -2
  115. data/test/lib/vedeu/output/output_test.rb +8 -8
  116. data/test/lib/vedeu/output/refresh_test.rb +2 -2
  117. data/test/lib/vedeu/output/viewport_test.rb +2 -2
  118. data/test/lib/vedeu/plugins/plugin_test.rb +4 -4
  119. data/test/lib/vedeu/presentation/background_test.rb +2 -2
  120. data/test/lib/vedeu/presentation/foreground_test.rb +2 -2
  121. data/test/lib/vedeu/presentation/style_test.rb +2 -2
  122. data/test/lib/vedeu/renderers/all_test.rb +2 -2
  123. data/test/lib/vedeu/renderers/file_test.rb +6 -6
  124. data/test/lib/vedeu/renderers/terminal_test.rb +2 -2
  125. data/test/lib/vedeu/repositories/collection_test.rb +2 -2
  126. data/test/lib/vedeu/repositories/defaults_test.rb +35 -0
  127. data/test/lib/vedeu/repositories/registerable_test.rb +2 -2
  128. data/test/lib/vedeu/runtime/bootstrap_test.rb +2 -2
  129. data/test/lib/vedeu/runtime/flags_test.rb +2 -2
  130. data/test/lib/vedeu/runtime/launcher_test.rb +4 -4
  131. data/test/lib/vedeu/runtime/main_loop_test.rb +2 -2
  132. data/test/lib/vedeu/runtime/router_test.rb +12 -12
  133. data/test/lib/vedeu/terminal/mode_test.rb +4 -4
  134. data/test/lib/vedeu/terminal/terminal_test.rb +19 -9
  135. data/test/lib/vedeu/views/char_test.rb +2 -2
  136. data/test/lib/vedeu/views/composition_test.rb +2 -2
  137. data/test/lib/vedeu/views/line_test.rb +2 -2
  138. data/test/lib/vedeu/views/stream_test.rb +2 -2
  139. data/test/lib/vedeu/views/view_test.rb +4 -4
  140. data/vedeu.gemspec +1 -1
  141. metadata +57 -4
@@ -12,9 +12,7 @@ module Vedeu
12
12
 
13
13
  include Vedeu::Common
14
14
 
15
- # @param name [String|Symbol]
16
- # @param attribute [Symbol]
17
- # @param value [String]
15
+ # @param (see #initialize)
18
16
  # @return [Vedeu::Borders::Border]
19
17
  def self.update(name, attribute, value)
20
18
  new(name, attribute, value).update
@@ -6,33 +6,38 @@ module Vedeu
6
6
  # title is longer than the interface is wide, and pad with a space
7
7
  # either side.
8
8
  #
9
+ # The title is displayed within the top border of the interface/
10
+ # view.
11
+ #
9
12
  # @api private
10
13
  #
11
14
  class Title
12
15
 
13
- # @param chars [Array<Vedeu::Views::Char>]
14
- # @param value [String|Vedeu::Borders::Title|
15
- # Vedeu::Borders::Caption]
16
- # @return [Array<Vedeu::Views::Char>]
17
- def self.render(value = '', chars = [])
18
- new(value, chars).render
16
+ include Vedeu::Common
17
+
18
+ # @param (see #initialize)
19
+ # @return (see #render)
20
+ def self.render(name, value = '', horizontal = [])
21
+ new(name, value, horizontal).render
19
22
  end
20
23
 
21
24
  # Returns a new instance of Vedeu::Borders::Title or
22
25
  # Vedeu::Borders::Caption.
23
26
  #
24
- # @param chars [Array<Vedeu::Views::Char>]
27
+ # @param name [String|Symbol]
25
28
  # @param value [String|Vedeu::Borders::Title|
29
+ # @param horizontal [Array<Vedeu::Cells::Horizontal>]
26
30
  # Vedeu::Borders::Caption]
27
31
  # @return [Vedeu::Borders::Title|Vedeu::Borders::Caption]
28
- def initialize(value = '', chars = [])
29
- @value = value
30
- @chars = chars
32
+ def initialize(name, value = '', horizontal = [])
33
+ @name = name
34
+ @value = value
35
+ @horizontal = horizontal
31
36
  end
32
37
 
33
38
  # An object is equal when its values are the same.
34
39
  #
35
- # @param other [Vedeu::Borders::Title]
40
+ # @param other [Vedeu::Borders::Title|Vedeu::Borders::Caption]
36
41
  # @return [Boolean]
37
42
  def eql?(other)
38
43
  self.class == other.class && value == other.value
@@ -43,16 +48,13 @@ module Vedeu
43
48
  # {Vedeu::Borders::Border#build_horizontal} on the top border to
44
49
  # include the title if given.
45
50
  #
46
- # @return [Array<Vedeu::Views::Char>]
51
+ # @return [Array<Vedeu::Cells::Horizontal|Vedeu::Cells::Char>]
47
52
  def render
48
- return chars if empty?
53
+ return horizontal if empty?
49
54
 
50
- chars.each_with_index do |char, index|
51
- next if index == start_index || index > size
55
+ horizontal[start_index..(start_index + (size - 1))] = chars
52
56
 
53
- char.border = nil
54
- char.value = characters[index - 1]
55
- end
57
+ horizontal
56
58
  end
57
59
 
58
60
  # Convert the value to a string.
@@ -74,13 +76,39 @@ module Vedeu
74
76
 
75
77
  protected
76
78
 
77
- # @!attribute [r] chars
78
- # @return [Array<Vedeu::Views::Char>] An array of border
79
+ # @!attribute [r] horizontal
80
+ # @return [Array<Vedeu::Cells::Horizontal>] An array of border
79
81
  # characters.
80
- attr_reader :chars
82
+ attr_reader :horizontal
83
+
84
+ # @!attribute [r] name
85
+ # @return [String|Symbol]
86
+ attr_reader :name
81
87
 
82
88
  private
83
89
 
90
+ # @param char [String]
91
+ # @param x [Fixnum]
92
+ # @return [Hash<Symbol => void>]
93
+ def attributes(char, x)
94
+ @_attributes ||= border.attributes
95
+
96
+ @_attributes.merge!(position: Vedeu::Geometries::Position.new(y, x),
97
+ value: char)
98
+ end
99
+
100
+ # @return [Vedeu::Borders::Border]
101
+ def border
102
+ @_border ||= Vedeu.borders.by_name(name)
103
+ end
104
+
105
+ # @return [Array<Vedeu::Cells::Horizontal|Vedeu::Cells::Char>]
106
+ def chars
107
+ characters.each_with_index.map do |char, index|
108
+ Vedeu::Cells::Char.new(attributes(char, x + index))
109
+ end
110
+ end
111
+
84
112
  # Return the padded, truncated value as an Array of String.
85
113
  #
86
114
  # @return [Array<String>]
@@ -95,6 +123,11 @@ module Vedeu
95
123
  value.empty?
96
124
  end
97
125
 
126
+ # @return [Vedeu::Geometries::Geometry]
127
+ def geometry
128
+ @_geometry ||= Vedeu.geometries.by_name(name)
129
+ end
130
+
98
131
  # Pads the value with a single whitespace either side.
99
132
  #
100
133
  # @example
@@ -120,7 +153,7 @@ module Vedeu
120
153
 
121
154
  # @return [Fixnum]
122
155
  def start_index
123
- 0
156
+ 1
124
157
  end
125
158
 
126
159
  # Truncates the value to the width of the interface, minus
@@ -138,14 +171,24 @@ module Vedeu
138
171
  #
139
172
  # @return [String]
140
173
  def truncate
141
- title.chomp.slice(0...(width - 4))
174
+ @_truncate ||= value.chomp.slice(0...(width - 4))
142
175
  end
143
176
 
144
- # Return the size of the horizontal border given via #chars.
177
+ # Return the size of the horizontal border given.
145
178
  #
146
179
  # @return [Fixnum]
147
180
  def width
148
- chars.size
181
+ horizontal.size
182
+ end
183
+
184
+ # @return [Fixnum]
185
+ def x
186
+ @_x ||= geometry.bx + start_index
187
+ end
188
+
189
+ # @return [Fixnum]
190
+ def y
191
+ @_y ||= geometry.y
149
192
  end
150
193
 
151
194
  end # Title
@@ -0,0 +1,23 @@
1
+ module Vedeu
2
+
3
+ # Each available character space in the visible terminal is
4
+ # represented in Vedeu as a cell of some type. Each type of cell
5
+ # has specific behaviour when handled (including being rendered) by
6
+ # Vedeu.
7
+ #
8
+ # @api private
9
+ #
10
+ module Cells
11
+
12
+ end # Cells
13
+
14
+ end # Vedeu
15
+
16
+ require 'vedeu/cells/empty'
17
+ require 'vedeu/cells/border'
18
+ require 'vedeu/cells/borders/all'
19
+ require 'vedeu/cells/char'
20
+ require 'vedeu/cells/clear'
21
+ require 'vedeu/cells/escape'
22
+ require 'vedeu/cells/html'
23
+ require 'vedeu/cells/json'
@@ -0,0 +1,72 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class Border < Vedeu::Cells::Empty
11
+
12
+ extend Forwardable
13
+ include Vedeu::Presentation
14
+
15
+ def_delegators :geometry,
16
+ :x,
17
+ :xn,
18
+ :y,
19
+ :yn
20
+
21
+ # @return [Hash<Symbol => void>]
22
+ def attributes
23
+ {
24
+ colour: colour,
25
+ name: @name,
26
+ style: style,
27
+ }
28
+ end
29
+
30
+ # @return [Boolean]
31
+ def cell?
32
+ false
33
+ end
34
+
35
+ # @param value [String|Symbol]
36
+ # @return [Vedeu::Cells::Border]
37
+ def name=(value)
38
+ @name = value
39
+
40
+ self
41
+ end
42
+
43
+ # @return [Vedeu::Borders::Border|Vedeu::Interfaces::Interface]
44
+ def named_parent
45
+ if border
46
+ border
47
+
48
+ elsif interface
49
+ interface
50
+
51
+ end
52
+ end
53
+
54
+ # @return [String]
55
+ def value
56
+ return '' unless present?(@value)
57
+
58
+ Vedeu::EscapeSequences::Esc.border { @value }
59
+ end
60
+
61
+ private
62
+
63
+ # @return [Hash<Symbol => Hash<void>>]
64
+ def defaults
65
+ super
66
+ end
67
+
68
+ end # Border
69
+
70
+ end # Cells
71
+
72
+ end # Vedeu
@@ -0,0 +1,18 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ end # Cells
6
+
7
+ end # Vedeu
8
+
9
+ require 'vedeu/cells/borders/horizontal'
10
+ require 'vedeu/cells/borders/bottom_horizontal'
11
+ require 'vedeu/cells/borders/bottom_left'
12
+ require 'vedeu/cells/borders/bottom_right'
13
+ require 'vedeu/cells/borders/top_horizontal'
14
+ require 'vedeu/cells/borders/top_left'
15
+ require 'vedeu/cells/borders/top_right'
16
+ require 'vedeu/cells/borders/vertical'
17
+ require 'vedeu/cells/borders/left_vertical'
18
+ require 'vedeu/cells/borders/right_vertical'
@@ -0,0 +1,28 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of the
6
+ # bottom horizontal border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class BottomHorizontal < Vedeu::Cells::Horizontal
11
+
12
+ # @return [Symbol]
13
+ def type
14
+ :bottom_horizontal
15
+ end
16
+
17
+ private
18
+
19
+ # @return [Hash<Symbol => String>]
20
+ def defaults
21
+ super.merge!(value: Vedeu::EscapeSequences::Borders.horizontal)
22
+ end
23
+
24
+ end # BottomHorizontal
25
+
26
+ end # Cells
27
+
28
+ end # Vedeu
@@ -0,0 +1,34 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw the bottom left
6
+ # border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class BottomLeft < Vedeu::Cells::Border
11
+
12
+ # @return [Vedeu::Geometries::Position]
13
+ def position
14
+ @position = defaults[:position]
15
+ end
16
+
17
+ # @return [Symbol]
18
+ def type
19
+ :bottom_left
20
+ end
21
+
22
+ private
23
+
24
+ # @return [Hash<Symbol => String>]
25
+ def defaults
26
+ super.merge!(position: Vedeu::Geometries::Position.coerce([yn, x]),
27
+ value: Vedeu::EscapeSequences::Borders.bottom_left)
28
+ end
29
+
30
+ end # BottomLeft
31
+
32
+ end # Cells
33
+
34
+ end # Vedeu
@@ -0,0 +1,34 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw the bottom right
6
+ # border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class BottomRight < Vedeu::Cells::Border
11
+
12
+ # @return [Vedeu::Geometries::Position]
13
+ def position
14
+ @position = defaults[:position]
15
+ end
16
+
17
+ # @return [Symbol]
18
+ def type
19
+ :bottom_right
20
+ end
21
+
22
+ private
23
+
24
+ # @return [Hash<Symbol => String>]
25
+ def defaults
26
+ super.merge!(position: Vedeu::Geometries::Position.coerce([yn, xn]),
27
+ value: Vedeu::EscapeSequences::Borders.bottom_right)
28
+ end
29
+
30
+ end # BottomRight
31
+
32
+ end # Cells
33
+
34
+ end # Vedeu
@@ -0,0 +1,28 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # horizontal border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class Horizontal < Vedeu::Cells::Border
11
+
12
+ # @return [Symbol]
13
+ def type
14
+ :horizontal
15
+ end
16
+
17
+ private
18
+
19
+ # @return [Hash<Symbol => String>]
20
+ def defaults
21
+ super.merge!(value: Vedeu::EscapeSequences::Borders.horizontal)
22
+ end
23
+
24
+ end # Horizontal
25
+
26
+ end # Cells
27
+
28
+ end # Vedeu
@@ -0,0 +1,28 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of the
6
+ # left vertical border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class LeftVertical < Vedeu::Cells::Vertical
11
+
12
+ # @return [Symbol]
13
+ def type
14
+ :left_vertical
15
+ end
16
+
17
+ private
18
+
19
+ # @return [Hash<Symbol => String>]
20
+ def defaults
21
+ super.merge!(value: Vedeu::EscapeSequences::Borders.vertical)
22
+ end
23
+
24
+ end # LeftVertical
25
+
26
+ end # Cells
27
+
28
+ end # Vedeu