now having copied a selection, if you paste it over selected text, the selected text is substituted with the text being pasted.
This commit is contained in:
parent
93eeae2118
commit
c13adf9d14
1 changed files with 20 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue