# HG changeset patch # User laurent # Date 1326046782 -3600 # Node ID 1a80e0598045355a4c8ec70bac0600acbd60c276 # Parent 8a60ffcfd70bdb2aeccc49a7012062d4d7748fdc Fixing bug in highlighting in variable panel diff -r 8a60ffcfd70b -r 1a80e0598045 PLCGenerator.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", ())] diff -r 8a60ffcfd70b -r 1a80e0598045 TextViewer.py --- 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)) diff -r 8a60ffcfd70b -r 1a80e0598045 Viewer.py --- 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) diff -r 8a60ffcfd70b -r 1a80e0598045 controls/EditorPanel.py --- 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) diff -r 8a60ffcfd70b -r 1a80e0598045 plcopen/plcopen.py --- 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"]))