[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Preliminary cut/copy/paste
From: |
Ralf Engels |
Subject: |
Preliminary cut/copy/paste |
Date: |
Sat, 28 Dec 2002 18:03:27 +0100 |
Hi,
this is the first shot at cut/copy/paste for the developer version.
One Problem I noticed: You copy a list of objects but neighter the clipboard
nor other functions are able to handle list of objects gracefully.
Anyway, here is the patch.
By the way. Are you all on holliday?
Ralf
--- Sketch.old/Editor/doceditor.py Wed Dec 25 21:50:35 2002
+++ Sketch/Editor/doceditor.py Thu Dec 26 17:24:42 2002
@@ -632,6 +632,53 @@
finally:
self.EndTransaction()
+ #
+ # Cut/Paste
+ #
+
+
+ # to think about... can we undo set operations to clipboard. emacs does
not so what should we do?
+ def CutSelected(self, context):
+ self.BeginTransaction(_("Cut"))
+ try:
+ try:
+ context.application.SetClipboard(self.selection.GetInfo())
+ undo = self.document.remove_objects(self.selection.GetInfo())
+ self.document.AddUndo(undo)
+ except:
+ self.AbortTransaction()
+ finally:
+ self.EndTransaction()
+
+
+ def CopySelected(self, context):
+ self.BeginTransaction(_("Copy"))
+ try:
+ try:
+ context.application.SetClipboard(self.selection.GetObjects())
+ except:
+ self.AbortTransaction()
+ finally:
+ self.EndTransaction()
+
+
+ def PasteClipboard(self, context):
+ self.BeginTransaction(_("Paste"))
+ try:
+ try:
+ list = context.application.GetClipboard().Object()
+ for obj in list:
+ obj = obj.Duplicate();
+ # insert the group and select it
+ self.document.Insert( obj, self.document.active_layer )
+ self._set_selection( obj, SelectSet)
+ #self.document.AddUndo(undo)
+ except:
+ self.AbortTransaction()
+ finally:
+ self.EndTransaction()
+
+
def TransformSelected(self, trafo, undo_text = ""):
self.apply_to_selected(undo_text, lambda o, t = trafo: o.Transform(t))
@@ -766,6 +813,19 @@
lambda context: context.editor.Delete(),
sensitive = sense_selection, channels = (SELECTION,))
+AddEditorBuiltin('cut', ''"Cut",
+ lambda context: context.editor.CutSelected(context),
+ sensitive = sense_selection, channels = (SELECTION,))
+
+AddEditorBuiltin('copy', ''"Copy",
+ lambda context: context.editor.CopySelected(context),
+ sensitive = sense_selection, channels = (SELECTION,))
+
+AddEditorBuiltin('paste', ''"Paste",
+ lambda context: context.editor.PasteClipboard(context),
+ sensitive = lambda context:
context.application.ClipboardContainsData(),
+ channels = (SELECTION,))
+
AddEditorBuiltin('group', ''"Group",
lambda context: context.editor.GroupSelected(),
sensitive = lambda context: context.editor.CanGroup(),
--
________________________
Ralf Engels
Software design engineer
www.rengels.de
- Preliminary cut/copy/paste,
Ralf Engels <=