示例#1
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_vim_command_with_parameter(self):
     i = PromptInput(text='buffer  term').parse()
     self.assertEqual(i.vim_command, 'buffer')
     self.assertEqual(i.vim_command_spacer, '  ')
     self.assertEqual(i.vim_command_parameter, 'term')
     self.assertTrue('' is i.terminal_command is i.terminal_command_spacer
                     is i.terminal_command_parameter)
示例#2
0
def _inside_main_loop(key, x_key_event, multiplier):
	command_input = PromptInput(
		time=x_key_event.time, keyval=x_key_event.keyval, parameters=key.parameters)

	execute(key.function, command_input, multiplier)

	return False
示例#3
0
    def on_entry_key_press(self, widget, event):
        if event.keyval in HISTORY_NAVIGATION_KEYS:
            self.prompt_history.navigate_history(
                -1 if event.keyval == Gdk.KEY_Up else 1,
                self.view.get_command())
            self.view.set_command(self.prompt_history.current_command())
            self.view.clean_hints()
            self.completion.clean()
            return True
        else:
            self.prompt_history.reset_history_pointer()

        if event.keyval not in HINT_NAVIGATION_KEYS:
            return False

        if not self.completion.assisting and event.keyval in HINT_LAUNCH_KEYS:
            self.completion.search_for(
                PromptInput(text=self.view.get_command()).parse())

        if self.completion.assisting:
            shift_mask = event.state & Gdk.ModifierType.SHIFT_MASK
            right = event.keyval in HINT_RIGHT or (
                event.keyval in HINT_LAUNCH_KEYS and not shift_mask)
            self.completion.cycle(1 if right else -1)
            if len(self.completion.options) == 1:
                self.view.clean_hints()
            else:
                self.view.offer(self.completion.options, self.completion.index,
                                self.completion.should_auto_assist())
            self.view.set_command(self.completion.mount_input())

        return True
示例#4
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_terminal_command_with_number(self):
     i = PromptInput(text='!  7z').parse()
     self.assertEqual(i.vim_command, '!')
     self.assertEqual(i.vim_command_spacer, '  ')
     self.assertEqual(i.vim_command_parameter, '7z')
     self.assertEqual(i.terminal_command, '7z')
     self.assertEqual(i.terminal_command_spacer, '')
     self.assertEqual(i.terminal_command_parameter, '')
示例#5
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_empty_terminal_command(self):
     i = PromptInput(text='!  ').parse()
     self.assertEqual(i.vim_command, '!')
     self.assertEqual(i.vim_command_spacer, '  ')
     self.assertEqual(i.vim_command_parameter, '')
     self.assertEqual(i.terminal_command, '')
     self.assertEqual(i.terminal_command_spacer, '')
     self.assertEqual(i.terminal_command_parameter, '')
示例#6
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_vim_command_with_number_parameter_without_separation(self):
     i = PromptInput(text='b2').parse()
     self.assertEqual(i.vim_command, 'b')
     self.assertEqual(i.vim_command_spacer, '')
     self.assertEqual(i.vim_command_parameter, '2')
     self.assertEqual(i.terminal_command, '')
     self.assertEqual(i.terminal_command_spacer, '')
     self.assertEqual(i.terminal_command_parameter, '')
示例#7
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_vim_command_with_number_parameter(self):
     i = PromptInput(text='buffer  23').parse()
     self.assertEqual(i.vim_command, 'buffer')
     self.assertEqual(i.vim_command_spacer, '  ')
     self.assertEqual(i.vim_command_parameter, '23')
     self.assertEqual(i.terminal_command, '')
     self.assertEqual(i.terminal_command_spacer, '')
     self.assertEqual(i.terminal_command_parameter, '')
示例#8
0
    def _window_key_press_callback(self, widget, event):
        ctrl = (event.state & Gdk.ModifierType.CONTROL_MASK)

        if event.keyval == Gdk.KEY_Escape or (ctrl and event.keyval
                                              == Gdk.KEY_bracketleft):
            self.escape(PromptInput(time=event.time, keyval=event.keyval))
            return

        if self.in_command_mode():
            return

        if event.keyval == Gdk.KEY_colon and not ctrl:
            self.colon(PromptInput(time=event.time, keyval=event.keyval))
            return True

        if event.keyval == Gdk.KEY_Return:
            self.enter(PromptInput(time=event.time, keyval=event.keyval))
            return True
