[TxMt] Suggestion: CSS Bundle color detection
Charilaos Skiadas
cskiadas at uchicago.edu
Fri Jul 21 16:53:15 UTC 2006
On Jul 21, 2006, at 11:23 AM, Eric D. Fields wrote:
> I'm going to take a stab at writing this one up this weekend, but
> before that I'm wondering if anyone else would find this useful or has
> already done similar (or knows of an even more productive way...).
>
> I've usually got a handful of colors that I use throughout a
> stylesheet; I'd say around 3-6 and that's about it. I'm thinking that
> a tab-complete on hex color values already in your stylesheet would be
> ridiculously helpful. so 'border-bottom: 1px solid #[tab]' would spit
> out a menu of all the colors already in your stylesheet as hex values.
That should be very easy to do. In ruby it would probably take about
6-7 lines, counting loading of the library dialog.rb for the dialogs.
Though perhaps a simpler way is using completion. For that you'll
just need to find out what the scope is after the #, ideally a unique
scope not occurring anywhere else. Then you create a preference item
that does completion by returning as the list of colors to complete
the list provided by scanning the document. More on that here: http://
macromates.com/textmate/manual/preferences_items#completions
An even easier approach is already there if # is considered as a word
character. If you go to the preferences menu, under Text Editing, and
add # as a word character, then just pressing escape after the #
should already complete with respect to all colors in the stylesheet.
> Even more sick would be identifying each item with their color
> somehow, either by coloring the menu items (would suck w/ whites,
> greys) or providing a box colorized next to each item indicating that
> color. Would this be feasible?
That is not easily feasible atm, but it might be once dynamic scopes
show up.
The only way to do that now is to radically change the grammar,
adding a separate rule for each color, and then adding colors for
those rules in the theme. I would not particularly recommend this
though. You could of course automate some part of it, but the
resulting grammar would be huge. Not sure what the implications of
this would be in terms of performance.
> Thoughts or suggestions would be great.
>
> --
> eric
Haris
More information about the textmate
mailing list