TextViewer.py
changeset 125 394d9f168258
parent 122 e6faee0c271b
child 136 858ff1a52d20
equal deleted inserted replaced
124:635d0817508c 125:394d9f168258
   158         
   158         
   159         self.Keywords = []
   159         self.Keywords = []
   160         self.Variables = []
   160         self.Variables = []
   161         self.Functions = []
   161         self.Functions = []
   162         self.Jumps = []
   162         self.Jumps = []
       
   163         self.EnumeratedValues = []
   163         self.TextChanged = False
   164         self.TextChanged = False
   164         self.DisableEvents = True
   165         self.DisableEvents = True
   165         self.TextSyntax = "ST"
   166         self.TextSyntax = "ST"
   166         self.CurrentAction = None
   167         self.CurrentAction = None
   167         self.TagName = tagname
   168         self.TagName = tagname
   284         self.Functions = []
   285         self.Functions = []
   285         for category in self.Controler.GetBlockTypes(self.TagName):
   286         for category in self.Controler.GetBlockTypes(self.TagName):
   286             for blocktype in category["list"]:
   287             for blocktype in category["list"]:
   287                 if blocktype["type"] == "function" and blocktype["name"] not in self.Keywords and blocktype["name"] not in self.Variables:
   288                 if blocktype["type"] == "function" and blocktype["name"] not in self.Keywords and blocktype["name"] not in self.Variables:
   288                     self.Functions.append(blocktype["name"].upper())
   289                     self.Functions.append(blocktype["name"].upper())
       
   290         
       
   291         self.EnumeratedValues = []
       
   292         for value in self.Controler.GetEnumeratedDataValues():
       
   293             self.EnumeratedValues.append(value.upper())
   289         
   294         
   290         self.Colourise(0, -1)
   295         self.Colourise(0, -1)
   291     
   296     
   292     def OnStyleNeeded(self, event):
   297     def OnStyleNeeded(self, event):
   293         self.TextChanged = True
   298         self.TextChanged = True
   318                         self.SetStyling(i - start_pos, STC_PLC_VARIABLE)
   323                         self.SetStyling(i - start_pos, STC_PLC_VARIABLE)
   319                     elif word in self.Functions:
   324                     elif word in self.Functions:
   320                         self.SetStyling(i - start_pos, STC_PLC_FUNCTION)
   325                         self.SetStyling(i - start_pos, STC_PLC_FUNCTION)
   321                     elif word in self.Jumps:
   326                     elif word in self.Jumps:
   322                         self.SetStyling(i - start_pos, STC_PLC_JUMP)
   327                         self.SetStyling(i - start_pos, STC_PLC_JUMP)
       
   328                     elif word in self.EnumeratedValues:
       
   329                         self.SetStyling(i - start_pos, STC_PLC_NUMBER)
   323                     else:
   330                     else:
   324                         self.SetStyling(i - start_pos, 31)
   331                         self.SetStyling(i - start_pos, 31)
   325                         if self.GetCurrentPos() < start_pos or self.GetCurrentPos() > i:
   332                         if self.GetCurrentPos() < start_pos or self.GetCurrentPos() > i:
   326                             self.StartStyling(start_pos, wx.stc.STC_INDICS_MASK)
   333                             self.StartStyling(start_pos, wx.stc.STC_INDICS_MASK)
   327                             self.SetStyling(i - start_pos, wx.stc.STC_INDIC0_MASK)
   334                             self.SetStyling(i - start_pos, wx.stc.STC_INDIC0_MASK)
   366                         self.SetStyling(i - start_pos, STC_PLC_VARIABLE)
   373                         self.SetStyling(i - start_pos, STC_PLC_VARIABLE)
   367                     elif word in self.Functions:
   374                     elif word in self.Functions:
   368                         self.SetStyling(i - start_pos, STC_PLC_FUNCTION)
   375                         self.SetStyling(i - start_pos, STC_PLC_FUNCTION)
   369                     elif word in self.Jumps:
   376                     elif word in self.Jumps:
   370                         self.SetStyling(i - start_pos, STC_PLC_JUMP)
   377                         self.SetStyling(i - start_pos, STC_PLC_JUMP)
       
   378                     elif word in self.EnumeratedValues:
       
   379                         self.SetStyling(i - start_pos, STC_PLC_NUMBER)
   371                     else:
   380                     else:
   372                         self.SetStyling(i - start_pos, 31)
   381                         self.SetStyling(i - start_pos, 31)
   373                         if self.GetCurrentPos() < start_pos or self.GetCurrentPos() > i:
   382                         if self.GetCurrentPos() < start_pos or self.GetCurrentPos() > i:
   374                             self.StartStyling(start_pos, wx.stc.STC_INDICS_MASK)
   383                             self.StartStyling(start_pos, wx.stc.STC_INDICS_MASK)
   375                             self.SetStyling(i - start_pos, wx.stc.STC_INDIC0_MASK)
   384                             self.SetStyling(i - start_pos, wx.stc.STC_INDIC0_MASK)
   393                 self.SetStyling(i - start_pos, STC_PLC_VARIABLE)
   402                 self.SetStyling(i - start_pos, STC_PLC_VARIABLE)
   394             elif word in self.Functions:
   403             elif word in self.Functions:
   395                 self.SetStyling(i - start_pos, STC_PLC_FUNCTION)
   404                 self.SetStyling(i - start_pos, STC_PLC_FUNCTION)
   396             elif word in self.Jumps:
   405             elif word in self.Jumps:
   397                 self.SetStyling(i - start_pos, STC_PLC_JUMP)
   406                 self.SetStyling(i - start_pos, STC_PLC_JUMP)
       
   407             elif word in self.EnumeratedValues:
       
   408                 self.SetStyling(i - start_pos, STC_PLC_NUMBER)
   398             else:
   409             else:
   399                 self.SetStyling(i - start_pos, 31)
   410                 self.SetStyling(i - start_pos, 31)
   400         else:
   411         else:
   401             self.SetStyling(i - start_pos, 31)
   412             self.SetStyling(i - start_pos, 31)
   402         event.Skip()
   413         event.Skip()