def change_mark_colors(error_color, warning_color):
"""Change SublimeLinter error/warning colors in user color schemes."""
error_color = error_color.lstrip('#')
warning_color = warning_color.lstrip('#')
base_path = os.path.join(sublime.packages_path(), 'User', '*.tmTheme')
sublime_path = os.path.join(sublime.packages_path(), 'User', 'SublimeLinter', '*.tmTheme')
themes = glob(sublime_path) + glob(base_path)
for theme in themes:
with open(theme, encoding='utf8') as f:
text = f.read()
if re.search(MARK_COLOR_RE.format(r'mark\.error'), text):
text = re.sub(MARK_COLOR_RE.format(r'mark\.error'), r'\1#{}\2'.format(error_color), text)
text = re.sub(MARK_COLOR_RE.format(r'mark\.warning'), r'\1#{}\2'.format(warning_color), text)
with open(theme, encoding='utf8', mode='w') as f:
f.write(text)
评论列表
文章目录