From james@vennt.net Thu May 24 12:05:49 2007
From: james@vennt.net
To: textmate@lists.macromates.com
Subject: [TxMt] List all colours in a CSS file command
Date: Thu, 24 May 2007 05:05:12 -0700
Message-ID: <2088.80.229.93.65.1180008312.squirrel@webmail.vennt.net>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============3215375584554837773=="
--===============3215375584554837773==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Thanks for the regex tip Chris, worked great.
The command now displays Hex, RGB and Named colours (thanks to the bit I
copied out of the CSS language file) and I tidied some of the layout up a
bit to fit the longer colour names etc.
So here is my final version
#!/usr/bin/env ruby
myFile =3D STDIN.read
fileName =3D ENV['TM_FILENAME']
hex =3D
Regexp.new(/(#[0-9a-fA-F]{3,6})|(seagreen|hotpink|lawngreen|darkgreen|violet|=
darkred|crimson|green|sandybrown|navy|magenta|darkslategray|steelblue|silver|=
darkgrey|mistyrose|gray|aliceblue|blueviolet|lightpink|saddlebrown|chocolate|=
limegreen|lightslategray|yellowgreen|pink|lightskyblue|indigo|lightblue|flora=
lwhite|navajowhite|mediumvioletred|honeydew|aquamarine|blue|olivedrab|palegre=
en|slategray|lavenderblush|wheat|moccasin|mediumturquoise|mediumspringgreen|l=
ightcoral|mintcream|tomato|lightgrey|black|darkmagenta|dimgray|darkturquoise|=
midnightblue|plum|indianred|coral|lightcyan|mediumslateblue|darkcyan|darkslat=
eblue|darkkhaki|ivory|azure|khaki|powderblue|darkgoldenrod|orangered|burlywoo=
d|turquoise|royalblue|maroon|cornsilk|antiquewhite|yellow|teal|orange|grey|da=
rkslategrey|slateblue|seashell|darkorchid|snow|lightslategrey|cyan|greenyello=
w|palevioletred|goldenrod|deepskyblue|lightyellow|lightseagreen|sienna|lemonc=
hiffon|darkviolet|paleturquoise|slategrey|skyblue|purple|mediumpurple|cadetbl=
ue|fuchsia|chartreuse|darksalmon|lightgoldenrodyellow|white|springgreen|olive=
|forestgreen|peachpuff|peru|dimgrey|mediumseagreen|thistle|firebrick|darkgray=
|mediumaquamarine|darkolivegreen|mediumblue|palegoldenrod|blanchedalmond|ghos=
twhite|gold|gainsboro|darkseagreen|cornflowerblue|lime|lavender|beige|orchid|=
mediumorchid|whitesmoke|bisque|lightgray|tan|salmon|rosybrown|red|dodgerblue|=
brown|aqua|oldlace|deeppink|papayawhip|lightsalmon|lightsteelblue|darkorange|=
darkblue|linen|lightgreen)|(rgb\([0-9]{1,3}\,[0-9]{1,3}\,[0-9]{1,3}\))/)
def swatch(colour,lineNumber)
puts "
#{lineNumber}
"
end
puts '