Input is now complelty handled in the SnippetManager

This commit is contained in:
Holger Rapp 2009-07-09 14:13:13 +02:00
parent 493c628346
commit 86a400df80
2 changed files with 14 additions and 19 deletions

View File

@ -62,7 +62,7 @@ inoremap <S-Tab> <C-R>=PyVimSnips_JumpBackwards()<cr>
snoremap <S-Tab> <Esc>:call PyVimSnips_JumpBackwards()<cr>
" Do not remap this.
snoremap <BS> <Esc>:py PySnipSnippets.backspace()<cr>
snoremap <BS> <Esc>:py PySnipSnippets.backspace_while_selected()<cr>
au CursorMovedI * py PySnipSnippets.cursor_moved()
au InsertEnter * py PySnipSnippets.entered_insert_mode()

View File

@ -304,18 +304,7 @@ class SnippetManager(object):
if self._vstate.moved.col <= 0 and self._vstate.moved.line == 1:
self._chars_entered('\n')
elif self._vstate.moved.col < 0: # Some deleting was going on
sline = self._csnippet.abs_start.line
dlines = self._csnippet.end.line - self._csnippet.start.line
self._csnippet.backspace(-self._vstate.moved.col)
# Replace
self._vb.replace_lines(sline, sline + dlines,
self._csnippet._current_text)
ct_end = self._ctab.abs_end
vim.current.window.cursor = ct_end.line +1, ct_end.col
self._vstate.update()
self._backspace(-self._vstate.moved.col)
else:
line = vim.current.line
@ -323,7 +312,6 @@ class SnippetManager(object):
self._vstate.pos.col]
self._chars_entered(chars)
self._expect_move_wo_change = False
def entered_insert_mode(self):
@ -332,15 +320,22 @@ class SnippetManager(object):
self.reset()
def _chars_entered(self, chars):
sline = self._csnippet.abs_start.line
dlines = self._csnippet.end.line - self._csnippet.start.line
if self._csnippet._tab_selected:
self._ctab.current_text = chars
self._csnippet._tab_selected = False
else:
self._ctab.current_text += chars
self._update_vim_buffer()
def _backspace(self, count):
self._ctab.current_text = self._ctab.current_text[:-count]
self._update_vim_buffer()
def _update_vim_buffer(self):
sline = self._csnippet.abs_start.line
dlines = self._csnippet.end.line - self._csnippet.start.line
self._csnippet.update()
# Replace
@ -352,7 +347,7 @@ class SnippetManager(object):
self._vstate.update()
def backspace(self):
def backspace_while_selected(self):
# BS was called in select mode
if self._csnippet and self._csnippet.tab_selected: