我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用sublime.IGNORECASE。
def get_QueryRegions ( QUERY, REGEX_ENABLED, IGNORE_CASE ): if REGEX_ENABLED == True and IGNORE_CASE == True: queryRegions = V.view.find_all ( QUERY, sublime.IGNORECASE ) elif REGEX_ENABLED == True and IGNORE_CASE == False: queryRegions = V.view.find_all ( QUERY ) elif REGEX_ENABLED == False and IGNORE_CASE == True: queryRegions = V.view.find_all ( QUERY, sublime.LITERAL|sublime.IGNORECASE ) elif REGEX_ENABLED == False and IGNORE_CASE == False: queryRegions = V.view.find_all ( QUERY, sublime.LITERAL ) return ( queryRegions ) #?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????¦?# #??????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????‡# #???????? { Variables } ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????c3# #??????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????‡# #?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????¦?#
def calculate_flags(self): # TODO: Implement smartcase? flags = 0 if self.view.settings().get('vintageous_magic') is False: flags |= sublime.LITERAL if self.view.settings().get('vintageous_ignorecase') is True: flags |= sublime.IGNORECASE return flags
def calculate_flags(self): if self.view.settings().get('vintageous_ignorecase') is True: return sublime.IGNORECASE return 0
def next_end_tag(view, pattern=RX_ANY_TAG, start=0, end=-1): region = view.find(pattern, start, sublime.IGNORECASE) if region.a == -1: return None, None, None match = re.search(pattern, view.substr(region)) return (region, match.group(1), match.group(0).startswith('</'))
def display_footer(self, hit_count): regions = self.whoosh_view.find_all(self.search_string, sublime.LITERAL | sublime.IGNORECASE) reg_num = len(regions) - 1 text = "\n%d matches across %d files\n" % (reg_num if reg_num >= 0 else 0, hit_count) self.whoosh_view.run_command("whoosh_view_append_text", {"text" : text, "search_string" : None})
def run(self, edit, text, search_string): start_point = self.view.size() self.view.insert(edit, start_point, text) if search_string is not None: regions = self.view.find_all(search_string, sublime.LITERAL | sublime.IGNORECASE) self.view.add_regions('whoosh_regions', regions[1:], "text.find-in-files", "", sublime.DRAW_OUTLINED)
def run(self, search_string='', mode=None, count=1): def f(view, s): if mode == modes.VISUAL: return sublime.Region(s.a, match.a + 1) elif mode == modes.INTERNAL_NORMAL: return sublime.Region(s.a, match.a) elif mode == modes.NORMAL: return sublime.Region(match.a, match.a) elif mode == modes.VISUAL_LINE: return sublime.Region(s.a, view.full_line(match.b - 1).b) return s # This happens when we attempt to repeat the search and there's no search term stored yet. if not search_string: return # We want to start searching right after the current selection. current_sel = self.view.sel()[0] start = current_sel.b if not current_sel.empty() else current_sel.b + 1 wrapped_end = self.view.size() # TODO: What should we do here? Case-sensitive or case-insensitive search? Configurable? # Search wrapping around the end of the buffer. # flags = sublime.IGNORECASE | sublime.LITERAL flags = self.calculate_flags() match = find_wrapping(self.view, search_string, start, wrapped_end, flags=flags, times=count) if not match: return regions_transformer(self.view, f) self.hilite(search_string)
def calculate_flags(self): # TODO: Implement smartcase? flags = 0 if self.view.settings().get('vintageous_magic') == False: flags |= sublime.LITERAL if self.view.settings().get('vintageous_ignorecase') == True: flags |= sublime.IGNORECASE return flags
def calculate_flags(self): if self.view.settings().get('vintageous_ignorecase') == True: return sublime.IGNORECASE return 0
def previous_begin_tag(view, pattern, start=0, end=0): assert pattern, 'bad call' region = reverse_search_by_pt(view, RX_ANY_TAG, start, end, sublime.IGNORECASE) if not region: return None, None, None match = re.search(RX_ANY_TAG, view.substr(region)) return (region, match.group(1), match.group(0)[1] != '/')
def plugin_loaded(): # Is there a way to get a reference to the plugin instance here? # It would be nice to avoid having to use the global user_whitelist variable. HighlightDodgyChars.getSettings() class HighlightDodgyChars(sublime_plugin.EventListener): def getSettings(): global users_whitelist settings = sublime.load_settings('HighlightDodgyChars.sublime-settings') users_whitelist = settings.get('whitelist_chars') if isinstance(users_whitelist, list): users_whitelist = ''.join(users_whitelist) if users_whitelist is None: users_whitelist = '' # for some reason the sublime.IGNORECASE -flag did not work so lets # duplicate the chars as lower and upper :( users_whitelist += users_whitelist.upper() def on_modified_async(self, view): self.highlight(view) def on_load_async(self, view): # load highlights as soon as the file is opened self.highlight(view) def highlight(self, view): highlights = [] whitelist = u'\n\u0009' # allow newline, forward-tick and tabulator # search for non-ascii characters that are not on the whitelist needle = '[^\x00-\x7F'+whitelist+users_whitelist+']' # search the view for pos in view.find_all(needle): highlights.append(pos) # if something dodgy was found, highlight the dodgy parts if highlights: view.add_regions('zero-width-and-bad-chars', highlights, 'invalid', '', sublime.DRAW_SOLID_UNDERLINE) else: view.erase_regions('zero-width-and-bad-chars')
def find_next_lone_bracket(view, start, items, unbalanced=0): # TODO: Extract common functionality from here and the % motion instead of # duplicating code. new_start = start for i in range(unbalanced or 1): next_closing_bracket = find_in_range( view, items[1], start=new_start, end=view.size(), flags=sublime.IGNORECASE ) if next_closing_bracket is None: # Unbalanced items; nothing we can do. return while view.substr(next_closing_bracket.begin() - 1) == '\\': next_closing_bracket = find_in_range(view, items[1], start=next_closing_bracket.end(), end=view.size(), flags=sublime.IGNORECASE) if next_closing_bracket is None: return new_start = next_closing_bracket.end() if view.substr(start) == items[0][-1]: start += 1 nested = 0 while True: next_opening_bracket = find_in_range(view, items[0], start=start, end=next_closing_bracket.b, flags=sublime.IGNORECASE) if not next_opening_bracket: break nested += 1 start = next_opening_bracket.end() if nested > 0: return find_next_lone_bracket(view, next_closing_bracket.end(), items, nested) else: return next_closing_bracket
def find_prev_lone_bracket(view, start, tags, unbalanced=0): # TODO: Extract common functionality from here and the % motion instead of # duplicating code. # XXX: refactor this if view.substr(start) == tags[0][1] if len(tags[0]) > 1 else tags[0]: if not unbalanced and view.substr(start - 1) != '\\': return sublime.Region(start, start + 1) new_start = start for i in range(unbalanced or 1): prev_opening_bracket = reverse_search_by_pt(view, tags[0], start=0, end=new_start, flags=sublime.IGNORECASE) if prev_opening_bracket is None: # Check whether the caret is exactly at a bracket. # Tag names may be escaped, so slice them. if (i == 0 and view.substr(start) == tags[0][-1] and view.substr(start - 1) != '\\'): return sublime.Region(start, start + 1) # Unbalanced tags; nothing we can do. return while view.substr(prev_opening_bracket.begin() - 1) == '\\': prev_opening_bracket = reverse_search_by_pt( view, tags[0], start=0, end=prev_opening_bracket.begin(), flags=sublime.IGNORECASE ) if prev_opening_bracket is None: return new_start = prev_opening_bracket.begin() nested = 0 while True: next_closing_bracket = reverse_search_by_pt(view, tags[1], start=prev_opening_bracket.a, end=start, flags=sublime.IGNORECASE) if not next_closing_bracket: break nested += 1 start = next_closing_bracket.begin() if nested > 0: return find_prev_lone_bracket(view, prev_opening_bracket.begin(), tags, nested) else: return prev_opening_bracket
def run(self, edit, args): settings = self.view.settings() minfo = args['minfo'] params = args['pv'] # retrieve connection (decl,ac,wc) = self.get_connect(self.view,settings,minfo) # print('decl = {}\nAC = {}\nwc = {}'.format(decl,ac,wc)) # Instance name inst = '\t' + settings.get('vhdl.instance_prefix','') + minfo['name'] + settings.get('vhdl.instance_suffix','') inst += ' : entity work.{}\n'.format(minfo['name']) # Generic Map if params : inst += '\t\tgeneric map (\n' max_len_l = max([len(x['name']) for x in params]) max_len_r = max([len(x['value']) for x in params]) for i,param in enumerate(params) : inst += '\t\t\t{} => {}'.format(param['name'].ljust(max_len_l),param['value'].ljust(max_len_r)) if i<len(params)-1: inst +=',' inst += '\n' inst += '\t\t)\n' # Port Map if minfo['port'] : inst += '\t\tport map (\n' max_len_l = max([len(x['name']) for x in minfo['port']]) max_len_r = 0 if not ac else max([len(x) for x in ac]) for i,port in enumerate(minfo['port']) : inst += '\t\t\t{} => {}'.format(port['name'].ljust(max_len_l), '' if port['name'] not in ac else ac[port['name']].ljust(max_len_r)) # Remove entry of ac if it is the same as the port (to be used by the final report) if port['name'] in ac and ac[port['name']] == port['name']: ac.pop(port['name'],0) if i<len(minfo['port'])-1: inst +=',' inst += '\n' inst += '\t\t);\n\n' report = '' # Insert code for module Instantiation self.view.insert(edit, self.view.line(self.view.sel()[0]).a, inst) # Insert signal declaration if any if decl: r_start = self.view.find(r'(?si)^\s*architecture\s+\w+\s+of\s+\w+\s+is(.*?)$',0, sublime.IGNORECASE) if r_start: # find position of last ; r_end = self.view.find(r'(?si);[^;]+begin',0, sublime.IGNORECASE) if r_end : # TODO check if not inside a comment ... r_start.a = r_end.a+1 self.view.insert(edit, r_start.a, '\n'+decl) report += 'Declaring {} signals\n'.format(len(decl.splitlines())) else : report += 'Unable to find declaration region:\n' + decl if len(ac)>0 : report+= 'Non-perfect name match for {} port(s) : {}\n'.format(len(ac),ac) if len(wc)>0 : report+= 'Found {} mismatch(es) for port(s): {}\n'.format(len(wc),[x for x in wc.keys()]) if report: sublime_util.print_to_panel(report,'SmartVHDL') # Find connection between instance port and local signal/port
def find_next_lone_bracket(view, start, items, unbalanced=0): # TODO: Extract common functionality from here and the % motion instead of # duplicating code. new_start = start for i in range(unbalanced or 1): next_closing_bracket = find_in_range(view, items[1], start=new_start, end=view.size(), flags=sublime.IGNORECASE) if next_closing_bracket is None: # Unbalanced items; nothing we can do. return while view.substr(next_closing_bracket.begin() - 1) == '\\': next_closing_bracket = find_in_range(view, items[1], start=next_closing_bracket.end(), end=view.size(), flags=sublime.IGNORECASE) if next_closing_bracket is None: return new_start = next_closing_bracket.end() if view.substr(start) == items[0][-1]: start += 1 nested = 0 while True: next_opening_bracket = find_in_range(view, items[0], start=start, end=next_closing_bracket.b, flags=sublime.IGNORECASE) if not next_opening_bracket: break nested += 1 start = next_opening_bracket.end() if nested > 0: return find_next_lone_bracket(view, next_closing_bracket.end(), items, nested) else: return next_closing_bracket
def find_prev_lone_bracket(view, start, tags, unbalanced=0): # TODO: Extract common functionality from here and the % motion instead of # duplicating code. # XXX: refactor this if view.substr(start) == tags[0][1] if len(tags[0]) > 1 else tags[0]: if not unbalanced and view.substr(start - 1) != '\\': return sublime.Region(start, start + 1) new_start = start for i in range(unbalanced or 1): prev_opening_bracket = reverse_search_by_pt(view, tags[0], start=0, end=new_start, flags=sublime.IGNORECASE) if prev_opening_bracket is None: # Check whether the caret is exactly at a bracket. # Tag names may be escaped, so slice them. if (i == 0 and view.substr(start) == tags[0][-1] and view.substr(start - 1) != '\\'): return sublime.Region(start, start + 1) # Unbalanced tags; nothing we can do. return while view.substr(prev_opening_bracket.begin() - 1) == '\\': prev_opening_bracket = reverse_search_by_pt( view, tags[0], start=0, end=prev_opening_bracket.begin(), flags=sublime.IGNORECASE) if prev_opening_bracket is None: return new_start = prev_opening_bracket.begin() nested = 0 while True: next_closing_bracket = reverse_search_by_pt(view, tags[1], start=prev_opening_bracket.a, end=start, flags=sublime.IGNORECASE) if not next_closing_bracket: break nested += 1 start = next_closing_bracket.begin() if nested > 0: return find_prev_lone_bracket(view, prev_opening_bracket.begin(), tags, nested) else: return prev_opening_bracket