mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
debugging for new runner, also add block comment/uncomment
This commit is contained in:
@@ -840,6 +840,50 @@ public class Editor extends JFrame {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
item = newJMenuItem("Comment/Uncomment", '/');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
beginCompoundEdit();
|
||||
|
||||
//textarea.selectAll();
|
||||
int startLine = textarea.getSelectionStartLine();
|
||||
int stopLine = textarea.getSelectionEndLine();
|
||||
int length = textarea.getDocumentLength();
|
||||
int pos = textarea.getLineStartOffset(startLine);
|
||||
//System.out.println("pos is " + pos + " and line is " + startLine);
|
||||
//System.out.println("doc length is " + length);
|
||||
if (pos + 2 > length) return;
|
||||
|
||||
String begin = textarea.getText(pos, 2);
|
||||
//System.out.println("begin is '" + begin + "'");
|
||||
boolean commented = begin.equals("//");
|
||||
|
||||
for (int line = startLine; line <= stopLine; line++) {
|
||||
int location = textarea.getLineStartOffset(line);
|
||||
if (commented) {
|
||||
// remove a comment
|
||||
textarea.select(location, location+2);
|
||||
if (textarea.getSelectedText().equals("//")) {
|
||||
textarea.setSelectedText("");
|
||||
}
|
||||
} else {
|
||||
// add a comment
|
||||
textarea.select(location, location);
|
||||
textarea.setSelectedText("//");
|
||||
}
|
||||
//System.out.println(line);
|
||||
}
|
||||
// Subtract one from the end, otherwise selects past the current line.
|
||||
// (Which causes subsequent calls to keep expanding the selection)
|
||||
textarea.select(textarea.getLineStartOffset(startLine),
|
||||
textarea.getLineEndOffset(stopLine) - 1);
|
||||
endCompoundEdit();
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
item = newJMenuItem("Find...", 'F');
|
||||
@@ -1109,7 +1153,10 @@ public class Editor extends JFrame {
|
||||
|
||||
try {
|
||||
//System.out.println("ed compiling");
|
||||
if (!sketch.handleCompile()) return;
|
||||
if (!sketch.handleCompile()) {
|
||||
System.out.println("compile failed");
|
||||
return;
|
||||
}
|
||||
|
||||
//System.out.println("ed running");
|
||||
//SwingUtilities.invokeLater(new Runnable() {
|
||||
@@ -1795,6 +1842,15 @@ public class Editor extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
public void highlightLine(int line) {
|
||||
// subtract one from the end so that the \n ain't included
|
||||
textarea.select(textarea.getLineStartOffset(line),
|
||||
textarea.getLineEndOffset(line) - 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// wow! this is old code. bye bye!
|
||||
public void highlightLine(int lnum) {
|
||||
if (lnum < 0) {
|
||||
textarea.select(0, 0);
|
||||
@@ -1843,6 +1899,7 @@ public class Editor extends JFrame {
|
||||
|
||||
textarea.select(st, end);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// ...................................................................
|
||||
@@ -1853,6 +1910,8 @@ public class Editor extends JFrame {
|
||||
*/
|
||||
public void error(String what) {
|
||||
status.error(what);
|
||||
//new Exception("deactivating RUN").printStackTrace();
|
||||
toolbar.deactivate(EditorToolbar.RUN);
|
||||
}
|
||||
|
||||
|
||||
@@ -1874,7 +1933,10 @@ public class Editor extends JFrame {
|
||||
if (mess.indexOf(javaLang) == 0) {
|
||||
mess = mess.substring(javaLang.length());
|
||||
}
|
||||
//System.out.println("message not null");
|
||||
error(mess);
|
||||
// } else {
|
||||
// System.out.println("message is null");
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1898,7 +1960,6 @@ public class Editor extends JFrame {
|
||||
mess = mess.substring(javaLang.length());
|
||||
}
|
||||
error(mess);
|
||||
//toolbar.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -277,7 +277,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener {
|
||||
message(title[which[slot]]);
|
||||
break;
|
||||
}
|
||||
if (updateAfter) repaint(); // changed for swing from update();
|
||||
if (updateAfter) {
|
||||
//System.out.println("trying to update " + slot + " " + state[slot]);
|
||||
//new Exception("setting slot " + slot + " to " + state[slot]).printStackTrace();
|
||||
repaint(); // changed for swing from update();
|
||||
//Toolkit.getDefaultToolkit().sync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -84,6 +84,11 @@ public class Sketch {
|
||||
// all these set each time build() is called
|
||||
String mainClassName;
|
||||
String classPath;
|
||||
/**
|
||||
* This is *not* the "Processing" libraries path, this is the Java libraries
|
||||
* path, as in java.library.path=BlahBlah, which identifies search paths for
|
||||
* DLLs or JNILIBs.
|
||||
*/
|
||||
String libraryPath;
|
||||
boolean externalRuntime;
|
||||
Vector importedLibraries; // vec of File objects
|
||||
@@ -1378,9 +1383,9 @@ public class Sketch {
|
||||
|
||||
//classPath += File.pathSeparator +
|
||||
//Compiler.contentsToClassPath(codeFolder);
|
||||
classPath =
|
||||
Compiler.contentsToClassPath(codeFolder) +
|
||||
File.pathSeparator + classPath;
|
||||
// classPath =
|
||||
// Compiler.contentsToClassPath(codeFolder) +
|
||||
// File.pathSeparator + classPath;
|
||||
|
||||
//codeFolderPackages = Compiler.packageListFromClassPath(classPath);
|
||||
//codeFolderPackages = Compiler.packageListFromClassPath(codeFolder);
|
||||
@@ -1390,9 +1395,12 @@ public class Sketch {
|
||||
// (class files in subfolders should also be picked up)
|
||||
String codeFolderClassPath =
|
||||
Compiler.contentsToClassPath(codeFolder);
|
||||
// prepend the jar files in the code folder to the class path
|
||||
classPath = codeFolderClassPath + File.pathSeparator + classPath;
|
||||
// get list of packages found in those jars
|
||||
codeFolderPackages =
|
||||
Compiler.packageListFromClassPath(codeFolderClassPath);
|
||||
|
||||
//PApplet.println(libraryPath);
|
||||
//PApplet.println("packages:");
|
||||
//PApplet.printarr(codeFolderPackages);
|
||||
@@ -1607,10 +1615,13 @@ public class Sketch {
|
||||
if (libFolder == null) {
|
||||
//throw new RunnerException("Could not find library for " + entry);
|
||||
continue;
|
||||
//} else {
|
||||
//System.out.println("found library folder " + libFolder.getAbsolutePath());
|
||||
}
|
||||
|
||||
importedLibraries.add(libFolder);
|
||||
libraryPath += File.pathSeparator + libFolder.getAbsolutePath();
|
||||
classPath += Compiler.contentsToClassPath(libFolder);
|
||||
//libraryPath += File.pathSeparator + libFolder.getAbsolutePath();
|
||||
|
||||
/*
|
||||
String list[] = libFolder.list();
|
||||
|
||||
@@ -103,13 +103,16 @@ public class Compiler implements MessageConsumer {
|
||||
// also for windows because qtjava will most likely be here
|
||||
// and for linux, it just doesn't hurt
|
||||
"-classpath",
|
||||
sketch.getClassPath(), //calcClassPath(includeFolder),
|
||||
//calcClassPath(includeFolder), // removed sometime after 135?
|
||||
sketch.getClassPath(),
|
||||
//sketch.getClassPath() + File.pathSeparator + sketch.getLibraryPath(),
|
||||
|
||||
"-nowarn", // we're not currently interested in warnings
|
||||
"+E", // output errors in machine-parsable format
|
||||
"-d", buildPath // output the classes in the buildPath
|
||||
//buildPath + File.separator + className + ".java" // file to compile
|
||||
};
|
||||
// PApplet.println(baseCommand);
|
||||
|
||||
// make list of code files that need to be compiled
|
||||
// (some files are skipped if they contain no class)
|
||||
|
||||
@@ -193,6 +193,7 @@ public class Runner implements MessageConsumer {
|
||||
|
||||
String outgoing[] = new String[params.size()];
|
||||
params.toArray(outgoing);
|
||||
//PApplet.println(outgoing);
|
||||
return outgoing;
|
||||
//return (String[]) params.toArray();
|
||||
|
||||
|
||||
@@ -136,10 +136,9 @@ public class PdePreprocessor {
|
||||
|
||||
static String defaultImports[][] = new String[3][];
|
||||
|
||||
// these ones have the .* at the end, since a class name
|
||||
// might be at the end instead of .* whcih would make trouble
|
||||
// other classes using this can lop of the . and anything after
|
||||
// it to produce a package name consistently.
|
||||
// these ones have the .* at the end, since a class name might be at the end
|
||||
// instead of .* which would make trouble other classes using this can lop
|
||||
// off the . and anything after it to produce a package name consistently.
|
||||
public String extraImports[];
|
||||
|
||||
// imports just from the code folder, treated differently
|
||||
|
||||
Reference in New Issue
Block a user