editors/TextViewer.py
changeset 871 1af078aa0cf8
parent 858 daafaa8a28fd
child 894 a4919f228924
equal deleted inserted replaced
870:61b32521442e 871:1af078aa0cf8
    45     LETTERS.append(chr(ord('A') + i))
    45     LETTERS.append(chr(ord('A') + i))
    46 
    46 
    47 [STC_PLC_WORD, STC_PLC_COMMENT, STC_PLC_NUMBER, STC_PLC_STRING, 
    47 [STC_PLC_WORD, STC_PLC_COMMENT, STC_PLC_NUMBER, STC_PLC_STRING, 
    48  STC_PLC_VARIABLE, STC_PLC_PARAMETER, STC_PLC_FUNCTION, STC_PLC_JUMP, 
    48  STC_PLC_VARIABLE, STC_PLC_PARAMETER, STC_PLC_FUNCTION, STC_PLC_JUMP, 
    49  STC_PLC_ERROR, STC_PLC_SEARCH_RESULT] = range(10)
    49  STC_PLC_ERROR, STC_PLC_SEARCH_RESULT] = range(10)
    50 [SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA] = range(7)
    50 [SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA, DPRAGMA] = range(8)
    51 
    51 
    52 [ID_TEXTVIEWER, ID_TEXTVIEWERTEXTCTRL,
    52 [ID_TEXTVIEWER, ID_TEXTVIEWERTEXTCTRL,
    53 ] = [wx.NewId() for _init_ctrls in range(2)]
    53 ] = [wx.NewId() for _init_ctrls in range(2)]
    54 
    54 
    55 if wx.Platform == '__WXMSW__':
    55 if wx.Platform == '__WXMSW__':
   593                 self.SetStyling(current_pos - last_styled_pos - 1, 31)
   593                 self.SetStyling(current_pos - last_styled_pos - 1, 31)
   594                 last_styled_pos = current_pos
   594                 last_styled_pos = current_pos
   595                 if state == WORD:
   595                 if state == WORD:
   596                     current_context = self.Variables
   596                     current_context = self.Variables
   597                 state = COMMENT
   597                 state = COMMENT
   598             elif line.endswith("{") and state != PRAGMA:
   598             elif line.endswith("{") and state not in [PRAGMA, DPRAGMA]:
   599                 self.SetStyling(current_pos - last_styled_pos, 31)
   599                 self.SetStyling(current_pos - last_styled_pos, 31)
   600                 last_styled_pos = current_pos
   600                 last_styled_pos = current_pos
   601                 if state == WORD:
   601                 if state == WORD:
   602                     current_context = self.Variables
   602                     current_context = self.Variables
   603                 state = PRAGMA
   603                 state = PRAGMA
       
   604             elif line.endswith("{{") and state == PRAGMA:
       
   605                 self.SetStyling(current_pos - last_styled_pos, 31)
       
   606                 last_styled_pos = current_pos
       
   607                 state = DPRAGMA
   604             elif state == COMMENT:
   608             elif state == COMMENT:
   605                 if line.endswith("*)"):
   609                 if line.endswith("*)"):
   606                     self.SetStyling(current_pos - last_styled_pos + 2, STC_PLC_COMMENT)
   610                     self.SetStyling(current_pos - last_styled_pos + 2, STC_PLC_COMMENT)
   607                     last_styled_pos = current_pos + 1
   611                     last_styled_pos = current_pos + 1
   608                     state = SPACE
   612                     state = SPACE
   609             elif state == PRAGMA:
   613             elif state == PRAGMA:
   610                 if line.endswith("}"):
   614                 if line.endswith("}"):
       
   615                     self.SetStyling(current_pos - last_styled_pos, 31)
       
   616                     last_styled_pos = current_pos
       
   617                     state = SPACE
       
   618             elif state == DPRAGMA:
       
   619                 if line.endswith("}}"):
   611                     self.SetStyling(current_pos - last_styled_pos + 2, 31)
   620                     self.SetStyling(current_pos - last_styled_pos + 2, 31)
   612                     last_styled_pos = current_pos + 1
   621                     last_styled_pos = current_pos + 1
   613                     state = SPACE
   622                     state = SPACE
   614             elif (line.endswith("'") or line.endswith('"')) and state not in [STRING, WSTRING]:
   623             elif (line.endswith("'") or line.endswith('"')) and state not in [STRING, WSTRING]:
   615                 self.SetStyling(current_pos - last_styled_pos, 31)
   624                 self.SetStyling(current_pos - last_styled_pos, 31)
   836                         elif words[0].upper() in ["JMP", "JMPC", "JMPNC"]:
   845                         elif words[0].upper() in ["JMP", "JMPC", "JMPNC"]:
   837                             kw = self.Jumps
   846                             kw = self.Jumps
   838                         else:
   847                         else:
   839                             kw = self.Variables.keys()
   848                             kw = self.Variables.keys()
   840                 else:
   849                 else:
   841                     kw = self.Keywords + self.Variables.keys() + self.Functions
   850                     kw = self.Keywords + self.Variables.keys() + self.Functions.keys()
   842                 if len(kw) > 0:
   851                 if len(kw) > 0:
   843                     if len(words[-1]) > 0:
   852                     if len(words[-1]) > 0:
   844                         kw = [keyword for keyword in kw if keyword.startswith(words[-1])]
   853                         kw = [keyword for keyword in kw if keyword.startswith(words[-1])]
   845                     kw.sort()
   854                     kw.sort()
   846                     self.Editor.AutoCompSetIgnoreCase(True)
   855                     self.Editor.AutoCompSetIgnoreCase(True)