45 LETTERS.append(chr(ord('a') + i)) |
45 LETTERS.append(chr(ord('a') + i)) |
46 LETTERS.append(chr(ord('A') + i)) |
46 LETTERS.append(chr(ord('A') + i)) |
47 |
47 |
48 [STC_PLC_WORD, STC_PLC_COMMENT, STC_PLC_NUMBER, STC_PLC_STRING, |
48 [STC_PLC_WORD, STC_PLC_COMMENT, STC_PLC_NUMBER, STC_PLC_STRING, |
49 STC_PLC_VARIABLE, STC_PLC_PARAMETER, STC_PLC_FUNCTION, STC_PLC_JUMP, |
49 STC_PLC_VARIABLE, STC_PLC_PARAMETER, STC_PLC_FUNCTION, STC_PLC_JUMP, |
50 STC_PLC_ERROR, STC_PLC_SEARCH_RESULT] = range(10) |
50 STC_PLC_ERROR, STC_PLC_SEARCH_RESULT, |
|
51 STC_PLC_EMPTY] = range(11) |
51 [SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA, DPRAGMA] = range(8) |
52 [SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA, DPRAGMA] = range(8) |
52 |
53 |
53 [ID_TEXTVIEWER, ID_TEXTVIEWERTEXTCTRL, |
54 [ID_TEXTVIEWER, ID_TEXTVIEWERTEXTCTRL, |
54 ] = [wx.NewId() for _init_ctrls in range(2)] |
55 ] = [wx.NewId() for _init_ctrls in range(2)] |
55 |
56 |
592 elif self.TextSyntax == "IL" and word in self.Jumps: |
593 elif self.TextSyntax == "IL" and word in self.Jumps: |
593 self.SetStyling(current_pos - last_styled_pos, STC_PLC_JUMP) |
594 self.SetStyling(current_pos - last_styled_pos, STC_PLC_JUMP) |
594 elif word in self.EnumeratedValues: |
595 elif word in self.EnumeratedValues: |
595 self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER) |
596 self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER) |
596 else: |
597 else: |
597 self.SetStyling(current_pos - last_styled_pos, 31) |
598 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
598 if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos): |
599 if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos): |
599 self.StartStyling(last_styled_pos, wx.stc.STC_INDICS_MASK) |
600 self.StartStyling(last_styled_pos, wx.stc.STC_INDICS_MASK) |
600 self.SetStyling(current_pos - last_styled_pos, wx.stc.STC_INDIC0_MASK) |
601 self.SetStyling(current_pos - last_styled_pos, wx.stc.STC_INDIC0_MASK) |
601 self.StartStyling(current_pos, 0xff) |
602 self.StartStyling(current_pos, 0xff) |
602 else: |
603 else: |
603 self.SetStyling(current_pos - last_styled_pos, 31) |
604 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
604 last_styled_pos = current_pos |
605 last_styled_pos = current_pos |
605 if state != DPRAGMA: |
606 if (state != DPRAGMA) and (state != COMMENT): |
606 state = SPACE |
607 state = SPACE |
607 line = "" |
608 line = "" |
608 line_number += 1 |
609 line_number += 1 |
609 self.RefreshLineFolding(line_number) |
610 self.RefreshLineFolding(line_number) |
610 elif line.endswith("(*") and state != COMMENT: |
611 elif line.endswith("(*") and state != COMMENT: |
611 self.SetStyling(current_pos - last_styled_pos - 1, 31) |
612 self.SetStyling(current_pos - last_styled_pos - 1, STC_PLC_EMPTY) |
612 last_styled_pos = current_pos |
613 last_styled_pos = current_pos |
613 if state == WORD: |
614 if state == WORD: |
614 current_context = self.Variables |
615 current_context = self.Variables |
615 state = COMMENT |
616 state = COMMENT |
616 elif line.endswith("{") and state not in [PRAGMA, DPRAGMA]: |
617 elif line.endswith("{") and state not in [PRAGMA, DPRAGMA]: |
617 self.SetStyling(current_pos - last_styled_pos, 31) |
618 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
618 last_styled_pos = current_pos |
619 last_styled_pos = current_pos |
619 if state == WORD: |
620 if state == WORD: |
620 current_context = self.Variables |
621 current_context = self.Variables |
621 state = PRAGMA |
622 state = PRAGMA |
622 elif line.endswith("{{") and state == PRAGMA: |
623 elif line.endswith("{{") and state == PRAGMA: |
623 self.SetStyling(current_pos - last_styled_pos, 31) |
624 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
624 last_styled_pos = current_pos |
625 last_styled_pos = current_pos |
625 state = DPRAGMA |
626 state = DPRAGMA |
626 elif state == COMMENT: |
627 elif state == COMMENT: |
627 if line.endswith("*)"): |
628 if line.endswith("*)"): |
628 self.SetStyling(current_pos - last_styled_pos + 2, STC_PLC_COMMENT) |
629 self.SetStyling(current_pos - last_styled_pos + 2, STC_PLC_COMMENT) |
629 last_styled_pos = current_pos + 1 |
630 last_styled_pos = current_pos + 1 |
630 state = SPACE |
631 state = SPACE |
631 elif state == PRAGMA: |
632 elif state == PRAGMA: |
632 if line.endswith("}"): |
633 if line.endswith("}"): |
633 self.SetStyling(current_pos - last_styled_pos, 31) |
634 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
634 last_styled_pos = current_pos |
635 last_styled_pos = current_pos |
635 state = SPACE |
636 state = SPACE |
636 elif state == DPRAGMA: |
637 elif state == DPRAGMA: |
637 if line.endswith("}}"): |
638 if line.endswith("}}"): |
638 self.SetStyling(current_pos - last_styled_pos + 1, 31) |
639 self.SetStyling(current_pos - last_styled_pos + 1, STC_PLC_EMPTY) |
639 last_styled_pos = current_pos + 1 |
640 last_styled_pos = current_pos + 1 |
640 state = SPACE |
641 state = SPACE |
641 elif (line.endswith("'") or line.endswith('"')) and state not in [STRING, WSTRING]: |
642 elif (line.endswith("'") or line.endswith('"')) and state not in [STRING, WSTRING]: |
642 self.SetStyling(current_pos - last_styled_pos, 31) |
643 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
643 last_styled_pos = current_pos |
644 last_styled_pos = current_pos |
644 if state == WORD: |
645 if state == WORD: |
645 current_context = self.Variables |
646 current_context = self.Variables |
646 if line.endswith("'"): |
647 if line.endswith("'"): |
647 state = STRING |
648 state = STRING |
691 elif self.TextSyntax == "IL" and word in self.Jumps: |
692 elif self.TextSyntax == "IL" and word in self.Jumps: |
692 self.SetStyling(current_pos - last_styled_pos, STC_PLC_JUMP) |
693 self.SetStyling(current_pos - last_styled_pos, STC_PLC_JUMP) |
693 elif word in self.EnumeratedValues: |
694 elif word in self.EnumeratedValues: |
694 self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER) |
695 self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER) |
695 else: |
696 else: |
696 self.SetStyling(current_pos - last_styled_pos, 31) |
697 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
697 if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos): |
698 if word not in ["]", ")"] and (self.GetCurrentPos() < last_styled_pos or self.GetCurrentPos() > current_pos): |
698 self.StartStyling(last_styled_pos, wx.stc.STC_INDICS_MASK) |
699 self.StartStyling(last_styled_pos, wx.stc.STC_INDICS_MASK) |
699 self.SetStyling(current_pos - last_styled_pos, wx.stc.STC_INDIC0_MASK) |
700 self.SetStyling(current_pos - last_styled_pos, wx.stc.STC_INDIC0_MASK) |
700 self.StartStyling(current_pos, 0xff) |
701 self.StartStyling(current_pos, 0xff) |
701 if char == '.': |
702 if char == '.': |
755 elif word in self.Jumps: |
756 elif word in self.Jumps: |
756 self.SetStyling(current_pos - last_styled_pos, STC_PLC_JUMP) |
757 self.SetStyling(current_pos - last_styled_pos, STC_PLC_JUMP) |
757 elif word in self.EnumeratedValues: |
758 elif word in self.EnumeratedValues: |
758 self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER) |
759 self.SetStyling(current_pos - last_styled_pos, STC_PLC_NUMBER) |
759 else: |
760 else: |
760 self.SetStyling(current_pos - last_styled_pos, 31) |
761 self.SetStyling(current_pos - last_styled_pos, STC_PLC_EMPTY) |
761 else: |
762 else: |
762 self.SetStyling(current_pos - start_pos, 31) |
763 self.SetStyling(current_pos - start_pos, STC_PLC_EMPTY) |
763 self.ShowHighlights(start_pos, end_pos) |
764 self.ShowHighlights(start_pos, end_pos) |
764 event.Skip() |
765 event.Skip() |
765 |
766 |
766 def OnMarginClick(self, event): |
767 def OnMarginClick(self, event): |
767 if event.GetMargin() == 2: |
768 if event.GetMargin() == 2: |