def diff(self, diffmode): with windows.remain(): getattr(self, '_diff_%d' % diffmode)() # Reset the scrollbind to whatever it was before we diffed. if not diffmode: self.scrollbind(self._current_scrollbind)
def key_use(self): current_diff = self._current_diff_mode with windows.remain(): self._diff_3() # diff the middle and result windows if buffers.current == buffers.result: vim.command('diffget') elif buffers.current in (buffers.one, buffers.two): vim.command('diffput') self.diff(current_diff)
def _key_use_12(self, target): targetwin = 2 if target == 1 else 4 with windows.remain(): self.diffoff() windows.focus(3) vim.command('diffthis') windows.focus(targetwin) vim.command('diffthis')
def redraw_hud(self): with windows.remain(): windows.focus(1) vim.command('setlocal modifiable') buffers.hud.set_lines(self.hud_lines()) vim.command('setlocal nomodifiable') vim.command('set winfixheight') vim.command('resize ' + setting('hud_size', '3')) vim.command('wincmd =')
def diffoff(self): with windows.remain(): for winnr in range(2, 2 + self._number_of_windows): windows.focus(winnr) curbuffer = buffers.current for buffer in buffers.all: buffer.open() vim.command('diffoff') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) curbuffer.open()
def scrollbind(self, enabled): if self._current_diff_mode: return with windows.remain(): self._current_scrollbind = enabled for winnr in range(2, 2 + self._number_of_windows): windows.focus(winnr) if enabled: vim.command('set scrollbind') else: vim.command('set noscrollbind') if enabled: vim.command('syncbind')
def key_use(self): active = (self._current_buffer_first, self._current_buffer_second) if buffers.result not in active: return if buffers.one not in active and buffers.two not in active: return current_diff = self._current_diff_mode with windows.remain(): self._diff_1() # diff the windows if buffers.current == buffers.result: vim.command('diffget') elif buffers.current in (buffers.one, buffers.two): vim.command('diffput') self.diff(current_diff)