61c6ca7b2d8a

Fix the binding of \u in grid/other modes.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 30 Jun 2011 18:53:30 -0400
parents 8cfa90490884
children f0cdadaa3be0
branches/tags (none)
files autoload/threesomelib/modes.py autoload/threesomelib/util/bufferlib.py autoload/threesomelib/util/keys.py

Changes

--- a/autoload/threesomelib/modes.py	Thu Jun 30 18:36:50 2011 -0400
+++ b/autoload/threesomelib/modes.py	Thu Jun 30 18:53:30 2011 -0400
@@ -387,6 +387,7 @@
 
 
     def activate(self):
+        keys.unbind('u')
         keys.bind('u1', ':ThreesomeUse1<cr>')
         keys.bind('u2', ':ThreesomeUse2<cr>')
         return super(GridMode, self).activate()
@@ -394,6 +395,7 @@
     def deactivate(self):
         keys.unbind('u1')
         keys.unbind('u2')
+        keys.bind('u', ':ThreesomeUse<cr>')
         return super(GridMode, self).deactivate()
 
 
@@ -885,20 +887,24 @@
 
 def key_grid():
     global current_mode
+    current_mode.deactivate()
     current_mode = grid
     grid.activate()
 
 def key_loupe():
     global current_mode
+    current_mode.deactivate()
     current_mode = loupe
     loupe.activate()
 
 def key_compare():
     global current_mode
+    current_mode.deactivate()
     current_mode = compare
     compare.activate()
 
 def key_path():
     global current_mode
+    current_mode.deactivate()
     current_mode = path
     path.activate()
--- a/autoload/threesomelib/util/bufferlib.py	Thu Jun 30 18:36:50 2011 -0400
+++ b/autoload/threesomelib/util/bufferlib.py	Thu Jun 30 18:53:30 2011 -0400
@@ -78,5 +78,14 @@
                  buffers.two.name: 'Two',
                  buffers.result.name: 'Result' }
 
+    class remain:
+        def __enter__(self):
+            self.curbuf = vim.eval('bufnr(bufname("%"))')
+            self.pos = windows.pos()
+
+        def __exit__(self, type, value, traceback):
+            vim.command('%dbuffer' % self.curbuf)
+            vim.current.window.cursor = self.pos
+
 buffers = _BufferList()
 
--- a/autoload/threesomelib/util/keys.py	Thu Jun 30 18:36:50 2011 -0400
+++ b/autoload/threesomelib/util/keys.py	Thu Jun 30 18:53:30 2011 -0400
@@ -1,4 +1,5 @@
 import vim
+from bufferlib import buffers
 
 
 def bind(key, to, options='', mode=None, leader='<localleader>'):
@@ -7,3 +8,14 @@
 def unbind(key, options='', leader='<localleader>'):
     vim.command('unmap %s %s%s' % (options, leader, key))
 
+def bind_for_all(key, to, options='', mode=None, leader='<localleader>'):
+    with buffers.remain():
+        for b in buffers.all:
+            b.open()
+            bind(key, to, options, mode, leader)
+
+def unbind_for_all(key, options='', leader='<localleader>'):
+    with buffers.remain():
+        for b in buffers.all:
+            b.open()
+            unbind(key, options, leader)