# HG changeset patch # User Steve Losh # Date 1307941436 14400 # Node ID 890a1d687c33571d553201080c0ff17cfd0206ca # Parent 0e3a284792b2bc1e027c0a8c87abe8afd2104d05 Diffoff and some cleanup. diff -r 0e3a284792b2 -r 890a1d687c33 plugin/threesome.py --- a/plugin/threesome.py Mon Jun 13 00:50:43 2011 -0400 +++ b/plugin/threesome.py Mon Jun 13 01:03:56 2011 -0400 @@ -47,6 +47,9 @@ def ThreesomeDiff(): threesome.modes.current_mode.key_diff() +def ThreesomeDiffoff(): + threesome.modes.current_mode.key_diffoff() + def ThreesomeNext(): threesome.modes.current_mode.key_next() diff -r 0e3a284792b2 -r 890a1d687c33 plugin/threesome.vim --- a/plugin/threesome.vim Mon Jun 13 00:50:43 2011 -0400 +++ b/plugin/threesome.vim Mon Jun 13 01:03:56 2011 -0400 @@ -98,6 +98,9 @@ function! s:ThreesomeDiff()"{{{ python ThreesomeDiff() endfunction"}}} +function! s:ThreesomeDiffoff()"{{{ + python ThreesomeDiffoff() +endfunction"}}} function! s:ThreesomeNext()"{{{ python ThreesomeNext() endfunction"}}} @@ -122,6 +125,7 @@ command! -nargs=0 ThreesomeResult call s:ThreesomeResult() command! -nargs=0 ThreesomeDiff call s:ThreesomeDiff() +command! -nargs=0 ThreesomeDiffoff call s:ThreesomeDiffoff() command! -nargs=0 ThreesomeNext call s:ThreesomeNext() command! -nargs=0 ThreesomePrev call s:ThreesomePrev() diff -r 0e3a284792b2 -r 890a1d687c33 plugin/threesomelib/init.py --- a/plugin/threesomelib/init.py Mon Jun 13 00:50:43 2011 -0400 +++ b/plugin/threesomelib/init.py Mon Jun 13 01:03:56 2011 -0400 @@ -1,3 +1,4 @@ +import vim import modes from util import buffers, keys, windows @@ -40,11 +41,30 @@ keys.bind('r', ':ThreesomeResult') keys.bind('d', ':ThreesomeDiff') + keys.bind('D', ':ThreesomeDiffoff') keys.bind('n', ':ThreesomeNext') keys.bind('N', ':ThreesomePrev') +def setlocal_buffers(): + buffers.original.open() + vim.command('setlocal buftype=nofile') + vim.command('setlocal noswapfile') + vim.command('setlocal nomodifiable') + + buffers.one.open() + vim.command('setlocal buftype=nofile') + vim.command('setlocal noswapfile') + vim.command('setlocal nomodifiable') + + buffers.two.open() + vim.command('setlocal buftype=nofile') + vim.command('setlocal noswapfile') + vim.command('setlocal nomodifiable') + + def init(): process_result() + setlocal_buffers() bind_global_keys() modes.current_mode = modes.grid modes.current_mode.activate() diff -r 0e3a284792b2 -r 890a1d687c33 plugin/threesomelib/modes.py --- a/plugin/threesomelib/modes.py Mon Jun 13 00:50:43 2011 -0400 +++ b/plugin/threesomelib/modes.py Mon Jun 13 01:03:56 2011 -0400 @@ -11,7 +11,9 @@ def diff(self, diffmode): + curwindow = windows.currentnr() getattr(self, '_diff_%d' % diffmode)() + windows.focus(curwindow) def key_diff(self, diffmode=None): next_diff_mode = self._current_diff_mode + 1 @@ -19,6 +21,9 @@ next_diff_mode = 0 self.diff(next_diff_mode) + def key_diffoff(self): + self.diff(0) + def key_original(self): pass @@ -211,8 +216,7 @@ def key_one(self): def open_one(winnr): - windows.focus(winnr) - buffers.one.open() + buffers.one.open(winnr) self.diff(self._current_diff_mode) curwindow = windows.currentnr() @@ -246,8 +250,7 @@ def key_two(self): def open_two(winnr): - windows.focus(winnr) - buffers.two.open() + buffers.two.open(winnr) self.diff(self._current_diff_mode) curwindow = windows.currentnr() @@ -358,11 +361,13 @@ windows.focus(2) buffers.one.open() self.diff(self._current_diff_mode) + windows.focus(2) def key_two(self): windows.focus(2) buffers.two.open() self.diff(self._current_diff_mode) + windows.focus(2) def key_result(self): windows.focus(3) diff -r 0e3a284792b2 -r 890a1d687c33 plugin/threesomelib/util/bufferlib.py --- a/plugin/threesomelib/util/bufferlib.py Mon Jun 13 00:50:43 2011 -0400 +++ b/plugin/threesomelib/util/bufferlib.py Mon Jun 13 01:03:56 2011 -0400 @@ -1,5 +1,6 @@ import os import vim +import windows ap = os.path.abspath @@ -9,7 +10,9 @@ self._buffer = vim.buffers[i] self.name = self._buffer.name - def open(self): + def open(self, winnr=None): + if winnr is not None: + windows.focus(winnr) vim.command('%dbuffer' % self.number) def set_lines(self, lines):