Exemplo n.º 1
0
    def async_execute(self):
        """Trigger actual BH command."""

        debug("Async Key Event")
        self.bh.match(self.view)
        bh_thread.ignore_all = False
        bh_thread.time = time()
Exemplo n.º 2
0
    def async_execute(self):
        """Trigger actual BH command."""

        debug("Async Key Event")
        self.bh.match(self.view)
        bh_thread.ignore_all = False
        bh_thread.time = time()
Exemplo n.º 3
0
    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
                    if not self.highlighting and entry.highlighting is not None:
                        self.highlighting = 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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
def init_bh_match():
    """
    Initialize the match object
    """

    global bh_match
    bh_match = BhCore().match
    debug("Match object loaded.")
Exemplo n.º 6
0
def init_bh_match():
    """
    Initialize the match object
    """

    global bh_match
    bh_match = BhCore().match
    debug("Match object loaded.")
Exemplo n.º 7
0
    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
                    if not self.highlighting and entry.highlighting is not None:
                        self.highlighting = 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)
Exemplo n.º 8
0
    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
                    if not self.highlighting and entry.highlighting is not None:
                        self.highlighting = 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)
Exemplo n.º 9
0
    def parse_scope_definition(self, language, loaded_modules):
        """Parse the scope definition."""

        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 entry.enabled:
                        log(
                            SCOPE_ERROR % (
                                str(params.get('name', '?')),
                                "\\A" + params.get("open", ""),
                                params.get("close", "") + "\\Z"
                            )
                        )
                        continue
                    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
                    if not self.highlighting and entry.highlighting is not None:
                        self.highlighting = 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)
Exemplo n.º 10
0
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
Exemplo n.º 11
0
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
Exemplo n.º 12
0
def init_bh_match():
    global bh_match
    bh_match = BhCore().match
    debug("Match object loaded.")
Exemplo n.º 13
0
 def async_execute(self):
     debug("Async Key Event")
     self.bh.match(self.view)
     bh_thread.ignore_all = False
     bh_thread.time = time()
Exemplo n.º 14
0
 def async_execute(self):
     debug("Async Key Event")
     self.bh.match(self.view)
     bh_thread.ignore_all = False
     bh_thread.time = time()
Exemplo n.º 15
0
 def execute(self):
     debug("Key Event")
     self.bh.match(self.view)
     BhEventMgr.ignore_all = False
     BhEventMgr.time = time()
Exemplo n.º 16
0
 def async_execute(self):
     debug("Async Key Event")
     self.bh.match(self.view)
     BhEventMgr.ignore_all = False
     BhEventMgr.time = time()