Esempio n. 1
0
File: buffer.py Progetto: tj90241/vx
 def delete(self, track=True):
     if track:
         self.dirty = True
         l, c = self.cursor
         move.right()
         lb, cb = self.cursor
         move.left()
         ch = vx.get_ch_linecol_window(self, l, c)
         self.undo_tree.add(removal(ch, l, c, hold=True, box=(l, c, lb, cb)))
     super(buffer, self).delete()
Esempio n. 2
0
 def delete(self, track=True):
     if track:
         self.dirty = True
         l, c = self.cursor
         move.right()
         lb, cb = self.cursor
         move.left()
         ch = vx.get_ch_linecol_window(self, l, c)
         self.undo_tree.add(removal(ch, l, c, hold=True,
                                    box=(l, c, lb, cb)))
     super().delete()
Esempio n. 3
0
File: concat.py Progetto: tj90241/vx
 def move(self):
     if not self._stack:
         move.right()
     else:
         i = self._stack.pop(0)
         if i == PlaceModifier.backward:
             move.left()
         elif isinstance(i, Times):
             utils.repeat(self.move, times=i.i)
         else:
             _, _, lb, cb = i.grab(self.for_window)
             self.for_window.cursor = lb, cb
Esempio n. 4
0
 def move(self):
     if not self._stack:
         move.right()
     else:
         i = self._stack.pop(0)
         if i == PlaceModifier.backward:
             move.left()
         elif isinstance(i, Times):
             utils.repeat(self.move, times=i.i)
         else:
             _, _, lb, cb = i.grab(self.for_window)
             self.for_window.cursor = lb, cb
Esempio n. 5
0
File: text.py Progetto: tj90241/vx
def get_offset_regex(window, regex, forwards=True, ignore_pos=True):
    if ignore_pos:
        move.right(window) if forwards else move.left(window)
    m = regex_forward(window, regex) if forwards else regex_backward(window, regex)
    if m is None: return None
    if ignore_pos:
        move.left(window) if forwards else move.right(window)
    offset = m.start()
    if ignore_pos:
        offset += 1
    if not forwards:
        contents = window.get_contents_before_cursor()
        offset = len(contents) - offset
    return offset
Esempio n. 6
0
def get_offset_regex(window, regex, forwards=True, ignore_pos=True):
    if ignore_pos:
        move.right(window) if forwards else move.left(window)
    m = regex_forward(window, regex) if forwards else regex_backward(
        window, regex)
    if m is None: return None
    if ignore_pos:
        move.left(window) if forwards else move.right(window)
    offset = m.start()
    if ignore_pos:
        offset += 1
    if not forwards:
        contents = window.get_contents_before_cursor()
        offset = len(contents) - offset
    return offset
Esempio n. 7
0
File: text.py Progetto: tj90241/vx
def get_offsets_of(breaks, forward=True, ignore_pos=True, ignore_failed=True):
    """Returns a list of the offsets of each of the characters inside `breaks`

    :param forward: if False, search backwards
    :param ignore_pos: flag for ignoring the cursors current location
    :param ignore_failed: flag to prune characters that weren't found
    """
    if ignore_pos and forward:
        move.right()
    else:
        move.left()
    offsets = map(lambda s: (s, vx.get_linecoloffset_of_str(windows.focused, s, int(forward))[2]), breaks)
    offsets = list(map(lambda x: (x[0], x[1] + 1 if x[1] != -1 else x[1]), offsets)) if ignore_pos else offsets
    if ignore_pos and forward:
        move.left()
    else:
        move.right()
    return list(filter(lambda x: x[1] != -1, offsets) if ignore_failed else offsets)