[GRASS-SVN] r55871 - grass/branches/releasebranch_6_4/gui/wxpython/modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 17 23:47:36 PDT 2013


Author: annakrat
Date: 2013-04-17 23:47:35 -0700 (Wed, 17 Apr 2013)
New Revision: 55871

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/modules/mcalc_builder.py
Log:
wxGUI/mapcalc: fix cursor position when adding function (merge from trunk, r55870)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/modules/mcalc_builder.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/modules/mcalc_builder.py	2013-04-18 06:42:18 UTC (rev 55870)
+++ grass/branches/releasebranch_6_4/gui/wxpython/modules/mcalc_builder.py	2013-04-18 06:47:35 UTC (rev 55871)
@@ -18,6 +18,7 @@
 
 import os
 import sys
+import re
 
 if __name__ == "__main__":
     sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'wxpython'))
@@ -444,11 +445,15 @@
             pass
         
         newmcalcstr += what + ' ' + mcalcstr[position:]
-        position_offset += len(what)
         
         self.text_mcalc.SetValue(newmcalcstr)
-        if len(what) > 1 and what[-2:] == '()':
-            position_offset -= 1
+        if len(what) > 1:
+            match = re.search(pattern="\(.*\)", string=what)
+            if match:
+                position_offset += match.start() + 1
+            else:
+                position_offset += len(what)
+
         self.text_mcalc.SetInsertionPoint(position + position_offset)
         self.text_mcalc.Update()
         



More information about the grass-commit mailing list