本文整理汇总了Python中sublime.View方法的典型用法代码示例。如果您正苦于以下问题:Python sublime.View方法的具体用法?Python sublime.View怎么用?Python sublime.View使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime
的用法示例。
在下文中一共展示了sublime.View方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_query_completions
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def on_query_completions(view_id, prefix, locations):
v = sublime.View(view_id)
completions = []
flags = 0
for callback in all_callbacks['on_query_completions']:
try:
res = callback.on_query_completions(v, prefix, locations)
if isinstance(res, tuple):
completions += [normalise_completion(c) for c in res[0]]
flags |= res[1]
elif isinstance(res, list):
completions += [normalise_completion(c) for c in res]
except:
traceback.print_exc()
return (completions,flags)
示例2: emit_event
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def emit_event(event_type, payload, view=None, plugin=u'FileBrowser'):
'''Notify our filesystem observer about changes in our views
event_type
Unicode object tells what happen, i.e start_refresh, finish_refresh, fold, view_closed, etc.
payload
some info for observer, e.g. id of view, list of paths, tuple of those things
must be immutable object
view
sublime.View object or None
plugin
Unicode object tells who is sender, in order to address event to certain listener
we have two different listeners for FileBrowser and FileBrowserWFS
FileBrowser
notifies observer about user actions to adjust scheduling paths
FileBrowserWFS
notifies FileSystemEventHandler about scheduled paths in order to schedule refresh when
sth is changed on file system
'''
if package_events is None:
return
if view and not view.settings().get('dired_autorefresh', True):
package_events.notify(plugin, u'stop_watch', view.id())
return
package_events.notify(plugin, event_type, payload)
示例3: sync
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def sync(self, view: sublime.View) -> None:
file = view.file_name()
if not file:
return
dirty = False
for b in self.breakpoints:
if b.file != file:
continue
identifier = b.region_name
regions = view.get_regions(identifier)
if len(regions) == 0:
b.add_to_view(view)
dirty = True
else:
dirty = True
line = view.rowcol(regions[0].a)[0] + 1
if line != b.line:
dirty = True
b.dap.line = line
self.updated(b, send=False)
# moves the view regions to match up with the data model
示例4: __init__
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def __init__(self, component: Union[span, div], view: sublime.View, region: sublime.Region, layout: int = sublime.LAYOUT_INLINE) -> None:
super().__init__(component, view)
self.cachedPhantom = None #type: Optional[sublime.Phantom]
self.region = region
self.layout = layout
self.view = view
self.set = sublime.PhantomSet(self.view)
Phantom.id += 1
# we use the region to track where we should place the new phantom so if text is inserted the phantom will be redrawn in the correct place
self.region_id = 'phantom_{}'.format(Phantom.id)
self.view.add_regions(self.region_id, [self.region], flags=sublime.DRAW_NO_FILL)
self.update()
_renderables_add.append(self)
示例5: select_item
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def select_item(view: sublime.View, sel: sublime.Region, is_css=False, is_previous=False):
"Selects next/previous item for CSS source"
buffer_id = view.buffer_id()
pos = sel.begin()
# Check if we are still in calculated model
model = models_for_buffer.get(buffer_id)
if model:
region = find_region(sel, model.ranges, is_previous)
if region:
select(view, region)
return
# Out of available selection range, move to next tag
pos = model.start if is_previous else model.end
# Calculate new model from current editor content
content = get_content(view)
model = emmet.select_item(content, pos, is_css, is_previous)
if model:
models_for_buffer[buffer_id] = model
region = find_region(sel, model.ranges, is_previous)
if region:
select(view, region)
return
示例6: patch_css_size
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def patch_css_size(view: sublime.View, edit: sublime.Edit, props: dict, width: int, height: int, context_prop: dict):
width = '%dpx' % width
height = '%dpx' % height
width_prop = props.get('width')
height_prop = props.get('height')
if width_prop and height_prop:
# We have both properties, patch them
if width_prop.before < height_prop.before:
view.replace(edit, height_prop.value, height)
view.replace(edit, width_prop.value, width)
else:
view.replace(edit, width_prop.value, width)
view.replace(edit, height_prop.value, height)
elif width_prop or height_prop:
# Use existing attribute and replace it with patched variations
prop = width_prop or height_prop
data = utils.patch_property(view, prop, width, 'width') + utils.patch_property(view, prop, height, 'height')
view.replace(edit, sublime.Region(prop.before, prop.after), data)
elif context_prop:
# Append to source property
data = utils.patch_property(view, context_prop, width, 'width') + utils.patch_property(view, context_prop, height, 'height')
view.insert(edit, context_prop.after, data)
示例7: info
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def info(view: sublime.View, pt: int, fallback=None):
"""
Returns Emmet syntax info for given location in view.
Syntax info is an abbreviation type (either 'markup' or 'stylesheet') and syntax
name, which is used to apply syntax-specific options for output.
By default, if given location doesn’t match any known context, this method
returns `None`, but if `fallback` argument is provided, it returns data for
given fallback syntax
"""
syntax = from_pos(view, pt) or fallback
if syntax:
return {
'syntax': syntax,
'type': get_type(syntax)
}
示例8: narrow_to_non_space
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def narrow_to_non_space(view: sublime.View, region: sublime.Region) -> sublime.Region:
"Returns copy of region which starts and ends at non-space character"
begin = region.begin()
end = region.end()
while begin < end:
if not view.substr(begin).isspace():
break
begin += 1
while end > begin:
if not view.substr(end - 1).isspace():
break
end -= 1
return sublime.Region(begin, end)
示例9: __init__
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def __init__(self, param):
# no super() call! this would get the references confused
if isinstance(param, sublime.Window):
self.window = param
self._window_command = True # probably called from build system
self.typ = WindowCommand
elif isinstance(param, sublime.View):
self.view = param
self._window_command = False
self.typ = TextCommand
else:
raise TypeError("Something really bad happened and you are responsible")
self._update_members()
示例10: create_text_commands
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def create_text_commands(view_id):
view = sublime.View(view_id)
cmds = []
for class_ in text_command_classes:
try:
cmds.append(class_(view))
except TypeError:
print(class_)
raise
return cmds
示例11: on_new
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def on_new(view_id):
v = sublime.View(view_id)
for callback in all_callbacks['on_new']:
try:
callback.on_new(v)
except:
traceback.print_exc()
示例12: on_new_async
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def on_new_async(view_id):
v = sublime.View(view_id)
for callback in all_callbacks['on_new_async']:
try:
callback.on_new_async(v)
except:
traceback.print_exc()
示例13: on_clone
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def on_clone(view_id):
v = sublime.View(view_id)
for callback in all_callbacks['on_clone']:
try:
callback.on_clone(v)
except:
traceback.print_exc()
示例14: on_clone_async
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def on_clone_async(view_id):
v = sublime.View(view_id)
for callback in all_callbacks['on_clone_async']:
try:
callback.on_clone_async(v)
except:
traceback.print_exc()
示例15: on_load_async
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import View [as 别名]
def on_load_async(view_id):
v = sublime.View(view_id)
for callback in all_callbacks['on_load_async']:
try:
callback.on_load_async(v)
except:
traceback.print_exc()