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


Python sublime.IGNORECASE属性代码示例

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


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

示例1: find

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [as 别名]
def find(self, regex, region_type, max_labels, case_sensitive):
        """Returns a list with all occurences matching the regex"""

        global next_search, last_index

        chars = []

        region = self.get_target_region(region_type)
        next_search = next_search if next_search else region.begin()
        last_search = region.end()

        while (next_search < last_search and last_index < max_labels):
            word = self.view.find(regex, next_search, 0 if case_sensitive else sublime.IGNORECASE)

            if not word or word.end() > last_search:
                break

            last_index += 1
            next_search = word.end()
            chars.append(sublime.Region(word.begin(), word.begin() + 1))

        if last_index < max_labels:
            next_search = False

        return chars 
开发者ID:ice9js,项目名称:ace-jump-sublime,代码行数:27,代码来源:ace_jump.py

示例2: on_done

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [as 别名]
def on_done(self, regex):

    case = sublime.IGNORECASE if not self.case else 0
    regions = self.view.find_all(regex, case)

    # we don't clear the selection so it's additive, it's nice to just add a
    # regex search on top of a previous search
    if not self.subtract:
      for region in regions:
        self.view.sel().add(region)

    # the resulting regions will be subtracted instead
    else:
      for region in regions:
        self.view.sel().subtract(region)

    # remove empty selections in both cases, so there aren't loose cursors
    regions = [r for r in self.view.sel() if not r.empty()]
    self.view.sel().clear()
    for region in regions:
      self.view.sel().add(region)
    for region in self.view.sel():
      print(region) 
开发者ID:philippotto,项目名称:Sublime-MultiEditUtils,代码行数:25,代码来源:MultiEditUtils.py

示例3: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [as 别名]
def on_query_completions(self, view, prefix, locations):
		if self.IsValidScope(view):
			settings = SublimePapyrus.GetSettings()
			if settings and settings.get("intelligent_code_completion", True):
				if self.completionRunning:
					return
				elif self.linterRunning:
					return
				self.completionRunning = True
				#start = time.time() #DEBUG
				completions = None
				if not view.find("scriptname", 0, sublime.IGNORECASE):
					path = view.file_name()
					if path:
						_, name = os.path.split(path)
						completions = [("scriptname\tscript header", "ScriptName %s" % name[:name.rfind(".")],)]
					else:
						completions = [("scriptname\tscript header", "ScriptName ",)]
				else:					
					completions = self.Completions(view, prefix, locations)
				if completions:
					completions = list(set(completions))
				elif completions == None:
					completions = []
				completions = (completions, sublime.INHIBIT_WORD_COMPLETIONS|sublime.INHIBIT_EXPLICIT_COMPLETIONS,)
				#print("Completions: Finished in %f milliseconds and releasing lock..." % ((time.time()-start)*1000.0)) #DEBUG
				self.completionRunning = False
				return completions 
开发者ID:Kapiainen,项目名称:SublimePapyrus,代码行数:30,代码来源:Plugin.py

示例4: find_variable_assignment

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [as 别名]
def find_variable_assignment(view, position, variable_name):
    regex_prefix = r"(\bvariables\.|\s|\bvar\s+)"
    regex = regex_prefix + variable_name + r"\b\s*=\s*"
    assignments = view.find_all(regex, sublime.IGNORECASE)
    for r in reversed(assignments):
        if r.begin() < position:
            # check for local var assignment
            # and ensure it is in the same function body
            if view.substr(r).lower().startswith("var "):
                function_region = get_current_function_body(view, r.end(), False)
                if not function_region or not function_region.contains(position):
                    continue
            return r
    return None 
开发者ID:jcberquist,项目名称:sublimetext-cfml,代码行数:16,代码来源:utils.py

