155 self.StructElementsStack = [] |
155 self.StructElementsStack = [] |
156 |
156 |
157 self.ParentWindow = window |
157 self.ParentWindow = window |
158 self.Controler = controler |
158 self.Controler = controler |
159 |
159 |
160 self.SetModEventMask(wx.stc.STC_MOD_BEFOREINSERT|wx.stc.STC_MOD_BEFOREDELETE) |
160 self.SetModEventMask(wx.stc.STC_MOD_BEFOREINSERT| |
|
161 wx.stc.STC_MOD_BEFOREDELETE| |
|
162 wx.stc.STC_PERFORMED_USER) |
161 |
163 |
162 self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded, id=ID_TEXTVIEWER) |
164 self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded, id=ID_TEXTVIEWER) |
163 if controler: |
165 if controler: |
164 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
166 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
165 self.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, id=ID_TEXTVIEWER) |
167 self.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, id=ID_TEXTVIEWER) |
188 pass |
190 pass |
189 |
191 |
190 def OnModification(self, event): |
192 def OnModification(self, event): |
191 if not self.DisableEvents: |
193 if not self.DisableEvents: |
192 mod_type = event.GetModificationType() |
194 mod_type = event.GetModificationType() |
193 if not (mod_type&wx.stc.STC_PERFORMED_UNDO or mod_type&wx.stc.STC_PERFORMED_REDO): |
195 if mod_type&wx.stc.STC_MOD_BEFOREINSERT: |
194 if mod_type&wx.stc.STC_MOD_BEFOREINSERT: |
196 if self.CurrentAction == None: |
195 if self.CurrentAction == None: |
197 self.StartBuffering() |
196 self.StartBuffering() |
198 elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1: |
197 elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1: |
199 self.Controler.EndBuffering() |
198 self.Controler.EndBuffering() |
200 self.StartBuffering() |
199 self.StartBuffering() |
201 self.CurrentAction = ("Add", event.GetPosition()) |
200 self.CurrentAction = ("Add", event.GetPosition()) |
202 wx.CallAfter(self.RefreshModel) |
201 elif mod_type&wx.stc.STC_MOD_BEFOREDELETE: |
203 elif mod_type&wx.stc.STC_MOD_BEFOREDELETE: |
202 if self.CurrentAction == None: |
204 if self.CurrentAction == None: |
203 self.StartBuffering() |
205 self.StartBuffering() |
204 elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1: |
206 elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1: |
205 self.Controler.EndBuffering() |
207 self.Controler.EndBuffering() |
206 self.StartBuffering() |
208 self.StartBuffering() |
207 self.CurrentAction = ("Delete", event.GetPosition()) |
209 self.CurrentAction = ("Delete", event.GetPosition()) |
|
210 wx.CallAfter(self.RefreshModel) |
208 event.Skip() |
211 event.Skip() |
209 |
212 |
210 def OnDoDrop(self, event): |
213 def OnDoDrop(self, event): |
211 try: |
214 try: |
212 values = eval(event.GetDragText()) |
215 values = eval(event.GetDragText()) |
504 kw = [keyword for keyword in kw if keyword.startswith(words[-1])] |
507 kw = [keyword for keyword in kw if keyword.startswith(words[-1])] |
505 kw.sort() |
508 kw.sort() |
506 self.AutoCompSetIgnoreCase(True) |
509 self.AutoCompSetIgnoreCase(True) |
507 self.AutoCompShow(len(words[-1]), " ".join(kw)) |
510 self.AutoCompShow(len(words[-1]), " ".join(kw)) |
508 else: |
511 else: |
509 wx.CallAfter(self.RefreshModel) |
|
510 event.Skip() |
512 event.Skip() |
511 |
513 |
512 def OnKillFocus(self, event): |
514 def OnKillFocus(self, event): |
513 self.AutoCompCancel() |
515 self.AutoCompCancel() |
514 event.Skip() |
516 event.Skip() |