vedeu 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/README.md +1 -1
  4. data/docs/api.md +60 -67
  5. data/docs/configuration.md +8 -5
  6. data/docs/events.md +31 -15
  7. data/docs/events/application.md +12 -0
  8. data/docs/events/document.md +57 -0
  9. data/docs/events/drb.md +43 -0
  10. data/docs/events/focus.md +24 -0
  11. data/docs/events/menu.md +57 -0
  12. data/docs/events/movement.md +57 -0
  13. data/docs/events/refresh.md +25 -0
  14. data/docs/events/system.md +90 -0
  15. data/docs/events/visibility.md +68 -0
  16. data/lib/vedeu.rb +2 -2
  17. data/lib/vedeu/all.rb +3 -2
  18. data/lib/vedeu/api.rb +18 -18
  19. data/lib/vedeu/application/controller.rb +1 -1
  20. data/lib/vedeu/application/helper.rb +1 -1
  21. data/lib/vedeu/application/view.rb +1 -1
  22. data/lib/vedeu/bindings/application.rb +1 -12
  23. data/lib/vedeu/bindings/bindings.rb +3 -1
  24. data/lib/vedeu/bindings/document.rb +9 -62
  25. data/lib/vedeu/bindings/drb.rb +12 -56
  26. data/lib/vedeu/bindings/focus.rb +3 -28
  27. data/lib/vedeu/bindings/menus.rb +10 -66
  28. data/lib/vedeu/bindings/movement.rb +4 -69
  29. data/lib/vedeu/bindings/refresh.rb +3 -33
  30. data/lib/vedeu/bindings/system.rb +14 -100
  31. data/lib/vedeu/bindings/visibility.rb +20 -71
  32. data/lib/vedeu/borders/all.rb +4 -3
  33. data/lib/vedeu/borders/border.rb +39 -33
  34. data/lib/vedeu/borders/dsl.rb +40 -33
  35. data/lib/vedeu/borders/null.rb +2 -2
  36. data/lib/vedeu/borders/render.rb +29 -24
  37. data/lib/vedeu/borders/repository.rb +2 -2
  38. data/lib/vedeu/buffers/all.rb +8 -7
  39. data/lib/vedeu/buffers/buffer.rb +47 -39
  40. data/lib/vedeu/buffers/null.rb +2 -2
  41. data/lib/vedeu/buffers/refresh.rb +4 -3
  42. data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
  43. data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
  44. data/lib/vedeu/colours/background.rb +2 -1
  45. data/lib/vedeu/colours/colour.rb +21 -19
  46. data/lib/vedeu/colours/foreground.rb +2 -1
  47. data/lib/vedeu/colours/repository.rb +6 -5
  48. data/lib/vedeu/colours/translator.rb +39 -35
  49. data/lib/vedeu/configuration/api.rb +59 -51
  50. data/lib/vedeu/configuration/cli.rb +9 -7
  51. data/lib/vedeu/configuration/configuration.rb +41 -32
  52. data/lib/vedeu/cursors/cursor.rb +1 -1
  53. data/lib/vedeu/cursors/refresh.rb +20 -16
  54. data/lib/vedeu/distributed/server.rb +8 -6
  55. data/lib/vedeu/distributed/subprocess.rb +90 -86
  56. data/lib/vedeu/distributed/uri.rb +4 -3
  57. data/lib/vedeu/dsl/composition.rb +2 -2
  58. data/lib/vedeu/dsl/group.rb +4 -4
  59. data/lib/vedeu/dsl/interface.rb +5 -5
  60. data/lib/vedeu/dsl/presentation.rb +2 -2
  61. data/lib/vedeu/dsl/text.rb +1 -1
  62. data/lib/vedeu/editor/cropper.rb +4 -4
  63. data/lib/vedeu/editor/cursor.rb +6 -4
  64. data/lib/vedeu/editor/document.rb +20 -18
  65. data/lib/vedeu/editor/editor.rb +2 -2
  66. data/lib/vedeu/editor/line.rb +10 -5
  67. data/lib/vedeu/editor/lines.rb +2 -2
  68. data/lib/vedeu/internal_api.rb +4 -4
  69. data/lib/vedeu/models/focus.rb +197 -191
  70. data/lib/vedeu/models/group.rb +171 -159
  71. data/lib/vedeu/models/groups.rb +14 -10
  72. data/lib/vedeu/models/interface.rb +116 -110
  73. data/lib/vedeu/models/interfaces.rb +24 -20
  74. data/lib/vedeu/models/toggleable.rb +4 -4
  75. data/lib/vedeu/models/views/char.rb +1 -1
  76. data/lib/vedeu/models/views/composition.rb +1 -1
  77. data/lib/vedeu/models/views/line.rb +1 -1
  78. data/lib/vedeu/models/views/stream.rb +1 -1
  79. data/lib/vedeu/models/views/view.rb +1 -1
  80. data/lib/vedeu/null/interface.rb +1 -1
  81. data/lib/vedeu/null/view.rb +1 -1
  82. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  83. data/lib/vedeu/output/compressor.rb +78 -73
  84. data/lib/vedeu/output/direct.rb +61 -57
  85. data/lib/vedeu/output/output.rb +34 -29
  86. data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
  87. data/lib/vedeu/output/presentation/style.rb +64 -18
  88. data/lib/vedeu/output/presentation/styles.rb +39 -0
  89. data/lib/vedeu/output/renderers/html.rb +2 -2
  90. data/lib/vedeu/output/renderers/json.rb +2 -1
  91. data/lib/vedeu/output/renderers/terminal.rb +3 -3
  92. data/lib/vedeu/output/renderers/text.rb +3 -3
  93. data/lib/vedeu/output/text.rb +186 -180
  94. data/lib/vedeu/output/wordwrap.rb +142 -138
  95. data/lib/vedeu/refresh/refresh.rb +2 -2
  96. data/lib/vedeu/templating/helpers.rb +11 -6
  97. data/lib/vedeu/templating/view_template.rb +1 -1
  98. data/lib/vedeu/terminal/terminal.rb +2 -2
  99. data/lib/vedeu/version.rb +1 -1
  100. data/test/lib/vedeu/borders/render_test.rb +1 -1
  101. data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
  102. data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
  103. data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
  104. data/test/lib/vedeu/colours/colour_test.rb +4 -4
  105. data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
  106. data/test/lib/vedeu/cursors/repository_test.rb +3 -3
  107. data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
  108. data/test/lib/vedeu/dsl/group_test.rb +3 -3
  109. data/test/lib/vedeu/dsl/interface_test.rb +6 -5
  110. data/test/lib/vedeu/dsl/line_test.rb +4 -2
  111. data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
  112. data/test/lib/vedeu/dsl/text_test.rb +8 -8
  113. data/test/lib/vedeu/editor/document_test.rb +10 -6
  114. data/test/lib/vedeu/input/keymap_test.rb +1 -10
  115. data/test/lib/vedeu/models/focus_test.rb +177 -170
  116. data/test/lib/vedeu/models/group_test.rb +99 -95
  117. data/test/lib/vedeu/models/groups_test.rb +13 -9
  118. data/test/lib/vedeu/models/interface_test.rb +93 -87
  119. data/test/lib/vedeu/models/interfaces_test.rb +24 -20
  120. data/test/lib/vedeu/models/views/char_test.rb +2 -2
  121. data/test/lib/vedeu/models/views/line_test.rb +11 -7
  122. data/test/lib/vedeu/models/views/stream_test.rb +1 -1
  123. data/test/lib/vedeu/models/views/view_test.rb +1 -1
  124. data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
  125. data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
  126. data/test/lib/vedeu/output/compressor_test.rb +126 -122
  127. data/test/lib/vedeu/output/direct_test.rb +49 -43
  128. data/test/lib/vedeu/output/output_test.rb +35 -31
  129. data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
  130. data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
  131. data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
  132. data/test/lib/vedeu/output/text_test.rb +109 -105
  133. data/test/lib/vedeu/output/viewport_test.rb +3 -1
  134. data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
  135. data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
  136. data/test/lib/vedeu/templating/helpers_test.rb +6 -6
  137. data/test/lib/vedeu/templating/view_template_test.rb +1 -1
  138. metadata +17 -8
  139. data/lib/vedeu/output/style.rb +0 -76
  140. data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -1,4 +1,5 @@
1
1
  require 'vedeu/output/presentation/colour'
2
+ require 'vedeu/output/presentation/styles'
2
3
  require 'vedeu/output/presentation/style'
3
4
 
4
5
  module Vedeu
@@ -9,7 +10,7 @@ module Vedeu
9
10
  module Presentation
10
11
 
11
12
  include Vedeu::Presentation::Colour
12
- include Vedeu::Presentation::Style
13
+ include Vedeu::Presentation::Styles
13
14
 
14
15
  # Converts the colours and styles to escape sequences, and when the parent
15
16
  # model has previously set the colour and style, reverts back to that for
@@ -2,34 +2,80 @@ module Vedeu
2
2
 
3
3
  module Presentation
4
4
 
5
- # Provides style related presentation behaviour.
5
+ # Converts the style value or value collection into a terminal
6
+ # escape sequence. Unrecognised values are discarded- an empty
7
+ # string is returned.
6
8
  #
7
- module Style
9
+ # Vedeu has a range of symbol styles which are compatible with
10
+ # most terminals which are ANSI compatible. Like colours, they can
11
+ # be defined in either interfaces, for specific lines or within
12
+ # streams. Styles are applied as encountered.
13
+ #
14
+ # @see Vedeu::Esc
15
+ #
16
+ class Style
17
+
18
+ include Vedeu::Common
19
+
20
+ # @!attribute [rw] value
21
+ # @return [String|Symbol]
22
+ attr_accessor :value
8
23
 
