Skip to content

Commit

Permalink
Handle schemes where global settings is not first.
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
facelessuser committed Nov 17, 2015
1 parent 37d613e commit a614c90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions st3/mdpopups/st_color_scheme_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def filter(self, plist):
def parse_scheme(self):
"""Parse the color scheme."""

color_settings = self.plist_file["settings"][0]["settings"]
color_settings = {}
for item in self.plist_file["settings"]:
if item.get('scope', None) is None:
color_settings = item["settings"]

# Get general theme colors from color scheme file
self.bground, self.bground_sim = self.strip_color(
Expand All @@ -100,19 +103,19 @@ def parse_scheme(self):
# Create scope colors mapping from color scheme file
self.colors = {}
for item in self.plist_file["settings"]:
name = item.get('name', None)
name = item.get('name', '')
scope = item.get('scope', None)
color = None
style = []
if 'settings' in item:
if 'settings' in item and scope is not None:
color = item['settings'].get('foreground', None)
bgcolor = item['settings'].get('background', None)
if 'fontStyle' in item['settings']:
for s in item['settings']['fontStyle'].split(' '):
if s == "bold" or s == "italic": # or s == "underline":
style.append(s)

if scope is not None and name is not None and (color is not None or bgcolor is not None):
if scope is not None and (color is not None or bgcolor is not None):
fg, fg_sim = self.strip_color(color)
bg, bg_sim = self.strip_color(bgcolor, bg=True)
self.colors[scope] = {
Expand Down
8 changes: 5 additions & 3 deletions st3/mdpopups/st_scheme_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def __init__(self, scheme_file):
def parse_global(self):
"""Parse global settings."""

color_settings = self.plist_file["settings"][0]["settings"]
color_settings = {}
for item in self.plist_file["settings"]:
if item.get('scope', None) is None:
color_settings = item["settings"]
# Get general theme colors from color scheme file
self.bground = self.strip_color(color_settings.get("background", '#FFFFFF'), simple_strip=True)
rgba = RGBA(self.bground)
Expand All @@ -106,13 +109,12 @@ def parse_settings(self):

# Create scope color mapping from color scheme file
for item in self.plist_file["settings"]:
name = item.get('name', None)
scope = item.get('scope', None)
color = None
bgcolor = None

# Get font colors, backgrounds, and stylig
if scope and name and 'settings' in item:
if scope is not None and 'settings' in item:
for subscope in [subscope.strip() for subscope in scope.split(',')]:
if not re_textmate_scopes.match(subscope):
# Ignore complex scopes like:
Expand Down

0 comments on commit a614c90

Please sign in to comment.