Пример #1
0
    def testCommandOutput(self):
        test_string = 'Testing!'
        test_command_line = ':!echo "' + test_string + '"'
        ex_cmd = parse_command(test_command_line)
        ex_cmd.args['line_range'] = ex_cmd.line_range

        output_panel = self.view.window().get_output_panel('vi_out')
        self.view.run_command(ex_cmd.command, ex_cmd.args)

        actual = output_panel.substr(self.R(0, output_panel.size()))
        expected = test_string + '\n'
        self.assertEqual(expected, actual)
Пример #2
0
    def testCommandOutput(self):
        test_string = 'Testing!'
        test_command_line = ':!echo "' + test_string + '"'
        ex_cmd = parse_command(test_command_line)
        ex_cmd.args['line_range'] = ex_cmd.line_range

        output_panel = self.view.window().get_output_panel('vi_out')
        self.view.run_command(ex_cmd.command, ex_cmd.args)

        actual = output_panel.substr(self.R(0, output_panel.size()))
        expected = '\\"{0}\\"\n'.format(test_string)
        self.assertEqual(expected, actual)
Пример #3
0
    def testMultipleFilterThroughShell(self):
        word_count_command = self.__class__.getWordCountCommand()
        # TODO implement test for Windows.
        if not word_count_command:
            return True
        self.view.sel().clear()
        self.write('''Beginning of test!
One two three four
five six seven eight
nine ten.
These two lines shouldn't be replaced
by the command.
One two three four five six
seven eight nine
ten
eleven
twelve
End of Test!
''')
        # Two selections touching all numeric word lines.
        self.add_sel(self.R((1, 11), (3, 1)))
        self.add_sel(self.R((6, 1), (10, 5)))

        test_command_line = ":'<,'>!" + word_count_command
        ex_cmd = parse_command(test_command_line)
        ex_cmd.args['line_range'] = ex_cmd.line_range

        self.view.run_command(ex_cmd.command, ex_cmd.args)

        actual = self.view.substr(self.R(0, self.view.size()))
        expected = '''Beginning of test!
10
These two lines shouldn't be replaced
by the command.
12
End of Test!
'''
        self.assertEqual(expected, actual)
        self.assertEqual(2, len(self.view.sel()))
        cursor0 = get_sel(self.view, 0)
        cursor1 = get_sel(self.view, 1)
        self.assertEqual(cursor0.begin(), cursor0.end())
        self.assertEqual(cursor1.begin(), cursor1.end())
        self.assertEqual(self.view.text_point(1, 0), cursor0.begin())
        self.assertEqual(self.view.text_point(4, 0), cursor1.begin())
Пример #4
0
    def testMultipleFilterThroughShell(self):
        word_count_command = self.__class__.getWordCountCommand()
        # TODO implement test for Windows.
        if not word_count_command:
            return True
        self.view.sel().clear()
        self.write('''Beginning of test!
One two three four
five six seven eight
nine ten.
These two lines shouldn't be replaced
by the command.
One two three four five six
seven eight nine
ten
eleven
twelve
End of Test!
''')
        # Two selections touching all numeric word lines.
        self.add_sel(self.R((1, 11), (3, 1)))
        self.add_sel(self.R((6, 1), (10, 5)))

        test_command_line = ":'<,'>!" + word_count_command
        ex_cmd = parse_command(test_command_line)
        ex_cmd.args['line_range'] = ex_cmd.line_range

        self.view.run_command(ex_cmd.command, ex_cmd.args)

        actual = self.view.substr(self.R(0, self.view.size()))
        expected = '''Beginning of test!
10
These two lines shouldn't be replaced
by the command.
12
End of Test!
'''
        self.assertEqual(expected, actual)
        self.assertEqual(2, len(self.view.sel()))
        cursor0 = get_sel(self.view, 0)
        cursor1 = get_sel(self.view, 1)
        self.assertEqual(cursor0.begin(), cursor0.end())
        self.assertEqual(cursor1.begin(), cursor1.end())
        self.assertEqual(self.view.text_point(1, 0), cursor0.begin())
        self.assertEqual(self.view.text_point(4, 0), cursor1.begin())
