Skip to content

Commit 5e30a83

Browse files
committed
Config setting to disable pasting when choosing a popup item.
closes #6
1 parent 80ed75d commit 5e30a83

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/com/esotericsoftware/clippy/Clippy.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ void store (String text) {
286286

287287
/** @param text May be null.
288288
* @return The new ID for the clipboard item that was moved to last, or -1. */
289-
public int paste (String text) {
290-
int newID = -1;
291-
if (text == null) return newID;
292-
if (!clipboard.setContents(text)) return newID;
289+
public int current (String text) {
290+
if (text == null) return -1;
291+
if (!clipboard.setContents(text)) return -1;
293292

293+
int newID = -1;
294294
try {
295295
if (!popup.lockCheckbox.isSelected()) {
296296
newID = db.getThreadConnection().makeLast(text);
@@ -300,6 +300,15 @@ public int paste (String text) {
300300
if (ERROR) error("Error moving clipboard text to last.", ex);
301301
}
302302

303+
return newID;
304+
}
305+
306+
/** @param text May be null.
307+
* @return The new ID for the clipboard item that was moved to last, or -1. */
308+
public int paste (String text) {
309+
int newID = current(text);
310+
if (newID == -1) return -1;
311+
303312
// Could use SendInput or menu->Edit->Paste, or users could install the clink CMD prompt addon or use Windows 10.
304313
// char[] chars = new char[2048];
305314
// int count = GetClassName(GetForegroundWindow(), chars, chars.length);

src/com/esotericsoftware/clippy/Config.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class Config {
6060
public int popupSearchCount = 60;
6161
public boolean popupDefaultNumbers;
6262
public String popupHotkey = "ctrl shift INSERT";
63+
public boolean popupPastes = true;
6364
public String font = "Consolas-14";
6465

6566
public String screenshotHotkey = null;

src/com/esotericsoftware/clippy/Popup.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,11 @@ public void selected () {
598598
void pasteItem (int id, String text) {
599599
if (text == null) throw new RuntimeException("Invalid item ID: " + id);
600600
hidePopup();
601-
int newID = clippy.paste(text);
601+
int newID;
602+
if (clippy.config.popupPastes)
603+
newID = clippy.paste(text);
604+
else
605+
newID = clippy.current(text);
602606
if (newID != -1) addRecentItem(newID, text);
603607
}
604608

0 commit comments

Comments
 (0)