Fixing bug in highlighting in variable panel
authorlaurent
Sun, 08 Jan 2012 19:19:42 +0100
changeset 617 1a80e0598045
parent 616 8a60ffcfd70b
child 618 6e48943e821e
Fixing bug in highlighting in variable panel
PLCGenerator.py
TextViewer.py
Viewer.py
controls/EditorPanel.py
plcopen/plcopen.py
--- a/PLCGenerator.py	Sun Jan 08 19:16:58 2012 +0100
+++ b/PLCGenerator.py	Sun Jan 08 19:19:42 2012 +0100
@@ -202,7 +202,7 @@
                                     (elementtype_name, (tagname, "struct", i, "type"))]
                     if element.initialValue is not None:
                         element_text.extend([(" := ", ()),
-                                             (self.ComputeValue(element.initialValue.getvalue(), elementtype_name), (tagname, "struct", i, "initial"))])
+                                             (self.ComputeValue(element.initialValue.getvalue(), elementtype_name), (tagname, "struct", i, "initial value"))])
                     element_text.append((";", ()))
                     elements.append(element_text)
                 datatype_def += [("STRUCT", ())]
@@ -214,7 +214,7 @@
             # Data type has an initial value
             if datatype.initialValue is not None:
                 datatype_def += [(" := ", ()),
-                                 (self.ComputeValue(datatype.initialValue.getvalue(), datatype_name), (tagname, "initial"))]
+                                 (self.ComputeValue(datatype.initialValue.getvalue(), datatype_name), (tagname, "initial value"))]
             datatype_def += [(";\n", ())]
             self.Program += datatype_def
 
@@ -279,7 +279,7 @@
                 address = var.getaddress()
                 if address:
                     config += [("AT ", ()),
-                               (address, (tagname, variable_type, var_number, "address")),
+                               (address, (tagname, variable_type, var_number, "location")),
                                (" ", ())]
                 config += [(": ", ()),
                            (var.gettypeAsText(), (tagname, variable_type, var_number, "type"))]
@@ -287,7 +287,7 @@
                 initial = var.getinitialValue()
                 if initial:
                     config += [(" := ", ()),
-                               (self.ComputeValue(initial.getvalue(), var_type), (tagname, variable_type, var_number, "initial"))]
+                               (self.ComputeValue(initial.getvalue(), var_type), (tagname, variable_type, var_number, "initial value"))]
                 config += [(";\n", ())]
                 var_number += 1
             config += [("  END_VAR\n", ())]
@@ -332,7 +332,7 @@
                 # Generate variable address if exists
                 if address:
                     resrce += [("AT ", ()),
-                               (address, (tagname, variable_type, var_number, "address")),
+                               (address, (tagname, variable_type, var_number, "location")),
                                (" ", ())]
                 resrce += [(": ", ()),
                            (var.gettypeAsText(), (tagname, variable_type, var_number, "type"))]
@@ -340,7 +340,7 @@
                 initial = var.getinitialValue()
                 if initial:
                     resrce += [(" := ", ()),
-                               (self.ComputeValue(initial.getvalue(), var_type), (tagname, variable_type, var_number, "initial"))]
+                               (self.ComputeValue(initial.getvalue(), var_type), (tagname, variable_type, var_number, "initial value"))]
                 resrce += [(";\n", ())]
                 var_number += 1
             resrce += [("    END_VAR\n", ())]
@@ -1309,13 +1309,13 @@
                                 (" ", ())]
                 if var_address != None:
                     program += [("AT ", ()),
-                                (var_address, (self.TagName, variable_type, var_number, "address")),
+                                (var_address, (self.TagName, variable_type, var_number, "location")),
                                 (" ", ())]
                 program += [(": ", ()),
                             (var_type, (self.TagName, variable_type, var_number, "type"))]
                 if var_initial != None:
                     program += [(" := ", ()),
-                                (self.ParentGenerator.ComputeValue(var_initial, var_type), (self.TagName, variable_type, var_number, "initial"))]
+                                (self.ParentGenerator.ComputeValue(var_initial, var_type), (self.TagName, variable_type, var_number, "initial value"))]
                 program += [(";\n", ())]
                 var_number += 1
             program += [("  END_VAR\n", ())]
--- a/TextViewer.py	Sun Jan 08 19:16:58 2012 +0100
+++ b/TextViewer.py	Sun Jan 08 19:19:42 2012 +0100
@@ -793,6 +793,8 @@
         event.Skip()
 
     def ClearHighlights(self, highlight_type=None):
+        EditorPanel.ClearHighlights(self, highlight_type)
+        
         if highlight_type is None:
             self.Highlights = []
         else:
@@ -802,6 +804,8 @@
         self.RefreshView()
 
     def AddHighlight(self, infos, start, end, highlight_type):
+        EditorPanel.AddHighlight(self, infos, start, end, highlight_type)
+        
         highlight_type = HIGHLIGHT_TYPES.get(highlight_type, None)
         if infos[0] == "body" and highlight_type is not None:
             self.Highlights.append((infos[1], start, end, highlight_type))
--- a/Viewer.py	Sun Jan 08 19:16:58 2012 +0100
+++ b/Viewer.py	Sun Jan 08 19:19:42 2012 +0100
@@ -2874,6 +2874,8 @@
         event.Skip()
 
     def ClearHighlights(self, highlight_type=None):
+        EditorPanel.ClearHighlights(self, highlight_type)
+        
         if highlight_type is None:
             self.Highlights = []
         else:
@@ -2881,6 +2883,8 @@
         self.RefreshView()
 
     def AddHighlight(self, infos, start, end, highlight_type):
+        EditorPanel.AddHighlight(self, infos, start, end, highlight_type)
+        
         self.Highlights.append((infos, start, end, highlight_type))
         self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True)
         
--- a/controls/EditorPanel.py	Sun Jan 08 19:16:58 2012 +0100
+++ b/controls/EditorPanel.py	Sun Jan 08 19:19:42 2012 +0100
@@ -134,6 +134,10 @@
     def RefreshScaling(self, refresh=True):
         pass
 
+    def AddHighlight(self, infos, start, end, highlight_type):
+        if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]:
+            self.VariableEditor.AddVariableHighlight(infos[1:], highlight_type)
+
     def ClearHighlights(self, highlight_type=None):
         if self.VariableEditor is not None:
             self.VariableEditor.ClearHighlights(highlight_type)
--- a/plcopen/plcopen.py	Sun Jan 08 19:16:58 2012 +0100
+++ b/plcopen/plcopen.py	Sun Jan 08 19:19:42 2012 +0100
@@ -999,11 +999,11 @@
     def Search(self, criteria, parent_infos=[]):
         search_result = _Search([("name", self.getname()), 
                                  ("type", self.gettypeAsText()),
-                                 ("address", self.getaddress())],
+                                 ("location", self.getaddress())],
                                 criteria, parent_infos)
         initial = self.getinitialValue()
         if initial is not None:
-            search_result.extend(_Search([("initial", initial.getvalue())], criteria, parent_infos))
+            search_result.extend(_Search([("initial value", initial.getvalue())], criteria, parent_infos))
         doc = self.getdocumentation()
         if doc is not None:
             search_result.extend(doc.Search(criteria, parent_infos + ["documentation"]))