def text(*val)
      if val.empty?
        return @list
      end
      $log.debug "  TEXTPAD inside text() with #{val.class} "
      case val
      when Array
        # either its an array of strings
        # or its an array, and val[0] is an array of strings, and val[1] is a hash / symbol TODO
        case val[0]
        when String
          # This is the usual simple case of an array of strings
          @list = val
          $log.debug "  creating TEXTDOC 0 with String"
        when TextDocument
          # this is repeating it seems FIXME
          $log.debug "  creating TEXTDOC 04 with TextDocu #{val[0].content_type} "

          @document = val[0]
          @document.source ||= self
          @document.parse_required # added 2014-09-03 - 17:54
          @list = @document.text
        when Array
          # This is the complex case which i would like to phase out.
          # Earlier this was what was used where the second arg was an optional hash
          @list = val[0]
          if val[1].is_a? Symbol
            content_type = val[1]
            hsh = { :text => @list, :content_type => content_type }
            $log.debug "  creating TEXTDOC 1 with #{content_type} "
            @document = TextDocument.new hsh
            @document.source = self
          elsif val[1].is_a? Hash
            # this is hack for those cases where ct is there, but the caller may not
            # pass it in config
            if val[1].key? :content_type and val[1][:content_type].nil?
              ;
            else
              # content type comes nil from viewer/help which sets it later using block yield
              content_type = val[1][:content_type]
              stylesheet = val[1][:stylesheet]
              @title = val[1][:title] if val[1].key? :title
              $log.debug "  creating TEXTDOC 2 with ct=#{content_type}, #{val[1]} "
              @document = TextDocument.new val[1]
              @document.text = @list
              @document.source = self
            end
          else
          #raise "val_1 Unable to do anything with #{val[1].class} "
            $log.debug " val_1 Unable to do anything with #{val[1].class} in textpad text()"
          end
        else
          raise "val_0 Unable to do anything with #{val[0].class} "
        end
      when Hash
        $log.debug "  creating TEXTDOC 3 with #{val[:content_type]} "
        @document = TextDocument.new val
        @document.source ||= self
        @list = @document.text
      when TextDocument
        $log.debug "  creating TEXTDOC 4 with TextDocu #{val.content_type} "

        @document = val
        @document.source ||= self
        @document.parse_required # added 2014-09-03 - 17:54
        @list = @document.text
      end
      @_populate_needed = true
      @repaint_all = true
      @repaint_required = true
      init_vars
      # i don't want the whole thing going into the event 2014-06-04
      fire_property_change :text, "dummmy", "text has changed"
      self
    end
def text(*val)
      if val.empty?
        return @list
      end
      $log.debug "  TEXTPAD inside text() with #{val.class} "
      case val
      when Array
        # either its an array of strings
        # or its an array, and val[0] is an array of strings, and val[1] is a hash / symbol TODO
        case val[0]
        when String
          # This is the usual simple case of an array of strings
          @list = val
          $log.debug "  creating TEXTDOC 0 with String"
        when TextDocument
          # this is repeating it seems FIXME
          $log.debug "  creating TEXTDOC 04 with TextDocu #{val[0].content_type} "

          @document = val[0]
          @document.source ||= self
          @document.parse_required # added 2014-09-03 - 17:54
          @list = @document.text
        when Array
          # This is the complex case which i would like to phase out.
          # Earlier this was what was used where the second arg was an optional hash
          @list = val[0]
          if val[1].is_a? Symbol
            content_type = val[1]
            hsh = { :text => @list, :content_type => content_type }
            $log.debug "  creating TEXTDOC 1 with #{content_type} "
            @document = TextDocument.new hsh
            @document.source = self
          elsif val[1].is_a? Hash
            # this is hack for those cases where ct is there, but the caller may not
            # pass it in config
            if val[1].key? :content_type and val[1][:content_type].nil?
              ;
            else
              # content type comes nil from viewer/help which sets it later using block yield
              content_type = val[1][:content_type]
              stylesheet = val[1][:stylesheet]
              @title = val[1][:title] if val[1].key? :title
              $log.debug "  creating TEXTDOC 2 with ct=#{content_type}, #{val[1]} "
              @document = TextDocument.new val[1]
              @document.text = @list
              @document.source = self
            end
          else
          #raise "val_1 Unable to do anything with #{val[1].class} "
            $log.debug " val_1 Unable to do anything with #{val[1].class} in textpad text()"
          end
        else
          raise "val_0 Unable to do anything with #{val[0].class} "
        end
      when Hash
        $log.debug "  creating TEXTDOC 3 with #{val[:content_type]} "
        @document = TextDocument.new val
        @document.source ||= self
        @list = @document.text
      when TextDocument
        $log.debug "  creating TEXTDOC 4 with TextDocu #{val.content_type} "

        @document = val
        @document.source ||= self
        @document.parse_required # added 2014-09-03 - 17:54
        @list = @document.text
      end
      @_populate_needed = true
      @repaint_all = true
      @repaint_required = true
      init_vars
      # i don't want the whole thing going into the event 2014-06-04
      fire_property_change :text, "dummmy", "text has changed"
      self
    end
NOTE this breaks widgets and everyone's text which returns text of object
 also list by itself should return the list as in listbox,  not just set
 Supply an array of string to be displayed
 This will replace existing text
 display text given in an array format. This is the principal way of giving content
 to a textpad, other than filename().
 @param Array of lines
 @param format (optional) can be :tmux :ansi or :none
 If a format other than :none is given, then formatted_text is called.