diff --git a/lib/vedeu/output/text.rb b/lib/vedeu/output/text.rb index e4083265a..7f4eb3f3e 100644 --- a/lib/vedeu/output/text.rb +++ b/lib/vedeu/output/text.rb @@ -14,6 +14,7 @@ def self.add(value = '', options = {}) end # @see Vedeu::DSL::Text#text + # @todo Remove this method once functionality moved elsewhere. def self.with(value = '', options = {}) new(value, options).aligned end @@ -60,9 +61,15 @@ def aligned # @return [void] def add if wrap? - model.add(wrapped) + if view? + model.add(wrapped) - else + elsif line? && model_parent_view? + model_parent.add(wrapped) + + end + + elsif model model.add(content) end @@ -106,9 +113,12 @@ def colour if options[:colour] || options[:background] || options[:foreground] Vedeu::Colours::Colour.coerce(options) - else + elsif model model.colour + else + {} + end end @@ -157,6 +167,16 @@ def line @line ||= Vedeu::Views::Line.build(parent: parent, client: client) end + # @return [Boolean] + def view? + model && model.is_a?(Vedeu::Views::View) + end + + # @return [Boolean] + def line? + model && model.is_a?(Vedeu::Views::Line) + end + # Returns the model option when set. # # @return [Vedeu::Views::View| @@ -164,7 +184,18 @@ def line # Vedeu::Null::Generic| # Vedeu::Views::Stream] def model - @model ||= options[:model] || Vedeu::Null::Generic.new + options[:model] + end + + # @return [void] + def model_parent + options[:model].parent + end + + # @return [Boolean] + def model_parent_view? + options[:model].parent && + options[:model].parent.is_a?(Vedeu::Views::View) end # @see Vedeu::Output::Wordwrap#mode @@ -221,7 +252,7 @@ def string # # @return [void] def style - model.style + model.style if model end # Return a boolean indicating that the string is greater than diff --git a/test/support/examples/material_colours_app.rb b/test/support/examples/material_colours_app.rb index 69e4d4a32..682f683f2 100755 --- a/test/support/examples/material_colours_app.rb +++ b/test/support/examples/material_colours_app.rb @@ -277,7 +277,17 @@ class VedeuMaterialColoursApp colour background: '#555555', foreground: '#ffffff' geometry do x 3 - xn 13 + xn 23 + y 36 + yn 39 + end + end + + Vedeu.interface 'wrapping2' do + colour background: '#888888', foreground: '#ffffff' + geometry do + x 26 + xn 46 y 36 yn 39 end @@ -598,6 +608,9 @@ class VedeuMaterialColoursApp line { text 'This is a line of text that should wrap.', mode: :wrap } end end + view('wrapping2') do + text 'This is a line of text that should wrap.', mode: :wrap + end end Vedeu.focus_by_name 'main_interface'