def move_me(self, what=None): if what is None: move.right() else: _, _, rb, cb = what() self.for_window.cursor = (rb, cb) if self._set_column: self.for_window.last_seeked_column = cb self._set_column = True
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()
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()
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
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
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
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)
def append(): '''Enter insert mode to the right''' move.right() insert()