From 92d0555a374fdeffd4bb1f585a0c13a295f5bb46 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Sat, 16 Aug 2014 16:52:47 +0530 Subject: [PATCH] add source option for CC insert --- .../mode/experimental/CompletionPanel.java | 13 +++++++++++-- pdex/src/processing/mode/experimental/TextArea.java | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pdex/src/processing/mode/experimental/CompletionPanel.java b/pdex/src/processing/mode/experimental/CompletionPanel.java index a81bd0ad5..d56c38bf6 100644 --- a/pdex/src/processing/mode/experimental/CompletionPanel.java +++ b/pdex/src/processing/mode/experimental/CompletionPanel.java @@ -86,6 +86,8 @@ public class CompletionPanel { private JScrollPane scrollPane; protected DebugEditor editor; + + public static final int MOUSE_COMPLETION = 10, KEYBOARD_COMPLETION = 20; /** * Triggers the completion popup @@ -254,7 +256,7 @@ public class CompletionPanel { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { - insertSelection(); + insertSelection(MOUSE_COMPLETION); hide(); } } @@ -296,7 +298,7 @@ public class CompletionPanel { * * @return */ - public boolean insertSelection() { + public boolean insertSelection(int completionSource) { if (completionList.getSelectedValue() != null) { try { // If user types 'abc.', subword becomes '.' and null is returned @@ -324,6 +326,13 @@ public class CompletionPanel { } } + if (completionSource == MOUSE_COMPLETION) { + if (completionString.endsWith("(")) { + completionString = completionString.substring(0, completionString + .length() - 2); + } + } + logE(subWord + " <= subword, Inserting suggestion=> " + selectedSuggestion + " Current sub: " + currentSubword); if (currentSubword.length() > 0) { diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index f6c1e0964..3c7f4d345 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -163,7 +163,7 @@ public class TextArea extends JEditTextArea { else if(evt.getKeyCode() == KeyEvent.VK_ENTER && evt.getID() == KeyEvent.KEY_PRESSED){ if (suggestion != null) { if (suggestion.isVisible()) { - if (suggestion.insertSelection()) { + if (suggestion.insertSelection(CompletionPanel.KEYBOARD_COMPLETION)) { //hideSuggestion(); // Kill it! evt.consume(); // Still try to show suggestions after inserting if it's