Exemple #1
0
    def test_run(self):
        wnd = self._getwnd("abc\ndef\n")

        macro = kaa.macro.Macro()
        macro.toggle_record()

        mode = wnd.document.mode
        macro.record(1, mode.get_command('cursor.right')[1])
        macro.record(1, mode.get_command('cursor.right')[1])
        macro.record(1, mode.get_command('cursor.right')[1])
        macro.record(1, mode.get_command('cursor.left')[1])
        macro.toggle_record()

        macro.run(wnd)

        assert wnd.cursor.pos == 2

        macro.toggle_record()

        macro.record_string('123', False)
        macro.record_string('45', False)
        macro.toggle_record()

        macro.run(wnd)

        assert wnd.cursor.pos == 7
        assert wnd.document.gettext(0, 7) == 'ab12345'
Exemple #2
0
    def test_run(self):
        wnd = self._getwnd("abc\ndef\n")

        macro = kaa.macro.Macro()
        macro.toggle_record()

        macro.record(wnd.document.mode.cursor_commands.right)
        macro.record(wnd.document.mode.cursor_commands.right)
        macro.record(wnd.document.mode.cursor_commands.right)
        macro.record(wnd.document.mode.cursor_commands.left)
        macro.toggle_record()

        macro.run(wnd)

        assert wnd.cursor.pos == 2

        macro.toggle_record()

        macro.record_string('123')
        macro.record_string('45')
        macro.toggle_record()

        macro.run(wnd)

        assert wnd.cursor.pos == 7
        assert wnd.document.gettext(0, 7) == 'ab12345'
Exemple #3
0
    def test_run(self):
        wnd = self._getwnd("abc\ndef\n")

        macro = kaa.macro.Macro()
        macro.toggle_record()

        mode = wnd.document.mode
        macro.record(1, mode.get_command('cursor.right')[1])
        macro.record(1, mode.get_command('cursor.right')[1])
        macro.record(1, mode.get_command('cursor.right')[1])
        macro.record(1, mode.get_command('cursor.left')[1])
        macro.toggle_record()

        macro.run(wnd)

        assert wnd.cursor.pos == 2

        macro.toggle_record()

        macro.record_string('123', False)
        macro.record_string('45', False)
        macro.toggle_record()

        macro.run(wnd)

        assert wnd.cursor.pos == 7
        assert wnd.document.gettext(0, 7) == 'ab12345'
Exemple #4
0
    def test_record(self):

        macro = kaa.macro.Macro()
        macro.toggle_record()

        @command('command1')
        def f():pass

        macro.record(f)
        assert macro.get_commands() == [('command1',(), {})]

        @command('command2')
        @norec
        def g():pass

        macro.record(g)
        assert macro.get_commands() == [('command1',(),{})]
Exemple #5
0
    def test_record(self):

        macro = kaa.macro.Macro()
        macro.toggle_record()

        @commandid('command1')
        def f():
            pass

        macro.record(1, f)
        assert macro.get_commands() == [(kaa.macro.rec_command, 1, 'command1',
                                         (), {})]

        @commandid('command2')
        @norec
        def g():
            pass

        macro.record(1, g)
        assert macro.get_commands() == [(kaa.macro.rec_command, 1, 'command1',
                                         (), {})]