Some more minor refactoring.

This commit is contained in:
Holger Rapp 2009-07-01 20:27:28 +02:00
parent 4f6d54335f
commit fa71c6fb33

View File

@ -98,6 +98,34 @@ class TabStop(TextObject):
return locals()
current_text = property(**current_text())
def select(self,start):
lineno, col = start
newline = lineno + self._start[0]
# TODO: remove span
if newline == lineno:
newcol = col + self.span[0]
endcol = col + self.span[1]
else:
newcol = self.span[0]
endcol = self.span[1]
vim.current.window.cursor = newline, newcol
# Select the word
# Depending on the current mode and position, we
# might need to move escape out of the mode and this
# will move our cursor one left
if endcol-newcol > 0:
if newcol != 0 and vim.eval("mode()") == 'i':
move_one_right = "l"
else:
move_one_right = ""
vim.command(r'call feedkeys("\<Esc>%sv%il\<c-g>")'
% (move_one_right, endcol-newcol-1))
@property
def span(self):
return (self._start[1]+self._delta_cols,self._start[1]+self._delta_cols+len(self._ct))
@ -150,32 +178,10 @@ class SnippetInstance(TextObject):
return False
ts = self._tabstops[self._cts]
lineno, col = self._start
newline = lineno + ts.start[0]
if newline == lineno:
newcol = col + ts.span[0]
endcol = col + ts.span[1]
else:
newcol = ts.span[0]
endcol = ts.span[1]
ts.select(self._start)
vim.current.window.cursor = newline, newcol
# Select the word
# Depending on the current mode and position, we
# might need to move escape out of the mode and this
# will move our cursor one left
if endcol-newcol > 0:
if newcol != 0 and vim.eval("mode()") == 'i':
move_one_right = "l"
else:
move_one_right = ""
vim.command(r'call feedkeys("\<Esc>%sv%il\<c-g>")'
% (move_one_right, endcol-newcol-1))
self._selected_tab = ts
return True