当前位置: 首页>>代码示例>>Python>>正文


Python sublime.LITERAL属性代码示例

本文整理汇总了Python中sublime.LITERAL属性的典型用法代码示例。如果您正苦于以下问题:Python sublime.LITERAL属性的具体用法?Python sublime.LITERAL怎么用?Python sublime.LITERAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sublime的用法示例。


在下文中一共展示了sublime.LITERAL属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: goto

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def goto(self, arrpos):
        # The position gives us the line number
        strgo = self.trimkeys[arrpos]

        # Check for matches in the array before 48
        found = 0
        for index, item in enumerate(self.trimkeys):
            if index >= arrpos:
                break
            if item == strgo:
                found += 1

        # Now we need to find that string N times in 
        # the text, and go to its line number
        # and highlight it, why not?
        regions = self.view.find_all(strgo, sublime.LITERAL)
        region = regions[found]
        self.view.sel().clear()
        self.view.sel().add(region)
        self.view.show(region) 
开发者ID:Flyclops,项目名称:JsonTree,代码行数:22,代码来源:JsonTree.py

示例2: find_hunk_in_view

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def find_hunk_in_view(view, patch):
    # type: (sublime.View, str) -> Optional[sublime.Region]
    """Given a patch, search for its first hunk in the view

    Returns the region of the first line of the hunk (the one starting
    with '@@ ...'), if any.
    """
    diff = SplittedDiff.from_string(patch)
    try:
        hunk = diff.hunks[0]
    except IndexError:
        return None

    return (
        view.find(hunk.header().text, 0, sublime.LITERAL)
        or fuzzy_search_hunk_content_in_view(view, hunk.content().text.splitlines())
    ) 
开发者ID:timbrel,项目名称:GitSavvy,代码行数:19,代码来源:diff.py

示例3: fuzzy_search_hunk_content_in_view

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def fuzzy_search_hunk_content_in_view(view, lines):
    # type: (sublime.View, List[str]) -> Optional[sublime.Region]
    """Fuzzy search the hunk content in the view

    Note that hunk content does not include the starting line, the one
    starting with '@@ ...', anymore.

    The fuzzy strategy here is to search for the hunk or parts of it
    by reducing the contextual lines symmetrically.

    Returns the region of the starting line of the found hunk, if any.
    """
    for hunk_content in shrink_list_sym(lines):
        region = view.find('\n'.join(hunk_content), 0, sublime.LITERAL)
        if region:
            diff = SplittedDiff.from_view(view)
            head_and_hunk = diff.head_and_hunk_for_pt(region.a)
            if head_and_hunk:
                _, hunk = head_and_hunk
                hunk_header = hunk.header()
                return sublime.Region(hunk_header.a, hunk_header.b)
            break
    return None 
开发者ID:timbrel,项目名称:GitSavvy,代码行数:25,代码来源:diff.py

示例4: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def run(self, view):
        path = self.path
        window = self.view.window()
        names = os.listdir(path)
        f = []
        for name in names:
            if isdir(join(path, name)):
                name += os.sep
            f.append(name)

        def on_done(select):
            if not select == -1 :
                line_str = f[select]
                r_list = self.view.find_all(line_str, sublime.LITERAL)

                # Make match whole word.
                if len(r_list) > 1 :
                    for r in r_list :
                        find_str = self.view.substr(self.view.line(r))
                        if find_str == line_str :
                            break
                else :
                    r = r_list[0]

                if self.p_key :
                    window.run_command('dired_preview_refresh', {'path':path + line_str})


                self.view.sel().clear()
                self.view.sel().add(r.a)
                self.view.show(r.a)

                if self.p_key :
                    self.view.settings().set('preview_key', True)

        self.p_key = self.view.settings().get('preview_key')
        self.view.settings().set('preview_key', False)
        window.show_quick_panel(f, on_done) 
开发者ID:kublaios,项目名称:dired,代码行数:40,代码来源:dired.py

示例5: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def run(self, edit, line='~~~'):
    region = self.view.find(line, 0, sublime.LITERAL)
    self.view.sel().add(region) 
开发者ID:toji,项目名称:semilive,代码行数:5,代码来源:semilive.py

示例6: get_available_regions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def get_available_regions(self):
        return (
            self.view.find_by_selector("gitsavvy.gotosymbol")
            + self.view.find_all("Your working directory is clean", sublime.LITERAL)
        ) 
开发者ID:timbrel,项目名称:GitSavvy,代码行数:7,代码来源:status.py

示例7: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import LITERAL [as 别名]
def run(self, edit, case=True, word=False, ignore_comments=False, expand=True):

    view = self.view
    newRegions = []

    # filter selections in order to exclude duplicates since it can hang
    # Sublime if search is performed on dozens of selections, this doesn't
    # happen with built-in command because it works on a single selection
    initial = [sel for sel in view.sel()]
    regions, substrings = [], []
    for region in view.sel():
      if expand and region.empty():
        # if expanding substring will be the word
        region = view.word(region.a)
        # add the region since nothing is selected yet
        view.sel().add(region)
      # filter by substring (word or not)
      substr = view.substr(region)
      if substr and substr not in substrings:
        regions.append(region)
        substrings.append(substr)
    view.sel().clear()
    if regions:
      for region in regions:
        view.sel().add(region)
    else:
      view.window().status_message("Multi Find All: nothing selected")
      for sel in initial:
        view.sel().add(sel)
      return

    selected_words = [view.substr(view.word(sel)).lower() for sel in view.sel()]

    for region in view.sel():
      substr = view.substr(region)

      if case:
          for region in view.find_all(substr, sublime.LITERAL):
            newRegions.append(region)
      else:
          for region in view.find_all(substr, sublime.LITERAL | sublime.IGNORECASE):
            newRegions.append(region)

      if word:
        deleted = [region for region in newRegions
                   if view.substr(view.word(region)).lower() not in selected_words]
        newRegions = [region for region in newRegions if region not in deleted]

      if ignore_comments:
        deleted = [region for region in newRegions
                   if re.search(r'\bcomment\b', view.scope_name(region.a))]
        newRegions = [region for region in newRegions if region not in deleted]

    for region in newRegions:
      view.sel().add(region) 
开发者ID:philippotto,项目名称:Sublime-MultiEditUtils,代码行数:57,代码来源:MultiEditUtils.py


注:本文中的sublime.LITERAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。