Exemple #1
0
 def next(self):
     if self.matching:
         if self.forwards:
             utils.repeat(partial(vx.move_right_window, self.attached_to), times=self.match_length)
         else:
             utils.repeat(partial(vx.move_left_window, self.attached_to), times=self.match_length)
             vx.move_left_window(self.attached_to)
Exemple #2
0
 def search(self):
     self.set_color(-1, -1)
     search_for = self.contents
     if not search_for:
         self.clear_color()
         return
     l, c, o, length = self.dosearch(self.attached_to, search_for,
                                     int(self.forwards))
     if o == -1:
         self.attached_to.cursor = (self.original_cursor[0],
                                    self.original_cursor[1])
         self.clear_color()
         self.set_color(-1, 11)
         self.matching = False
         return
     self.attached_to.ensure_visible(l, c + length)
     self.matching = True
     self.match_length = length
     self.attached_to.cursor = (l, c)
     self.clear_color()
     self.attached_to.add_color_tag('search', l, c, length, 1, 10)
     all_matches = self.attached_to.get_all_regex_linecoloffsetlengths_of(
         search_for, self.forwards)
     if not self.forwards:
         # quick and ugly, this should be fixed with better overlap
         # color tag detection
         all_matches = [None] + list(all_matches)
     for l, c, _, length in list(all_matches)[1:]:
         self.attached_to.add_color_tag('search', l, c, length, 1, 9)
     if not self.forwards:
         utils.repeat(partial(vx.move_right_window, self.attached_to),
                      times=length)
Exemple #3
0
 def next(self):
     if self.matching:
         if self.forwards:
             utils.repeat(partial(vx.move_right_window, self.attached_to),
                          times=self.match_length)
         else:
             utils.repeat(partial(vx.move_left_window, self.attached_to),
                          times=self.match_length)
             vx.move_left_window(self.attached_to)
Exemple #4
0
    def getout(self):
        if self.matching:
            if self.forwards:
                utils.repeat(partial(vx.move_right_window, self.attached_to), times=self.match_length)

        if self.remove_callback:
            self.remove_callback(self)

        self.remove(force=True)
        unregister_key_listener(self.isearch)
        self.clear_color()
Exemple #5
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
Exemple #6
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
Exemple #7
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
Exemple #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
Exemple #9
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
Exemple #10
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
Exemple #11
0
    def getout(self):
        if self.matching:
            if self.forwards:
                utils.repeat(partial(vx.move_right_window, self.attached_to),
                             times=self.match_length)

        if self.remove_callback:
            self.remove_callback(self)

        self.remove(force=True)
        unregister_key_listener(self.isearch)
        self.clear_color()
Exemple #12
0
 def search(self):
     self.set_color(-1, -1)
     search_for = self.contents
     if not search_for: self.clear_color(); return
     l, c, o, length = self.dosearch(self.attached_to, search_for, int(self.forwards))
     if o == -1:
         self.attached_to.cursor = (self.original_cursor[0], self.original_cursor[1])
         self.clear_color()
         self.set_color(-1, 11)
         self.matching = False
         return
     self.attached_to.ensure_visible(l, c + length)
     self.matching = True
     self.match_length = length
     self.attached_to.cursor = (l, c)
     self.clear_color()
     self.attached_to.add_color_tag("search", l, c, length, 1, 10)
     if not self.forwards:
         utils.repeat(partial(vx.move_right_window, self.attached_to), times=length)
Exemple #13
0
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca = buffer.cursor
         utils.repeat(move.right if self.forward else move.left, times=self.how_many)
         lb, cb = buffer.cursor
         return la, ca, lb, cb
Exemple #14
0
 def grab(self, buffer):
     with buffer.cursor_wander():
         la, ca = buffer.cursor
         utils.repeat(move.right if self.forward else move.left, times=self.how_many)
         lb, cb = buffer.cursor
         return la, ca, lb, cb