mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Allow theme colors to use the sRGB color profile
This is enabled by adding the following to your theme:
colorSpaceName = sRGB;
The default color space used for themes is “Apple Generic RGB” which is a bad choice for interoperability with other software (e.g. exporting a theme to CSS, creating theme colors in Photoshop, and similar).
Related to issue #768.
This commit is contained in:
@@ -185,7 +185,6 @@ static CGColorRef OakColorCreateCopySoften (CGColorPtr cgColor, CGFloat factor)
|
||||
|
||||
theme_t::shared_styles_t::shared_styles_t (bundles::item_ptr const& themeItem): _item(themeItem), _callback(*this)
|
||||
{
|
||||
_color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
setup_styles();
|
||||
bundles::add_callback(&_callback);
|
||||
}
|
||||
@@ -193,18 +192,33 @@ theme_t::shared_styles_t::shared_styles_t (bundles::item_ptr const& themeItem):
|
||||
theme_t::shared_styles_t::~shared_styles_t ()
|
||||
{
|
||||
bundles::remove_callback(&_callback);
|
||||
CGColorSpaceRelease(_color_space);
|
||||
if(_color_space)
|
||||
CGColorSpaceRelease(_color_space);
|
||||
}
|
||||
|
||||
void theme_t::shared_styles_t::setup_styles ()
|
||||
{
|
||||
_styles.clear();
|
||||
|
||||
if(_color_space)
|
||||
{
|
||||
CGColorSpaceRelease(_color_space);
|
||||
_color_space = NULL;
|
||||
}
|
||||
|
||||
if(_item)
|
||||
{
|
||||
if(bundles::item_ptr newItem = bundles::lookup(_item->uuid()))
|
||||
_item = newItem;
|
||||
|
||||
std::string colorSpaceName;
|
||||
if(plist::get_key_path(_item->plist(), "colorSpaceName", colorSpaceName) && colorSpaceName == "sRGB")
|
||||
{
|
||||
if(_color_space)
|
||||
CGColorSpaceRelease(_color_space);
|
||||
_color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
|
||||
}
|
||||
|
||||
plist::array_t items;
|
||||
if(plist::get_key_path(_item->plist(), "settings", items))
|
||||
{
|
||||
@@ -224,6 +238,9 @@ void theme_t::shared_styles_t::setup_styles ()
|
||||
}
|
||||
}
|
||||
|
||||
if(!_color_space)
|
||||
_color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
|
||||
// =======================================
|
||||
// = Find “global” foreground/background =
|
||||
// =======================================
|
||||
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
static decomposed_style_t parse_styles (plist::dictionary_t const& plist);
|
||||
|
||||
bundles::item_ptr _item;
|
||||
CGColorSpaceRef _color_space;
|
||||
CGColorSpaceRef _color_space = NULL;
|
||||
std::vector<decomposed_style_t> _styles;
|
||||
gutter_styles_t _gutter_styles;
|
||||
CGColorPtr _foreground;
|
||||
|
||||
Reference in New Issue
Block a user