diff --git a/app/.classpath b/app/.classpath
index b7dd58fc4bc..cbc51d593bb 100644
--- a/app/.classpath
+++ b/app/.classpath
@@ -4,7 +4,6 @@
-
@@ -44,6 +43,7 @@
+
@@ -53,4 +53,5 @@
+
diff --git a/app/.project b/app/.project
index 69a82c3d004..a4bf3cc2226 100644
--- a/app/.project
+++ b/app/.project
@@ -1,6 +1,6 @@
- processing
+ app
diff --git a/app/lib/autocomplete-2.6.1.jar b/app/lib/autocomplete-2.6.1.jar
new file mode 100755
index 00000000000..46964593fea
Binary files /dev/null and b/app/lib/autocomplete-2.6.1.jar differ
diff --git a/app/src/cc/arduino/autocomplete/BaseCCompletionProvider.java b/app/src/cc/arduino/autocomplete/BaseCCompletionProvider.java
new file mode 100755
index 00000000000..a37aaef1d98
--- /dev/null
+++ b/app/src/cc/arduino/autocomplete/BaseCCompletionProvider.java
@@ -0,0 +1,40 @@
+/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
+
+/*
+ Part of the Arduino project - http://www.arduino.cc
+
+ Copyright (c) 2015 Matthijs Kooijman
+ Copyright (c) 2004-09 Ben Fry and Casey Reas
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+package cc.arduino.autocomplete;
+
+import org.fife.ui.autocomplete.DefaultCompletionProvider;
+
+/**
+ * Base completion provider for C/C++.
+ * @author Ricardo JL Rufino (ricardo@criativasoft.com.br)
+ * @date 28/04/2017
+ */
+public class BaseCCompletionProvider extends DefaultCompletionProvider{
+
+ @Override
+ protected boolean isValidChar(char ch) {
+ return super.isValidChar(ch) || '.' == ch || '>' == ch || '-' == ch || '<' == ch || '#' == ch || ':' == ch /**|| getParameterListStart() == ch */;
+ }
+
+}
diff --git a/app/src/cc/arduino/autocomplete/FakeCompletionProvider.java b/app/src/cc/arduino/autocomplete/FakeCompletionProvider.java
new file mode 100755
index 00000000000..62c3b8f1795
--- /dev/null
+++ b/app/src/cc/arduino/autocomplete/FakeCompletionProvider.java
@@ -0,0 +1,51 @@
+/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
+
+/*
+ Part of the Arduino project - http://www.arduino.cc
+
+ Copyright (c) 2015 Matthijs Kooijman
+ Copyright (c) 2004-09 Ben Fry and Casey Reas
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+package cc.arduino.autocomplete;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.text.JTextComponent;
+
+import org.fife.ui.autocomplete.BasicCompletion;
+import org.fife.ui.autocomplete.Completion;
+
+import processing.app.syntax.SketchTextArea;
+
+public class FakeCompletionProvider extends BaseCCompletionProvider {
+
+ @Override
+ protected List getCompletionsImpl(JTextComponent comp) {
+ List list = new LinkedList<>();
+
+ SketchTextArea area = (SketchTextArea) comp;
+
+ list.add(new BasicCompletion(this, "Text: " + getAlreadyEnteredText(comp)));
+ list.add(new BasicCompletion(this, "Line: " + area.getCaretLineNumber()));
+
+ return list;
+ }
+
+
+}
diff --git a/app/src/cc/arduino/autocomplete/SketchCompletionProvider.java b/app/src/cc/arduino/autocomplete/SketchCompletionProvider.java
new file mode 100755
index 00000000000..961e483ea04
--- /dev/null
+++ b/app/src/cc/arduino/autocomplete/SketchCompletionProvider.java
@@ -0,0 +1,50 @@
+/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
+
+/*
+ Part of the Arduino project - http://www.arduino.cc
+
+ Copyright (c) 2015 Matthijs Kooijman
+ Copyright (c) 2004-09 Ben Fry and Casey Reas
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+package cc.arduino.autocomplete;
+
+import org.fife.ui.autocomplete.CompletionProvider;
+import org.fife.ui.autocomplete.LanguageAwareCompletionProvider;
+
+import processing.app.Sketch;
+import processing.app.syntax.SketchTextArea;
+
+/**
+ * CompletionProvider for Arduino/CPP Language.
+ * Setup basic logic for completions using {@link LanguageAwareCompletionProvider}.
+ * Filtering and decision will appear in the autocomplete dialog by implementations of: {@link CompletionProvider}.
+ *
+ * @author Ricardo JL Rufino (ricardo@criativasoft.com.br)
+ * @date 28/04/2017
+ */
+public class SketchCompletionProvider extends LanguageAwareCompletionProvider {
+
+ public SketchCompletionProvider(Sketch sketch, SketchTextArea textArea, CompletionProvider provider) {
+
+ setDefaultCompletionProvider(provider);
+ // provider.setParameterChoicesProvider(new ParameterChoicesProvider(this));
+ // provider.setParameterizedCompletionParams('(', ", ", ')');
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/processing/app/EditorTab.java b/app/src/processing/app/EditorTab.java
index eab701d80a0..0eb4b1b90d9 100644
--- a/app/src/processing/app/EditorTab.java
+++ b/app/src/processing/app/EditorTab.java
@@ -47,6 +47,8 @@
import javax.swing.text.DefaultCaret;
import javax.swing.text.Document;
+import org.fife.ui.autocomplete.AutoCompletion;
+import org.fife.ui.autocomplete.CompletionProvider;
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit;
import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities;
@@ -54,6 +56,8 @@
import org.fife.ui.rtextarea.RTextScrollPane;
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
+import cc.arduino.autocomplete.FakeCompletionProvider;
+import cc.arduino.autocomplete.SketchCompletionProvider;
import processing.app.helpers.DocumentTextChangeListener;
import processing.app.syntax.ArduinoTokenMakerFactory;
import processing.app.syntax.PdeKeywords;
@@ -106,6 +110,24 @@ public EditorTab(Editor editor, SketchFile file, String contents)
file.setStorage(this);
applyPreferences();
add(scrollPane, BorderLayout.CENTER);
+
+ // setAutocompletionProvider(new FakeCompletionProvider());
+ }
+
+ public void setAutocompletionProvider(CompletionProvider provider) {
+
+ SketchCompletionProvider completionProvider = new SketchCompletionProvider(editor.getSketch(), textarea, provider);
+
+ AutoCompletion ac = new AutoCompletion( completionProvider );
+
+ ac.setAutoActivationEnabled(true);
+ ac.setShowDescWindow(false);
+ ac.setAutoCompleteSingleChoices(true);
+ ac.setParameterAssistanceEnabled(true);
+// ac.setParamChoicesRenderer(new CompletionsRenderer());
+// ac.setListCellRenderer(new CompletionsRenderer());
+ ac.install(textarea);
+
}
private RSyntaxDocument createDocument(String contents) {
diff --git a/app/src/processing/app/syntax/SketchTextArea.java b/app/src/processing/app/syntax/SketchTextArea.java
index a2d78703ac1..e0a1c253d46 100644
--- a/app/src/processing/app/syntax/SketchTextArea.java
+++ b/app/src/processing/app/syntax/SketchTextArea.java
@@ -30,24 +30,12 @@
package processing.app.syntax;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Font;
+import java.awt.Insets;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
-import javax.swing.KeyStroke;
-import org.apache.commons.compress.utils.IOUtils;
-import org.fife.ui.rsyntaxtextarea.*;
-import org.fife.ui.rsyntaxtextarea.Token;
-import org.fife.ui.rtextarea.RTextArea;
-import org.fife.ui.rtextarea.RTextAreaUI;
-import processing.app.Base;
-import processing.app.BaseNoGui;
-import processing.app.PreferencesData;
-
-import javax.swing.event.EventListenerList;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Segment;
-import java.awt.*;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
@@ -56,6 +44,34 @@
import java.net.URL;
import java.util.Map;
import java.util.logging.Logger;
+
+import javax.swing.KeyStroke;
+import javax.swing.event.EventListenerList;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Segment;
+
+import org.apache.commons.compress.utils.IOUtils;
+import org.fife.ui.autocomplete.AutoCompletion;
+import org.fife.ui.autocomplete.CompletionProvider;
+import org.fife.ui.rsyntaxtextarea.LinkGenerator;
+import org.fife.ui.rsyntaxtextarea.LinkGeneratorResult;
+import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
+import org.fife.ui.rsyntaxtextarea.Style;
+import org.fife.ui.rsyntaxtextarea.Theme;
+import org.fife.ui.rsyntaxtextarea.Token;
+import org.fife.ui.rsyntaxtextarea.TokenImpl;
+import org.fife.ui.rsyntaxtextarea.TokenTypes;
+import org.fife.ui.rtextarea.RTextArea;
+import org.fife.ui.rtextarea.RTextAreaUI;
+
+import cc.arduino.autocomplete.SketchCompletionProvider;
+import processing.app.Base;
+import processing.app.BaseNoGui;
+import processing.app.PreferencesData;
+import processing.app.Sketch;
import processing.app.helpers.OSUtils;
/**
@@ -69,7 +85,7 @@ public class SketchTextArea extends RSyntaxTextArea {
private final static Logger LOG = Logger.getLogger(SketchTextArea.class.getName());
private PdeKeywords pdeKeywords;
-
+
public SketchTextArea(RSyntaxDocument document, PdeKeywords pdeKeywords) throws IOException {
super(document);
this.pdeKeywords = pdeKeywords;
@@ -81,6 +97,22 @@ public void setKeywords(PdeKeywords keywords) {
pdeKeywords = keywords;
setLinkGenerator(new DocLinkGenerator(pdeKeywords));
}
+
+ public void setupAutoComplete(Sketch sketch, CompletionProvider provider) {
+
+ SketchCompletionProvider completionProvider = new SketchCompletionProvider(sketch, this, provider);
+
+ AutoCompletion ac = new AutoCompletion( completionProvider );
+
+ ac.setAutoActivationEnabled(true);
+ ac.setShowDescWindow(false);
+ ac.setAutoCompleteSingleChoices(true);
+ ac.setParameterAssistanceEnabled(true);
+// ac.setParamChoicesRenderer(new CompletionsRenderer());
+// ac.setListCellRenderer(new CompletionsRenderer());
+ ac.install(this);
+
+ }
private void installFeatures() throws IOException {
setTheme(PreferencesData.get("editor.syntax_theme", "default"));
diff --git a/arduino-core/.classpath b/arduino-core/.classpath
index 4167a9dd3cd..2d35f9fbe44 100644
--- a/arduino-core/.classpath
+++ b/arduino-core/.classpath
@@ -11,16 +11,16 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/arduino-core/src/processing/app/SketchFile.java b/arduino-core/src/processing/app/SketchFile.java
index 0a6f4cc4d09..64e19347b72 100644
--- a/arduino-core/src/processing/app/SketchFile.java
+++ b/arduino-core/src/processing/app/SketchFile.java
@@ -246,7 +246,7 @@ public boolean isModified() {
public boolean equals(Object o) {
return (o instanceof SketchFile) && file.equals(((SketchFile) o).file);
}
-
+
/**
* Load this piece of code from a file and return the contents. This
* completely ignores any changes in the linked storage, if any, and
diff --git a/build/windows/launcher/config.xml b/build/windows/launcher/config.xml
index 2abf18455c7..a5ca4ca5d94 100644
--- a/build/windows/launcher/config.xml
+++ b/build/windows/launcher/config.xml
@@ -50,6 +50,7 @@
%EXEDIR%/lib/jssc-2.8.0.jar
%EXEDIR%/lib/pde.jar
%EXEDIR%/lib/rsyntaxtextarea-2.6.1.jar
+ %EXEDIR%/lib/autocomplete-2.6.1.jar
%EXEDIR%/lib/xml-apis-1.3.04.jar
%EXEDIR%/lib/xml-apis-ext-1.3.04.jar
%EXEDIR%/lib/xmlgraphics-commons-2.0.jar
diff --git a/build/windows/launcher/config_debug.xml b/build/windows/launcher/config_debug.xml
index 04386666306..fd0b964e010 100644
--- a/build/windows/launcher/config_debug.xml
+++ b/build/windows/launcher/config_debug.xml
@@ -50,6 +50,7 @@
%EXEDIR%/lib/jssc-2.8.0.jar
%EXEDIR%/lib/pde.jar
%EXEDIR%/lib/rsyntaxtextarea-2.6.1.jar
+ %EXEDIR%/lib/autocomplete-2.6.1.jar
%EXEDIR%/lib/xml-apis-1.3.04.jar
%EXEDIR%/lib/xml-apis-ext-1.3.04.jar
%EXEDIR%/lib/xmlgraphics-commons-2.0.jar