in colorSchemeTool.py [0:0]
def load_textmate_scheme(tmtheme):
themeDict = None
with open(tmtheme, 'rb') as f:
themeDict = plistlib.load(f)
all_settings = themeDict['settings']
used_scopes = set()
default_settings = find_by_scope(all_settings, None)
if not default_settings:
print("Cannot find default settings")
return
default_settings = default_settings['settings']
text.value = attr_from_textmate(default_settings, None, None)
background = None
selection_background = None
caret_row_color = None
if 'background' in default_settings:
background = default_settings['background']
all_colors["GUTTER_BACKGROUND"] = color_from_textmate(background)
if 'invisibles' in default_settings:
all_colors['INDENT_GUIDE'] = color_from_textmate(default_settings['invisibles'], background)
all_colors['SELECTED_INDENT_GUIDE'] = all_colors['INDENT_GUIDE']
all_colors['WHITESPACES'] = color_from_textmate(default_settings['invisibles'], background)
if 'selection' in default_settings:
selection_background = color_from_textmate(default_settings['selection'], background)
all_colors['SELECTION_BACKGROUND'] = selection_background
if 'lineHighlight' in default_settings:
caret_row_color = color_from_textmate(default_settings['lineHighlight'], background)
if 'caret' in default_settings:
all_colors['CARET_COLOR'] = color_from_textmate(default_settings['caret'])
if 'foreground' in default_settings:
all_colors["LINE_NUMBERS_COLOR"] = color_from_textmate(default_settings['foreground'])
if caret_row_color is not None and selection_background is not None and selection_background == caret_row_color:
y, i, q = hex_to_yiq(caret_row_color)
if y < 0.5:
y /= 2
else:
y += 0.2
caret_row_color = rgb_to_hex(*colorsys.yiq_to_rgb(y, i, q))
if caret_row_color is not None:
all_colors['CARET_ROW_COLOR'] = caret_row_color
all_colors['CONSOLE_BACKGROUND_KEY'] = text.value.background
if background is not None:
blend_spy_js_attributes(background)
for attr in all_attributes:
if attr.scope:
settings = find_by_scope(all_settings, attr.scope)
if settings:
the_scope = settings['scope']
if the_scope:
print("converting attribute " + attr.id + " from TextMate scope " + the_scope)
used_scopes.add(the_scope)
attr.value = attr_from_textmate(settings['settings'], attr.value, background)
else:
print("[!] scope not found: " + attr.scope)
return all_settings, used_scopes