Forráskód Böngészése

Raster calculator: Do not add extra spaces;
Better insertion position handling.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72551 15284696-431f-4ddb-bdfa-cd5b030d7da7

Maris Nartiss 7 éve
szülő
commit
3a9cab6ee1
1 módosított fájl, 18 hozzáadás és 2 törlés
  1. 18 2
      gui/wxpython/modules/mcalc_builder.py

+ 18 - 2
gui/wxpython/modules/mcalc_builder.py

@@ -568,6 +568,8 @@ class MapCalcFrame(wx.Frame):
         self._addSomething(item)
 
         win.ChangeValue('')  # reset
+        # Map selector likes to keep focus. Set it back to expression input area
+        wx.CallAfter(self.text_mcalc.SetFocus)
 
     def OnUpdateStatusBar(self, event):
         """Update statusbar text"""
@@ -619,8 +621,17 @@ class MapCalcFrame(wx.Frame):
         except:
             pass
 
-        newmcalcstr += what + ' ' + mcalcstr[position:]
-
+        newmcalcstr += what
+        
+        # Do not add extra space if there is already one
+        try:
+            if newmcalcstr[-1] != ' ' and mcalcstr[position] != ' ':
+                newmcalcstr += ' '
+        except:
+            newmcalcstr += ' '
+        
+        newmcalcstr += mcalcstr[position:]
+        
         self.text_mcalc.SetValue(newmcalcstr)
         if len(what) > 0:
             match = re.search(pattern="\(.*\)", string=what)
@@ -628,6 +639,11 @@ class MapCalcFrame(wx.Frame):
                 position_offset += match.start() + 1
             else:
                 position_offset += len(what)
+                try:
+                    if newmcalcstr[position + position_offset] == ' ':
+                        position_offset += 1
+                except:
+                    pass
 
         self.text_mcalc.SetInsertionPoint(position + position_offset)
         self.text_mcalc.Update()