def decorate(string, (fg, bg, bright, underline))
      if (!STDOUT.isatty) || @output_type == :raw || @disabled
        return string
      end

      fg = get_colour_instance fg
      bg = get_colour_instance bg

      output = []
      lines = string.lines.map(&:chomp)
      lines.each do |line|
        unless line.length <= 0
          line = case @palette.type
                 when "ansi" then colour_ansi line, fg, bg
                 when "extended" then colour_extended line, fg, bg
                 else raise "Unknown palette '#{@palette.type}'."
                 end

          if bright
            line = e(1) + line
          end

          if underline
            line = e(4) + line
          end

          if (bright or underline) and fg == nil and bg == nil
            line << e(0)
          end
        end

        output.push line
      end

      output << "" if string =~ /\n$/
      output.join "\n"
    end
def decorate(string, (fg, bg, bright, underline))
      if (!STDOUT.isatty) || @output_type == :raw || @disabled
        return string
      end

      fg = get_colour_instance fg
      bg = get_colour_instance bg

      output = []
      lines = string.lines.map(&:chomp)
      lines.each do |line|
        unless line.length <= 0
          line = case @palette.type
                 when "ansi" then colour_ansi line, fg, bg
                 when "extended" then colour_extended line, fg, bg
                 else raise "Unknown palette '#{@palette.type}'."
                 end

          if bright
            line = e(1) + line
          end

          if underline
            line = e(4) + line
          end

          if (bright or underline) and fg == nil and bg == nil
            line << e(0)
          end
        end

        output.push line
      end

      output << "" if string =~ /\n$/
      output.join "\n"
    end
Decorate a string according to the style passed. The input string
 is processed line-by-line (the escape sequences are added to each
 line). This is due to some problems I've been having with some
 terminal emulators not handling multi-line coloured sequences well.