示例5: get_network

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [as 别名]
def get_network(self, network, find_all=False):
        search_network = Network.get(network)

        current_regions = self.view.sel()

        logger.debug('Searching for network {}'.format(search_network))
        if not search_network:
            logger.debug('Invalid network {}'.format(network))
        else:
            for region in self.view.sel():
                cursor = region.end()
                searched_from_start = cursor is 0

                while True:
                    found_region = self.view.find(
                        sublime_ip.v4.any,
                        cursor,
                        sublime.IGNORECASE
                    )

                    if not found_region:
                        self.view.sel().clear()

                        if not searched_from_start:
                            self.view.sel().add(sublime.Region(0, 0))
                            searched_from_start = True
                            cursor = 0
                            continue

                        self.view.sel().add_all(current_regions)
                        break

                    cleaned_region = Network.clean_region(self.view, found_region)
                    network_re_match = self.view.substr(cleaned_region)
                    logger.debug('Network RE match {}'.format(network_re_match))
                    found_network = Network.get(network_re_match)
                    logger.debug('Network Object {} generated'.format(found_network))
                    if found_network and Network.contains(search_network, found_network):
                        self.view.sel().clear()
                        self.view.show_at_center(cleaned_region.begin())
                        logger.debug('Network found in {} {}'.format(
                            cleaned_region.begin(),
                            cleaned_region.end())
                        )
                        self.view.sel().add(sublime.Region(
                            cleaned_region.begin(),
                            cleaned_region.end()
                        ))
                        break
                    cursor = cleaned_region.end()

        self._find_input_panel(network) 
开发者ID:heyglen,项目名称:network_tech,代码行数:54,代码来源:listener.py

示例6: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [as 别名]
def run(self, edit, query):
        super(HoundSearchCommand, self).run(edit)
        self.edit = edit
        self.result_view = self.create_result_view()

        result_view_start_point = self.result_view.size()
        self.print_result("Searching for \"%s\"\n" % query)

        repos = self.fetch_repos(self.exclude_repos)

        self.result_view.insert(edit, result_view_start_point + 9, " %d repositories" % len(repos))

        num_matching_files = 0
        search_results = self.fetch_search_results(query, repos)
        for repo, repo_data in search_results.items():
            for file_match in repo_data['Matches']:
                num_matching_files += 1
                self.print_result("\n[%s] %s:\n" % (repos[repo]['name'], file_match['Filename']))
                lines = OrderedDict()
                for line_match in file_match['Matches']:
                    lineno = line_match['LineNumber']
                    num_before = len(line_match['Before'])
                    for i in range(num_before):
                        adjusted_lineno = lineno - num_before + i
                        if not adjusted_lineno in lines:
                            lines[adjusted_lineno] = "% 5d  %s\n" % (adjusted_lineno, line_match['Before'][i])
                    lines[lineno] = "% 5d: %s\n" % (lineno, line_match['Line'])
                    num_after = len(line_match['After'])
                    for i in range(num_after):
                        adjusted_lineno = lineno + i + 1
                        if not adjusted_lineno in lines:
                            lines[adjusted_lineno] =  "% 5d  %s\n" % (adjusted_lineno, line_match['After'][i])

                last_lineno = list(lines)[0]
                for lineno, line in lines.items():
                    if lineno - last_lineno > 1:
                        self.print_result("  ...\n")
                    self.print_result(line)
                    last_lineno = lineno

        # highlight matches
        matching_regions = self.result_view.find_all(query, sublime.IGNORECASE)
        total_matches = len(matching_regions)
        self.result_view.add_regions('a', matching_regions, 'string', '', sublime.DRAW_NO_FILL)
        self.print_result("\n%d matches across %d files" % (total_matches, num_matching_files))
        # scroll back to beginning of matches
        # TODO: figure out how to get this to scroll to the top of the page
        self.result_view.show(result_view_start_point) 
开发者ID:bgreenlee,项目名称:SublimeHound,代码行数:50,代码来源:hound.py

示例7: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import IGNORECASE [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.IGNORECASE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。