gedit-plugins r351 - in trunk: . plugins/bracketcompletion



Author: pborelli
Date: Sat Mar 22 13:04:47 2008
New Revision: 351
URL: http://svn.gnome.org/viewvc/gedit-plugins?rev=351&view=rev

Log:
2008-03-22  Paolo Borelli  <pborelli katamail com>

	* plugins/bracketcompletion/bracketcompletion.py: only watch the
	necessary keyvalues. Bug #518985.


Modified:
   trunk/ChangeLog
   trunk/plugins/bracketcompletion/bracketcompletion.py

Modified: trunk/plugins/bracketcompletion/bracketcompletion.py
==============================================================================
--- trunk/plugins/bracketcompletion/bracketcompletion.py	(original)
+++ trunk/plugins/bracketcompletion/bracketcompletion.py	Sat Mar 22 13:04:47 2008
@@ -39,6 +39,7 @@
     'xml': { '<' : '>' },
 }
 
+
 class BracketCompletionViewHelper(object):
     def __init__(self, view):
         self._view = view
@@ -92,6 +93,13 @@
         else:
             self._brackets = common_brackets
 
+        # get the corresponding keyvals
+        self._bracket_keyvals = set()
+        for b in self._brackets:
+            kv = gtk.gdk.unicode_to_keyval(ord(b[-1]))
+            if (kv):
+                self._bracket_keyvals.add(kv)
+
     def get_current_token(self):
         end = self._doc.get_iter_at_mark(self._doc.get_insert())
         start = end.copy()
@@ -183,7 +191,7 @@
     def on_event_after(self, view, event):
         if event.type != gdk.KEY_PRESS or \
            event.state & (gdk.CONTROL_MASK | gdk.MOD1_MASK) or \
-           event.keyval < 32 or event.keyval > 126:
+           event.keyval not in self._bracket_keyvals:
             return
 
         word, start, end = self.get_current_token()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]