9
- # When the style for the model exists, return it, otherwise returns the
10
- # parent style, or an empty Vedeu::Style.
24
+ # Produces new objects of the correct class from the value,
25
+ # ignores objects that have already been coerced.
11
26
  #
12
- # @return [Vedeu::Style]
13
- def style
14
- @style ||= if attributes[:style]
15
- Vedeu::Style.coerce(attributes[:style])
27
+ # @param value [Object|NilClass]
28
+ # @return [Object]
29
+ def self.coerce(value)
30
+ if value.is_a?(self)
31
+ value
16
32
 
17
- elsif parent
18
- Vedeu::Style.coerce(parent.style)
33
+ else
34
+ new(value)
19
35
 
20
- else
21
- Vedeu::Style.new
36
+ end
37
+ end
22
38
 
23
- end
39
+ # Return a new instance of Vedeu::Presentation::Style.
40
+ #
41
+ # @param value [Array<String|Symbol>|String|Symbol]
42
+ # The style value or a collection of values.
43
+ # @return [Vedeu::Presentation::Style]
44
+ def initialize(value = nil)
45
+ @value = value
24
46
  end
25
47
 
26
- # Allows the setting of the style by coercing the given value into a
27
- # Vedeu::Style.
48
+ # Return an attributes hash for this class.
28
49
  #
