diff --git a/core/todo.txt b/core/todo.txt index 09fe69ecf..d956d5166 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -15,6 +15,9 @@ X could add -Dapp.root=$APP_ROOT and get via System.getProperty("app.root") X https://github.com/processing/processing/issues/2181 X textWidth() incorrect with default (JAVA2D) renderer and default font X https://github.com/processing/processing/issues/2175 +X Error on size() when using FX2D due to stage inset issues +X https://github.com/processing/processing/issues/3412 +X probably fixes w/ size() removal change jakub X Remove alpha filler (hopefully no regression here) @@ -58,8 +61,6 @@ _ https://github.com/processing/processing/issues/2063 javafx -_ Error on size() when using FX2D due to stage inset issues -_ https://github.com/processing/processing/issues/3412 _ static mode sketches (draw once and halt w/o closing window) _ fix display handling, line up the device order with AWT _ https://docs.oracle.com/javafx/2/api/javafx/stage/Screen.html diff --git a/java/src/processing/mode/java/Commander.java b/java/src/processing/mode/java/Commander.java index 9a193b83a..4a3b1b7ce 100644 --- a/java/src/processing/mode/java/Commander.java +++ b/java/src/processing/mode/java/Commander.java @@ -112,10 +112,10 @@ public class Commander implements RunnerListener { System.exit(1); } -// File preferencesFile = Base.getSettingsFile("preferences.txt"); -// System.out.println("Preferences file at " + preferencesFile.getAbsolutePath()); - + int argOffset = 0; for (String arg : args) { + argOffset++; + if (arg.length() == 0) { // ignore it, just the crappy shell script @@ -127,18 +127,19 @@ public class Commander implements RunnerListener { } else if (arg.equals(buildArg)) { task = BUILD; + break; } else if (arg.equals(runArg)) { task = RUN; + break; } else if (arg.equals(presentArg)) { task = PRESENT; - -// } else if (arg.equals(exportAppletArg)) { -// task = EXPORT_APPLET; + break; } else if (arg.equals(exportApplicationArg)) { task = EXPORT; + break; } else if (arg.equals(noJavaArg)) { embedJava = false; @@ -189,6 +190,7 @@ public class Commander implements RunnerListener { complainAndQuit("I don't know anything about " + arg + ".", true); } } + String[] sketchArgs = PApplet.subset(args, argOffset); // if ((outputPath == null) && // (task == PREPROCESS || task == BUILD || @@ -268,7 +270,11 @@ public class Commander implements RunnerListener { success = true; if (task == RUN || task == PRESENT) { Runner runner = new Runner(build, this); - runner.launch(task == PRESENT); + if (task == PRESENT) { + runner.present(sketchArgs); + } else { + runner.launch(sketchArgs); + } } } else { success = false; @@ -369,7 +375,7 @@ public class Commander implements RunnerListener { out.println(); out.println("--build Preprocess and compile a sketch into .class files."); out.println("--run Preprocess, compile, and run a sketch."); - out.println("--present Preprocess, compile, and run a sketch full screen."); + out.println("--present Preprocess, compile, and run a sketch in presentation mode."); out.println(); out.println("--export Export an application."); out.println("--no-java Do not embed Java. Use at your own risk!"); @@ -378,6 +384,13 @@ public class Commander implements RunnerListener { // out.println("--bits Must be specified if libraries are used that are"); // out.println(" 32- or 64-bit specific such as the OpenGL library."); // out.println(" Otherwise specify 0 or leave it out."); + + out.println("The --build, --run, --present, or --export must be the final parameter."); + out.println("Additional arguments will be passed to the sketch itself and available"); + out.println("in the sketch's 'args' field. To pass options understood by PApplet.main(),"); + out.println("write a custom main() method so that the preprocessor does not add one."); + out.println("https://github.com/processing/processing/wiki/Command-Line"); + out.println(); } diff --git a/java/src/processing/mode/java/Debugger.java b/java/src/processing/mode/java/Debugger.java index 7c7307839..9f79a1fee 100644 --- a/java/src/processing/mode/java/Debugger.java +++ b/java/src/processing/mode/java/Debugger.java @@ -216,7 +216,7 @@ public class Debugger implements VMEventListener { log(Level.INFO, "launching debuggee runtime"); runtime = new Runner(build, editor); - VirtualMachine vm = runtime.launchDebug(); // non-blocking + VirtualMachine vm = runtime.debug(null); // non-blocking if (vm == null) { log(Level.SEVERE, "error 37: launch failed"); } diff --git a/java/src/processing/mode/java/JavaMode.java b/java/src/processing/mode/java/JavaMode.java index a6fcfdbf0..a88d2e24f 100644 --- a/java/src/processing/mode/java/JavaMode.java +++ b/java/src/processing/mode/java/JavaMode.java @@ -149,7 +149,12 @@ public class JavaMode extends Mode { final Runner runtime = new Runner(build, listener); new Thread(new Runnable() { public void run() { - runtime.launch(present); // this blocks until finished + // these block until finished + if (present) { + runtime.present(null); + } else { + runtime.launch(null); + } } }).start(); return runtime; @@ -197,15 +202,20 @@ public class JavaMode extends Mode { if (appletClassName != null) { final Runner runtime = new Runner(build, listener); new Thread(new Runnable() { - public void run() { - runtime.launch(present); // this blocks until finished - // next lines are executed when the sketch quits - if (launchInteractive) { - editor.initEditorCode(parser.allHandles, false); - editor.stopTweakMode(parser.allHandles); - } + public void run() { + // these block until finished + if (present) { + runtime.present(null); + } else { + runtime.launch(null); } - }).start(); + // next lines are executed when the sketch quits + if (launchInteractive) { + editor.initEditorCode(parser.allHandles, false); + editor.stopTweakMode(parser.allHandles); + } + } + }).start(); if (launchInteractive) { // replace editor code with baseCode diff --git a/java/src/processing/mode/java/runner/Runner.java b/java/src/processing/mode/java/runner/Runner.java index 7aa4175a1..2410e9c2c 100644 --- a/java/src/processing/mode/java/runner/Runner.java +++ b/java/src/processing/mode/java/runner/Runner.java @@ -26,6 +26,7 @@ import processing.app.*; import processing.app.exec.StreamRedirectThread; import processing.app.ui.Editor; import processing.core.*; +import processing.data.StringList; import processing.mode.java.JavaBuild; import java.awt.GraphicsDevice; @@ -113,10 +114,19 @@ public class Runner implements MessageConsumer { } - public void launch(boolean presenting) { - if (launchVirtualMachine(presenting)) { + public VirtualMachine launch(String[] args) { + if (launchVirtualMachine(false, args)) { generateTrace(); } + return vm; + } + + + public VirtualMachine present(String[] args) { + if (launchVirtualMachine(true, args)) { + generateTrace(); + } + return vm; } @@ -124,8 +134,8 @@ public class Runner implements MessageConsumer { * Simple non-blocking launch of the virtual machine. VM starts suspended. * @return debuggee VM or null on failure */ - public VirtualMachine launchDebug() { - if (launchVirtualMachine(false)) { // will return null on failure + public VirtualMachine debug(String[] args) { + if (launchVirtualMachine(false, args)) { // will return null on failure redirectStreams(vm); } return vm; @@ -153,9 +163,9 @@ public class Runner implements MessageConsumer { } - public boolean launchVirtualMachine(boolean presenting) { - String[] vmParams = getMachineParams(); - String[] sketchParams = getSketchParams(presenting); + public boolean launchVirtualMachine(boolean present, String[] args) { + StringList vmParams = getMachineParams(); + StringList sketchParams = getSketchParams(present, args); // PApplet.printArray(sketchParams); int port = 8000 + (int) (Math.random() * 1000); String portStr = String.valueOf(port); @@ -167,13 +177,13 @@ public class Runner implements MessageConsumer { String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y"; // Everyone works the same under Java 7 (also on OS X) - String[] commandArgs = new String[] { Platform.getJavaPath(), jdwpArg }; + StringList commandArgs = new StringList(); + commandArgs.append(Platform.getJavaPath()); + commandArgs.append(jdwpArg); - commandArgs = PApplet.concat(commandArgs, vmParams); - commandArgs = PApplet.concat(commandArgs, sketchParams); -// PApplet.println(commandArgs); -// commandArg.setValue(commandArgs); - launchJava(commandArgs); + commandArgs.append(vmParams); + commandArgs.append(sketchParams); + launchJava(commandArgs.array()); AttachingConnector connector = (AttachingConnector) findConnector("com.sun.jdi.SocketAttach"); @@ -228,8 +238,8 @@ public class Runner implements MessageConsumer { } - protected String[] getMachineParams() { - ArrayList params = new ArrayList(); + protected StringList getMachineParams() { + StringList params = new StringList(); //params.add("-Xint"); // interpreted mode //params.add("-Xprof"); // profiler @@ -244,7 +254,7 @@ public class Runner implements MessageConsumer { for (int i = 0; i < pieces.length; i++) { String p = pieces[i].trim(); if (p.length() > 0) { - params.add(p); + params.append(p); } } } @@ -252,65 +262,45 @@ public class Runner implements MessageConsumer { // params.add("-Djava.ext.dirs=nuffing"); if (Preferences.getBoolean("run.options.memory")) { - params.add("-Xms" + Preferences.get("run.options.memory.initial") + "m"); - params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m"); + params.append("-Xms" + Preferences.get("run.options.memory.initial") + "m"); + params.append("-Xmx" + Preferences.get("run.options.memory.maximum") + "m"); } if (Platform.isMacOS()) { - params.add("-Xdock:name=" + build.getSketchClassName()); + params.append("-Xdock:name=" + build.getSketchClassName()); // params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" + // sketch.getMainClassName()); } // sketch.libraryPath might be "" // librariesClassPath will always have sep char prepended - params.add("-Djava.library.path=" + - build.getJavaLibraryPath() + - File.pathSeparator + - System.getProperty("java.library.path")); + params.append("-Djava.library.path=" + + build.getJavaLibraryPath() + + File.pathSeparator + + System.getProperty("java.library.path")); - params.add("-cp"); - params.add(build.getClassPath()); -// params.add(sketch.getClassPath() + -// File.pathSeparator + -// Base.librariesClassPath); + params.append("-cp"); + params.append(build.getClassPath()); // enable assertions // http://dev.processing.org/bugs/show_bug.cgi?id=1188 - params.add("-ea"); + params.append("-ea"); //PApplet.println(PApplet.split(sketch.classPath, ':')); - String outgoing[] = new String[params.size()]; - params.toArray(outgoing); - -// PApplet.println(outgoing); -// PApplet.println(PApplet.split(outgoing[0], ":")); -// PApplet.println(); -// PApplet.println("class path"); -// PApplet.println(PApplet.split(outgoing[2], ":")); - - return outgoing; - //return (String[]) params.toArray(); - -// System.out.println("sketch class path"); -// PApplet.println(PApplet.split(sketch.classPath, ';')); -// System.out.println(); -// System.out.println("libraries class path"); -// PApplet.println(PApplet.split(Base.librariesClassPath, ';')); -// System.out.println(); + return params; } - protected String[] getSketchParams(boolean presenting) { - ArrayList params = new ArrayList(); + protected StringList getSketchParams(boolean present, String[] args) { + StringList params = new StringList(); // It's dangerous to add your own main() to your code, // but if you've done it, we'll respect your right to hang yourself. // http://processing.org/bugs/bugzilla/1446.html if (build.getFoundMain()) { - params.add(build.getSketchClassName()); + params.append(build.getSketchClassName()); } else { - params.add("processing.core.PApplet"); + params.append("processing.core.PApplet"); // get the stored device index (starts at 1) int runDisplay = Preferences.getInteger("run.display"); @@ -366,8 +356,8 @@ public class Runner implements MessageConsumer { // If sketches are to be shown on the same display as the editor, // provide the editor location so the sketch's main() can place it. Point editorLocation = editor.getLocation(); - params.add(PApplet.ARGS_EDITOR_LOCATION + "=" + - editorLocation.x + "," + editorLocation.y); + params.append(PApplet.ARGS_EDITOR_LOCATION + "=" + + editorLocation.x + "," + editorLocation.y); } else { // The sketch's main() will set a location centered on the new // display. It has to happen in main() because the width/height @@ -379,37 +369,38 @@ public class Runner implements MessageConsumer { // params.add(PApplet.ARGS_LOCATION + "=" + runX + "," + runY); } } else { - params.add(PApplet.ARGS_LOCATION + "=" + - windowLocation.x + "," + windowLocation.y); + params.append(PApplet.ARGS_LOCATION + "=" + + windowLocation.x + "," + windowLocation.y); } - params.add(PApplet.ARGS_EXTERNAL); + params.append(PApplet.ARGS_EXTERNAL); } - params.add(PApplet.ARGS_DISPLAY + "=" + runDisplay); + params.append(PApplet.ARGS_DISPLAY + "=" + runDisplay); - if (presenting) { - params.add(PApplet.ARGS_PRESENT); + if (present) { + params.append(PApplet.ARGS_PRESENT); // if (Preferences.getBoolean("run.present.exclusive")) { // params.add(PApplet.ARGS_EXCLUSIVE); // } - params.add(PApplet.ARGS_STOP_COLOR + "=" + - Preferences.get("run.present.stop.color")); - params.add(PApplet.ARGS_WINDOW_COLOR + "=" + - Preferences.get("run.present.bgcolor")); + params.append(PApplet.ARGS_STOP_COLOR + "=" + + Preferences.get("run.present.stop.color")); + params.append(PApplet.ARGS_WINDOW_COLOR + "=" + + Preferences.get("run.present.bgcolor")); } // There was a PDE X hack that put this after the class name, but it was // removed for 3.0a6 because it would break the args passed to sketches. - params.add(PApplet.ARGS_SKETCH_FOLDER + "=" + build.getSketchPath()); + params.append(PApplet.ARGS_SKETCH_FOLDER + "=" + build.getSketchPath()); - params.add(build.getSketchClassName()); + params.append(build.getSketchClassName()); } - -// String outgoing[] = new String[params.size()]; -// params.toArray(outgoing); -// return outgoing; - return params.toArray(new String[0]); + // Add command-line arguments to be given to the sketch itself + if (args != null) { + params.append(args); + } + // Pass back the whole list + return params; } diff --git a/todo.txt b/todo.txt index c7255e4b5..0f35021ad 100644 --- a/todo.txt +++ b/todo.txt @@ -9,6 +9,8 @@ X https://github.com/processing/processing/issues/3586 X also showError() there shouldn't die if other Java windows open X move Platform into its own class, also Messages and others X https://github.com/processing/processing/issues/2765 +X Pass command line arguments to sketches +X https://github.com/processing/processing/issues/2552 api changes X Make fields and functions in PdeKeywords protected @@ -35,6 +37,10 @@ X Add disconnectEvent() to Server X https://github.com/processing/processing/issues/2133 X False positive for mixing active/static mode in Tweak Mode 3.0 alpha 5 X https://github.com/processing/processing/issues/3140 +X Determine shortcut for Export vs Use Selection for Find +X https://github.com/processing/processing/issues/2985 +X PDE erroneously detects changes in non-sketch files +X https://github.com/processing/processing/issues/2759 known issues