Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
def test_clean_hanging_newline():
    s = "foo\n"
    assert strutils.clean_hanging_newline(s) == "foo"
    assert strutils.clean_hanging_newline("foo") == "foo"
Exemplo n.º 4
0
def test_clean_hanging_newline():
    s = "foo\n"
    assert strutils.clean_hanging_newline(s) == "foo"
    assert strutils.clean_hanging_newline("foo") == "foo"
Exemplo n.º 5
0
 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)