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
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