From f56436a19d8a9ef68536f06af2b43e24b229978a Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 20 Jan 2015 19:05:51 -0500 Subject: [PATCH] well, time for the 'ole git push that destroys everything, leaving devastation as i leave for the day. --- app/src/processing/app/Base.java | 12 +++--- app/src/processing/app/Editor.java | 23 ++++++++++- app/src/processing/app/Toolkit.java | 4 +- .../processing/app/syntax/JEditTextArea.java | 3 +- .../mode/java/debug/DebugEditor.java | 38 ++++++++++++++++++- .../mode/java/pdex/XQPreprocessor.java | 16 ++++---- todo.txt | 10 +++-- 7 files changed, 83 insertions(+), 23 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 1f8d1a8d2..71ab1ab9b 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -53,8 +53,8 @@ public class Base { // static private boolean RELEASE = false; /** True if heavy debugging error/log messages are enabled */ -// static public boolean DEBUG = false; - static public boolean DEBUG = true; + static public boolean DEBUG = false; +// static public boolean DEBUG = true; static HashMap platformNames = new HashMap(); @@ -2235,7 +2235,7 @@ public class Base { // Path may have URL encoding, so remove it String decodedPath = PApplet.urlDecode(path); - if (decodedPath.contains("/app/bin")) { + if (decodedPath.contains("/app/bin")) { // This means we're in Eclipse if (Base.isMacOS()) { processingRoot = new File(path, "../../build/macosx/work/Processing.app/Contents/Java"); @@ -2252,11 +2252,9 @@ public class Base { // This works for Windows, Linux, and Apple's Java 6 on OS X. processingRoot = jarFolder.getParentFile(); } else if (Base.isMacOS()) { - // This works for Java 7 on OS X. The 'lib' folder is not part of the - // classpath on OS X, and adding it creates more problems than it's - // worth. + // This works for Java 8 on OS X. We don't have things inside a 'lib' + // folder on OS X. Adding it caused more problems than it was worth. processingRoot = jarFolder; - } if (processingRoot == null || !processingRoot.exists()) { // Try working directory instead (user.dir, different from user.home) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 5958e6254..2067629b5 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -304,7 +304,28 @@ public abstract class Editor extends JFrame implements RunnerListener { * solution where the listeners are handled properly. */ protected JEditTextArea createTextArea() { - return new JEditTextArea(new PdeTextAreaDefaults(mode)); + return new JEditTextArea(new PdeTextAreaDefaults(mode)) { + // this is a kludge that needs to be removed [fry 150120] + public void processKeyEvent(KeyEvent evt) { + // this had to be added in Processing 007X, because the menu key + // events weren't making it up to the frame. + super.processKeyEvent(evt); + + if (inputHandler != null) { + switch (evt.getID()) { + case KeyEvent.KEY_TYPED: + inputHandler.keyTyped(evt); + break; + case KeyEvent.KEY_PRESSED: + inputHandler.keyPressed(evt); + break; + case KeyEvent.KEY_RELEASED: + inputHandler.keyReleased(evt); + break; + } + } + } + }; } diff --git a/app/src/processing/app/Toolkit.java b/app/src/processing/app/Toolkit.java index 3c387175d..1b21680d6 100644 --- a/app/src/processing/app/Toolkit.java +++ b/app/src/processing/app/Toolkit.java @@ -725,8 +725,8 @@ public class Toolkit { if (!fontFile.exists()) { // if we're debugging from Eclipse, grab it from the work folder (user.dir is /app) //fontFile = new File(System.getProperty("user.dir"), "../build/shared/lib/fonts/" + filename); - // if we're debugging Java Mode from Eclipse, user.dir is the work folder - fontFile = new File(System.getProperty("user.dir"), "../../build/shared/lib/fonts/" + filename); + // if we're debugging the new Java Mode from Eclipse, paths are different + fontFile = new File(System.getProperty("user.dir"), "../../shared/lib/fonts/" + filename); } BufferedInputStream input = new BufferedInputStream(new FileInputStream(fontFile)); Font font = Font.createFont(Font.TRUETYPE_FONT, input); diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 763c44831..e44759b47 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -1962,8 +1962,9 @@ public class JEditTextArea extends JComponent break; } } - */ + */ + // protected members protected static String CENTER = "center"; protected static String RIGHT = "right"; diff --git a/java/src/processing/mode/java/debug/DebugEditor.java b/java/src/processing/mode/java/debug/DebugEditor.java index 9e4c99b27..02ac8c4d8 100644 --- a/java/src/processing/mode/java/debug/DebugEditor.java +++ b/java/src/processing/mode/java/debug/DebugEditor.java @@ -81,6 +81,7 @@ import processing.app.syntax.JEditTextArea; import processing.app.syntax.PdeTextAreaDefaults; import processing.core.PApplet; import processing.mode.java.JavaEditor; +import processing.mode.java.PdeKeyListener; import processing.mode.java.pdex.ErrorBar; import processing.mode.java.pdex.ErrorCheckerService; import processing.mode.java.pdex.ErrorMessageSimplifier; @@ -1297,11 +1298,44 @@ public class DebugEditor extends JavaEditor implements ActionListener { * @return the customized text area object */ @Override +// protected JEditTextArea createTextArea() { +// //System.out.println("overriding creation of text area"); +// return new TextArea(new PdeTextAreaDefaults(mode), this); +// } protected JEditTextArea createTextArea() { - //System.out.println("overriding creation of text area"); - return new TextArea(new PdeTextAreaDefaults(mode), this); + return new TextArea(new PdeTextAreaDefaults(mode), this) { + // Forwards key events directly to the input handler. This is slightly + // faster than using a KeyListener because some Swing overhead is avoided. + PdeKeyListener editorListener = new PdeKeyListener(DebugEditor.this, this); + + // Moved out of JEditTextArea for 3.0a6 to remove dependency on Java Mode + public void processKeyEvent(KeyEvent evt) { + // this had to be added in Processing 007X, because the menu key + // events weren't making it up to the frame. + super.processKeyEvent(evt); + + if (inputHandler != null) { + switch (evt.getID()) { + case KeyEvent.KEY_TYPED: + if ((editorListener == null) || !editorListener.keyTyped(evt)) { + inputHandler.keyTyped(evt); + } + break; + case KeyEvent.KEY_PRESSED: + if ((editorListener == null) || !editorListener.keyPressed(evt)) { + inputHandler.keyPressed(evt); + } + break; + case KeyEvent.KEY_RELEASED: + inputHandler.keyReleased(evt); + break; + } + } + } + }; } + /** * Set the line to highlight as currently suspended at. Will override the * breakpoint color, if set. Switches to the appropriate tab and scroll to diff --git a/java/src/processing/mode/java/pdex/XQPreprocessor.java b/java/src/processing/mode/java/pdex/XQPreprocessor.java index ee47da0f9..6908bac28 100644 --- a/java/src/processing/mode/java/pdex/XQPreprocessor.java +++ b/java/src/processing/mode/java/pdex/XQPreprocessor.java @@ -58,12 +58,14 @@ public class XQPreprocessor { private String[] coreImports, defaultImports; + public XQPreprocessor() { PdePreprocessor p = new PdePreprocessor(null); defaultImports = p.getDefaultImports(); coreImports = p.getCoreImports(); } + /** * The main method that performs preprocessing. Converts code into compilable java. * @param source - String @@ -71,7 +73,7 @@ public class XQPreprocessor { * @return String - Compile ready java code */ public String doYourThing(String source, - ArrayList programImports) { + ArrayList programImports) { this.extraImports = programImports; //source = prepareImports() + source; Document doc = new Document(source); @@ -118,9 +120,9 @@ public class XQPreprocessor { return doc.get(); } + /** * Returns all import statements as lines of code - * * @return String - All import statements combined. Each import in a separate line. */ public String prepareImports() { @@ -143,11 +145,13 @@ public class XQPreprocessor { return totalImports; } + public String prepareImports(ArrayList programImports) { this.extraImports = programImports; return prepareImports(); } + /** * Visitor implementation that does all the substitution dirty work.
*
  • Any function not specified as being protected or private will be made @@ -190,6 +194,7 @@ public class XQPreprocessor { return true; } + public boolean visit(NumberLiteral node) { if (!node.getToken().endsWith("f") @@ -206,6 +211,7 @@ public class XQPreprocessor { return true; } + // public boolean visit(FieldDeclaration node) { // if (node.getType().toString().equals("color")){ // System.err.println("color type detected!"); @@ -231,13 +237,9 @@ public class XQPreprocessor { */ public boolean visit(SimpleType node) { if (node.toString().equals("color")) { - System.err - .println("color type detected! \nThis shouldn't be happening! Please report this as an issue."); + System.err.println("color type detected! \nThis shouldn't be happening! Please report this as an issue."); } return true; - } - } - } diff --git a/todo.txt b/todo.txt index 9774077be..13c4de0f2 100644 --- a/todo.txt +++ b/todo.txt @@ -78,11 +78,15 @@ X https://github.com/processing/processing/pull/3048 integration of pdex +X changed JLS4 to JLS8 (but make sure it doesn't introduce anything too weird) +X change build scripts, get things running _ remove public 'ta' object in DebugEditor, also dmode _ rename TextArea and TextAreaPainter to JavaTextArea - -@SuppressWarnings({ "unused", "unchecked", "cast" }) -change JLS4 to JLS8 (but make sure it doesn't introduce anything too weird) +_ DebugEditor.createTextArea() is copy & pasted from JavaEditor +_ this whole setup is really gross at the moment +_ auto-insert after antlr @SuppressWarnings({ "unused", "unchecked", "cast" }) +_ crashed on startup w/ JavaScript mode as default b/c PdeKeyListener not found +_ because it's in the other package, can no longer rely on it _ make examples pull/build automatic during dist