29
- # @return [Vedeu::Style]
30
- def style=(value)
31
- @style = Vedeu::Style.coerce(value)
50
+ # @return [Hash<Symbol => Array<String|Symbol>|String|Symbol>]
51
+ def attributes
52
+ {
53
+ style: value,
54
+ }
55
+ end
56
+
57
+ # An object is equal when its values are the same.
58
+ #
59
+ # @param other [Vedeu::Views::Char]
60
+ # @return [Boolean]
61
+ def eql?(other)
62
+ self.class == other.class && value == other.value
63
+ end
64
+ alias_method :==, :eql?
65
+
66
+ # Return the terminal escape sequences after converting the
67
+ # style or styles.
68
+ #
69
+ # @return [String]
70
+ def to_s
71
+ return '' unless present?(value)
72
+
73
+ @sequences ||= Array(value).flatten.map do |v|
74
+ Vedeu::Esc.string(v)
75
+ end.join
32
76
  end
77
+ alias_method :escape_sequences, :to_s
78
+ alias_method :to_str, :to_s
33
79
 
34
80
  end # Style
35
81
 
@@ -0,0 +1,39 @@
1
+ module Vedeu
2
+
3
+ module Presentation
4
+
5
+ # Provides style related presentation behaviour.
6
+ #
7
+ module Styles
8
+
9
+ # When the style for the model exists, return it, otherwise
10
+ # returns the parent style, or an empty
11
+ # {Vedeu::Presentation::Style}.
12
+ #
13
+ # @return [Vedeu::Presentation::Style]
14
+ def style
15
+ @style ||= if attributes[:style]
16
+ Vedeu::Presentation::Style.coerce(attributes[:style])
17
+
18
+ elsif parent
19
+ Vedeu::Presentation::Style.coerce(parent.style)
20
+
21
+ else
22
+ Vedeu::Presentation::Style.new
23
+
24
+ end
25
+ end
26
+
27
+ # Allows the setting of the style by coercing the given value
28
+ # into a {Vedeu::Presentation::Style}.
29
+ #
30
+ # @return [Vedeu::Presentation::Style]
31
+ def style=(value)
32
+ @style = Vedeu::Presentation::Style.coerce(value)
33
+ end
34
+
35
+ end # Style
36
+
37
+ end # Presentation
38
+
39
+ end # Vedeu
@@ -2,8 +2,8 @@ module Vedeu
2
2
 
3
3
  module Renderers
4
4
 
5
- # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML
6
- # snippet; a table by default.
5
+ # Renders a {Vedeu::Buffers::VirtualBuffer} or
6
+ # {Vedeu::Output::Output} as a HTML snippet; a table by default.
7
7
  #
8
8
  class HTML < Vedeu::Renderers::File
9
9
 
@@ -2,7 +2,8 @@ module Vedeu
2
2
 
3
3
  module Renderers
4
4
 
5
- # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as JSON.
5
+ # Renders a {Vedeu::Buffers::VirtualBuffer} or
6
+ # {Vedeu::Output::Output} as JSON.
6
7
  #
7
8
  class JSON < Vedeu::Renderers::File
8
9
 
@@ -2,8 +2,8 @@ module Vedeu
2
2
 
3
3
  module Renderers
4
4
 
5
- # Converts a grid of {Vedeu::Views::Char} objects into a stream of escape
6
- # sequences and content suitable for a terminal.
5
+ # Converts a grid of {Vedeu::Views::Char} objects into a stream of
6
+ # escape sequences and content suitable for a terminal.
7
7
  #
8
8
  class Terminal
9
9
 
@@ -31,7 +31,7 @@ module Vedeu
31
31
  store!(output)
32
32
 
33
33
  Vedeu.timer('Compression') do
34
- Vedeu::Compressor.render(output)
34
+ Vedeu::Output::Compressor.render(output)
35
35
  end
36
36
  end
37
37
 
@@ -2,8 +2,8 @@ module Vedeu
2
2
 
3
3
  module Renderers
4
4
 
5
- # Converts a grid of {Vedeu::Views::Char} objects into a stream of escape
6
- # sequences and content.
5
+ # Converts a grid of {Vedeu::Views::Char} objects into a stream of
6
+ # escape sequences and content.
7
7
  #
8
8
  class Text
9
9
 
@@ -20,7 +20,7 @@ module Vedeu
20
20
  # @param output [Array<Array<Vedeu::Views::Char>>]
