WIP adding searching capabilities in python files. was done : search_in_CTN
authorEdouard Tisserant
Fri, 22 Mar 2019 10:57:04 +0100
branchsearch_in_CTN
changeset 2528 6bfc8a9bf0e7
parent 2527 f47e397e9b61
child 2529 efb532295607
WIP adding searching capabilities in python files. was done :
- added search in body of Code File Tree Nodes (moved editor code so that we CTN search can have the same sections text layout as editor to search in)
CodeFileTreeNode.py
editors/CodeFileEditor.py
--- a/CodeFileTreeNode.py	Thu Mar 21 14:00:26 2019 +0100
+++ b/CodeFileTreeNode.py	Fri Mar 22 10:57:04 2019 +0100
@@ -37,6 +37,7 @@
 from ConfigTreeNode import XSDSchemaErrorMessage
 
 from plcopen.plcopen import TestTextElement
+from editors.CodeFileEditor import GetSectionsText
 
 CODEFILE_XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -221,9 +222,10 @@
             varname = var["Name"]
             results.extend([((tagname, "var_inout", index, "name"),) + result
                             for result in TestTextElement(varname, criteria)])
-        print("FFFFFFFFFF", results)
-        return results + [((self.CTNFullName(),"var_inout",1,"name"), (0,2),(0,4),"a_cow"),
-                ((self.CTNFullName(),"body"), (1,12),(1,15),"Bitch I'm a cow !")]
+        results.extend([((tagname, "body"),) + result
+                        for result in TestTextElement(
+                            GetSectionsText(self, lambda x:""), criteria)])
+        return results
 
 # -------------------------------------------------------------------------------
 #                      Current Buffering Management Functions
--- a/editors/CodeFileEditor.py	Thu Mar 21 14:00:26 2019 +0100
+++ b/editors/CodeFileEditor.py	Fri Mar 22 10:57:04 2019 +0100
@@ -56,6 +56,21 @@
 EDGE_COLUMN = 80
 
 
+def GetSectionsText(controler, sections_headers):
+    parts = controler.GetTextParts()
+    text = ""
+    for section in controler.SECTIONS_NAMES:
+        text += sections_headers(section)
+        if parts[section] == "":
+            text += "\n"
+        else:
+            if not parts[section].startswith("\n"):
+                text += "\n"
+            text += parts[section]
+            if not parts[section].endswith("\n"):
+                text += "\n"
+    return text
+
 class CodeEditor(CustomStyledTextCtrl):
 
     KEYWORDS = []
@@ -239,20 +254,9 @@
             self.CurrentAction = None
 
     def GetCodeText(self):
-        parts = self.Controler.GetTextParts()
-        text = ""
-        for section in self.Controler.SECTIONS_NAMES:
-            section_comments = self.SectionsComments[section]
-            text += section_comments["comment"]
-            if parts[section] == "":
-                text += "\n"
-            else:
-                if not parts[section].startswith("\n"):
-                    text += "\n"
-                text += parts[section]
-                if not parts[section].endswith("\n"):
-                    text += "\n"
-        return text
+        return GetSectionsText(
+            self.Controler, 
+            lambda section : self.SectionsComments[section]["comment"])
 
     def RefreshView(self, scroll_to_highlight=False):
         self.ResetBuffer()