當前位置: 首頁>>代碼示例>>Python>>正文


Python sublime.View方法代碼示例

本文整理匯總了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) 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:20,代碼來源:sublime_plugin.py

示例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) 
開發者ID:aziz,項目名稱:SublimeFileBrowser,代碼行數:26,代碼來源:common.py

示例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 
開發者ID:daveleroy,項目名稱:sublime_debugger,代碼行數:25,代碼來源:source_breakpoints.py

示例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) 
開發者ID:daveleroy,項目名稱:sublime_debugger,代碼行數:18,代碼來源:render.py

示例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 
開發者ID:emmetio,項目名稱:sublime-text-plugin,代碼行數:27,代碼來源:select_item.py

示例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) 
開發者ID:emmetio,項目名稱:sublime-text-plugin,代碼行數:25,代碼來源:update_image_size.py

示例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)
        } 
開發者ID:emmetio,項目名稱:sublime-text-plugin,代碼行數:18,代碼來源:syntax.py

示例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) 
開發者ID:emmetio,項目名稱:sublime-text-plugin,代碼行數:18,代碼來源:utils.py

示例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() 
開發者ID:typeintandem,項目名稱:tandem,代碼行數:16,代碼來源:__init__.py

示例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 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:12,代碼來源:sublime_plugin.py

示例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() 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:9,代碼來源:sublime_plugin.py

示例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() 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:9,代碼來源:sublime_plugin.py

示例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() 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:9,代碼來源:sublime_plugin.py

示例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() 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:9,代碼來源:sublime_plugin.py

示例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() 
開發者ID:Wramberg,項目名稱:TerminalView,代碼行數:9,代碼來源:sublime_plugin.py


注:本文中的sublime.View方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。