21
21
  # @return [String]
22
22
  def render(output)
23
- Vedeu::Compressor.render(output)
23
+ Vedeu::Output::Compressor.render(output)
24
24
  end
25
25
 
26
26
  end # Text
@@ -1,216 +1,222 @@
1
1
  module Vedeu
2
2
 
3
- # Present a string (or object responding to `to_s`).
4
- #
5
- class Text
3
+ module Output
6
4
 
7
- # @see Vedeu::DSL::Text#text
8
- def self.add(value = '', options = {})
9
- new(value, options).add
10
- end
5
+ # Present a string (or object responding to `to_s`).
6
+ #
7
+ class Text
11
8
 
12
- # @see Vedeu::DSL::Text#text
13
- def self.with(value = '', options = {})
14
- new(value, options).aligned
15
- end
9
+ # @see Vedeu::DSL::Text#text
10
+ def self.add(value = '', options = {})
11
+ new(value, options).add
12
+ end
16
13
 
17
- # Returns a new instance of Vedeu::Text.
18
- #
19
- # @param value [String]
20
- # @param options [Hash]
21
- # @option options anchor [Symbol] See {Text#anchor}
22
- # @option options background [String]
23
- # @option options colour [Hash|NilClass]
24
- # @option options foreground [String]
25
- # @option options model
26
- # [Vedeu::Views::View|Vedeu::Views::Line|Vedeu::Views::Stream]
27
- # @option options pad [String]
28
- # @option options width [Integer]
29
- # @return [Vedeu::Text]
30
- def initialize(value = '', options = {})
31
- @value = value
32
- @options = defaults.merge!(options)
33
- end
34
-
35
- # Aligns the value.
36
- #
37
- # @return [String]
38
- def aligned
39
- return string unless width
14
+ # @see Vedeu::DSL::Text#text
15
+ def self.with(value = '', options = {})
16
+ new(value, options).aligned
17
+ end
40
18
 
41
- return truncated if truncate?
19
+ # Returns a new instance of Vedeu::Output::Text.
20
+ #
21
+ # @param value [String]
22
+ # @param options [Hash]
23
+ # @option options anchor [Symbol] See {Text#anchor}
24
+ # @option options background [String]
25
+ # @option options colour [Hash|NilClass]
26
+ # @option options foreground [String]
27
+ # @option options model
28
+ # [Vedeu::Views::View|Vedeu::Views::Line|Vedeu::Views::Stream]
29
+ # @option options pad [String]
30
+ # @option options width [Integer]
31
+ # @return [Vedeu::Output::Text]
32
+ def initialize(value = '', options = {})
33
+ @value = value
34
+ @options = defaults.merge!(options)
35
+ end
42
36
 
43
- case anchor
44
- when :align, :left, :text then left
45
- when :centre, :center then centre
46
- when :right then right
47
- else
48
- left
37
+ # Aligns the value.
38
+ #
39
+ # @return [String]
40
+ def aligned
41
+ return string unless width
42
+
43
+ return truncated if truncate?
44
+
45
+ case anchor
46
+ when :align, :left, :text then left
47
+ when :centre, :center then centre
48
+ when :right then right
49
+ else
50
+ left
51
+ end
49
52
  end
50
- end
51
53
 
52
- # Adds the content to the model.
53
- #
54
- # @return [void]
55
- def add
56
- model.add(content)
57
- end
54
+ # Adds the content to the model.
55
+ #
56
+ # @return [void]
57
+ def add
58
+ model.add(content)
59
+ end
58
60
 
59
- protected
61
+ protected
60
62
 
61
- # @!attribute [r] value
62
- # @return [String]
63
- attr_reader :value
63
+ # @!attribute [r] value
64
+ # @return [String]
65
+ attr_reader :value
64
66
 
