Skip to content

Commit 9be1960

Browse files
committed
new debug setup
1 parent 65c8375 commit 9be1960

File tree

14 files changed

+5566
-4591
lines changed

14 files changed

+5566
-4591
lines changed

app/src/processing/app/Base.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import com.ice.jni.registry.*;
3636

37+
import processing.app.debug.Compiler;
3738
import processing.core.*;
3839

3940

@@ -64,7 +65,7 @@ public class Base {
6465
// classpath for all known libraries for p5
6566
// (both those in the p5/libs folder and those with lib subfolders
6667
// found in the sketchbook)
67-
static String librariesClassPath;
68+
static public String librariesClassPath;
6869

6970
// Location for untitled items
7071
static File untitledFolder;

app/src/processing/app/Compiler.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2323
*/
2424

25-
package processing.app;
25+
package processing.app.debug;
2626

27+
import processing.app.Base;
28+
import processing.app.Preferences;
29+
import processing.app.Sketch;
2730
import processing.core.*;
2831

2932
import java.io.*;
@@ -100,7 +103,7 @@ public boolean compile(Sketch sketch, String buildPath)
100103
// also for windows because qtjava will most likely be here
101104
// and for linux, it just doesn't hurt
102105
"-classpath",
103-
sketch.classPath, //calcClassPath(includeFolder),
106+
sketch.getClassPath(), //calcClassPath(includeFolder),
104107

105108
"-nowarn", // we're not currently interested in warnings
106109
"+E", // output errors in machine-parsable format
@@ -110,11 +113,11 @@ public boolean compile(Sketch sketch, String buildPath)
110113

111114
// make list of code files that need to be compiled
112115
// (some files are skipped if they contain no class)
113-
String preprocNames[] = new String[sketch.codeCount];
116+
String preprocNames[] = new String[sketch.getCodeCount()];
114117
int preprocCount = 0;
115-
for (int i = 0; i < sketch.codeCount; i++) {
116-
if (sketch.code[i].preprocName != null) {
117-
preprocNames[preprocCount++] = sketch.code[i].preprocName;
118+
for (int i = 0; i < sketch.getCodeCount(); i++) {
119+
if (sketch.getCode(i).preprocName != null) {
120+
preprocNames[preprocCount++] = sketch.getCode(i).preprocName;
118121
}
119122
}
120123
String command[] = new String[baseCommand.length + preprocCount];
@@ -231,10 +234,10 @@ public void message(String s) {
231234
int fileIndex = -1; // use this to build a better exception
232235

233236
// iterate through the project files to see who's causing the trouble
234-
for (int i = 0; i < sketch.codeCount; i++) {
235-
if (sketch.code[i].preprocName == null) continue;
237+
for (int i = 0; i < sketch.getCodeCount(); i++) {
238+
if (sketch.getCode(i).preprocName == null) continue;
236239

237-
partialTempPath = buildPathSubst + sketch.code[i].preprocName;
240+
partialTempPath = buildPathSubst + sketch.getCode(i).preprocName;
238241
partialStartIndex = s.indexOf(partialTempPath);
239242
if (partialStartIndex != -1) {
240243
fileIndex = i;
@@ -258,16 +261,16 @@ public void message(String s) {
258261
//System.out.println("pde / line number: " + lineNumber);
259262

260263
if (fileIndex == 0) { // main class, figure out which tab
261-
for (int i = 1; i < sketch.codeCount; i++) {
262-
if (sketch.code[i].flavor == Sketch.PDE) {
263-
if (sketch.code[i].preprocOffset < lineNumber) {
264+
for (int i = 1; i < sketch.getCodeCount(); i++) {
265+
if (sketch.getCode(i).flavor == Sketch.PDE) {
266+
if (sketch.getCode(i).preprocOffset < lineNumber) {
264267
fileIndex = i;
265268
//System.out.println("i'm thinkin file " + i);
266269
}
267270
}
268271
}
269272
if (fileIndex != 0) { // if found another culprit
270-
lineNumber -= sketch.code[fileIndex].preprocOffset;
273+
lineNumber -= sketch.getCode(fileIndex).preprocOffset;
271274
//System.out.println("i'm sayin line " + lineNumber);
272275
}
273276
}

app/src/processing/app/Editor.java

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
package processing.app;
2525

26+
import processing.app.debug.Runner;
27+
import processing.app.debug.RunnerException;
2628
import processing.app.syntax.*;
2729
import processing.app.tools.*;
2830
import processing.core.*;
@@ -104,8 +106,8 @@ public class Editor extends JFrame {
104106
EditorListener listener;
105107

106108
// runtime information and window placement
107-
Point appletLocation;
108-
RunButtonWatcher watcher;
109+
Point sketchWindowLocation;
110+
//RunButtonWatcher watcher;
109111
Runner runtime;
110112

111113
JMenuItem exportAppItem;
@@ -1106,19 +1108,28 @@ public void handleRun(boolean present) {
11061108
}
11071109

11081110
try {
1109-
if (!sketch.handleRun()) return;
1111+
if (!sketch.handleCompile()) return;
11101112

1111-
runtime = new Runner(sketch, Editor.this);
1112-
runtime.start(appletLocation);
1113+
//SwingUtilities.invokeLater(new Runnable() {
1114+
Thread t = new Thread(new Runnable() {
1115+
public void run() {
1116+
try {
1117+
runtime = new Runner(Editor.this, presenting);
1118+
//runtime.go();
1119+
} catch (RunnerException e) {
1120+
error(e);
1121+
}
1122+
}
1123+
});
1124+
t.start();
1125+
//runtime.start(appletLocation);
11131126

11141127
// run button watcher not currently enabled
11151128
// it was contributing to the external vm hanging
1116-
watcher = new RunButtonWatcher();
1117-
1118-
} catch (RunnerException e) {
1119-
error(e);
1129+
//watcher = new RunButtonWatcher();
11201130

11211131
} catch (Exception e) {
1132+
System.err.println("exception reached editor");
11221133
e.printStackTrace();
11231134
}
11241135

@@ -1147,7 +1158,18 @@ public Object construct() {
11471158
//sketch.cleanup(); // where does this go?
11481159
}
11491160

1161+
1162+
public void setSketchLocation(Point p) {
1163+
sketchWindowLocation = p;
1164+
}
1165+
1166+
1167+
public Point getSketchLocation() {
1168+
return sketchWindowLocation;
1169+
}
11501170

1171+
1172+
/*
11511173
class RunButtonWatcher implements Runnable {
11521174
Thread thread;
11531175
@@ -1188,33 +1210,42 @@ public void stop() {
11881210
thread = null;
11891211
}
11901212
}
1213+
*/
11911214

11921215

11931216
public void handleStop() { // called by menu or buttons
1217+
// System.out.println("stopping");
1218+
toolbar.activate(EditorToolbar.STOP);
1219+
11941220
if (presenting) {
11951221
closeRunner();
1196-
} else if (runtime.window != null) {
1197-
// When run externally, kill the applet window,
1198-
// otherwise things may not stop properly with libraries.
1199-
closeRunner();
1222+
// } else if (runtime.window != null) {
1223+
// // When run externally, kill the applet window,
1224+
// // otherwise things may not stop properly with libraries.
1225+
// closeRunner();
12001226
} else {
12011227
stopRunner();
12021228
}
1203-
toolbar.clear();
1229+
//System.out.println("clearing toolbar");
1230+
//toolbar.clear();
1231+
toolbar.deactivate(EditorToolbar.RUN);
1232+
toolbar.deactivate(EditorToolbar.STOP);
12041233
}
12051234

12061235

12071236
/**
12081237
* Stop the applet but don't kill its window.
12091238
*/
12101239
public void stopRunner() {
1240+
//System.out.println("stopRunner 1");
12111241
if (runtime != null) runtime.stop();
1212-
if (watcher != null) watcher.stop();
1242+
//System.out.println("stopRunner 2");
1243+
//if (watcher != null) watcher.stop();
12131244
message(EMPTY);
12141245

12151246
// the buttons are sometimes still null during the constructor
12161247
// is this still true? are people still hitting this error?
1217-
/*if (buttons != null)*/ toolbar.clear();
1248+
/*if (buttons != null)*/ //toolbar.clear();
12181249

12191250
running = false;
12201251
}
@@ -1225,19 +1256,21 @@ public void stopRunner() {
12251256
* mode, this will always be called instead of doStop().
12261257
*/
12271258
public void closeRunner() {
1259+
//System.out.println("closing runner");
1260+
12281261
//if (presenting) {
12291262
//presentationWindow.hide();
12301263
//} else {
1231-
try {
1232-
// the window will also be null the process was running
1233-
// externally. so don't even try setting if window is null
1234-
// since Runner will set the appletLocation when an
1235-
// external process is in use.
1236-
if (runtime.window != null) {
1237-
appletLocation = runtime.window.getLocation();
1238-
}
1239-
} catch (NullPointerException e) { }
1240-
//}
1264+
// try {
1265+
// // the window will also be null the process was running
1266+
// // externally. so don't even try setting if window is null
1267+
// // since Runner will set the appletLocation when an
1268+
// // external process is in use.
1269+
// if (runtime.window != null) {
1270+
// appletLocation = runtime.window.getLocation();
1271+
// }
1272+
// } catch (NullPointerException e) { }
1273+
// //}
12411274

12421275
//if (running) doStop();
12431276
stopRunner(); // need to stop if runtime error
@@ -1252,8 +1285,7 @@ public void closeRunner() {
12521285

12531286
sketch.cleanup();
12541287

1255-
// [toxi 030903]
1256-
// focus the PDE again after quitting presentation mode
1288+
// focus the PDE again after quitting presentation mode [toxi 030903]
12571289
toFront();
12581290
}
12591291

@@ -1464,7 +1496,8 @@ protected boolean handleOpenInternal(String path) {
14641496
* <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=276">Bug 276</A>.
14651497
*/
14661498
public boolean handleSave(boolean immediately) {
1467-
stopRunner();
1499+
//stopRunner();
1500+
handleStop(); // 0136
14681501

14691502
if (untitled) {
14701503
return handleSaveAs();
@@ -1509,12 +1542,15 @@ protected void handleSave2() {
15091542
//checkModifiedMode = 0;
15101543
// this is used when another operation calls a save
15111544
}
1512-
toolbar.clear();
1545+
//toolbar.clear();
1546+
toolbar.deactivate(EditorToolbar.SAVE);
15131547
}
15141548

15151549

15161550
public boolean handleSaveAs() {
1517-
stopRunner();
1551+
//stopRunner(); // formerly from 0135
1552+
handleStop();
1553+
15181554
toolbar.activate(EditorToolbar.SAVE);
15191555

15201556
//SwingUtilities.invokeLater(new Runnable() {
@@ -1534,9 +1570,11 @@ public boolean handleSaveAs() {
15341570
} catch (Exception e) {
15351571
// show the error as a message in the window
15361572
error(e);
1573+
1574+
} finally {
1575+
// make sure the toolbar button deactivates
1576+
toolbar.deactivate(EditorToolbar.SAVE);
15371577
}
1538-
toolbar.clear();
1539-
//}});
15401578

15411579
return true;
15421580
}
@@ -1567,7 +1605,8 @@ public void run() {
15671605
} catch (Exception e) {
15681606
error(e);
15691607
}
1570-
toolbar.clear();
1608+
//toolbar.clear();
1609+
toolbar.deactivate(EditorToolbar.EXPORT);
15711610
}});
15721611
}
15731612

@@ -1592,7 +1631,8 @@ public void run() {
15921631
message("Error during export.");
15931632
e.printStackTrace();
15941633
}
1595-
toolbar.clear();
1634+
//toolbar.clear();
1635+
toolbar.deactivate(EditorToolbar.EXPORT);
15961636
}});
15971637
}
15981638

@@ -1625,7 +1665,7 @@ public boolean handleExportCheckModified() {
16251665
// but f-- it.. let's get this shite done..
16261666
//} else if (result == JOptionPane.CANCEL_OPTION) {
16271667
message("Export canceled, changes must first be saved.");
1628-
toolbar.clear();
1668+
//toolbar.clear();
16291669
return false;
16301670
}
16311671
return true;
@@ -1853,7 +1893,7 @@ public void error(RunnerException e) {
18531893
mess = mess.substring(javaLang.length());
18541894
}
18551895
error(mess);
1856-
toolbar.clear();
1896+
//toolbar.clear();
18571897
}
18581898

18591899

app/src/processing/app/EditorStatus.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected void setup() {
243243
public void actionPerformed(ActionEvent e) {
244244
if (mode == EDIT) {
245245
unedit();
246-
editor.toolbar.clear();
246+
//editor.toolbar.clear();
247247
}
248248
}
249249
});
@@ -297,7 +297,7 @@ public void actionPerformed(ActionEvent e) {
297297
public void keyPressed(KeyEvent event) {
298298
if (event.getKeyChar() == KeyEvent.VK_ESCAPE) {
299299
unedit();
300-
editor.toolbar.clear();
300+
//editor.toolbar.clear();
301301
event.consume();
302302
}
303303
}
@@ -419,7 +419,7 @@ public Dimension getMaximumSize() {
419419
public void actionPerformed(ActionEvent e) {
420420
if (e.getSource() == cancelButton) {
421421
if (mode == EDIT) unedit();
422-
editor.toolbar.clear();
422+
//editor.toolbar.clear();
423423

424424
} else if (e.getSource() == okButton) {
425425
// answering to rename/new code question

0 commit comments

Comments
 (0)