本文整理汇总了Python中sublime.load_binary_resource方法的典型用法代码示例。如果您正苦于以下问题:Python sublime.load_binary_resource方法的具体用法?Python sublime.load_binary_resource怎么用?Python sublime.load_binary_resource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime
的用法示例。
在下文中一共展示了sublime.load_binary_resource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def run(self, *args, **kwargs):
view = sublime.active_window().active_view()
#settings = sublime.load_settings('KSP.sublime-settings')
#scheme_file = settings.get('color_scheme', 'Packages/SublimeKSP/KScript Light.tmTheme')
scheme_file = 'Packages/SublimeKSP/KScript Light.tmTheme'
plist = readPlistFromBytes(sublime.load_binary_resource(scheme_file))
result = ['[pre]']
start, end = view.sel()[0].a, view.sel()[0].b
if start == end:
start, end = 0, view.size()
for a, b, scopes in get_ranges(view.scope_name(i) for i in range(start, end)):
result.append(self.apply_style(scopes, plist, view.substr(sublime.Region(start+a, start+b))))
result.append('[/pre]')
sublime.set_clipboard(''.join(result))
示例2: handle_tm_language_files
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def handle_tm_language_files():
# type: () -> None
syntax_files = sublime.find_resources("*.tmLanguage")
for syntax_file in syntax_files:
try:
resource = sublime.load_binary_resource(syntax_file)
except Exception:
print("GitSavvy: could not load {}".format(syntax_file))
continue
try:
extensions = plistlib.readPlistFromBytes(resource).get("fileTypes", [])
except Exception:
print("GitSavvy: could not parse {}".format(syntax_file))
continue
for extension in extensions:
syntax_file_map[extension].append(syntax_file)
示例3: get_color_scheme
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def get_color_scheme(view=None):
if int(sublime.version()) > 3153:
return view.style()
setting = sublime.load_settings("Preferences.sublime-settings").get("color_scheme")
color_scheme_bytes = sublime.load_binary_resource(setting)
color_scheme = {"scopes": []}
for setting in plistlib.readPlistFromBytes(color_scheme_bytes)["settings"]:
if "scope" in setting:
this_scope = {"scope": setting["scope"], "style": {}}
for key in ["foreground", "background"]:
if key in setting["settings"]:
this_scope["style"][key] = setting["settings"][key]
for key in ["italic", "bold"]:
this_scope["style"][key] = (
"fontStyle" in setting["settings"]
and key in setting["settings"]["fontStyle"].lower()
)
color_scheme["scopes"].append(this_scope)
elif "settings" in setting:
for key in ["foreground", "background"]:
if key in setting["settings"]:
color_scheme[key] = setting["settings"][key]
return color_scheme
示例4: _data_image_png_b64_png_from_resource
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def _data_image_png_b64_png_from_resource(path: str) -> str:
png_data = sublime.load_binary_resource(path)
return "data:image/png;base64,{}".format(base64.b64encode(png_data).decode('ascii'))
示例5: tint
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def tint(img, color, opacity=255, height=None, width=None):
"""Tint the image."""
if isinstance(img, str):
try:
img = sublime.load_binary_resource(img)
except Exception:
_log('Could not open binary file!')
_debug(traceback.format_exc(), ERROR)
return ''
return imagetint.tint(img, color, opacity, height, width)
示例6: tint_raw
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def tint_raw(img, color, opacity=255):
"""Tint the image."""
if isinstance(img, str):
try:
img = sublime.load_binary_resource(img)
except Exception:
_log('Could not open binary file!')
_debug(traceback.format_exc(), ERROR)
return ''
return imagetint.tint_raw(img, color, opacity)
示例7: __init__
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def __init__(self, scheme_file, color_filter=None):
"""Initialize."""
if color_filter is None:
color_filter = self.filter
self.color_scheme = scheme_file.replace('\\', '/')
self.scheme_file = path.basename(self.color_scheme)
if NEW_SCHEMES and scheme_file.endswith(('.sublime-color-scheme', '.hidden-color-scheme')):
self.legacy = False
self.scheme_obj = {
'variables': {},
GLOBAL_OPTIONS: {},
'rules': []
}
else:
try:
content = sublime.load_binary_resource(sublime_format_path(self.color_scheme))
except IOError:
# Fallback if file was created manually and not yet found in resources
with open(packages_path(self.color_scheme), 'rb') as f:
content = f.read()
self.legacy = True
self.convert_format(readPlistFromBytes(XML_COMMENT_RE.sub(b'', content)))
self.overrides = []
if NEW_SCHEMES:
self.merge_overrides()
self.scheme_file = scheme_file
self.matched = {}
self.variables = {}
self.parse_scheme()
self.scheme_obj = color_filter(self.scheme_obj)
self.setup_matcher()
示例8: set_view
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import load_binary_resource [as 别名]
def set_view(self, src, lang):
"""Setup view for conversion."""
# Get the output panel
self.view = sublime.active_window().create_output_panel('mdpopups', unlisted=True)
# Let all plugins no to leave this view alone
self.view.settings().set('is_widget', True)
# Don't translate anything.
self.view.settings().set("translate_tabs_to_spaces", False)
# Don't mess with my indenting Sublime!
self.view.settings().set("auto_indent", False)
# Insert into the view
self.view.run_command('insert', {'characters': src})
# Setup the proper syntax
lang = lang.lower()
user_map = sublime.load_settings('Preferences.sublime-settings').get('mdpopups.sublime_user_lang_map', {})
keys = set(list(user_map.keys()) + list(lang_map.keys()))
loaded = False
for key in keys:
v = lang_map.get(key, (tuple(), tuple()))
user_v = user_map.get(key, (tuple(), tuple()))
if lang in (tuple(user_v[0]) + v[0]):
for l in (tuple(user_v[1]) + v[1]):
for ext in ST_LANGUAGES:
sytnax_file = 'Packages/%s%s' % (l, ext)
try:
sublime.load_binary_resource(sytnax_file)
except Exception:
continue
self.view.set_syntax_file(sytnax_file)
loaded = True
break
if loaded:
break
if loaded:
break
if not loaded:
# Default to plain text
for ext in ST_LANGUAGES:
# Just in case text one day switches to 'sublime-syntax'
sytnax_file = 'Packages/Plain text%s' % ext
try:
sublime.load_binary_resource(sytnax_file)
except Exception:
continue
self.view.set_syntax_file(sytnax_file)