# HG changeset patch # User Steve Losh # Date 1307940424 14400 # Node ID 0d5394864481ad1b46a9cede05812dc699e543ff # Parent bb3247356f2212690d538398d8b8bcfd1bdfea8f Path view and next/prev conflicts. diff -r bb3247356f22 -r 0d5394864481 plugin/threesome.py --- a/plugin/threesome.py Mon Jun 13 00:25:16 2011 -0400 +++ b/plugin/threesome.py Mon Jun 13 00:47:04 2011 -0400 @@ -40,7 +40,16 @@ def ThreesomeCompare(): threesome.modes.key_compare() +def ThreesomePath(): + threesome.modes.key_path() + def ThreesomeDiff(): threesome.modes.current_mode.key_diff() +def ThreesomeNext(): + threesome.modes.current_mode.key_next() + +def ThreesomePrev(): + threesome.modes.current_mode.key_prev() + diff -r bb3247356f22 -r 0d5394864481 plugin/threesome.vim --- a/plugin/threesome.vim Mon Jun 13 00:25:16 2011 -0400 +++ b/plugin/threesome.vim Mon Jun 13 00:47:04 2011 -0400 @@ -78,6 +78,9 @@ function! s:ThreesomeCompare()"{{{ python ThreesomeCompare() endfunction"}}} +function! s:ThreesomePath()"{{{ + python ThreesomePath() +endfunction"}}} function! s:ThreesomeOriginal()"{{{ python ThreesomeOriginal() @@ -95,6 +98,12 @@ function! s:ThreesomeDiff()"{{{ python ThreesomeDiff() endfunction"}}} +function! s:ThreesomeNext()"{{{ + python ThreesomeNext() +endfunction"}}} +function! s:ThreesomePrev()"{{{ + python ThreesomePrev() +endfunction"}}} "}}} @@ -105,6 +114,7 @@ command! -nargs=0 ThreesomeGrid call s:ThreesomeGrid() command! -nargs=0 ThreesomeLoupe call s:ThreesomeLoupe() command! -nargs=0 ThreesomeCompare call s:ThreesomeCompare() +command! -nargs=0 ThreesomePath call s:ThreesomePath() command! -nargs=0 ThreesomeOriginal call s:ThreesomeOriginal() command! -nargs=0 ThreesomeOne call s:ThreesomeOne() @@ -112,6 +122,8 @@ command! -nargs=0 ThreesomeResult call s:ThreesomeResult() command! -nargs=0 ThreesomeDiff call s:ThreesomeDiff() +command! -nargs=0 ThreesomeNext call s:ThreesomeNext() +command! -nargs=0 ThreesomePrev call s:ThreesomePrev() "}}} diff -r bb3247356f22 -r 0d5394864481 plugin/threesomelib/init.py --- a/plugin/threesomelib/init.py Mon Jun 13 00:25:16 2011 -0400 +++ b/plugin/threesomelib/init.py Mon Jun 13 00:47:04 2011 -0400 @@ -32,6 +32,7 @@ keys.bind('g', ':ThreesomeGrid') keys.bind('l', ':ThreesomeLoupe') keys.bind('c', ':ThreesomeCompare') + keys.bind('p', ':ThreesomePath') keys.bind('o', ':ThreesomeOriginal') keys.bind('1', ':ThreesomeOne') @@ -39,6 +40,8 @@ keys.bind('r', ':ThreesomeResult') keys.bind('d', ':ThreesomeDiff') + keys.bind('n', ':ThreesomeNext') + keys.bind('N', ':ThreesomePrev') def init(): process_result() diff -r bb3247356f22 -r 0d5394864481 plugin/threesomelib/modes.py --- a/plugin/threesomelib/modes.py Mon Jun 13 00:25:16 2011 -0400 +++ b/plugin/threesomelib/modes.py Mon Jun 13 00:47:04 2011 -0400 @@ -37,6 +37,15 @@ self._diff_0() + def key_next(self): + self.goto_result() + vim.command(r'exe "normal! /\=\=\=\=\=\=\=\"') + + def key_prev(self): + self.goto_result() + vim.command(r'exe "normal! ?\=\=\=\=\=\=\=\"') + + class GridMode(Mode): """ Layout 1 Layout 2 @@ -109,6 +118,10 @@ def key_result(self): windows.focus(4) + + def goto_result(self): + windows.focus(4) + class LoupeMode(Mode): def __init__(self): self._number_of_diff_modes = 1 @@ -150,6 +163,10 @@ windows.focus(1) buffers.result.open() + + def goto_result(self): + self.key_result() + class CompareMode(Mode): def __init__(self): self._number_of_diff_modes = 2 @@ -224,8 +241,8 @@ open_one(1) return - # Otherwise, open file one in window 1. - open_one(1) + # Otherwise, open file one in the current window. + open_one(curwindow) def key_two(self): def open_two(winnr): @@ -260,7 +277,7 @@ return # Otherwise, open file two in window 2. - open_two(2) + open_two(curwindow) def key_result(self): windows.focus(2) @@ -268,9 +285,97 @@ self.diff(self._current_diff_mode) + def goto_result(self): + self.key_result() + +class PathMode(Mode): + def __init__(self): + self._number_of_diff_modes = 4 + return super(PathMode, self).__init__() + + + def _init_layout(self): + # Open the layout + windows.close_all() + windows.vsplit() + windows.vsplit() + + # Put the buffers in the appropriate windows + windows.focus(1) + buffers.original.open() + + windows.focus(2) + buffers.one.open() + + windows.focus(3) + buffers.result.open() + + + def _diff_0(self): + vim.command('diffoff!') + self._current_diff_mode = 0 + + def _diff_1(self): + vim.command('diffoff!') + self._current_diff_mode = 1 + + windows.focus(1) + vim.command('diffthis') + + windows.focus(3) + vim.command('diffthis') + + def _diff_2(self): + vim.command('diffoff!') + self._current_diff_mode = 2 + + windows.focus(1) + vim.command('diffthis') + + windows.focus(2) + vim.command('diffthis') + + def _diff_3(self): + vim.command('diffoff!') + self._current_diff_mode = 3 + + windows.focus(2) + vim.command('diffthis') + + windows.focus(3) + vim.command('diffthis') + + + def activate(self): + self._init_layout() + super(PathMode, self).activate() + + + def key_original(self): + windows.focus(1) + + def key_one(self): + windows.focus(2) + buffers.one.open() + self.diff(self._current_diff_mode) + + def key_two(self): + windows.focus(2) + buffers.two.open() + self.diff(self._current_diff_mode) + + def key_result(self): + windows.focus(3) + + + def goto_result(self): + windows.focus(3) + + grid = GridMode() loupe = LoupeMode() compare = CompareMode() +path = PathMode() def key_grid(): @@ -286,3 +391,7 @@ global current_mode current_mode = compare compare.activate() +def key_path(): + global current_mode + current_mode = path + path.activate()