equal
deleted
inserted
replaced
98 self.ParentWindow = window |
98 self.ParentWindow = window |
99 |
99 |
100 self.DisableEvents = True |
100 self.DisableEvents = True |
101 self.CurrentAction = None |
101 self.CurrentAction = None |
102 |
102 |
103 self.Highlights = [] |
103 self.ResetSearchResults() |
104 self.SearchParams = None |
|
105 self.SearchResults = None |
|
106 self.CurrentFindHighlight = None |
|
107 |
104 |
108 self.RefreshHighlightsTimer = wx.Timer(self, -1) |
105 self.RefreshHighlightsTimer = wx.Timer(self, -1) |
109 self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) |
106 self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) |
110 |
107 |
111 self.SectionsComments = {} |
108 self.SectionsComments = {} |
137 self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) |
134 self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) |
138 self.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification) |
135 self.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification) |
139 |
136 |
140 def SetCodeLexer(self): |
137 def SetCodeLexer(self): |
141 pass |
138 pass |
|
139 |
|
140 def ResetSearchResults(self): |
|
141 self.Highlights = [] |
|
142 self.SearchParams = None |
|
143 self.SearchResults = None |
|
144 self.CurrentFindHighlight = None |
142 |
145 |
143 def OnModification(self, event): |
146 def OnModification(self, event): |
144 if not self.DisableEvents: |
147 if not self.DisableEvents: |
145 mod_type = event.GetModificationType() |
148 mod_type = event.GetModificationType() |
146 if not (mod_type&wx.stc.STC_PERFORMED_UNDO or mod_type&wx.stc.STC_PERFORMED_REDO): |
149 if not (mod_type&wx.stc.STC_PERFORMED_UNDO or mod_type&wx.stc.STC_PERFORMED_REDO): |
239 self.DisableEvents = False |
242 self.DisableEvents = False |
240 |
243 |
241 self.RefreshSectionStyling() |
244 self.RefreshSectionStyling() |
242 |
245 |
243 self.ShowHighlights() |
246 self.ShowHighlights() |
244 |
247 |
245 def RefreshSectionStyling(self): |
248 def RefreshSectionStyling(self): |
246 self.Colourise(0, -1) |
249 self.Colourise(0, -1) |
247 |
250 |
248 text = self.GetText() |
251 text = self.GetText() |
249 for line in xrange(self.GetLineCount()): |
252 for line in xrange(self.GetLineCount()): |
272 if result is not None: |
275 if result is not None: |
273 parts[section] = result.group(1) |
276 parts[section] = result.group(1) |
274 else: |
277 else: |
275 parts[section] = "" |
278 parts[section] = "" |
276 self.Controler.SetTextParts(parts) |
279 self.Controler.SetTextParts(parts) |
277 |
280 self.ResetSearchResults() |
|
281 |
278 def OnKeyPressed(self, event): |
282 def OnKeyPressed(self, event): |
279 if self.CallTipActive(): |
283 if self.CallTipActive(): |
280 self.CallTipCancel() |
284 self.CallTipCancel() |
281 key = event.GetKeyCode() |
285 key = event.GetKeyCode() |
282 current_pos = self.GetCurrentPos() |
286 current_pos = self.GetCurrentPos() |
501 if idx != old_idx: |
505 if idx != old_idx: |
502 self.RemoveHighlight(*self.CurrentFindHighlight) |
506 self.RemoveHighlight(*self.CurrentFindHighlight) |
503 self.CurrentFindHighlight = self.SearchResults[idx] |
507 self.CurrentFindHighlight = self.SearchResults[idx] |
504 self.AddHighlight(*self.CurrentFindHighlight) |
508 self.AddHighlight(*self.CurrentFindHighlight) |
505 else: |
509 else: |
506 self.CurrentFindHighlight = self.SearchResults[0] |
510 caret_pos = self.GetCurrentPos() |
507 self.AddHighlight(*self.CurrentFindHighlight) |
511 if self.SearchParams["wrap"]: |
|
512 self.CurrentFindHighlight = self.SearchResults[0] |
|
513 else: |
|
514 self.CurrentFindHighlight = None |
|
515 for start, end, highlight_type in self.SearchResults: |
|
516 if start[0] == 0: |
|
517 highlight_start_pos = start[1] |
|
518 else: |
|
519 highlight_start_pos = self.GetLineEndPosition(start[0] - 1) + start[1] + 1 |
|
520 if highlight_start_pos >= caret_pos: |
|
521 self.CurrentFindHighlight = (start, end, highlight_type) |
|
522 break |
|
523 if self.CurrentFindHighlight is not None: |
|
524 self.AddHighlight(*self.CurrentFindHighlight) |
508 |
525 |
509 self.ScrollToLine(self.CurrentFindHighlight[0][0]) |
526 self.ScrollToLine(self.CurrentFindHighlight[0][0]) |
510 |
527 |
511 else: |
528 else: |
512 if self.CurrentFindHighlight is not None: |
529 if self.CurrentFindHighlight is not None: |
550 if start[0] == 0: |
567 if start[0] == 0: |
551 highlight_start_pos = start[1] |
568 highlight_start_pos = start[1] |
552 else: |
569 else: |
553 highlight_start_pos = self.GetLineEndPosition(start[0] - 1) + start[1] + 1 |
570 highlight_start_pos = self.GetLineEndPosition(start[0] - 1) + start[1] + 1 |
554 if end[0] == 0: |
571 if end[0] == 0: |
555 highlight_end_pos = end[1] - indent + 1 |
572 highlight_end_pos = end[1] + 1 |
556 else: |
573 else: |
557 highlight_end_pos = self.GetLineEndPosition(end[0] - 1) + end[1] + 2 |
574 highlight_end_pos = self.GetLineEndPosition(end[0] - 1) + end[1] + 2 |
558 self.StartStyling(highlight_start_pos, 0xff) |
575 self.StartStyling(highlight_start_pos, 0xff) |
559 self.SetStyling(highlight_end_pos - highlight_start_pos, highlight_type) |
576 self.SetStyling(highlight_end_pos - highlight_start_pos, highlight_type) |
560 self.StartStyling(highlight_start_pos, 0x00) |
577 self.StartStyling(highlight_end_pos, 0x00) |
561 self.SetStyling(len(self.GetText()) - highlight_end_pos, stc.STC_STYLE_DEFAULT) |
578 self.SetStyling(len(self.GetText()) - highlight_end_pos, stc.STC_STYLE_DEFAULT) |
562 |
579 |
563 |
580 |
564 #------------------------------------------------------------------------------- |
581 #------------------------------------------------------------------------------- |
565 # Helper for VariablesGrid values |
582 # Helper for VariablesGrid values |