예제 #1
0
    def check_empty(self):
        if self._context['cursor_pos'].isnumeric():
            self.init_cursor()
            self.move_to_pos(int(self._context['cursor_pos']))
        elif re.match(r'\+\d+', self._context['cursor_pos']):
            for _ in range(int(self._context['cursor_pos'][1:])):
                self.move_to_next_line()
        elif re.match(r'-\d+', self._context['cursor_pos']):
            for _ in range(int(self._context['cursor_pos'][1:])):
                self.move_to_prev_line()
        elif self._context['cursor_pos'] == '$':
            self.move_to_last_line()

        if (self._candidates and self._context['immediately'] or
                len(self._candidates) == 1 and self._context['immediately_1']):
            goto = self._winid > 0 and self._vim.call(
                'win_gotoid', self._winid)
            if goto:
                # Jump to denite window
                self.init_buffer()
                self.update_cursor()
            self.do_action('default')
            candidate = self.get_cursor_candidate()
            echo(self._vim, 'Normal', '[{0}/{1}] {2}'.format(
                self._cursor + self._win_cursor, self._candidates_len,
                candidate.get('abbr', candidate['word'])))
            if goto:
                # Move to the previous window
                self.suspend()
                self._vim.command('wincmd p')
            return True
        return not (self._context['empty'] or
                    self._denite.is_async() or self._candidates)
예제 #2
0
파일: default.py 프로젝트: isJone99/dotvim
    def check_empty(self):
        if self._context['cursor_pos'].isnumeric():
            self.init_cursor()
            self.move_to_pos(int(self._context['cursor_pos']))
        elif re.match(r'\+\d+', self._context['cursor_pos']):
            for _ in range(int(self._context['cursor_pos'][1:])):
                self.move_to_next_line()
        elif re.match(r'-\d+', self._context['cursor_pos']):
            for _ in range(int(self._context['cursor_pos'][1:])):
                self.move_to_prev_line()
        elif self._context['cursor_pos'] == '$':
            self.move_to_last_line()

        if (self._candidates and self._context['immediately'] or
                len(self._candidates) == 1 and self._context['immediately_1']):
            goto = self._winid > 0 and self._vim.call(
                'win_gotoid', self._winid)
            if goto:
                # Jump to denite window
                self.init_buffer()
                self.update_cursor()
            self.do_action('default')
            candidate = self.get_cursor_candidate()
            echo(self._vim, 'Normal', '[{0}/{1}] {2}]'.format(
                self._cursor + self._win_cursor, self._candidates_len,
                candidate.get('abbr', candidate['word'])))
            if goto:
                # Move to the previous window
                self.suspend()
                self._vim.command('wincmd p')
            return True
        return not (self._context['empty'] or
                    self._denite.is_async() or self._candidates)
예제 #3
0
 def check_empty(self):
     if self._candidates and self._context['immediately']:
         self.do_action('default')
         candidate = self.get_cursor_candidate()
         echo(self._vim, 'Normal', '[{0}/{1}] {2}]'.format(
             self._cursor + self._win_cursor, self._candidates_len,
             candidate.get('abbr', candidate['word'])))
         return True
     return not (self._context['empty'] or
                 self._denite.is_async() or self._candidates)
예제 #4
0
파일: default.py 프로젝트: amosbird/vimrc
 def check_empty(self):
     if self._candidates and self._context['immediately']:
         self.do_action('default')
         candidate = self.get_cursor_candidate()
         echo(self._vim, 'Normal', '[{0}/{1}] {2}]'.format(
             self._cursor + self._win_cursor, self._candidates_len,
             candidate.get('abbr', candidate['word'])))
         return True
     return not (self._context['empty'] or
                 self._denite.is_async() or self._candidates)
예제 #5
0
 def do_immediately(self):
     goto = self._winid > 0 and self._vim.call(
         'win_gotoid', self._winid)
     if goto:
         # Jump to denite window
         self.init_buffer()
         self.update_cursor()
     self.do_action('default')
     candidate = self.get_cursor_candidate()
     echo(self._vim, 'Normal', '[{0}/{1}] {2}'.format(
         self._cursor + self._win_cursor, self._candidates_len,
         candidate.get('abbr', candidate['word'])))
     if goto:
         # Move to the previous window
         self.suspend()
         self._vim.command('wincmd p')