Пример #5
0
    def on_done(self, cmd_line):
        if not getattr(self, 'non_interactive', None):
            update_command_line_history(cmd_line, 'cmdline')
        else:
            self.non_interactive = False
        ex_cmd = parse_command(cmd_line)
        print(ex_cmd)

        if ex_cmd and ex_cmd.parse_errors:
            ex_error.display_error(ex_cmd.parse_errors[0])
            return
        if ex_cmd and ex_cmd.name:
            if ex_cmd.can_have_range:
                ex_cmd.args["line_range"] = ex_cmd.line_range
            if ex_cmd.forced:
                ex_cmd.args['forced'] = ex_cmd.forced
            self.window.run_command(ex_cmd.command, ex_cmd.args)
        else:
            ex_error.display_error(ex_error.ERR_UNKNOWN_COMMAND, cmd_line)
Пример #6
0
    def on_done(self, cmd_line):
        if not getattr(self, 'non_interactive', None):
            update_command_line_history(cmd_line, 'cmdline')
        else:
            self.non_interactive = False
        ex_cmd = parse_command(cmd_line)
        print(ex_cmd)

        if ex_cmd and ex_cmd.parse_errors:
            ex_error.display_error(ex_cmd.parse_errors[0])
            return
        if ex_cmd and ex_cmd.name:
            if ex_cmd.can_have_range:
                ex_cmd.args["line_range"] = ex_cmd.line_range
            if ex_cmd.forced:
                ex_cmd.args['forced'] = ex_cmd.forced
            self.window.run_command(ex_cmd.command, ex_cmd.args)
        else:
            ex_error.display_error(ex_error.ERR_UNKNOWN_COMMAND, cmd_line)
Пример #7
0
    def testSimpleFilterThroughShell(self):
        word_count_command = self.__class__.getWordCountCommand()
        # TODO implement test for Windows.
        if not word_count_command:
            return True
        set_text(self.view, 'One two three four\nfive six seven eight\nnine ten.')
        add_sel(self.view, self.R((0, 8), (1, 3)))

        test_command_line = ":'<,'>!" + word_count_command
        ex_cmd = parse_command(test_command_line)
        ex_cmd.args['line_range'] = ex_cmd.line_range

        self.view.run_command(ex_cmd.command, ex_cmd.args)

        actual = self.view.substr(self.R(0, self.view.size()))
        expected = '8\nnine ten.'
        self.assertEqual(expected, actual)
        self.assertEqual(1, len(self.view.sel()))
        cursor = get_sel(self.view, 0)
        self.assertEqual(cursor.begin(), cursor.end())
        self.assertEqual(self.view.text_point(0, 0), cursor.begin())
Пример #8
0
    def testSimpleFilterThroughShell(self):
        word_count_command = self.__class__.getWordCountCommand()
        # TODO implement test for Windows.
        if not word_count_command:
            return True
        set_text(self.view, 'One two three four\nfive six seven eight\nnine ten.')
        add_sel(self.view, self.R((0, 8), (1, 3)))

        test_command_line = ":'<,'>!" + word_count_command
        ex_cmd = parse_command(test_command_line)
        ex_cmd.args['line_range'] = ex_cmd.line_range

        self.view.run_command(ex_cmd.command, ex_cmd.args)

        actual = self.view.substr(self.R(0, self.view.size()))
        expected = '8\nnine ten.'
        self.assertEqual(expected, actual)
        self.assertEqual(1, len(self.view.sel()))
        cursor = get_sel(self.view, 0)
        self.assertEqual(cursor.begin(), cursor.end())
        self.assertEqual(self.view.text_point(0, 0), cursor.begin())