[TxMt] Insert Color Revised (help needed)

Brett Terpstra brett at circlesixdesign.com
Sat Oct 21 02:42:41 UTC 2006


Okay, I'm trying to keep this one simple and meet my own needs at the  
same time.  First of all, the insert color command didn't recognize  
abbreviated (3 character) RGB color codes.  This had 2 drawbacks:   
The tab stop inserted by any of the CSS commands, when used in  
combination with Insert Color, would add an extra # sign and it  
wouldn't properly set the default color when it loaded the color  
picker.  This revised command is my usual unskilled kludge, but it  
recognizes both 3 and 6 character rgb strings, strips the # sign if  
unnecessary, and if the resulting hex code is a series of double  
repeating characters it will abbreviate (BBAADD becomes BAD).  I  
wanted to use squeeze to do this in Ruby, but had trouble with colors  
like 0000FF, where it would just give back 0F.  So I made a mess of  
it.  It works, but I'd really like to see it cleaned up (I know Haris  
could do this in about 4 lines of code).  So if anyone has the  
time... It'd be great to learn a new algorithm to handle this.

As a side note, I've been using Color Schemer Studio to create  
websmart palettes.  I can drag directly from the current color  
selection into textmate, but it was less convenient than the color  
picker.  So I've been creating the palettes, and then importing them  
into the color picker.  That's where this command came from...

Thanks,
Brett

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Insert Color revised.tmCommand
Type: application/octet-stream
Size: 1576 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20061020/cb1f94e1/attachment.tmCommand>
-------------- next part --------------




More information about the textmate mailing list