diff --git a/source/org/thdl/tib/input/DuffPane.java b/source/org/thdl/tib/input/DuffPane.java index 9da603f..a3db6f9 100644 --- a/source/org/thdl/tib/input/DuffPane.java +++ b/source/org/thdl/tib/input/DuffPane.java @@ -186,7 +186,6 @@ public class DuffPane extends TibetanPane implements FocusListener { private Caret caret; private Style rootStyle; private boolean skipUpdate = false; - private boolean isCutAndPasteEnabled = true; private String romanFontFamily; private int romanFontSize; @@ -992,7 +991,6 @@ public class DuffPane extends TibetanPane implements FocusListener { * false if it is 'copy' */ private void copy(int start, int end, boolean remove) { - updateStatus("Copied to clipboard"); int p1 = start; int p2 = end; if (p1 != p2) { @@ -1000,11 +998,14 @@ public class DuffPane extends TibetanPane implements FocusListener { RTFSelection rtfSelection = new RTFSelection((StyledDocument)getDocument(), p1, p2-p1); try { rtfBoard.setContents(rtfSelection, rtfSelection); + updateStatus("Copied to clipboard"); } catch (IllegalStateException ise) { ise.printStackTrace(); ThdlDebug.noteIffyCode(); } - } + } else + updateStatus("Nothing to copy/cut"); + if (remove) { // Respect setEditable(boolean): if (!this.isEditable()) @@ -1013,6 +1014,7 @@ public class DuffPane extends TibetanPane implements FocusListener { try { ThdlDebug.verify(getDocument() == getTibDoc()); getDocument().remove(p1, p2-p1); + updateStatus("Cut to clipboard"); } catch (BadLocationException ble) { ble.printStackTrace(); ThdlDebug.noteIffyCode(); @@ -1117,29 +1119,6 @@ public void paste(int offset) } } -/** -* Enables cutting and pasting of Tibetan text. -*/ - public void enableCutAndPaste() { - isCutAndPasteEnabled = true; - } - - /** Returns true iff cut-and-paste operations are enabled. */ - public boolean isCutAndPasteOn() { - return isCutAndPasteEnabled; - } - -/** -* Disables cutting and pasting of Tibetan text. -* Cut and paste must be disabled if Jskad's -* parent is an applet, because it violates the -* Java security sandbox to cut and paste from an -* applet to the system clipboard. -*/ - public void disableCutAndPaste() { - isCutAndPasteEnabled = false; - } - private void processRomanChar(String key, AttributeSet attSet) { switch (key.charAt(0)) { case KeyEvent.VK_TAB: @@ -1652,20 +1631,23 @@ public void paste(int offset) - // FIXMEDOC +/** The JDK contains StringSelection, but we want to copy and paste + RTF sometimes. Enter RTFSelection. */ class RTFSelection implements ClipboardOwner, Transferable { - private DataFlavor[] supportedFlavor; + private DataFlavor[] supportedFlavors; private ByteArrayOutputStream rtfOut; private String plainText; - // FIXMEDOC RTFSelection(StyledDocument sdoc, int offset, int length) { - supportedFlavor = new DataFlavor[2]; - supportedFlavor[0] = rtfFlavor; - supportedFlavor[1] = DataFlavor.stringFlavor; + supportedFlavors = new DataFlavor[2]; + supportedFlavors[0] = rtfFlavor; + supportedFlavors[1] = DataFlavor.stringFlavor; try { //construct new document that contains only portion of text you want to copy - //this workaround is due to bug 4129911, which will not be fixed (see below after source code) + //this workaround is due to bug 4129911, which will not be fixed + + // TODO(dchandler): Is this where we lose formatting like + // centering and indention? StyledDocument newDoc = new DefaultStyledDocument(); for (int i=offset; i