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);
|
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
|
* Cuts or copies the specified portion of this object's document
|
||||||
* to the system clipboard. What is cut/copied is Wylie text -
|
* to the system clipboard. What is cut/copied is Wylie text -
|
||||||
|
@ -948,6 +965,7 @@ public void paste(int offset) {
|
||||||
// Respect setEditable(boolean):
|
// Respect setEditable(boolean):
|
||||||
if (!this.isEditable())
|
if (!this.isEditable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Transferable contents = rtfBoard.getContents(this);
|
Transferable contents = rtfBoard.getContents(this);
|
||||||
|
|
||||||
|
@ -1092,6 +1110,8 @@ public void paste(int offset) {
|
||||||
case KeyEvent.VK_V:
|
case KeyEvent.VK_V:
|
||||||
if (e.isControlDown() && isCutAndPasteEnabled) {
|
if (e.isControlDown() && isCutAndPasteEnabled) {
|
||||||
e.consume();
|
e.consume();
|
||||||
|
// since paste is substituting selected text, first delete
|
||||||
|
deleteCurrentSelection();
|
||||||
paste(caret.getDot());
|
paste(caret.getDot());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue