Some more minor refactoring.
This commit is contained in:
parent
4f6d54335f
commit
fa71c6fb33
54
PySnipEmu.py
54
PySnipEmu.py
@ -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]
|
||||
|
||||
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
|
||||
ts.select(self._start)
|
||||
|
||||
self._selected_tab = ts
|
||||
return True
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user