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
@@ -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
+ # right vertical border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class RightVertical < Vedeu::Cells::Vertical
11
+
12
+ # @return [Symbol]
13
+ def type
14
+ :right_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 # RightVertical
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
+ # top horizontal border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class TopHorizontal < Vedeu::Cells::Horizontal
11
+
12
+ # @return [Symbol]
13
+ def type
14
+ :top_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 # TopHorizontal
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 top left
6
+ # border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class TopLeft < 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
+ :top_left
20
+ end
21
+
22
+ private
23
+
24
+ # @return [Hash<Symbol => String>]
25
+ def defaults
26
+ super.merge!(position: Vedeu::Geometries::Position.coerce([y, x]),
27
+ value: Vedeu::EscapeSequences::Borders.top_left)
28
+ end
29
+
30
+ end # TopLeft
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 top right
6
+ # border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class TopRight < 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
+ :top_right
20
+ end
21
+
22
+ private
23
+
24
+ # @return [Hash<Symbol => String>]
25
+ def defaults
26
+ super.merge!(position: Vedeu::Geometries::Position.coerce([y, xn]),
27
+ value: Vedeu::EscapeSequences::Borders.top_right)
28
+ end
29
+
30
+ end # TopRight
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
+ # vertical border with a custom value, colour and style.
7
+ #
8
+ # @api private
9
+ #
10
+ class Vertical < Vedeu::Cells::Border
11
+
12
+ # @return [Symbol]
13
+ def type
14
+ :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 # Vertical
25
+
26
+ end # Cells
27
+
28
+ end # Vedeu
@@ -0,0 +1,24 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # with a custom value, colour and style.
7
+ #
8
+ # The Vedeu::Cells::Char object represents an alpha-numeric
9
+ # character.
10
+ #
11
+ # @api private
12
+ #
13
+ class Char < Vedeu::Cells::Empty
14
+
15
+ # @return [Boolean]
16
+ def cell?
17
+ false
18
+ end
19
+
20
+ end # Char
21
+
22
+ end # Cells
23
+
24
+ end # Vedeu
@@ -0,0 +1,29 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # with a custom value, colour and style.
7
+ #
8
+ # The Vedeu::Cells::Clear object represents a cleared cell using
9
+ # the space character.
10
+ #
11
+ # @api private
12
+ #
13
+ class Clear < Vedeu::Cells::Empty
14
+
15
+ # @return [Boolean]
16
+ def cell?
17
+ false
18
+ end
19
+
20
+ # @return [String]
21
+ def value
22
+ ' '.freeze
23
+ end
24
+
25
+ end # Clear
26
+
27
+ end # Cells
28
+
29
+ end # Vedeu
@@ -0,0 +1,78 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # with a custom value, colour and style.
7
+ #
8
+ # The Vedeu::Cells::Empty object represents an empty cell with no
9
+ # content and is the basis of all the Vedeu::Cells objects.
10
+ #
11
+ # @api private
12
+ #
13
+ class Empty
14
+
15
+ include Comparable
16
+ include Vedeu::Common
17
+ include Vedeu::Presentation
18
+ include Vedeu::Repositories::Defaults
19
+
20
+ # @!attribute [r] name
21
+ # @return [String|Symbol] The name of the interface/view this
22
+ # cell belongs to.
23
+ attr_reader :name
24
+
25
+ # @!attribute [r] value
26
+ # @return [String]
27
+ attr_reader :value
28
+
29
+ # @return [Boolean]
30
+ def cell?
31
+ true
32
+ end
33
+
34
+ # An object is equal when its values are the same.
35
+ #
36
+ # @param other [void]
37
+ # @return [Boolean]
38
+ def eql?(other)
39
+ self.class == other.class &&
40
+ position == other.position &&
41
+ value == other.value &&
42
+ colour == other.colour
43
+ end
44
+ alias_method :==, :eql?
45
+
46
+ private
47
+
48
+ # @return [Hash<Symbol => Hash<void>|NilClass|String>]
49
+ def defaults
50
+ {
51
+ colour: {},
52
+ name: '',
53
+ position: nil,
54
+ style: '',
55
+ value: '',
56
+ }
57
+ end
58
+
59
+ # @return [Vedeu::Borders::Border]
60
+ def border
61
+ Vedeu.borders.by_name(name)
62
+ end
63
+
64
+ # @return [Vedeu::Geometries::Geometry]
65
+ def geometry
66
+ Vedeu.geometries.by_name(name)
67
+ end
68
+
69
+ # @return [Vedeu::Interfaces::Interface]
70
+ def interface
71
+ Vedeu.interfaces.by_name(name)
72
+ end
73
+
74
+ end # Empty
75
+
76
+ end # Cells
77
+
78
+ end # Vedeu
@@ -0,0 +1,24 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # with a custom value, colour and style.
7
+ #
8
+ # The Vedeu::Cells::Escape object represents an escape sequence as
9
+ # a single character, meaning they will behave dependent on the
10
+ # context in which they are used.
11
+ #
12
+ # (In a terminal, an escape sequence makes sense, when a view is
13
+ # being rendered as HTML, the sequence may be meaningless, for
14
+ # example; the sequence to show or hide the cursor.)
15
+ #
16
+ # @api private
17
+ #
18
+ class Escape < Vedeu::Cells::Empty
19
+
20
+ end # Escape
21
+
22
+ end # Cells
23
+
24
+ end # Vedeu
@@ -0,0 +1,19 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # with a custom value, colour and style.
7
+ #
8
+ # The Vedeu::Cells::HTML object represents a cell as a snippet
9
+ # of HTML. A table cell perhaps: `<td>a</td>`.
10
+ #
11
+ # @api private
12
+ #
13
+ class HTML < Vedeu::Cells::Empty
14
+
15
+ end # HTML
16
+
17
+ end # Cells
18
+
19
+ end # Vedeu
@@ -0,0 +1,19 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the character/escape sequence to draw one cell of a
6
+ # with a custom value, colour and style.
7
+ #
8
+ # The Vedeu::Cells::JSON object represents a cell as a snippet of
9
+ # JSON.
10
+ #
11
+ # @api private
12
+ #
13
+ class JSON < Vedeu::Cells::Empty
14
+
15
+ end # JSON
16
+
17
+ end # Cells
18
+
19
+ end # Vedeu
@@ -87,15 +87,15 @@ module Vedeu
87
87
 
