예제 #1
0
 def _jump(self, backwards = False):
     jumped = False
     if self._cs:
         self._ctab = self._cs.select_next_tab(backwards)
         if self._ctab:
             before, after = _vim.buf.current_line_splitted
             if self._cs.snippet.has_option("s"):
                 if after == "":
                     m = re.match(r'(.*?)\s+$', before)
                     if m:
                         lineno = _vim.buf.cursor.line
                         _vim.text_to_vim(Position(lineno,0), Position(
                             lineno,len(before)+len(after)), m.group(1))
             _vim.select(self._ctab.start, self._ctab.end)
             jumped = True
             if self._ctab.no == 0:
                 self._current_snippet_is_done()
         else:
             # This really shouldn't happen, because a snippet should
             # have been popped when its final tabstop was used.
             # Cleanup by removing current snippet and recursing.
             self._current_snippet_is_done()
             jumped = self._jump(backwards)
     if jumped:
         self._vstate.remember_position()
         self._ignore_movements = True
     return jumped
예제 #2
0
 def _jump(self, backwards=False):
     jumped = False
     if self._cs:
         self._ctab = self._cs.select_next_tab(backwards)
         if self._ctab:
             before, after = _vim.buf.current_line_splitted
             if self._cs.snippet.has_option("s"):
                 if after == "":
                     m = re.match(r'(.*?)\s+$', before)
                     if m:
                         lineno = _vim.buf.cursor.line
                         _vim.text_to_vim(
                             Position(lineno, 0),
                             Position(lineno,
                                      len(before) + len(after)), m.group(1))
             _vim.select(self._ctab.start, self._ctab.end)
             jumped = True
             if self._ctab.no == 0:
                 self._current_snippet_is_done()
         else:
             # This really shouldn't happen, because a snippet should
             # have been popped when its final tabstop was used.
             # Cleanup by removing current snippet and recursing.
             self._current_snippet_is_done()
             jumped = self._jump(backwards)
     if jumped:
         self._vstate.remember_position()
     return jumped
예제 #3
0
 def overwrite(self, gtext=None):
     """
     Overwrite the text of this object in the Vim Buffer and update its
     length information
     """
     # We explicitly do not want to move our childs around here as we
     # either have non or we are replacing text initially which means we do
     # not want to mess with their positions
     if self.current_text == gtext: return
     old_end = self._end
     self._end = _vim.text_to_vim(self._start, self._end, gtext
                                  or self._initial_text)
     if self._parent:
         self._parent._child_has_moved(self._parent._childs.index(self),
                                       min(old_end, self._end),
                                       self._end.diff(old_end))
예제 #4
0
 def overwrite(self, gtext = None):
     """
     Overwrite the text of this object in the Vim Buffer and update its
     length information
     """
     # We explicitly do not want to move our childs around here as we
     # either have non or we are replacing text initially which means we do
     # not want to mess with their positions
     if self.current_text == gtext: return
     old_end = self._end
     self._end = _vim.text_to_vim(
             self._start, self._end, gtext or self._initial_text)
     if self._parent:
         self._parent._child_has_moved(
             self._parent._childs.index(self), min(old_end, self._end),
             self._end.diff(old_end)
         )