示例#9
0
    def on_entry_key_release(self, widget, event):
        if event.keyval in HINT_OPERATION_KEYS:
            return False

        if not self.view.colon_prompt.get_text().strip():
            self.clean_state()
            self.show(Gtk.get_current_event_time())
            return True

        if self.configurations.is_auto_hint():
            self.completion.search_for(
                PromptInput(text=self.view.get_command()).parse())
        else:
            self.completion.clean()

        if self.completion.assisting:
            self.view.offer(self.completion.options, self.completion.index,
                            self.completion.should_auto_assist())
        else:
            self.view.clean_hints()
示例#10
0
    def on_prompt_input(self, pane_owner, current):
        if not self.command_mode:
            return

        gtk_time = Gtk.get_current_event_time()
        cmd = self.view.get_command()

        if self.completion.should_auto_assist():
            self.completion.cycle(1)
            cmd = self.completion.mount_input()

        self.prompt_history.append(cmd)

        if names.has_multiple_names(cmd):
            raise Exception('TODO: iterate multiple commands')

        c_in = PromptInput(time=gtk_time, text=cmd).parse()
        name = names.match(c_in)

        if name:
            poco.service.execute(name.function, c_in)
        else:
            self.clean_state()
            self.show(gtk_time, error_message='Not an editor command: ' + cmd)
示例#11
0
文件: assistant.py 项目: ecb-eng/poco
 def test_bang_vim_command_is_mounted_even_if_empty(self):
     self.completion.search_for(PromptInput(text='!').parse())
     self.completion.index = 0
     self.assertEqual('!foobar', self.completion.mount_input())
示例#12
0
文件: assistant.py 项目: ecb-eng/poco
 def test_mount_spaces(self):
     self.completion.search_for(PromptInput(text='  !   foo').parse())
     self.completion.cycle(1)
     self.assertEqual('  !   foobar', self.completion.mount_input())
示例#13
0
文件: assistant.py 项目: ecb-eng/poco
 def test_dont_query_vim_command_if_bang(self):
     command_input = PromptInput(text='!foo').parse()
     poco.assistant.completions_for(command_input, self.reading)
     names.completions_for.assert_not_called()
示例#14
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_colon_spacer(self):
     i = PromptInput(text='  buffers').parse()
     self.assertEqual(i.colon_spacer, '  ')
     self.assertEqual(i.vim_command, 'buffers')
示例#15
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_vim_command(self):
     i = PromptInput(text='buffers').parse()
     self.assertEqual(i.vim_command, 'buffers')
     self.assertTrue('' == i.vim_command_spacer == i.vim_command_parameter)
     self.assertTrue('' is i.terminal_command is i.terminal_command_spacer
                     is i.terminal_command_parameter)
示例#16
0
文件: assistant.py 项目: ecb-eng/poco
 def test_query_vim_commands(self):
     self.completion.search_for(PromptInput(text='foo').parse())
     names.completions_for.assert_called_once_with('foo')
示例#17
0
文件: assistant.py 项目: ecb-eng/poco
 def test_query_vim_commands_with_number(self):
     self.completion.search_for(PromptInput(text='b4').parse())
     names.completions_for.assert_not_called()
示例#18
0
 def execute(self, cmd):
     self.windows.read_screen()
     c_in = PromptInput(time=None, text=cmd).parse()
     name = names.match(c_in)
     name.function(c_in)
示例#19
0
文件: assistant.py 项目: ecb-eng/poco
 def test_query_vim_commands_even_if_partial_match(self):
     self.completion.search_for(PromptInput(text='b').parse())
     names.completions_for.assert_called_once_with('b')
示例#20
0
文件: terminal.py 项目: ecb-eng/poco
 def test_autocomplete_parameters(self):
     terminal.query_command_parameters = lambda x: ['bar']
     self.assertEqual(['bar'],
                      terminal.list_completions(
                          PromptInput(text='!foo ').parse()))
示例#21
0
文件: names.py 项目: ecb-eng/poco
 def test_parse_empty_input(self):
     i = PromptInput(text='').parse()
     self.assertEqual(i.colon_spacer, '')
     self.assertEqual(i.vim_command, '')