[GRASS-SVN] r58987 - grass/branches/releasebranch_6_4/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 10 17:52:32 PST 2014


Author: annakrat
Date: 2014-02-10 17:52:31 -0800 (Mon, 10 Feb 2014)
New Revision: 58987

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_core/prompt.py
Log:
wxGUI/prompt: fix character events for keyboard layouts different from US (merge from trunk, r58984)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_core/prompt.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_core/prompt.py	2014-02-11 01:22:49 UTC (rev 58986)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_core/prompt.py	2014-02-11 01:52:31 UTC (rev 58987)
@@ -752,6 +752,7 @@
         # bindings
         #
         self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
+        self.Bind(wx.EVT_CHAR, self.OnChar)
         self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)
         self.Bind(wx.stc.EVT_STC_AUTOCOMP_SELECTION, self.OnItemSelected)
         self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemChanged)
@@ -934,16 +935,73 @@
         if len(self.autoCompList) > 0:
             self.autoCompList.sort()
             self.AutoCompShow(lenEntered = 0, itemList = ' '.join(self.autoCompList))    
-        
+
     def OnKeyPressed(self, event):
-        """!Key press capture for autocompletion, calltips, and command history
+        """!Key pressed capture special treatment for tabulator to show help"""
+        pos = self.GetCurrentPos()
+        if event.GetKeyCode() == wx.WXK_TAB:
+            # show GRASS command calltips (to hide press 'ESC')
+            entry = self.GetTextLeft()
+            try:
+                cmd = entry.split()[0].strip()
+            except IndexError:
+                cmd = ''
 
+            if cmd not in globalvar.grassCmd:
+                return
+
+            info = gtask.command_info(GetRealCmd(cmd))
+
+            self.CallTipSetBackground("#f4f4d1")
+            self.CallTipSetForeground("BLACK")
+            self.CallTipShow(pos, info['usage'] + '\n\n' + info['description'])
+        elif event.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER) and \
+                not self.AutoCompActive():
+            # run command on line when <return> is pressed
+            self._runCmd(self.GetCurLine()[0].strip())
+        elif event.GetKeyCode() in [wx.WXK_UP, wx.WXK_DOWN] and \
+                not self.AutoCompActive():
+            # Command history using up and down
+            if len(self.cmdbuffer) < 1:
+                return
+
+            self.DocumentEnd()
+
+            # move through command history list index values
+            if event.GetKeyCode() == wx.WXK_UP:
+                self.cmdindex = self.cmdindex - 1
+            if event.GetKeyCode() == wx.WXK_DOWN:
+                self.cmdindex = self.cmdindex + 1
+            if self.cmdindex < 0:
+                self.cmdindex = 0
+            if self.cmdindex > len(self.cmdbuffer) - 1:
+                self.cmdindex = len(self.cmdbuffer) - 1
+
+            try:
+                txt = self.cmdbuffer[self.cmdindex]
+            except KeyError:
+                txt = ''
+
+            # clear current line and insert command history
+            self.DelLineLeft()
+            self.DelLineRight()
+            pos = self.GetCurrentPos()
+            self.InsertText(pos, txt)
+            self.LineEnd()
+
+            self.ShowStatusText('')
+        else:
+            event.Skip()
+
+    def OnChar(self, event):
+        """!Key char capture for autocompletion, calltips, and command history
+
         @todo event.ControlDown() for manual autocomplete
         """
         # keycodes used: "." = 46, "=" = 61, "-" = 45 
         pos = self.GetCurrentPos()
         # complete command after pressing '.'
-        if event.GetKeyCode() == 46 and not event.ShiftDown():
+        if event.GetKeyCode() == 46:
             self.autoCompList = list()
             entry = self.GetTextLeft()
             self.InsertText(pos, '.')
@@ -963,8 +1021,10 @@
                 return
             self.ShowList()
 
-        # complete flags after pressing '-'       
-        elif event.GetKeyCode() == 45 and not event.ShiftDown(): 
+        # complete flags after pressing '-'
+        elif (event.GetKeyCode() == 45) \
+                or event.GetKeyCode() == wx.WXK_NUMPAD_SUBTRACT \
+                or event.GetKeyCode() == wx.WXK_SUBTRACT:
             self.autoCompList = list()
             entry = self.GetTextLeft()
             self.InsertText(pos, '-')
@@ -982,7 +1042,7 @@
             self.ShowList()
             
         # complete map or values after parameter
-        elif event.GetKeyCode() == 61 and not event.ShiftDown():
+        elif event.GetKeyCode() == 61:
             self.autoCompList = list()
             self.InsertText(pos, '=')
             self.CharRight()
@@ -997,7 +1057,7 @@
             self.ShowList()
         
         # complete mapset ('@')
-        elif event.GetKeyCode() == 50 and event.ShiftDown():
+        elif event.GetKeyCode() == 64:
             self.autoCompList = list()
             self.InsertText(pos, '@')
             self.CharRight()
@@ -1070,60 +1130,6 @@
                 
             self.ShowList()
 
-        elif event.GetKeyCode() == wx.WXK_TAB:
-            # show GRASS command calltips (to hide press 'ESC')
-            entry = self.GetTextLeft()
-            try:
-                cmd = entry.split()[0].strip()
-            except IndexError:
-                cmd = ''
-            
-            if cmd not in globalvar.grassCmd:
-                return
-            
-            info = gtask.command_info(GetRealCmd(cmd))
-            
-            self.CallTipSetBackground("#f4f4d1")
-            self.CallTipSetForeground("BLACK")
-            self.CallTipShow(pos, info['usage'] + '\n\n' + info['description'])
-            
-            
-        elif event.GetKeyCode() in [wx.WXK_UP, wx.WXK_DOWN] and \
-                 not self.AutoCompActive():
-            # Command history using up and down   
-            if len(self.cmdbuffer) < 1:
-                return
-            
-            self.DocumentEnd()
-            
-            # move through command history list index values
-            if event.GetKeyCode() == wx.WXK_UP:
-                self.cmdindex = self.cmdindex - 1
-            if event.GetKeyCode() == wx.WXK_DOWN:
-                self.cmdindex = self.cmdindex + 1
-            if self.cmdindex < 0:
-                self.cmdindex = 0
-            if self.cmdindex > len(self.cmdbuffer) - 1:
-                self.cmdindex = len(self.cmdbuffer) - 1
-            
-            try:
-                txt = self.cmdbuffer[self.cmdindex]
-            except:
-                txt = ''
-            
-            # clear current line and insert command history    
-            self.DelLineLeft()
-            self.DelLineRight()
-            pos = self.GetCurrentPos()            
-            self.InsertText(pos,txt)
-            self.LineEnd()
-            self.parent.parent.statusbar.SetStatusText('')
-            
-        elif event.GetKeyCode() in [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER] and \
-                self.AutoCompActive() == False:
-            # run command on line when <return> is pressed
-            self._runCmd(self.GetCurLine()[0].strip())
-                        
         elif event.GetKeyCode() == wx.WXK_SPACE:
             items = self.GetTextLeft().split()
             if len(items) == 1:



More information about the grass-commit mailing list