Python sublime.IGNORECASE Examples
The following are 8
code examples of sublime.IGNORECASE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sublime
, or try the search function
.
Example #1
Source File: ace_jump.py From ace-jump-sublime with MIT License | 6 votes |
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
Example #2
Source File: MultiEditUtils.py From Sublime-MultiEditUtils with MIT License | 6 votes |
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)
Example #3
Source File: Plugin.py From SublimePapyrus with MIT License | 5 votes |
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
Example #4
Source File: utils.py From sublimetext-cfml with MIT License | 5 votes |
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
Example #5
Source File: listener.py From network_tech with Apache License 2.0 | 4 votes |
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)
Example #6
Source File: listener.py From network_tech with Apache License 2.0 | 4 votes |
def get_network(self, networks, find_all=False): search_networks = {Network.get(n) for n in networks.split(',')} current_regions = self.view.sel() logger.debug('Searching for network(s) {}'.format(networks)) for network in search_networks: if not network: message = 'Invalid network {}'.format(network) logger.debug(message) self.view.show_popup_menu(message) return else: self.view.sel().clear() self.view.sel().add(sublime.Region(0, 0)) found_regions = self.view.find_all( sublime_ip.v4.any, sublime.IGNORECASE, ) matching_networks = set() found_networks = {self.view.substr(r) for r in found_regions} logger.debug('Found {} IP like objects'.format(len(found_networks))) for found_network in found_networks: if found_network in matching_networks: continue logger.debug('Getting network "{}"'.format(found_network)) for search_network in search_networks: network_object = Network.get(found_network) if network_object and Network.contains(search_network, network_object): matching_networks.add(found_network) break self.view.sel().clear() if matching_networks: moved_view = False for region in found_regions: cleaned_region = Network.clean_region(self.view, region) if self.view.substr(cleaned_region) in matching_networks: self.view.sel().add(cleaned_region) if not moved_view: self.view.show_at_center(cleaned_region.begin()) moved_view = True else: logger.debug('No matches') self.view.sel().add_all(current_regions) self.view.show_at_center(current_regions[0].begin())
Example #7
Source File: hound.py From SublimeHound with MIT License | 4 votes |
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)
Example #8
Source File: MultiEditUtils.py From Sublime-MultiEditUtils with MIT License | 4 votes |
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)