195 self.EnumeratedValues = [] |
195 self.EnumeratedValues = [] |
196 self.DisableEvents = True |
196 self.DisableEvents = True |
197 self.TextSyntax = None |
197 self.TextSyntax = None |
198 self.CurrentAction = None |
198 self.CurrentAction = None |
199 self.Highlights = [] |
199 self.Highlights = [] |
|
200 self.SearchParams = None |
|
201 self.SearchResults = None |
|
202 self.CurrentFindHighlight = None |
200 self.InstancePath = instancepath |
203 self.InstancePath = instancepath |
201 self.ContextStack = [] |
204 self.ContextStack = [] |
202 self.CallStack = [] |
205 self.CallStack = [] |
203 |
206 |
204 self.RefreshHighlightsTimer = wx.Timer(self, -1) |
207 self.RefreshHighlightsTimer = wx.Timer(self, -1) |
737 self.Editor.CmdKeyExecute(wx.stc.STC_CMD_PASTE) |
740 self.Editor.CmdKeyExecute(wx.stc.STC_CMD_PASTE) |
738 self.DisableEvents = False |
741 self.DisableEvents = False |
739 self.RefreshModel() |
742 self.RefreshModel() |
740 self.RefreshBuffer() |
743 self.RefreshBuffer() |
741 |
744 |
|
745 def Find(self, direction, search_params): |
|
746 if self.SearchParams != search_params: |
|
747 self.ClearHighlights(SEARCH_RESULT_HIGHLIGHT) |
|
748 |
|
749 self.SearchParams = search_params |
|
750 criteria = { |
|
751 "raw_pattern": search_params["find_pattern"], |
|
752 "pattern": re.compile(search_params["find_pattern"]), |
|
753 "case_sensitive": search_params["case_sensitive"], |
|
754 "regular_expression": search_params["regular_expression"], |
|
755 "filter": "all"} |
|
756 |
|
757 self.SearchResults = [ |
|
758 (infos[1:], start, end, SEARCH_RESULT_HIGHLIGHT) |
|
759 for infos, start, end, text in |
|
760 self.Controler.SearchInPou(self.TagName, criteria, self.Debug)] |
|
761 |
|
762 if len(self.SearchResults) > 0: |
|
763 if self.CurrentFindHighlight is not None: |
|
764 old_idx = self.SearchResults.index(self.CurrentFindHighlight) |
|
765 if self.SearchParams["wrap"]: |
|
766 idx = (old_idx + direction) % len(self.SearchResults) |
|
767 else: |
|
768 idx = max(0, min(old_idx + direction, len(self.SearchResults) - 1)) |
|
769 if idx != old_idx: |
|
770 self.RemoveHighlight(*self.CurrentFindHighlight) |
|
771 self.CurrentFindHighlight = self.SearchResults[idx] |
|
772 self.AddHighlight(*self.CurrentFindHighlight) |
|
773 else: |
|
774 self.CurrentFindHighlight = self.SearchResults[0] |
|
775 self.AddHighlight(*self.CurrentFindHighlight) |
|
776 |
|
777 else: |
|
778 if self.CurrentFindHighlight is not None: |
|
779 self.RemoveHighlight(*self.CurrentFindHighlight) |
|
780 self.CurrentFindHighlight = None |
|
781 |
742 def RefreshModel(self): |
782 def RefreshModel(self): |
743 self.RefreshJumpList() |
783 self.RefreshJumpList() |
744 self.Controler.SetEditedElementText(self.TagName, self.GetText()) |
784 self.Controler.SetEditedElementText(self.TagName, self.GetText()) |
745 |
785 |
746 def OnKeyDown(self, event): |
786 def OnKeyDown(self, event): |
830 EditorPanel.AddHighlight(self, infos, start, end, highlight_type) |
870 EditorPanel.AddHighlight(self, infos, start, end, highlight_type) |
831 |
871 |
832 highlight_type = HIGHLIGHT_TYPES.get(highlight_type, None) |
872 highlight_type = HIGHLIGHT_TYPES.get(highlight_type, None) |
833 if infos[0] == "body" and highlight_type is not None: |
873 if infos[0] == "body" and highlight_type is not None: |
834 self.Highlights.append((infos[1], start, end, highlight_type)) |
874 self.Highlights.append((infos[1], start, end, highlight_type)) |
|
875 self.Editor.GotoPos(self.Editor.PositionFromLine(start[0]) + start[1]) |
835 self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
876 self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
836 |
877 |
|
878 def RemoveHighlight(self, infos, start, end, highlight_type): |
|
879 EditorPanel.RemoveHighlight(self, infos, start, end, highlight_type) |
|
880 |
|
881 highlight_type = HIGHLIGHT_TYPES.get(highlight_type, None) |
|
882 if (infos[0] == "body" and highlight_type is not None and |
|
883 (infos[1], start, end, highlight_type) in self.Highlights): |
|
884 self.Highlights.remove((infos[1], start, end, highlight_type)) |
|
885 self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
|
886 |
837 def ShowHighlights(self, start_pos, end_pos): |
887 def ShowHighlights(self, start_pos, end_pos): |
838 for indent, start, end, highlight_type in self.Highlights: |
888 for indent, start, end, highlight_type in self.Highlights: |
839 if start[0] == 0: |
889 if start[0] == 0: |
840 highlight_start_pos = start[1] - indent |
890 highlight_start_pos = start[1] - indent |
841 else: |
891 else: |