예제 #1
0
def big_word_starts(view, start, count=1, internal=False):
    assert start >= 0
    assert count > 0

    pt = start
    for i in range(count):
        if internal and i == count - 1 and view.line(start) == view.line(pt):
            if view.substr(pt) == '\n':
                return pt + 1
            return next_big_word_start(view, pt, internal=True)

        pt = next_big_word_start(view, pt)
        if not internal or i != count - 1:
            pt = next_non_white_space_char(view, pt, white_space=' \t')
            while not (view.size() == pt or view.line(pt).empty()
                       or view.substr(view.line(pt)).strip()):
                pt = next_big_word_start(view, pt)
                pt = next_non_white_space_char(view, pt, white_space=' \t')

    if (internal and (view.line(start) != view.line(pt))
            and (start != view.line(start).a
                 and not view.substr(view.line(pt - 1)).isspace())
            and at_eol(view, pt - 1)):  # FIXME # noqa: E501
        pt -= 1

    return pt
예제 #2
0
def word_starts(view, start, count=1, internal=False):
    assert start >= 0
    assert count > 0

    pt = start
    for i in range(count):
        # On the last motion iteration, we must do some special stuff if we are still on the
        # starting line of the motion.
        if (internal and (i == count - 1)
                and (view.line(start) == view.line(pt))):
            if view.substr(pt) == '\n':
                return pt + 1
            return next_word_start(view, pt, internal=True)

        pt = next_word_start(view, pt)
        if not internal or (i != count - 1):
            pt = next_non_white_space_char(view, pt, white_space=' \t')
            while not (view.size() == pt or view.line(pt).empty()
                       or view.substr(view.line(pt)).strip()):
                pt = next_word_start(view, pt)
                pt = next_non_white_space_char(view, pt, white_space=' \t')

    if (internal and (view.line(start) != view.line(pt))
            and (start != view.line(start).a
                 and not view.substr(view.line(pt - 1)).isspace())
            and at_eol(view, pt - 1)):  # FIXME # noqa: E501
        pt -= 1

    return pt
예제 #3
0
    def f(view, s):
        if mode == INTERNAL_NORMAL:
            view.run_command('toggle_comment')
            if utils.row_at(view, s.a) != utils.row_at(view, view.size()):
                pt = next_non_white_space_char(view, s.a, white_space=' \t')
            else:
                pt = next_non_white_space_char(view,
                                               view.line(s.a).a,
                                               white_space=' \t')

            return Region(pt)

        return s
예제 #4
0
def inner_lines(view, s, count=1):
    """
    Return a region spanning @count inner lines.

    Inner lines are lines excluding leading/trailing whitespace at outer ends.

    Assumes we're operating in INTERNAL_NORMAL mode.

    @view
      Target view.
    @s
      Selection in @view taken as starting point.
    @count
      Number of lines to include in returned region.
    """
    end = view.text_point(row_at(view, s.b) + (count - 1), 0)
    begin = view.line(s.b).a
    begin = next_non_white_space_char(view, begin, white_space=' \t')

    return Region(begin, view.line(end).b)
예제 #5
0
파일: cmds.py 프로젝트: SCdF/NeoVintageous
 def run(self, edit, with_what):
     b = self.view.line(self.view.sel()[0].b).a
     pt = next_non_white_space_char(self.view, b, white_space=' \t')
     self.view.replace(edit, Region(pt, self.view.line(pt).b), with_what)