+ def CanPaste(self):
+ """Return true if a paste should succeed."""
+ if self.CanEdit() and wxStyledTextCtrl.CanPaste(self):
+ return 1
+ else:
+ return 0
+
+ def CanEdit(self):
+ """Return true if editing should succeed."""
+ return self.GetCurrentPos() >= self.prompt1Pos[1]
+
+ def Cut(self):
+ """Remove selection and place it on the clipboard."""
+ if self.CanCut() and self.CanCopy():
+ if self.AutoCompActive(): self.AutoCompCancel()
+ if self.CallTipActive: self.CallTipCancel()
+ self.Copy()
+ self.ReplaceSelection('')
+
+ def Copy(self):
+ """Copy selection and place it on the clipboard."""
+ if self.CanCopy():
+ command = self.GetSelectedText()
+ command = command.replace(os.linesep + sys.ps2, os.linesep)
+ data = wxTextDataObject(command)
+ if wxTheClipboard.Open():
+ wxTheClipboard.SetData(data)
+ wxTheClipboard.Close()
+
+ def Paste(self):
+ """Replace selection with clipboard contents."""
+ if self.CanPaste():
+ if wxTheClipboard.Open():
+ if wxTheClipboard.IsSupported(wxDataFormat(wxDF_TEXT)):
+ data = wxTextDataObject()
+ if wxTheClipboard.GetData(data):
+ command = data.GetText()
+ command = self.fixLineEndings(command)
+ command = command.replace(os.linesep + sys.ps2, '\n')
+ command = command.replace(os.linesep, '\n')
+ command = command.replace('\n', os.linesep + sys.ps2)
+ self.ReplaceSelection('')
+ self.write(command)
+ wxTheClipboard.Close()
+