# HG changeset patch # User Laurent Bessard # Date 1351187946 -7200 # Node ID 1af078aa0cf8523e6a229519a16e99661e036e4c # Parent 61b32521442e7da133ae4a0f2873a6baf6d432db Add support for double bracket pragma in syntax highlighting of TextViewer diff -r 61b32521442e -r 1af078aa0cf8 editors/TextViewer.py --- a/editors/TextViewer.py Thu Oct 25 19:57:53 2012 +0200 +++ b/editors/TextViewer.py Thu Oct 25 19:59:06 2012 +0200 @@ -47,7 +47,7 @@ [STC_PLC_WORD, STC_PLC_COMMENT, STC_PLC_NUMBER, STC_PLC_STRING, STC_PLC_VARIABLE, STC_PLC_PARAMETER, STC_PLC_FUNCTION, STC_PLC_JUMP, STC_PLC_ERROR, STC_PLC_SEARCH_RESULT] = range(10) -[SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA] = range(7) +[SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA, DPRAGMA] = range(8) [ID_TEXTVIEWER, ID_TEXTVIEWERTEXTCTRL, ] = [wx.NewId() for _init_ctrls in range(2)] @@ -595,12 +595,16 @@ if state == WORD: current_context = self.Variables state = COMMENT - elif line.endswith("{") and state != PRAGMA: + elif line.endswith("{") and state not in [PRAGMA, DPRAGMA]: self.SetStyling(current_pos - last_styled_pos, 31) last_styled_pos = current_pos if state == WORD: current_context = self.Variables state = PRAGMA + elif line.endswith("{{") and state == PRAGMA: + self.SetStyling(current_pos - last_styled_pos, 31) + last_styled_pos = current_pos + state = DPRAGMA elif state == COMMENT: if line.endswith("*)"): self.SetStyling(current_pos - last_styled_pos + 2, STC_PLC_COMMENT) @@ -608,6 +612,11 @@ state = SPACE elif state == PRAGMA: if line.endswith("}"): + self.SetStyling(current_pos - last_styled_pos, 31) + last_styled_pos = current_pos + state = SPACE + elif state == DPRAGMA: + if line.endswith("}}"): self.SetStyling(current_pos - last_styled_pos + 2, 31) last_styled_pos = current_pos + 1 state = SPACE @@ -838,7 +847,7 @@ else: kw = self.Variables.keys() else: - kw = self.Keywords + self.Variables.keys() + self.Functions + kw = self.Keywords + self.Variables.keys() + self.Functions.keys() if len(kw) > 0: if len(words[-1]) > 0: kw = [keyword for keyword in kw if keyword.startswith(words[-1])]