當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。