editors/TextViewer.py
branchwxPython4
changeset 3303 0ffb41625592
parent 2737 38afed869ff6
child 3327 d753cc166bd0
equal deleted inserted replaced
3302:c89fc366bebd 3303:0ffb41625592
   196         self.Editor.SelectAll()
   196         self.Editor.SelectAll()
   197 
   197 
   198     def Colourise(self, start, end):
   198     def Colourise(self, start, end):
   199         self.Editor.Colourise(start, end)
   199         self.Editor.Colourise(start, end)
   200 
   200 
   201     def StartStyling(self, pos, mask):
   201     def StartStyling(self, pos):
   202         self.Editor.StartStyling(pos, mask)
   202         self.Editor.StartStyling(pos)
       
   203 
       
   204     INDIC0 = 0
       
   205     INDIC1 = 1
       
   206     INDIC2 = 2
   203 
   207 
   204     def SetStyling(self, length, style):
   208     def SetStyling(self, length, style):
   205         self.Editor.SetStyling(length, style)
   209         self.Editor.SetStyling(length, style)
       
   210 
       
   211     def SetIndicatorCurrentFillRange(start, length, indic):
       
   212         self.Editor.SetIndicatorCurrent(indic)
       
   213         self.Editor.IndicatorFillRange(start, length)
   206 
   214 
   207     def GetCurrentPos(self):
   215     def GetCurrentPos(self):
   208         return self.Editor.GetCurrentPos()
   216         return self.Editor.GetCurrentPos()
   209 
   217 
   210     def ResetSearchResults(self):
   218     def ResetSearchResults(self):
   557             start_pos = last_styled_pos = 0
   565             start_pos = last_styled_pos = 0
   558         else:
   566         else:
   559             start_pos = last_styled_pos = self.Editor.GetLineEndPosition(line_number - 1) + 1
   567             start_pos = last_styled_pos = self.Editor.GetLineEndPosition(line_number - 1) + 1
   560         self.RefreshLineFolding(line_number)
   568         self.RefreshLineFolding(line_number)
   561         end_pos = event.GetPosition()
   569         end_pos = event.GetPosition()
   562         self.StartStyling(start_pos, 0xff)
   570         self.StartStyling(start_pos)
   563 
   571 
   564         current_context = self.Variables
   572         current_context = self.Variables
   565         current_call = None
   573         current_call = None
   566 
   574 
   567         current_pos = last_styled_pos
   575         current_pos = last_styled_pos
   592                     elif word in self.EnumeratedValues:
   600                     elif word in self.EnumeratedValues:
   593                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER)
   601                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER)
   594                     else:
   602                     else:
   595                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY)
   603                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY)
   596                         if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos):
   604                         if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos):
   597                             self.StartStyling(last_styled_pos, wx.stc.STC_INDICS_MASK)
   605                             self.SetIndicatorCurrentFillRange(last_styled_pos, current_pos - last_styled_pos, self.INDIC0)
   598                             self.SetStyling(current_pos - last_styled_pos, wx.stc.STC_INDIC0_MASK)
   606                             self.StartStyling(current_pos)
   599                             self.StartStyling(current_pos, 0xff)
       
   600                 else:
   607                 else:
   601                     self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY)
   608                     self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY)
   602                 last_styled_pos = current_pos
   609                 last_styled_pos = current_pos
   603                 if (state != DPRAGMA) and (state != COMMENT):
   610                 if (state != DPRAGMA) and (state != COMMENT):
   604                     state = SPACE
   611                     state = SPACE
   695                     elif word in self.EnumeratedValues:
   702                     elif word in self.EnumeratedValues:
   696                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER)
   703                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER)
   697                     else:
   704                     else:
   698                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY)
   705                         self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY)
   699                         if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos):
   706                         if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos):
   700                             self.StartStyling(last_styled_pos, wx.stc.STC_INDICS_MASK)
   707                             self.SetIndicatorCurrentFillRange(last_styled_pos, current_pos - last_styled_pos, self.INDIC0)
   701                             self.SetStyling(current_pos - last_styled_pos, wx.stc.STC_INDIC0_MASK)
   708                             self.StartStyling(current_pos)
   702                             self.StartStyling(current_pos, 0xff)
       
   703                     if char == '.':
   709                     if char == '.':
   704                         if word != "]":
   710                         if word != "]":
   705                             if current_context is not None:
   711                             if current_context is not None:
   706                                 current_context = current_context.get(word, None)
   712                                 current_context = current_context.get(word, None)
   707                             else:
   713                             else:
   953             if end[0] == 0:
   959             if end[0] == 0:
   954                 highlight_end_pos = end[1] - indent + 1
   960                 highlight_end_pos = end[1] - indent + 1
   955             else:
   961             else:
   956                 highlight_end_pos = self.Editor.GetLineEndPosition(end[0] - 1) + end[1] - indent + 2
   962                 highlight_end_pos = self.Editor.GetLineEndPosition(end[0] - 1) + end[1] - indent + 2
   957             if highlight_start_pos < end_pos and highlight_end_pos > start_pos:
   963             if highlight_start_pos < end_pos and highlight_end_pos > start_pos:
   958                 self.StartStyling(highlight_start_pos, 0xff)
   964                 self.StartStyling(highlight_start_pos)
   959                 self.SetStyling(highlight_end_pos - highlight_start_pos, highlight_type)
   965                 self.SetStyling(highlight_end_pos - highlight_start_pos, highlight_type)
   960                 self.StartStyling(highlight_start_pos, 0x00)
   966                 self.StartStyling(highlight_start_pos)
   961                 until_end = max(0, len(self.Editor.GetText()) - highlight_end_pos)
   967                 until_end = max(0, len(self.Editor.GetText()) - highlight_end_pos)
   962                 self.SetStyling(until_end, wx.stc.STC_STYLE_DEFAULT)
   968                 self.SetStyling(until_end, wx.stc.STC_STYLE_DEFAULT)