def keypress(self, key, editor): if key == "r": if editor.walker.get_current_value() is not None: signals.status_prompt_path.send( self, prompt="Read file", callback=read_file, args=(editor.walker.set_current_value, True) ) elif key == "R": if editor.walker.get_current_value() is not None: signals.status_prompt_path.send( self, prompt="Read unescaped file", callback=read_file, args=(editor.walker.set_current_value, False) ) elif key == "e": o = editor.walker.get_current_value() if o is not None: n = editor.master.spawn_editor(o) n = strutils.clean_hanging_newline(n) editor.walker.set_current_value(n) elif key in ["enter"]: editor.walker.start_edit() else: return key
def keypress(self, key, editor): if key == "r": if editor.walker.get_current_value() is not None: signals.status_prompt_path.send( self, prompt="Read file", callback=read_file, args=(editor.walker.set_current_value, True)) elif key == "R": if editor.walker.get_current_value() is not None: signals.status_prompt_path.send( self, prompt="Read unescaped file", callback=read_file, args=(editor.walker.set_current_value, False)) elif key == "e": o = editor.walker.get_current_value() if o is not None: n = editor.master.spawn_editor(o) n = strutils.clean_hanging_newline(n) editor.walker.set_current_value(n) elif key in ["enter"]: editor.walker.start_edit() else: return key
def test_clean_hanging_newline(): s = "foo\n" assert strutils.clean_hanging_newline(s) == "foo" assert strutils.clean_hanging_newline("foo") == "foo"
def cmd_spawn_editor(self): o = self.walker.get_current_value() if o is not None: n = self.master.spawn_editor(o) n = strutils.clean_hanging_newline(n) self.walker.set_current_value(n)