88
88
  # @return [Vedeu::Colours::Background]
89
89
  def background
90
- @background = Vedeu::Colours::Background.coerce(@background)
90
+ @_background ||= Vedeu::Colours::Background.coerce(@background)
91
91
  end
92
92
 
93
93
  # Converts the value into a Vedeu::Colours::Background.
94
94
  #
95
95
  # @param value [String]
96
- # @return [String]
96
+ # @return [Vedeu::Colours::Foreground]
97
97
  def background=(value)
98
- @background = Vedeu::Colours::Background.coerce(value)
98
+ @_background = @background = Vedeu::Colours::Background.coerce(value)
99
99
  end
100
100
 
101
101
  # An object is equal when its values are the same.
@@ -110,15 +110,15 @@ module Vedeu
110
110
 
111
111
  # @return [Vedeu::Colours::Foreground]
112
112
  def foreground
113
- @foreground = Vedeu::Colours::Foreground.coerce(@foreground)
113
+ @_foreground ||= Vedeu::Colours::Foreground.coerce(@foreground)
114
114
  end
115
115
 
116
116
  # Converts the value into a Vedeu::Colours::Foreground.
117
117
  #
118
118
  # @param value [String]
119
- # @return [String]
119
+ # @return [Vedeu::Colours::Foreground]
120
120
  def foreground=(value)
121
- @foreground = Vedeu::Colours::Foreground.coerce(value)
121
+ @_foreground = @foreground = Vedeu::Colours::Foreground.coerce(value)
122
122
  end
123
123
 
124
124
  # Returns both or either of the converted attributes into a
data/lib/vedeu/common.rb CHANGED
@@ -15,6 +15,15 @@ module Vedeu
15
15
  !present?(variable)
16
16
  end
17
17
 
18
+ # Converts one class into another.
19
+ #
20
+ # @param klass [Class] The class to become an instance of.
21
+ # @param attributes [Hash] The attributes of klass.
22
+ # @return [Class] Returns a new instance of klass.
23
+ def become(klass, attributes)
24
+ klass.new(attributes)
25
+ end
26
+
18
27
  # Removes the module part from the expression in the string.
19
28
  #
20
29
  # @example
@@ -14,9 +14,8 @@ module Vedeu
14
14
  def_delegators :cursor,
15
15
  :visible?
16
16
 
17
- # @param name [String|Symbol]
18
- # @param direction [Symbol]
19
- # @return [Vedeu::Cursors::Cursor]
17
+ # @param (see #initialize)
18
+ # @return (see #move)
20
19
  def self.move(name, direction)
21
20
  new(name, direction).move
22
21
  end
@@ -9,7 +9,7 @@ module Vedeu
9
9
  class Insert
10
10
 
11
11
  # @param (see #initialize)
12
- # @return [Vedeu::Editor::Line|Vedeu::Editor::Lines]
12
+ # @return (see #insert)
13
13
  def self.into(collection, entity, index = nil, size = 0)
14
14
  new(collection, entity, index, size).insert
15
15
  end
@@ -8,9 +8,8 @@ module Vedeu
8
8
  #
9
9
  class Item
10
10
 
11
- # @param collection [Vedeu::Editor::Line|Vedeu::Editor::Lines]
12
- # @param index [Fixnum]
13
- # @return [String|Vedeu::Editor::Line]
11
+ # @param (see #initialize)
12
+ # @return (see #by_index)
14
13
  def self.by_index(collection, index = nil)
15
14
  new(collection, index).by_index
16
15
  end