11bf5263576c

GO AWAY, DIFFS.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 13 Jun 2011 09:39:02 -0400
parents 4bfdd4a89d4c
children 158ad3aea810
branches/tags (none)
files plugin/threesomelib/modes.py plugin/threesomelib/util/bufferlib.py

Changes

--- a/plugin/threesomelib/modes.py	Mon Jun 13 01:09:41 2011 -0400
+++ b/plugin/threesomelib/modes.py	Mon Jun 13 09:39:02 2011 -0400
@@ -15,6 +15,21 @@
         getattr(self, '_diff_%d' % diffmode)()
         windows.focus(curwindow)
 
+    def diffoff(self):
+        curwindow = windows.currentnr()
+
+        for winnr in range(1, 1 + self._number_of_windows):
+            windows.focus(winnr)
+            curbuffer = buffers.current
+
+            for buffer in buffers.all:
+                buffer.open()
+                vim.command('diffoff')
+
+            curbuffer.open()
+
+        windows.focus(curwindow)
+
     def key_diff(self, diffmode=None):
         next_diff_mode = self._current_diff_mode + 1
         if next_diff_mode >= self._number_of_diff_modes:
@@ -68,6 +83,7 @@
 
     def __init__(self):
         self._number_of_diff_modes = 2
+        self._number_of_windows = 4
         return super(GridMode, self).__init__()
 
 
@@ -94,11 +110,11 @@
 
 
     def _diff_0(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 0
 
     def _diff_1(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 1
 
         for i in range(1, 5):
@@ -130,6 +146,7 @@
 class LoupeMode(Mode):
     def __init__(self):
         self._number_of_diff_modes = 1
+        self._number_of_windows = 1
         return super(LoupeMode, self).__init__()
 
 
@@ -143,7 +160,7 @@
 
 
     def _diff_0(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 0
 
 
@@ -175,6 +192,7 @@
 class CompareMode(Mode):
     def __init__(self):
         self._number_of_diff_modes = 2
+        self._number_of_windows = 2
         return super(CompareMode, self).__init__()
 
 
@@ -192,11 +210,11 @@
 
 
     def _diff_0(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 0
 
     def _diff_1(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 1
 
         for i in range(1, 3):
@@ -294,6 +312,7 @@
 class PathMode(Mode):
     def __init__(self):
         self._number_of_diff_modes = 4
+        self._number_of_windows = 3
         return super(PathMode, self).__init__()
 
 
@@ -315,11 +334,11 @@
 
 
     def _diff_0(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 0
 
     def _diff_1(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 1
 
         windows.focus(1)
@@ -329,7 +348,7 @@
         vim.command('diffthis')
 
     def _diff_2(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 2
 
         windows.focus(1)
@@ -339,7 +358,7 @@
         vim.command('diffthis')
 
     def _diff_3(self):
-        vim.command('diffoff!')
+        self.diffoff()
         self._current_diff_mode = 3
 
         windows.focus(2)
--- a/plugin/threesomelib/util/bufferlib.py	Mon Jun 13 01:09:41 2011 -0400
+++ b/plugin/threesomelib/util/bufferlib.py	Mon Jun 13 09:39:02 2011 -0400
@@ -55,5 +55,8 @@
         elif bufname == ap(self.result.name):
             return self.result
 
+    @property
+    def all(self):
+        return [self.original, self.one, self.two, self.result]
 
 buffers = _BufferList()