Sha256: a9b9d1989f83df858349de7ae86f08b32765de8685ca80b4ae22aae495e69b26
Contents?: true
Size: 461 Bytes
Versions: 6
Compression:
Stored size: 461 Bytes
Contents
module Rainbow class StringUtils def self.wrap_with_sgr(string, codes) return string if codes.empty? seq = "\e[" + codes.join(";") + "m" match = string.match(/^(\e\[([\d;]+)m)*/) if match seq_pos = match.end(0) string = string[0...seq_pos] + seq + string[seq_pos..-1] else string = seq + string end string = string + "\e[0m" unless string =~ /\e\[0m$/ string end end end
Version data entries
6 entries across 6 versions & 2 rubygems