def __init__(self, view, edit, find_only, full_file, selection_only, max_sweeps, action): """Initialize find replace object.""" Plugin.purge() self.view = view self.edit = edit self.find_only = find_only self.full_file = full_file self.selection_only = selection_only self.max_sweeps = max_sweeps self.action = action self.target_regions = [] self.plugin = None settings = sublime.load_settings('reg_replace.sublime-settings') self.extend = bool(settings.get("extended_back_references", False)) self.use_regex = bool(settings.get('use_regex_module', False)) and REGEX_SUPPORT self.sel_input_max_size = int(settings.get('selection_input_max_size', 256)) self.sel_input_max_count = int(settings.get('selection_input_max_count', 10)) self.use_format = (self.extend or self.use_regex) and FORMAT_REPLACE if self.use_regex: regex_version = int(settings.get('regex_module_version', 0)) if regex_version > 1: regex_version = 0 self.regex_version_flag = bregex.VERSION1 if regex_version else bregex.VERSION0 else: self.regex_version_flag = 0 self.extend_module = bregex if self.use_regex else bre self.normal_module = regex if self.use_regex else re
def __init__(self, view, edit, find_only, full_file, selection_only, max_sweeps, action): """Initialize find replace object.""" Plugin.purge() self.view = view self.edit = edit self.find_only = find_only self.full_file = full_file self.selection_only = selection_only self.max_sweeps = max_sweeps self.action = action self.target_regions = [] self.plugin = None settings = sublime.load_settings("reg_replace.sublime-settings") self.extend = bool(settings.get("extended_back_references", False)) self.use_regex = bool(settings.get("use_regex_module", False)) and bregex.REGEX_SUPPORT if self.use_regex: regex_version = int(settings.get("regex_module_version", 0)) if regex_version > 1: regex_version = 0 self.regex_version_flag = bregex.VERSION1 if regex_version else bregex.VERSION0 else: self.regex_version_flag = 0 self.extend_module = bregex if self.use_regex else bre self.normal_module = bregex.regex if self.use_regex else bre.re
def __init__(self, view, edit, find_only, full_file, selection_only, max_sweeps, action): """Initialize find replace object.""" Plugin.purge() self.view = view self.edit = edit self.find_only = find_only self.full_file = full_file self.selection_only = selection_only self.max_sweeps = max_sweeps self.action = action self.target_regions = [] self.plugin = None settings = sublime.load_settings('reg_replace.sublime-settings') self.extend = bool(settings.get("extended_back_references", False))
def __init__(self, view, edit, find_only, full_file, selection_only, max_sweeps, action): """ Initialize find replace object """ Plugin.purge() self.view = view self.edit = edit self.find_only = find_only self.full_file = full_file self.selection_only = selection_only self.max_sweeps = max_sweeps self.action = action self.target_regions = [] self.plugin = None settings = sublime.load_settings('reg_replace.sublime-settings') self.extend = bool(settings.get("extended_back_references", False))
def on_replace(self, m): """Run the associated plugin on the replace event.""" try: module = Plugin.load(self.plugin) text = module.replace(m, **self.plugin_args) except Exception: text = m.group(0) print(str(traceback.format_exc())) return text
def close(self): """Clean up for the object. Mainly clean up the tracked loaded plugins.""" Plugin.purge()