예제 #6
0
 def _do_immediately(self) -> None:
     goto = self._winid > 0 and self._vim.call(
         'win_gotoid', self._winid)
     if goto:
         # Jump to denite window
         self._init_buffer()
     self.do_action('default')
     candidate = self._get_cursor_candidate()
     if not candidate:
         return
     echo(self._vim, 'Normal', '[{}/{}] {}'.format(
         self._cursor, len(self._candidates),
         candidate.get('abbr', candidate['word'])))
     if goto:
         # Move to the previous window
         self._vim.command('wincmd p')
예제 #7
0
파일: default.py 프로젝트: lilydjwg/dotvim
 def do_immediately(self):
     goto = self._winid > 0 and self._vim.call(
         'win_gotoid', self._winid)
     if goto:
         # Jump to denite window
         self.init_buffer()
         self.update_cursor()
     self.do_action('default')
     candidate = self.get_cursor_candidate()
     echo(self._vim, 'Normal', '[{0}/{1}] {2}'.format(
         self._cursor + self._win_cursor, self._candidates_len,
         candidate.get('abbr', candidate['word'])))
     if goto:
         # Move to the previous window
         self.suspend()
         self._vim.command('wincmd p')
예제 #8
0
 def update_prompt(self):
     self.__vim.command('redraw')
     if self.__context['prompt'] != '':
         echo(self.__vim, self.__context['prompt_highlight'],
              self.__context['prompt'] + ' ')
     echo(self.__vim, 'Normal', self.__input_before)
     echo(self.__vim, self.__context['cursor_highlight'],
          self.__input_cursor)
     echo(self.__vim, 'Normal', self.__input_after)
예제 #9
0
    def update_prompt(self, context):
        prompt_color = context.get('prompt_color', 'Statement')
        prompt = context.get('prompt', '# ')
        cursor_color = context.get('cursor_color', 'Cursor')

        self.__vim.command('redraw')
        echo(self.__vim, prompt_color, prompt)
        echo(self.__vim, 'Normal', self.__input_before)
        echo(self.__vim, cursor_color, self.__input_cursor)
        echo(self.__vim, 'Normal', self.__input_after)
예제 #10
0
    def check_empty(self):
        if self._context['cursor_pos'].isnumeric():
            self.init_cursor()
            self.move_to_pos(int(self._context['cursor_pos']))
        elif re.match(r'\+\d+', self._context['cursor_pos']):
            for _ in range(int(self._context['cursor_pos'][1:])):
                self.move_to_next_line()
        elif re.match(r'-\d+', self._context['cursor_pos']):
            for _ in range(int(self._context['cursor_pos'][1:])):
                self.move_to_prev_line()
        elif self._context['cursor_pos'] == '$':
            self.move_to_last_line()

        if self._candidates and self._context['immediately']:
            self.do_action('default')
            candidate = self.get_cursor_candidate()
            echo(
                self._vim, 'Normal', '[{0}/{1}] {2}]'.format(
                    self._cursor + self._win_cursor, self._candidates_len,
                    candidate.get('abbr', candidate['word'])))
            return True
        return not (self._context['empty'] or self._denite.is_async()
                    or self._candidates)
예제 #11
0
    def input_loop(self, context):
        prompt_color = context.get('prompt_color', 'Statement')
        prompt = context.get('prompt', '# ')
        cursor_color = context.get('cursor_color', 'Cursor')

        self.__input_before = context.get('input', '')
        self.__input_cursor = ''
        self.__input_after = ''

        esc = self.__vim.eval('"\<Esc>"')

        while True:
            self.__vim.command('redraw')
            echo(self.__vim, prompt_color, prompt)
            echo(self.__vim, 'Normal', self.__input_before)
            echo(self.__vim, cursor_color, self.__input_cursor)
            echo(self.__vim, 'Normal', self.__input_after)

            nr = self.__vim.funcs.getchar(
                0) if context['is_async'] else self.__vim.funcs.getchar()
            char = nr if isinstance(nr, str) else chr(nr)
            if not isinstance(nr, str) and nr >= 0x20:
                # Normal input string
                self.__input_before += char
                self.update_input(context)
                continue

            if char in self.__mappings and hasattr(self,
                                                   self.__mappings[char]):
                func = getattr(self, self.__mappings[char])
                ret = func(context)
                if ret:
                    break
            elif char == esc:
                self.quit_buffer(context)
                break

            if context['is_async']:
                time.sleep(0.05)