X copying files from 'data' dir is not recursive.. fixed

X move structure of app/application dirs around a bit
X make a new 'dist' function for building
X save window position (only during session) of sketch run window
X shouldn't substitute f's for: "Univers76.vlw.gz";
X   need lots of testing--this changes lots of things
X fixed commentsCodec which was mangling things
o present mode doesn't work for draw()
X   tested, seems to be fine?
X console - convert tabs to spaces
o   line wrapping (but save info for resize? noo..)
X fix to line numbers being off for KjcEngine exception highlights
X changed error color slightly for console to fit status error
X size() not being called in setup is gonna cause lots of headaches
X   hack: put exception handler around setup and re-call if necessary
X linefeeds were wrong in BApplet
This commit is contained in:
benfry
2002-07-28 03:46:25 +00:00
parent a97c796901
commit b2dec16e51
6 changed files with 121 additions and 115 deletions

View File

@@ -44,7 +44,7 @@ public class KjcEngine extends PdeEngine {
boolean running;
KjcApplet applet;
Window window;
//Window window;
Process process;
static int portnum = 8192;
@@ -69,6 +69,8 @@ public class KjcEngine extends PdeEngine {
if (dataPath != null) {
File dataDir = new File(dataPath);
if (dataDir.exists()) {
PdeEditor.copyDir(dataDir, buildDir);
/*
String files[] = dataDir.list();
for (int i = 0; i < files.length; i++) {
File sourceFile = new File(dataDir, files[i]);
@@ -78,6 +80,7 @@ public class KjcEngine extends PdeEngine {
// " target is " + targetFile);
PdeEditor.copyFile(sourceFile, targetFile);
}
*/
}
}
@@ -123,7 +126,21 @@ public class KjcEngine extends PdeEngine {
program = commentsCodec(program /*, true*/);
// insert 'f' for all floats
// shouldn't substitute f's for: "Univers76.vlw.gz";
if (PdeBase.getBoolean("compiler.substitute_f", true)) {
/*
a = 0.2 * 3
(3.)
(.3 * 6)
(.30*7)
next to white space \s or math ops +-/*()
*/
program = substipoot(program, "([\\s\\+\\-\\/\\*\\(\\)])(\\d+\\.\\d*)([\\s\\+\\-\\/\\*\\(\\)])", "$1$2f$3");
program = substipoot(program, "([\\s\\+\\-\\/\\*\\(\\)])(\\d*\\.\\d+)([\\s\\+\\-\\/\\*\\(\\)])", "$1$2f$3");
/*
// allow 3. to work (also allows x.x too)
program = substipoot(program, "(\\d+\\.\\d*)(\\D)", "$1f$2");
program = substipoot(program, "(\\d+\\.\\d*)ff", "$1f");
@@ -131,29 +148,7 @@ public class KjcEngine extends PdeEngine {
// allow .3 to work (also allows x.x)
program = substipoot(program, "(\\d*\\.\\d+)(\\D)", "$1f$2");
program = substipoot(program, "(\\d*\\.\\d+)ff", "$1f");
/*
PatternMatcher matcher = new Perl5Matcher();
PatternCompiler compiler = new Perl5Compiler();
Pattern pattern = null;
try {
pattern = compiler.compile("(\\d+\\.\\d+)([\\D^f])");
//pattern = compiler.compile("(\\.\\d+)([^f])");
//String $1f
} catch (MalformedPatternException e){
System.err.println("Bad pattern.");
System.err.println(e.getMessage());
System.exit(1);
}
Perl5Substitution subst =
new Perl5Substitution("$1f$2", Perl5Substitution.INTERPOLATE_ALL);
program = Util.substitute(matcher, pattern, subst, program,
Util.SUBSTITUTE_ALL);
*/
//System.out.println(program);
}
// allow int(3.75) instead of just (int)3.75
@@ -162,44 +157,6 @@ public class KjcEngine extends PdeEngine {
program = substipoot(program, "([^A-Za-z0-9_])char\\((.*)\\)", "$1(char)($2)");
program = substipoot(program, "([^A-Za-z0-9_])int\\((.*)\\)", "$1(int)($2)");
program = substipoot(program, "([^A-Za-z0-9_])float\\((.*)\\)", "$1(float)($2)");
//program = substipoot(program, "(\\W)float\\((.*)\\)", "$1(float)($2)");
//program = substipoot(program, "(\\W)int\\((.*)\\)", "$1(int)($2)");
//System.out.println(program);
/*
PatternMatcher matcher = new Perl5Matcher();
PatternCompiler compiler = new Perl5Compiler();
Pattern pattern = null;
Perl5Substitution subst;
try {
pattern = compiler.compile("\\sfloat\\((.*)\\)");
} catch (MalformedPatternException e){
System.err.println("Bad pattern.");
System.err.println(e.getMessage());
System.exit(1);
}
subst = new Perl5Substitution(" (float)$1",
Perl5Substitution.INTERPOLATE_ALL);
program = Util.substitute(matcher, pattern, subst, program,
Util.SUBSTITUTE_ALL);
try {
pattern = compiler.compile("\\sint\\((.*)\\)");
} catch (MalformedPatternException e){
System.err.println("Bad pattern.");
System.err.println(e.getMessage());
System.exit(1);
}
subst = new Perl5Substitution(" (int)$1",
Perl5Substitution.INTERPOLATE_ALL);
program = Util.substitute(matcher, pattern, subst, program,
Util.SUBSTITUTE_ALL);
*/
}
if (PdeBase.getBoolean("compiler.color_datatype", true)) {
@@ -385,7 +342,8 @@ public class KjcEngine extends PdeEngine {
slash = false;
} else {
if ((p[i] > 32) && (p[i] < 127)) {
//if ((p[i] > 32) && (p[i] < 127)) {
if ((p[i] >= 0x30) && (p[i] < 127)) {
p[i] = rotateTable[p[i]];
//p[i] = encode ? encodeTable[p[i]] : decodeTable[p[i]];
}
@@ -487,12 +445,14 @@ public class KjcEngine extends PdeEngine {
String lineNumberStr = s.substring(index + len + 1);
index = lineNumberStr.indexOf(')');
lineNumberStr = lineNumberStr.substring(0, index);
System.err.println("error line is: " + lineNumberStr);
//System.err.println("error line is: " + lineNumberStr);
try {
exception.line = Integer.parseInt(lineNumberStr) - 2;
exception.line = Integer.parseInt(lineNumberStr) - 1; //2;
//System.out.println("exception in RUNNING");
editor.error(exception);
} catch (NumberFormatException e) { }
} catch (NumberFormatException e) {
e.printStackTrace();
}
} else if ((index = s.indexOf(tempClass)) != -1) {
// code to check for:
// at Temporary_484_3845.loop(Compiled Code)
@@ -564,7 +524,8 @@ public class KjcEngine extends PdeEngine {
}
public void start() throws PdeException { // part of PdeEngine
// part of PdeEngine
public void start(Point windowLocation) throws PdeException {
int numero1 = (int) (Math.random() * 10000);
int numero2 = (int) (Math.random() * 10000);
tempClass = TEMP_CLASS + "_" + numero1 + "_" + numero2;
@@ -801,6 +762,9 @@ public class KjcEngine extends PdeEngine {
//window.pack();
applet.setVisible(true); // no effect
if (windowLocation != null) {
window.setLocation(windowLocation);
}
window.show();
applet.requestFocus(); // necessary for key events
}
@@ -827,9 +791,9 @@ public class KjcEngine extends PdeEngine {
}
public void front() { // part of PdeEngine
window.toFront();
}
//public void front() { // part of PdeEngine
//window.toFront();
//}
protected void cleanup() {

View File

@@ -43,7 +43,10 @@ public class PdeEditor extends Panel {
//String lastFile;
//PdeRunner runner;
KjcEngine engine;
//KjcEngine engine;
PdeEngine engine;
Point appletLocation; //= new Point(0, 0);
Point presentLocation; // = new Point(0, 0);
Frame frame;
Window presentationWindow;
@@ -186,19 +189,20 @@ public class PdeEditor extends Panel {
try {
String program = textarea.getText();
if (program.length() != 0) {
String buildPath = "lib" + File.separator + "build"; // TEMPORARY
File buildDir = new File(buildPath);
if (!buildDir.exists()) buildDir.mkdirs();
//if (program.length() != 0) {
String buildPath = "lib" + File.separator + "build"; // TEMPORARY
File buildDir = new File(buildPath);
if (!buildDir.exists()) buildDir.mkdirs();
String dataPath =
sketchFile.getParent() + File.separator + "data";
//editor.sketchFile.getParent() + File.separator + "data";
String dataPath =
sketchFile.getParent() + File.separator + "data";
//editor.sketchFile.getParent() + File.separator + "data";
engine = new KjcEngine(this, program, buildPath, dataPath);
engine.start();
//System.out.println("done iwth engine.start()");
}
engine = new KjcEngine(this, program, buildPath, dataPath);
//engine.start();
engine.start(presenting ? presentLocation : appletLocation);
//System.out.println("done iwth engine.start()");
//}
} catch (PdeException e) {
//state = RUNNER_ERROR;
@@ -297,7 +301,7 @@ public class PdeEditor extends Panel {
//if (frame != null) frame.toFront();
try {
//((KjcEngine)(runner.engine)).window.toFront();
engine.front();
engine.window.toFront();
} catch (Exception ex) { }
}
}
@@ -320,7 +324,7 @@ public class PdeEditor extends Panel {
try {
//((KjcEngine)(runner.engine)).window.toFront();
engine.front();
engine.window.toFront();
} catch (Exception e) {
// rather than writing code to check all the posible
@@ -380,6 +384,20 @@ public class PdeEditor extends Panel {
// may just roll this in with the other code
// -> keep this around for closing the external window
public void doClose() {
// grab window position
if (engine != null) {
if ((presentationWindow == null) ||
(!presentationWindow.isVisible())) {
appletLocation = engine.window.getLocation();
}
// prone to bugs and doesn't work yet
// if ((presentationWindow != null) &&
// (presentationWindow.isVisible())) {
// presentLocation = engine.window.getLocation();
// }
}
if (running) {
//System.out.println("was running, will call doStop()");
doStop();
@@ -610,6 +628,9 @@ public class PdeEditor extends Panel {
//header.setProject(file.getName(), projectDir);
header.reset();
presentLocation = null;
appletLocation = null;
} catch (FileNotFoundException e1) {
e1.printStackTrace();

View File

@@ -12,8 +12,16 @@ import java.io.*;
public class PdeEditorConsole extends Component {
PdeEditor editor;
static final byte CR = (byte)'\r';
static final byte LF = (byte)'\n';
static final byte CR = (byte)'\r';
static final byte LF = (byte)'\n';
static final byte TAB = (byte)'\t';
static final int TAB_SIZE = 2;
//static byte tabchunk[] = new byte[TAB_SIZE];
//static {
//for (int i = 0; i < TAB_SIZE; i++) {
// tabchunk[i] = ' ';
//}
//}
int lineCount;
int maxLineCount;
@@ -88,11 +96,11 @@ public class PdeEditorConsole extends Component {
//systemOut.println("paint()");
if (bgColor == null) {
bgColor = PdeBase.getColor("editor.console.bgcolor",
new Color(26, 26, 26));
new Color(26, 26, 26));
fgColorOut = PdeBase.getColor("editor.console.fgcolor.output",
new Color(153, 153, 153));
new Color(153, 153, 153));
fgColorErr = PdeBase.getColor("editor.console.fgcolor.error",
new Color(153, 0, 0));
new Color(204, 51, 0));
screen.setFont(font);
metrics = screen.getFontMetrics();
ascent = metrics.getAscent();
@@ -175,6 +183,16 @@ public class PdeEditorConsole extends Component {
message(new String(cline, 0, clength), cerror, true);
clength = 0;
} else if (b[i] == TAB) {
if (clength + TAB_SIZE > cline.length) {
byte temp[] = new byte[clength * 2];
System.arraycopy(cline, 0, temp, 0, clength);
cline = temp;
}
for (int m = 0; m < TAB_SIZE; m++) {
cline[clength++] = ' ';
}
} else {
if (cline.length == clength) {
byte temp[] = new byte[clength * 2];
@@ -206,7 +224,7 @@ public class PdeEditorConsole extends Component {
//systemOut.println("pref'd sizde");
if (font == null) {
font = PdeBase.getFont("editor.console.font",
new Font("Monospaced", Font.PLAIN, 11));
new Font("Monospaced", Font.PLAIN, 11));
//font = new Font("SansSerif", Font.PLAIN, 10);
//g.setFont(font);
//metrics = g.getFontMetrics();

View File

@@ -1,5 +1,9 @@
import java.awt.*;
public class PdeEngine {
PdeEditor editor;
Window window;
public PdeEngine(PdeEditor editor) {
this.editor = editor;
@@ -7,11 +11,11 @@ public class PdeEngine {
// implemented by subclasses
public void start() throws PdeException {
public void start(Point windowLocation) throws PdeException {
}
public void front() {
}
//public void front() {
//}
public void stop() {
}

View File

@@ -57,8 +57,7 @@ echo Zipping and finishing...
P5=processing-$REVISION
mv processing $P5
zip -rq $P5.zip $P5
rm -rf $P5
#zip -rq processing-$1.zip processing
#rm -rf processing
# nah, keep the new directory around
#rm -rf $P5
echo Done.

View File

@@ -1,4 +1,20 @@
0037
X copying files from 'data' dir is not recursive.. fixed
X move structure of app/application dirs around a bit
X make a new 'dist' function for building
X save window position (only during session) of sketch run window
X shouldn't substitute f's for: "Univers76.vlw.gz";
X need lots of testing--this changes lots of things
X fixed commentsCodec which was mangling things
o present mode doesn't work for draw()
X tested, seems to be fine?
X console - convert tabs to spaces
o line wrapping (but save info for resize? noo..)
X fix to line numbers being off for KjcEngine exception highlights
X changed error color slightly for console to fit status error
X size() not being called in setup is gonna cause lots of headaches
X hack: put exception handler around setup and re-call if necessary
X linefeeds were wrong in BApplet
bagel
a _ do some serial testing
@@ -7,38 +23,20 @@ a _ serial works poorly for starting/stopping applets
a _ this is behaving strangely
a _ breaks on every 2nd run when using serial apps (or others?)
a _ try calling gc on stop as well
a _ size() not being called in setup is gonna cause lots of headaches
ui
pde
a _ saving to gzipped 'versions' file
a _ autosave every few minutes, also on each compile, also on save
a _ mark each as 'save', 'autosave', 'failed' or 'successful' compile
a _ also include a timestamp
a _ make scrollbar for console
a _ remove projects if created but nothing happens to them
a _ console work
a _ make scrollbar for console
a _ convert tabs to 8 spaces
a o line wrapping (but save info for resize? noo..)
a _ option to delete current project
play
a _ save window position (only during session) of sketch run window
a _ present mode doesn't work for draw()
a _ see if play being highlighted can be implemented again
a _ shouldn't substitute f's for: "Univers76.vlw.gz";
pde
a _ class unloading not happening
a _ when doing an extends ProcessingApplet
a _ need to add randomizer to even non-self gen'd classes
a _ or figure out how to unload old classes.. grr
a _ copying files from 'data' dir is not recursive
cvs
a _ move structure of app/application dirs around a bit
a _ make a new 'dist' function for building
a _ easier to build on mac for pc than vice-versa..
a _ small script to remove CVS directories from a tree
windows
_ figure out how to do do simple .exe with icons
@@ -92,6 +90,7 @@ a _ something that docks better to java serial api
a _ check to see if lines for error messages are off
release
a _ small script to remove CVS directories from a tree
a _ get icon in macos9/macosx/windows formats
a _ check osname under win98 and linux
a _ write message to people who signed up for p5 alpha
@@ -105,6 +104,7 @@ a _ these should become the standard test cases for everything
a _ faq on where the project is going
a _ information on how to submit bugs to p5-bugs@proce55ing.net
a _ include release number, platform, and a copy of the code
a _ need comprehensive set of tests for 'f' substitution scenarios
web
a _ online discussion/talk system (gets people using the site too)