65
- # @!attribute [r] options
66
- # @return [Hash]
67
- attr_reader :options
67
+ # @!attribute [r] options
68
+ # @return [Hash]
69
+ attr_reader :options
68
70
 
69
- private
71
+ private
70
72
 
71
- # @return [Symbol] One of :align, :centre, :center, :left, :right, :text
72
- def anchor
73
- options[:anchor]
74
- end
73
+ # @return [Symbol] One of :align, :centre, :center, :left,
74
+ # :right, :text
75
+ def anchor
76
+ options[:anchor]
77
+ end
75
78
 
76
- # The string padded to width, centralized.
77
- #
78
- # @return [String]
79
- def centre
80
- string.center(width, pad)
81
- end
79
+ # The string padded to width, centralized.
80
+ #
81
+ # @return [String]
82
+ def centre
83
+ string.center(width, pad)
84
+ end
82
85
 
83
- # If a colour, background or foreground option is set, use them as the
84
- # colour settings for the new Vedeu::Views::Stream.
85
- #
86
- # @return [void]
87
- def colour
88
- if options[:colour] || options[:background] || options[:foreground]
89
- Vedeu::Colours::Colour.coerce(options)
86
+ # If a colour, background or foreground option is set, use them
87
+ # as the colour settings for the new Vedeu::Views::Stream.
88
+ #
89
+ # @return [void]
90
+ def colour
91
+ if options[:colour] || options[:background] || options[:foreground]
92
+ Vedeu::Colours::Colour.coerce(options)
90
93
 
91
- else
92
- model.colour
94
+ else
95
+ model.colour
93
96
 
97
+ end
94
98
  end
95
- end
96
99
 
97
- # Returns either a Vedeu::Views::Line or Vedeu::Views::Stream containing the
98
- # text value.
99
- #
100
- # @return [Vedeu::Views::Line|Vedeu::Views::Stream]
101
- def content
102
- if model.is_a?(Vedeu::Views::View)
103
- stream.parent = line
104
- line.add(stream)
105
- line
100
+ # Returns either a Vedeu::Views::Line or Vedeu::Views::Stream
101
+ # containing the text value.
102
+ #
103
+ # @return [Vedeu::Views::Line|Vedeu::Views::Stream]
104
+ def content
105
+ if model.is_a?(Vedeu::Views::View)
106
+ stream.parent = line
107
+ line.add(stream)
108
+ line
106
109
 
107
- else
108
- stream
110
+ else
111
+ stream
109
112
 
113
+ end
110
114
  end
111
- end
112
115
 
113
- # The default values for a new instance of this class.
114
- #
115
- # @return [Hash<Symbol => NilClass, String, Symbol>]
116
- def defaults
117
- {
118
- anchor: :left,
119
- colour: nil,
120
- model: nil,
121
- pad: ' ',
122
- width: nil,
123
- }
124
- end
125
-
126
- # The string padded to width, left justified.
127
- #
128
- # @return [String]
129
- def left
130
- string.ljust(width, pad)
131
- end
116
+ # The default values for a new instance of this class.
117
+ #
118
+ # @return [Hash<Symbol => NilClass, String, Symbol>]
119
+ def defaults
120
+ {
121
+ anchor: :left,
122
+ colour: nil,
123
+ model: nil,
124
+ pad: ' ',
125
+ width: nil,
126
+ }
127
+ end
132
128
 
133
- # @return [Vedeu::Views::Line]
134
- def line
135
- @line ||= Vedeu::Views::Line.build(parent: parent)
136
- end
129
+ # The string padded to width, left justified.
130
+ #
131
+ # @return [String]
132
+ def left
133
+ string.ljust(width, pad)
134
+ end
137
135
 
