コード例 #1
0
ファイル: nodes.py プロジェクト: eanhuddleston/NeoVintageous
    def resolve_line_reference(self, view, line_reference, current=0):
        """
        Calculate the line offset determined by @line_reference.

        @view
          The view where the calculation is made.
        @line_reference
          The sequence of tokens defining the line range to be calculated.
        @current
          Line number where we are now.
        """
        last_token = None
        # XXX: what happens if there is no selection in the view?
        current = row_at(view, first_sel(view).b)
        for token in line_reference:
            # Make sure a search forward doesn't overlap with a match obtained
            # right before this search.
            if isinstance(last_token, TokenOfSearch) and isinstance(
                    token, TokenOfSearch):
                if isinstance(token, TokenSearchForward):
                    current += 1

            current = self.resolve_notation(view, token, current)

            last_token = token

        return current
コード例 #2
0
    def get_visual_repeat_data(self):
        # Return the data needed to restore visual selections.
        #
        # Before repeating a visual mode command in normal mode.
        #
        # Returns:
        #   3-tuple (lines, chars, mode)
        if self.mode not in (VISUAL, VISUAL_LINE):
            return

        first = first_sel(self.view)
        lines = (utils.row_at(self.view, first.end()) -
                 utils.row_at(self.view, first.begin()))

        if lines > 0:
            chars = utils.col_at(self.view, first.end())
        else:
            chars = first.size()

        return (lines, chars, self.mode)
コード例 #3
0
ファイル: state.py プロジェクト: chandlerc/NeoVintageous
    def restore_visual_data(self, data):
        rows, chars, old_mode = data
        first = first_sel(self.view)

        if old_mode == VISUAL:
            if rows > 0:
                end = self.view.text_point(utils.row_at(self.view, first.b) + rows, chars)
            else:
                end = first.b + chars

            self.view.sel().add(Region(first.b, end))
            self.mode = VISUAL

        elif old_mode == VISUAL_LINE:
            rows, _, old_mode = data
            begin = self.view.line(first.b).a
            end = self.view.text_point(utils.row_at(self.view, begin) +
                                       (rows - 1), 0)
            end = self.view.full_line(end).b
            self.view.sel().add(Region(begin, end))
            self.mode = VISUAL_LINE
コード例 #4
0
ファイル: nodes.py プロジェクト: chandlerc/NeoVintageous
def _resolve_line_reference(view, line_reference, current=0):
    # type: (...) -> int
    # Args:
    #   view (View): The view where the calculation is made.
    #   line_reference (list): The sequence of tokens defining the line range to be calculated.
    #   current (int): Line number where we are now.
    last_token = None
    # XXX: what happens if there is no selection in the view?
    current = row_at(view, first_sel(view).b)
    for token in line_reference:
        # Make sure a search forward doesn't overlap with
        # a match obtained right before this search.
        if isinstance(last_token, TokenOfSearch) and isinstance(
                token, TokenOfSearch):
            if isinstance(token, TokenSearchForward):
                current += 1

        current = _resolve_line_number(view, token, current)

        last_token = token

    return current