editors/TextViewer.py
changeset 1745 f9d32913bad4
parent 1744 69dfdb26f600
child 1747 6046ffa2280f
equal deleted inserted replaced
1744:69dfdb26f600 1745:f9d32913bad4
   223         self.CurrentFindHighlight = None
   223         self.CurrentFindHighlight = None
   224 
   224 
   225     def OnModification(self, event):
   225     def OnModification(self, event):
   226         if not self.DisableEvents:
   226         if not self.DisableEvents:
   227             mod_type = event.GetModificationType()
   227             mod_type = event.GetModificationType()
   228             if mod_type&wx.stc.STC_MOD_BEFOREINSERT:
   228             if mod_type & wx.stc.STC_MOD_BEFOREINSERT:
   229                 if self.CurrentAction is None:
   229                 if self.CurrentAction is None:
   230                     self.StartBuffering()
   230                     self.StartBuffering()
   231                 elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1:
   231                 elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1:
   232                     self.Controler.EndBuffering()
   232                     self.Controler.EndBuffering()
   233                     self.StartBuffering()
   233                     self.StartBuffering()
   234                 self.CurrentAction = ("Add", event.GetPosition())
   234                 self.CurrentAction = ("Add", event.GetPosition())
   235                 wx.CallAfter(self.RefreshModel)
   235                 wx.CallAfter(self.RefreshModel)
   236             elif mod_type&wx.stc.STC_MOD_BEFOREDELETE:
   236             elif mod_type & wx.stc.STC_MOD_BEFOREDELETE:
   237                 if self.CurrentAction is None:
   237                 if self.CurrentAction is None:
   238                     self.StartBuffering()
   238                     self.StartBuffering()
   239                 elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
   239                 elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
   240                     self.Controler.EndBuffering()
   240                     self.Controler.EndBuffering()
   241                     self.StartBuffering()
   241                     self.StartBuffering()
   259                     blockinputs = values[3]
   259                     blockinputs = values[3]
   260                 else:
   260                 else:
   261                     blockinputs = None
   261                     blockinputs = None
   262                 if values[1] != "function":
   262                 if values[1] != "function":
   263                     if blockname == "":
   263                     if blockname == "":
   264                         dialog = wx.TextEntryDialog(self.ParentWindow, _("Block name"), _("Please enter a block name"), "", wx.OK|wx.CANCEL|wx.CENTRE)
   264                         dialog = wx.TextEntryDialog(self.ParentWindow, _("Block name"), _("Please enter a block name"), "", wx.OK | wx.CANCEL | wx.CENTRE)
   265                         if dialog.ShowModal() == wx.ID_OK:
   265                         if dialog.ShowModal() == wx.ID_OK:
   266                             blockname = dialog.GetValue()
   266                             blockname = dialog.GetValue()
   267                         else:
   267                         else:
   268                             event.SetDragText("")
   268                             event.SetDragText("")
   269                             return
   269                             return
   305                         location = values[0]
   305                         location = values[0]
   306                         if not location.startswith("%"):
   306                         if not location.startswith("%"):
   307                             dialog = wx.SingleChoiceDialog(self.ParentWindow,
   307                             dialog = wx.SingleChoiceDialog(self.ParentWindow,
   308                                   _("Select a variable class:"), _("Variable class"),
   308                                   _("Select a variable class:"), _("Variable class"),
   309                                   [_("Input"), _("Output"), _("Memory")],
   309                                   [_("Input"), _("Output"), _("Memory")],
   310                                   wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
   310                                   wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
   311                             if dialog.ShowModal() == wx.ID_OK:
   311                             if dialog.ShowModal() == wx.ID_OK:
   312                                 selected = dialog.GetSelection()
   312                                 selected = dialog.GetSelection()
   313                             else:
   313                             else:
   314                                 selected = None
   314                                 selected = None
   315                             dialog.Destroy()
   315                             dialog.Destroy()
   386                 event.SetDragText(values[0])
   386                 event.SetDragText(values[0])
   387                 wx.CallAfter(self.RefreshModel)
   387                 wx.CallAfter(self.RefreshModel)
   388             else:
   388             else:
   389                 message = _("Variable don't belong to this POU!")
   389                 message = _("Variable don't belong to this POU!")
   390             if message is not None:
   390             if message is not None:
   391                 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
   391                 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
   392                 dialog.ShowModal()
   392                 dialog.ShowModal()
   393                 dialog.Destroy()
   393                 dialog.Destroy()
   394                 event.SetDragText("")
   394                 event.SetDragText("")
   395         event.Skip()
   395         event.Skip()
   396 
   396