138
- # Returns the model option when set.
139
- #
140
- # @return [Vedeu::Views::View|
141
- # Vedeu::Views::Line|
142
- # Vedeu::Null::Generic|
143
- # Vedeu::Views::Stream]
144
- def model
145
- @model ||= options[:model] || Vedeu::Null::Generic.new
146
- end
147
-
148
- # The character to use for padding the string.
149
- #
150
- # @return [String]
151
- def pad
152
- options[:pad]
153
- end
136
+ # @return [Vedeu::Views::Line]
137
+ def line
138
+ @line ||= Vedeu::Views::Line.build(parent: parent)
139
+ end
154
140
 
155
- # Returns the parent for the new Vedeu::Views::Stream.
156
- #
157
- # @return [void]
158
- def parent
159
- model.is_a?(Vedeu::Views::Stream) ? model.parent : model
160
- end
141
+ # Returns the model option when set.
142
+ #
143
+ # @return [Vedeu::Views::View|
144
+ # Vedeu::Views::Line|
145
+ # Vedeu::Null::Generic|
146
+ # Vedeu::Views::Stream]
147
+ def model
148
+ @model ||= options[:model] || Vedeu::Null::Generic.new
149
+ end
161
150
 
162
- # The string padded to width, right justified.
163
- #
164
- # @return [String]
165
- def right
166
- string.rjust(width, pad)
167
- end
151
+ # The character to use for padding the string.
152
+ #
153
+ # @return [String]
154
+ def pad
155
+ options[:pad]
156
+ end
168
157
 
169
- # Builds and returns a new Vedeu::Views::Stream.
170
- #
171
- # @return [void]
172
- def stream
173
- @stream ||= Vedeu::Views::Stream.build(colour: colour,
174
- parent: parent,
175
- style: style,
176
- value: aligned)
177
- end
178
-
179
- # The string, coerced.
180
- #
181
- # @return [String]
182
- def string
183
- value.to_s
184
- end
158
+ # Returns the parent for the new Vedeu::Views::Stream.
159
+ #
160
+ # @return [void]
161
+ def parent
162
+ model.is_a?(Vedeu::Views::Stream) ? model.parent : model
163
+ end
185
164
 
186
- # Returns the model's styles.
187
- #
188
- # @return [void]
189
- def style
190
- model.style
191
- end
165
+ # The string padded to width, right justified.
166
+ #
167
+ # @return [String]
168
+ def right
169
+ string.rjust(width, pad)
170
+ end
192
171
 
193
- # Return a boolean indicating that the string is greater than the width.
194
- #
195
- # @return [Boolean]
196
- def truncate?
197
- string.size > width
198
- end
172
+ # Builds and returns a new Vedeu::Views::Stream.
173
+ #
174
+ # @return [void]
175
+ def stream
176
+ @stream ||= Vedeu::Views::Stream.build(colour: colour,
177
+ parent: parent,
178
+ style: style,
179
+ value: aligned)
180
+ end
199
181
 
200
- # Return the string truncated to the width.
201
- #
202
- # @return [String]
203
- def truncated
204
- string.slice(0, width)
205
- end
182
+ # The string, coerced.
183
+ #
184
+ # @return [String]
185
+ def string
186
+ value.to_s
187
+ end
206
188
 
207
- # Return the width.
208
- #
209
- # @return [Fixnum]
210
- def width
211
- options[:width]
212
- end
189
+ # Returns the model's styles.
190
+ #
191
+ # @return [void]
192
+ def style
193
+ model.style
194
+ end
195
+
196
+ # Return a boolean indicating that the string is greater than
197
+ # the width.
198
+ #
199
+ # @return [Boolean]
200
+ def truncate?
201
+ string.size > width
202
+ end
203
+
204
+ # Return the string truncated to the width.
205
+ #
206
+ # @return [String]
207
+ def truncated
208
+ string.slice(0, width)
209
+ end
210
+
211
+ # Return the width.
212
+ #
213
+ # @return [Fixnum]
214
+ def width
215
+ options[:width]
216
+ end
217
+
218
+ end # Text
213
219
 
214
- end # Align
220
+ end # Output
215
221
 
216
222
  end # Vedeu