Ejemplo n.º 1
0
 def _run_vim_replace(self, pattern):
     filer = widgets.filer
     patterns = re.split(r"(?<!\\)/", pattern)
     if len(patterns) > 1:
         pattern = util.U(patterns[0])
         repl = patterns[1]
     else:
         pattern = util.U(pattern)
         repl = ""
     pattern = re.sub(r"\\/", "/", pattern)
     repl = re.sub(r"\\/", "/", repl)
     try:
         reg = re.compile(pattern)
     except re.error as e:
         return message.exception(e)
     filectrl.replace(reg, repl)
     filer.workspace.all_reload()
Ejemplo n.º 2
0
 def _run_emacs_replace(self, pattern):
     filer = widgets.filer
     if not pattern and not self.pattern and self.default:
         filectrl.replace(self.default[0], self.default[1])
         filer.dir.mark_clear()
         filer.workspace.all_reload()
     elif self.pattern is None:
         try:
             self.pattern = re.compile(util.U(pattern))
         except re.error as e:
             return message.exception(e)
         return ("", 0)
     else:
         filectrl.replace(self.pattern, pattern)
         Replace.default[:] = []
         Replace.default.append(self.pattern)
         Replace.default.append(pattern)
         filer.workspace.all_reload()