Good call.
I think this needed a minor revision to make it work if there was no text selected (no previous color) and you just wanted to insert a color. Once again, probably not the most elegant way to handle it (but it works). Let me know what you think.
Why not instead simply give it a default, if string is empty?
string = STDIN.read string = "#999" if string.empty? prefix, string = string.match(/(#?)(.*)/)[1,2] string = $1 * 2 + $2 * 2 + $3 * 2 if string =~ /^(.)(.)(.)$/ def_col = ' default color {' + string.scan(/../).map { |i| i.hex * 257 }.join(",") + '}' ......
Haris
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................