本文整理匯總了Python中sublime.View.match_selector方法的典型用法代碼示例。如果您正苦於以下問題:Python View.match_selector方法的具體用法?Python View.match_selector怎麽用?Python View.match_selector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sublime.View
的用法示例。
在下文中一共展示了View.match_selector方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: last_block_in_region
# 需要導入模塊: from sublime import View [as 別名]
# 或者: from sublime.View import match_selector [as 別名]
def last_block_in_region(
view: sublime.View,
begin: int,
scope: str,
end: Optional[int] = None,
skip: int = SKIP_ANYTHING,
) -> Optional[Tuple[int, int]]:
skipper = SKIPPERS.get(skip, do_skip_anything)
stop = view.size() if end is None else end
empty = True
while (
stop > begin and
not view.match_selector(stop, scope) and
skipper(view, stop)
):
stop -= 1
start = stop
while start > begin and view.match_selector(start, scope):
start -= 1
empty = False
if empty:
return None
return start + 1, stop + 1
示例2: enclosing_block
# 需要導入模塊: from sublime import View [as 別名]
# 或者: from sublime.View import match_selector [as 別名]
def enclosing_block(
view: sublime.View, point: int, scope: str, end: Optional[int] = None,
) -> Optional[Tuple[int, int]]:
start = stop = point
while start > 0 and view.match_selector(start, scope):
start -= 1
end_ = view.size() if end is None else end
while stop < end_ and view.match_selector(stop, scope):
stop += 1
if start < stop:
return start + 1, stop
return None
示例3: is_scope
# 需要導入模塊: from sublime import View [as 別名]
# 或者: from sublime.View import match_selector [as 別名]
def is_scope(view: sublime.View, scope: str) -> bool:
sel = view.sel()
try:
return view.match_selector(sel[0].begin(), scope)
except IndexError:
# If in doubt, let's return `False`.
return False
示例4: left_enclosing_block
# 需要導入模塊: from sublime import View [as 別名]
# 或者: from sublime.View import match_selector [as 別名]
def left_enclosing_block(
view: sublime.View, point: int, scope: str, end: Optional[int] = None,
) -> Optional[Tuple[int, int]]:
"""
Like `enclosing_block`, but checks that `point` is the right-boundary of
the eventual block. If not, signal an error with `None`.
"""
if end is None:
end = view.size()
block = enclosing_block(view, point, scope, end=end)
if block and not view.match_selector(point + 1, scope):
return block
return None
示例5: do_skip_args_and_spaces
# 需要導入模塊: from sublime import View [as 別名]
# 或者: from sublime.View import match_selector [as 別名]
def do_skip_args_and_spaces(view: sublime.View, point: int) -> bool:
if view.substr(point).isspace() or view.match_selector(point, ARGUMENT):
return True
return False