From c13adf9d14d7bf8dfbc5a52a84722b8b0659ebe8 Mon Sep 17 00:00:00 2001 From: amontano Date: Wed, 27 Nov 2002 23:29:31 +0000 Subject: [PATCH] now having copied a selection, if you paste it over selected text, the selected text is substituted with the text being pasted. --- source/org/thdl/tib/input/DuffPane.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/org/thdl/tib/input/DuffPane.java b/source/org/thdl/tib/input/DuffPane.java index 0e16baa..3242a6e 100644 --- a/source/org/thdl/tib/input/DuffPane.java +++ b/source/org/thdl/tib/input/DuffPane.java @@ -895,6 +895,23 @@ class RTFSelection implements ClipboardOwner, Transferable { copy(getSelectionStart(), getSelectionEnd(), true); } + /** If this.isEditable(), then this deletes the current selection. */ + public void deleteCurrentSelection() + { + int start=getSelectionStart(), end=getSelectionEnd(); + + if (!this.isEditable()) + return; + try + { + getDocument().remove(start, end-start); + } catch (BadLocationException ble) { + ble.printStackTrace(); + ThdlDebug.noteIffyCode(); + } + } + + /** * Cuts or copies the specified portion of this object's document * to the system clipboard. What is cut/copied is Wylie text - @@ -948,6 +965,7 @@ public void paste(int offset) { // Respect setEditable(boolean): if (!this.isEditable()) return; + try { Transferable contents = rtfBoard.getContents(this); @@ -1092,6 +1110,8 @@ public void paste(int offset) { case KeyEvent.VK_V: if (e.isControlDown() && isCutAndPasteEnabled) { e.consume(); + // since paste is substituting selected text, first delete + deleteCurrentSelection(); paste(caret.getDot()); } break;