예제 #1
0
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca = buffer.cursor
         for _ in range(self.how_many):
             offset = text.get_offset_regex(buffer, r'^$', forwards=self.forward)
             if offset is None:
                 move.end(buffer) if self.forward else move.end(buffer)
             else:
                 utils.repeat(move.right if self.forward else move.left, times=offset)
             lb, cb = buffer.cursor
         return la, ca, lb, cb
예제 #2
0
파일: concat.py 프로젝트: tj90241/vx
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca = buffer.cursor
         for _ in range(self.how_many):
             offset = text.get_offset_regex(buffer, r'^$', forwards=self.forward)
             if offset is None:
                 move.end(buffer) if self.forward else move.end(buffer)
             else:
                 utils.repeat(move.right if self.forward else move.left, times=offset)
             lb, cb = buffer.cursor
         return la, ca, lb, cb
예제 #3
0
파일: test.py 프로젝트: philipdexter/vx
def run_tests():
    try:
        w = windows.focused
        w.blank()


        def check_at(s, a, forwards=True):
            check_items(vx.get_linecoloffset_of_str(w, s, int(forwards)), a)

        w.add_string(
'''
Tests are being run
''')
        move.beg()

        w.add_string('öäå')
        move.beg()

        check_at('ä', (1, 2, 1))
        check_at('ä', (1, 2, 1))
        check_at('öäå', (1, 1, 0))
        check_at('öäå\n', (1, 1, 0))

        move.down()

        check_at('ö', (1, 1, 4), False)

        move.eol()

        check_at('ö', (1, 1, 23), False)
        check_at('ä', (1, 2, 22), False)

        vx.set_linecol_window(w, 1, 2)

        check_at('ä', (1, 2, 0))
        check_at('å', (1, 3, 1))
        check_at('öäå', (1, 1, 1), False)
        check_at('öäå\n', (1, 1, 1), False)
        check_at('å\n', (1, 3, 1))

        for t in _tests:
            t()

        move.end()
        w.add_string('''
All tests have passed
''')
    except AssertionError as e:
        move.end()
        w.add_string('\n\n')
        w.add_string(traceback.format_exc())
예제 #4
0
def run_tests():
    try:
        w = windows.focused
        w.blank()

        def check_at(s, a, forwards=True):
            check_items(vx.get_linecoloffset_of_str(w, s, int(forwards)), a)

        w.add_string('''
Tests are being run
''')
        move.beg()

        w.add_string('öäå')
        move.beg()

        check_at('ä', (1, 2, 1))
        check_at('ä', (1, 2, 1))
        check_at('öäå', (1, 1, 0))
        check_at('öäå\n', (1, 1, 0))

        move.down()

        check_at('ö', (1, 1, 4), False)

        move.eol()

        check_at('ö', (1, 1, 23), False)
        check_at('ä', (1, 2, 22), False)

        vx.set_linecol_window(w, 1, 2)

        check_at('ä', (1, 2, 0))
        check_at('å', (1, 3, 1))
        check_at('öäå', (1, 1, 1), False)
        check_at('öäå\n', (1, 1, 1), False)
        check_at('å\n', (1, 3, 1))

        for t in _tests:
            t()

        move.end()
        w.add_string('''
All tests have passed
''')
    except AssertionError as e:
        move.end()
        w.add_string('\n\n')
        w.add_string(traceback.format_exc())