Esempio n. 1
0
File: concat.py Progetto: tj90241/vx
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca, lb, cb = super(end_lines, self).grab(buffer)
         buffer.cursor = (lb, cb)
         move.eol()
         lb, cb = buffer.cursor
         return la, ca, lb, cb
Esempio n. 2
0
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca, lb, cb = super().grab(buffer)
         buffer.cursor = (lb, cb)
         move.eol()
         lb, cb = buffer.cursor
         return la, ca, lb, cb
Esempio n. 3
0
File: buffer.py Progetto: tj90241/vx
 def column_restore(self, column=None):
     if not column:
         column = self.last_seeked_column
     yield
     with self.cursor_wander():
         move.eol()
         _, end = self.cursor
     self.cursor = (self.cursor[0], min(end, column))
Esempio n. 4
0
File: concat.py Progetto: tj90241/vx
 def grab(self, buffer):
     with buffer.cursor_wander():
         move.bol() if self.forward else move.eol()
         la, ca, lb, cb = super(whole_lines, self).grab(buffer)
         buffer.cursor = (lb, cb)
         move.eol() if self.forward else move.bol()
         lb, cb = buffer.cursor
         return la, ca, lb, cb
Esempio n. 5
0
 def grab(self, buffer):
     with buffer.cursor_wander():
         move.bol() if self.forward else move.eol()
         la, ca, lb, cb = super().grab(buffer)
         buffer.cursor = (lb, cb)
         move.eol() if self.forward else move.bol()
         lb, cb = buffer.cursor
         return la, ca, lb, cb
Esempio n. 6
0
 def column_restore(self, column=None):
     if not column:
         column = self.last_seeked_column
     yield
     with self.cursor_wander():
         move.eol()
         _, end = self.cursor
     self.cursor = (self.cursor[0], min(end, column))
Esempio n. 7
0
File: concat.py Progetto: tj90241/vx
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca = buffer.cursor
         breaks = (' ', '\n')
         for _ in range(self.how_many):
             offset = text.get_offset_regex(buffer, '[{}]'.format(''.join(breaks)), forwards=self.forward)
             if offset is None:
                 move.eol(buffer) if self.forward else move.bol(buffer)
             else:
                 utils.repeat(move.right if self.forward else move.left, times=offset)
             lb, cb = buffer.cursor
         return la, ca, lb, cb
Esempio n. 8
0
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca = buffer.cursor
         breaks = (' ', '\n')
         for _ in range(self.how_many):
             offset = text.get_offset_regex(buffer, '[{}]'.format(''.join(breaks)), forwards=self.forward)
             if offset is None:
                 move.eol(buffer) if self.forward else move.bol(buffer)
             else:
                 utils.repeat(move.right if self.forward else move.left, times=offset)
             lb, cb = buffer.cursor
         return la, ca, lb, cb
Esempio n. 9
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())
Esempio n. 10
0
 def cut_to_eol(self):
     (la, ca) = self.for_window.cursor
     with self.for_window.cursor_wander():
         move.eol()
         (lb, cb) = self.for_window.cursor
         if la == la and ca == cb:
             move.down()
             (lb, cb) = self.for_window.cursor
     text_between = vx.get_str_linecol_to_linecol_window(self.for_window, la, ca, lb, cb)
     self.for_window.copystack.push(text_between)
     self.for_window.remove_text(la, ca, lb, cb)
     self.for_window.dirty = True
     self.for_window.undo_tree.add(undo.removal(text_between, la, ca, (la, ca, lb, cb), True))
     self.for_window.cursor = (la, ca)
Esempio n. 11
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())
Esempio n. 12
0
File: buffer.py Progetto: tj90241/vx
 def backspace(self, track=True):
     if track:
         self.dirty = True
         l, c = self.cursor
         lb, cb = l, c
         if l > 1 or c > 1:
             c = c - 1
             if c == 0:
                 l -= 1
                 move.up()
                 move.eol()
                 _, c = self.cursor
                 move.down()
                 move.bol()
             ch = vx.get_ch_linecol_window(self, l, c)
             if ch == '\t':
                 c -= 7
             self.undo_tree.add(removal(ch, l, c, hold=False, box=(l, c, lb, cb)))
     super(buffer, self).backspace()
Esempio n. 13
0
 def backspace(self, track=True):
     if track:
         self.dirty = True
         l, c = self.cursor
         lb, cb = l, c
         if l > 1 or c > 1:
             c = c - 1
             if c == 0:
                 l -= 1
                 move.up()
                 move.eol()
                 _, c = self.cursor
                 move.down()
                 move.bol()
             ch = vx.get_ch_linecol_window(self, l, c)
             if ch == '\t':
                 c -= 7
             self.undo_tree.add(
                 removal(ch, l, c, hold=False, box=(l, c, lb, cb)))
     super().backspace()
Esempio n. 14
0
File: vigor.py Progetto: tj90241/vx
def eol_append():
    '''Move to end of line and enter insert mode'''
    move.eol()
    insert()