def saveas name=nil, config={}
      unless name
        name = rb_gets "File to save as: "
        return if name.nil? || name == ""
      end
      overwrite_if_exists = config[:overwrite_if_exists] || false
      unless overwrite_if_exists
        exists = File.exists? name
        if exists # need to prompt
          return unless rb_confirm("Overwrite existing file? ")
        end
      end
      # if it has been set do not prompt. or ask only if value is :ask
      # But this should only be if there is someformatting provided, that is there 
      # is a @document
      l = @list
      # the check for document is to see if it is some old widget like textarea that is calling this.
      if @document
        if config.key? :save_with_formatting
          save_with_formatting = config[:save_with_formatting] 
        else
          save_with_formatting = rb_confirm("Save with formatting?")
        end
        if save_with_formatting
          l = @list
        else
          l = @document.native_text().map do |w| w.to_s ; end
        end
      end
      #l = getvalue
      File.open(name, "w"){ |f|
        l.each { |line| f.puts line }
        #l.each { |line| f.write line.gsub(/\r/,"\n") }
      }
      rb_puts "#{name} written."
    end
def saveas name=nil, config={}
      unless name
        name = rb_gets "File to save as: "
        return if name.nil? || name == ""
      end
      overwrite_if_exists = config[:overwrite_if_exists] || false
      unless overwrite_if_exists
        exists = File.exists? name
        if exists # need to prompt
          return unless rb_confirm("Overwrite existing file? ")
        end
      end
      # if it has been set do not prompt. or ask only if value is :ask
      # But this should only be if there is someformatting provided, that is there 
      # is a @document
      l = @list
      # the check for document is to see if it is some old widget like textarea that is calling this.
      if @document
        if config.key? :save_with_formatting
          save_with_formatting = config[:save_with_formatting] 
        else
          save_with_formatting = rb_confirm("Save with formatting?")
        end
        if save_with_formatting
          l = @list
        else
          l = @document.native_text().map do |w| w.to_s ; end
        end
      end
      #l = getvalue
      File.open(name, "w"){ |f|
        l.each { |line| f.puts line }
        #l.each { |line| f.write line.gsub(/\r/,"\n") }
      }
      rb_puts "#{name} written."
    end
def
 adding here so that textpad can also use. Earlier in textarea only
 Test out with textarea too TODO
 2014-09-03 - 12:49