Skip to content

Commit 1ac9e0a

Browse files
committed
tweakmode: handle comment blocks, ignore global assignments
1 parent 1626cd8 commit 1ac9e0a

3 files changed

Lines changed: 152 additions & 91 deletions

File tree

java/src/processing/mode/java/JavaEditor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,9 +2739,11 @@ private void removeSpacesFromCode() {
27392739
* Replace all numbers with variables and add code to initialize
27402740
* these variables and handle update messages.
27412741
*/
2742-
protected boolean automateSketch(Sketch sketch, List<List<Handle>> handles) {
2742+
protected boolean automateSketch(Sketch sketch, SketchParser parser) {
27432743
SketchCode[] code = sketch.getCode();
27442744

2745+
List<List<Handle>> handles = parser.allHandles;
2746+
27452747
if (code.length < 1) {
27462748
return false;
27472749
}
@@ -2793,7 +2795,7 @@ protected boolean automateSketch(Sketch sketch, List<List<Handle>> handles) {
27932795
}
27942796
code[tab].setProgram(c);
27952797
}
2796-
2798+
27972799
// add the main header to the code in the first tab
27982800
String c = code[0].getProgram();
27992801

java/src/processing/mode/java/JavaMode.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ public Runner handleTweak(Sketch sketch,
167167
RunnerListener listener,
168168
final boolean present) throws SketchException {
169169
final JavaEditor editor = (JavaEditor)listener;
170-
boolean launchInteractive = false;
171170

172171
if (isSketchModified(sketch)) {
173172
editor.deactivateRun();
@@ -193,7 +192,7 @@ public Runner handleTweak(Sketch sketch,
193192
final SketchParser parser = new SketchParser(editor.baseCode, requiresTweak);
194193

195194
// add our code to the sketch
196-
launchInteractive = editor.automateSketch(sketch, parser.allHandles);
195+
final boolean launchInteractive = editor.automateSketch(sketch, parser);
197196

198197
build = new JavaBuild(sketch);
199198
appletClassName = build.build(false);
@@ -204,8 +203,10 @@ public Runner handleTweak(Sketch sketch,
204203
public void run() {
205204
runtime.launch(present); // this blocks until finished
206205
// next lines are executed when the sketch quits
207-
editor.initEditorCode(parser.allHandles, false);
208-
editor.stopInteractiveMode(parser.allHandles);
206+
if (launchInteractive) {
207+
editor.initEditorCode(parser.allHandles, false);
208+
editor.stopInteractiveMode(parser.allHandles);
209+
}
209210
}
210211
}).start();
211212

0 commit comments

Comments
 (0)