Esempio n. 1
0
    def setup(self,
              override_thresh=False,
              count_lines=False,
              adj_only=None,
              ignore={},
              plugin={}):
        self.last_id_view = None
        self.last_id_sel = None
        self.targets = []
        self.sels = []
        self.highlight_us = {}
        self.brackets = self.init_brackets()
        self.lines = 0
        self.chars = 0
        self.count_lines = count_lines
        self.new_select = False

        # On demand ignore
        self.ignore = ignore

        # Setup for bracket plugins
        self.transform = {'quote': False, 'bracket': False, 'tag': False}

        if 'command' in plugin:
            self.plugin = BracketPlugin(plugin)
            self.new_select = True
            if 'type' in plugin:
                if 'quote' in plugin['type']:
                    self.transform['quote'] = True
                if 'bracket' in plugin['type']:
                    self.transform['bracket'] = True
                if 'tag' in plugin['type']:
                    self.transform['tag'] = True

        # General search options
        self.adj_only = adj_only if adj_only != None else bool(
            self.settings.get('match_adjacent_only', False))
        self.use_threshold = False if override_thresh else bool(
            self.settings.get('use_search_threshold', True))
        self.tag_use_threshold = False if override_thresh else bool(
            self.settings.get('tag_use_search_threshold', True))
        self.use_selection_threshold = False if override_thresh else True
        self.search_threshold = int(self.settings.get('search_threshold',
                                                      2000))
        self.tag_search_threshold = int(
            self.settings.get('tag_search_threshold', 2000))
        self.selection_threshold = int(
            self.settings.get('auto_selection_threshold', 10))
        self.no_multi_select_icons = bool(
            self.settings.get('no_multi_select_icons', False))

        # Match convention
        match_between = bool(
            self.settings.get('match_brackets_only_when_between', True))
        self.adj_adjust = self.adjacent_adjust_inside if match_between else self.adjacent_adjust
        self.string_adj_adjust = self.string_adjacent_adjust_inside if match_between else self.string_adjacent_adjust

        # Tag special options
        self.brackets_only = bool(self.settings.get('tag_brackets_only',
                                                    False))
        self.ignore_angle = bool(self.settings.get('ignore_non_tags', False))
        self.tag_type = self.settings.get('tag_type', 'html')

        # String Options
        self.match_string_brackets = bool(
            self.settings.get('match_string_brackets', True))
        self.find_brackets_in_any_string = bool(
            self.settings.get('find_brackets_in_any_string', False))
        self.ignore_string_bracket_parent = bool(
            self.settings.get('highlight_string_brackets_only', False))