def parse_scope_definition(self, language, loaded_modules): """ Parse the scope defintion """ scopes = {} scope_count = 0 for params in self.scope_rules: if is_valid_definition(params, language): try: bh_plugin.load_modules(params, loaded_modules) entry = ScopeDefinition(params) if not self.check_compare and entry.compare is not None: self.check_compare = True if not self.check_validate and entry.validate is not None: self.check_validate = True if not self.check_post_match and entry.post_match is not None: self.check_post_match = True for x in entry.scopes: if x not in scopes: scopes[x] = scope_count scope_count += 1 self.scopes.append({"name": x, "brackets": [entry]}) else: self.scopes[scopes[x]]["brackets"].append(entry) debug("Scope Regex (%s)\n Opening: %s\n Closing: %s\n" % (entry.name, entry.open.pattern, entry.close.pattern)) except Exception as e: log(e)
def init_bh_match(): """ Initialize the match object """ global bh_match bh_match = BhCore().match debug("Match object loaded.")
def parse_bracket_definition(self, language, loaded_modules): """ Parse the bracket defintion """ names = [] subnames = [] find_regex = [] sub_find_regex = [] for params in self.bracket_rules: if is_valid_definition(params, language): try: bh_plugin.load_modules(params, loaded_modules) entry = BracketDefinition(params) if not self.check_compare and entry.compare is not None: self.check_compare = True if not self.check_validate and entry.validate is not None: self.check_validate = True if not self.check_post_match and entry.post_match is not None: self.check_post_match = True self.brackets.append(entry) if not entry.find_in_sub_search_only: find_regex.append(params["open"]) find_regex.append(params["close"]) names.append(params["name"]) else: find_regex.append(r"([^\s\S])") find_regex.append(r"([^\s\S])") if entry.find_in_sub_search: sub_find_regex.append(params["open"]) sub_find_regex.append(params["close"]) subnames.append(params["name"]) else: sub_find_regex.append(r"([^\s\S])") sub_find_regex.append(r"([^\s\S])") except Exception as e: log(e) if len(self.brackets): self.brackets = tuple(self.brackets) debug( "Bracket Pattern: (%s)\n" % ','.join(names) + " (Opening|Closing): (?:%s)\n" % '|'.join(find_regex) ) debug( "SubBracket Pattern: (%s)\n" % ','.join(subnames) + " (Opening|Closing): (?:%s)\n" % '|'.join(sub_find_regex) ) self.sub_pattern = ure.compile("(?:%s)" % '|'.join(sub_find_regex), ure.MULTILINE | ure.IGNORECASE) self.pattern = ure.compile("(?:%s)" % '|'.join(find_regex), ure.MULTILINE | ure.IGNORECASE)
def plugin_loaded(): """ Load up uniocode table, initialize settings and match object, and start event loop. Restart event loop if already loaded. """ BhEventMgr.load() init_bh_match() ure.set_cache_directory(join(sublime.packages_path(), "User"), "bh") global HIGH_VISIBILITY if sublime.load_settings("bh_core.sublime-settings").get('high_visibility_enabled_by_default', False): HIGH_VISIBILITY = True if 'running_bh_loop' not in globals(): global running_bh_loop running_bh_loop = True thread.start_new_thread(bh_loop, ()) debug("Starting Thread") else: debug("Restarting Thread") BhThreadMgr.restart = True
def plugin_loaded(): """ Load up uniocode table, initialize settings and match object, and start event loop. Restart event loop if already loaded. """ BhEventMgr.load() init_bh_match() ure.set_cache_directory(join(sublime.packages_path(), "User"), "bh") global HIGH_VISIBILITY if sublime.load_settings("bh_core.sublime-settings").get( 'high_visibility_enabled_by_default', False): HIGH_VISIBILITY = True if 'running_bh_loop' not in globals(): global running_bh_loop running_bh_loop = True thread.start_new_thread(bh_loop, ()) debug("Starting Thread") else: debug("Restarting Thread") BhThreadMgr.restart = True
def execute(self): debug("Key Event") self.bh.match(self.view) BhEventMgr.ignore_all = False BhEventMgr.time = time()