mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
first version that fully compiles since the overhaul
This commit is contained in:
+39
-13
@@ -398,7 +398,7 @@ public class PdeBase /*extends JFrame implements ActionListener*/
|
||||
// ...................................................................
|
||||
|
||||
|
||||
static protected byte[] grabFile(File file) throws IOException {
|
||||
static public byte[] grabFile(File file) throws IOException {
|
||||
int size = (int) file.length();
|
||||
FileInputStream input = new FileInputStream(file);
|
||||
byte buffer[] = new byte[size];
|
||||
@@ -414,7 +414,7 @@ public class PdeBase /*extends JFrame implements ActionListener*/
|
||||
}
|
||||
|
||||
|
||||
static protected void copyFile(File afile, File bfile) {
|
||||
static public void copyFile(File afile, File bfile) {
|
||||
try {
|
||||
FileInputStream from = new FileInputStream(afile);
|
||||
FileOutputStream to = new FileOutputStream(bfile);
|
||||
@@ -437,7 +437,7 @@ public class PdeBase /*extends JFrame implements ActionListener*/
|
||||
}
|
||||
}
|
||||
|
||||
static protected void copyDir(File sourceDir, File targetDir) {
|
||||
static public void copyDir(File sourceDir, File targetDir) {
|
||||
String files[] = sourceDir.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") || files[i].equals("..")) continue;
|
||||
@@ -456,16 +456,27 @@ public class PdeBase /*extends JFrame implements ActionListener*/
|
||||
}
|
||||
|
||||
|
||||
// remove all files in a directory
|
||||
//
|
||||
/**
|
||||
* Remove all files in a directory and the directory itself.
|
||||
*/
|
||||
static public void removeDir(File dir) {
|
||||
//System.out.println("removing " + dir);
|
||||
removeDescendants(dir);
|
||||
dir.delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recursively remove all files within a directory,
|
||||
* used with removeDir().
|
||||
*/
|
||||
static protected void removeDescendants(File dir) {
|
||||
String files[] = dir.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") || files[i].equals("..")) continue;
|
||||
File dead = new File(dir, files[i]);
|
||||
if (!dead.isDirectory()) {
|
||||
//if (!PdePreferences.getBoolean("editor.save_build_files", false)) {
|
||||
if (!PdePreferences.getBoolean("editor.save_build_files")) {
|
||||
if (!PdePreferences.getBoolean("compiler.save_build_files")) {
|
||||
if (!dead.delete()) {
|
||||
// temporarily disabled
|
||||
//System.err.println("couldn't delete " + dead);
|
||||
@@ -479,11 +490,26 @@ public class PdeBase /*extends JFrame implements ActionListener*/
|
||||
}
|
||||
|
||||
|
||||
// remove all files in a directory and the dir itself
|
||||
//
|
||||
static protected void removeDir(File dir) {
|
||||
//System.out.println("removing " + dir);
|
||||
removeDescendants(dir);
|
||||
dir.delete();
|
||||
/**
|
||||
* Calculate the size of the contents of a folder.
|
||||
* Used to determine whether sketches are empty or not.
|
||||
* Note that the function calls itself recursively.
|
||||
*/
|
||||
static public int calcFolderSize(File folder) {
|
||||
int size = 0;
|
||||
|
||||
//System.out.println("calcFolderSize " + folder);
|
||||
String files[] = folder.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") || (files[i].equals("..")) ||
|
||||
files[i].equals(".DS_Store")) continue;
|
||||
File fella = new File(folder, files[i]);
|
||||
if (fella.isDirectory()) {
|
||||
size += calcFolderSize(fella);
|
||||
} else {
|
||||
size += (int) fella.length();
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,12 +122,10 @@ public class PdeCompiler implements PdeMessageConsumer {
|
||||
String msg = e.getMessage();
|
||||
if ((msg != null) && (msg.indexOf("jikes: not found") != -1)) {
|
||||
//System.err.println("jikes is missing");
|
||||
JOptionPane.showMessageDialog(editor.base,
|
||||
"Could not find the compiler.\n" +
|
||||
"jikes is missing from your PATH,\n" +
|
||||
"see readme.txt for help.",
|
||||
"Compiler error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
PdeBase.showWarning("Compiler error",
|
||||
"Could not find the compiler.\n" +
|
||||
"jikes is missing from your PATH,\n" +
|
||||
"see readme.txt for help.", null);
|
||||
return false;
|
||||
}
|
||||
e.printStackTrace();
|
||||
@@ -469,7 +467,7 @@ public class PdeCompiler implements PdeMessageConsumer {
|
||||
files[i].charAt(0) != '.') {
|
||||
ZipEntry entry = new ZipEntry(nowfar);
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(PdeEditor.grabFile(sub));
|
||||
zos.write(PdeBase.grabFile(sub));
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
+14
-24
@@ -66,6 +66,8 @@ public class PdeEditor extends JFrame
|
||||
String openingPath;
|
||||
String openingName;
|
||||
|
||||
PdeEditorListener listener;
|
||||
|
||||
PdeEditorButtons buttons;
|
||||
PdeEditorHeader header;
|
||||
PdeEditorStatus status;
|
||||
@@ -238,7 +240,7 @@ public class PdeEditor extends JFrame
|
||||
|
||||
// hopefully these are no longer needed w/ swing
|
||||
// (that was wishful thinking, they still are, until we switch to jedit)
|
||||
PdeEditorListener listener = new PdeEditorListener(this, textarea);
|
||||
listener = new PdeEditorListener(this, textarea);
|
||||
textarea.pdeEditorListener = listener;
|
||||
|
||||
// set the undo stuff for this feller
|
||||
@@ -422,6 +424,7 @@ public class PdeEditor extends JFrame
|
||||
|
||||
boolean external = PdePreferences.getBoolean("editor.external");
|
||||
|
||||
listener.setExternalEditor(external);
|
||||
textarea.setEditable(!external);
|
||||
saveMenuItem.setEnabled(!external);
|
||||
saveAsMenuItem.setEnabled(!external);
|
||||
@@ -616,11 +619,7 @@ public class PdeEditor extends JFrame
|
||||
menu.add(newMenuItem("Stop", 'T'));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (presenting) {
|
||||
doClose();
|
||||
} else {
|
||||
doStop();
|
||||
}
|
||||
handleStop();
|
||||
}
|
||||
});
|
||||
menu.addSeparator();
|
||||
@@ -1305,6 +1304,15 @@ public class PdeEditor extends JFrame
|
||||
}
|
||||
|
||||
|
||||
public void handleStop() { // called by menu or buttons
|
||||
if (presenting) {
|
||||
doClose();
|
||||
} else {
|
||||
doStop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void doStop() {
|
||||
if (runtime != null) runtime.stop();
|
||||
if (watcher != null) watcher.stop();
|
||||
@@ -2126,24 +2134,6 @@ public class PdeEditor extends JFrame
|
||||
//System.out.println("exiting doquit");
|
||||
}
|
||||
|
||||
protected int calcFolderSize(File folder) {
|
||||
int size = 0;
|
||||
|
||||
//System.out.println("calcFolderSize " + folder);
|
||||
String files[] = folder.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") || (files[i].equals("..")) ||
|
||||
files[i].equals(".DS_Store")) continue;
|
||||
File fella = new File(folder, files[i]);
|
||||
if (fella.isDirectory()) {
|
||||
size += calcFolderSize(fella);
|
||||
} else {
|
||||
size += (int) fella.length();
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
protected void doQuit2() {
|
||||
storePreferences();
|
||||
|
||||
+72
-230
@@ -29,23 +29,15 @@ import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
|
||||
//public class PdeEditorButtons extends Panel /*implements ActionListener*/ {
|
||||
public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
static final String EMPTY_STATUS = " ";
|
||||
|
||||
// run, stop, save, export, open
|
||||
public class PdeEditorButtons extends JComponent implements MouseInputListener {
|
||||
|
||||
static final String title[] = {
|
||||
"", "run", "stop", "new", "open", "save", "export"
|
||||
//"", "Run", "Stop", "Save", "Open", "Export"
|
||||
//"Run", "Stop", "Close",
|
||||
//"Open", "Save", "Export Applet", "Print", "Beautify",
|
||||
//"Disable Full Screen", "Full Screen"
|
||||
};
|
||||
|
||||
static final int BUTTON_COUNT = title.length;
|
||||
static final int BUTTON_WIDTH = PdeEditor.GRID_SIZE; //33;
|
||||
static final int BUTTON_HEIGHT = PdeEditor.GRID_SIZE; //33;
|
||||
static final int BUTTON_WIDTH = PdePreferences.GRID_SIZE;
|
||||
static final int BUTTON_HEIGHT = PdePreferences.GRID_SIZE;
|
||||
|
||||
static final int NOTHING = 0;
|
||||
static final int RUN = 1;
|
||||
@@ -56,17 +48,12 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
static final int SAVE = 5;
|
||||
static final int EXPORT = 6;
|
||||
|
||||
//static final int PRINT = 6;
|
||||
//static final int BEAUTIFY = 7;
|
||||
//static final int DISABLE_FULL_SCREEN = 8;
|
||||
//static final int FULL_SCREEN = 9;
|
||||
|
||||
static final int INACTIVE = 0;
|
||||
static final int ROLLOVER = 1;
|
||||
static final int ACTIVE = 2;
|
||||
|
||||
PdeEditor editor;
|
||||
Label status;
|
||||
//Label status;
|
||||
|
||||
Image offscreen;
|
||||
int width, height;
|
||||
@@ -78,19 +65,21 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
int currentRollover;
|
||||
int currentSelection;
|
||||
|
||||
//JPopupMenu popup;
|
||||
PopupMenu popup;
|
||||
JPopupMenu popup;
|
||||
|
||||
int buttonCount;
|
||||
int state[];
|
||||
Image stateImage[];
|
||||
int which[]; // mapping indices to implementation
|
||||
|
||||
//int x1[], x2[];
|
||||
//int y1, y2;
|
||||
int x1, x2;
|
||||
int y1[], y2[];
|
||||
|
||||
String status;
|
||||
Font statusFont;
|
||||
Color statusColor;
|
||||
int statusY;
|
||||
|
||||
|
||||
public PdeEditorButtons(PdeEditor editor) {
|
||||
this.editor = editor;
|
||||
@@ -109,23 +98,23 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
|
||||
currentRollover = -1;
|
||||
|
||||
setLayout(null);
|
||||
status = new Label();
|
||||
status.setFont(PdePreferences.getFont("editor.buttons.status.font",
|
||||
new Font("SansSerif", Font.PLAIN, 10)));
|
||||
status.setForeground(PdePreferences.getColor("editor.buttons.status.color",
|
||||
Color.black));
|
||||
add(status);
|
||||
//setLayout(null);
|
||||
//status = new JLabel();
|
||||
statusFont = PdePreferences.getFont("buttons.status.font");
|
||||
statusColor = PdePreferences.getColor("buttons.status.color");
|
||||
//add(status);
|
||||
|
||||
//status.setBounds(-5, BUTTON_COUNT * BUTTON_HEIGHT,
|
||||
// BUTTON_WIDTH + 15, BUTTON_HEIGHT);
|
||||
//status.setAlignment(Label.CENTER);
|
||||
statusY = (BUTTON_COUNT + 1) * BUTTON_HEIGHT;
|
||||
|
||||
status.setBounds(-5, BUTTON_COUNT*BUTTON_HEIGHT,
|
||||
BUTTON_WIDTH + 15, BUTTON_HEIGHT);
|
||||
status.setAlignment(Label.CENTER);
|
||||
|
||||
addMouseListener(this);
|
||||
addMouseMotionListener(this);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void update() {
|
||||
paint(this.getGraphics());
|
||||
}
|
||||
@@ -133,12 +122,14 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
public void update(Graphics g) {
|
||||
paint(g);
|
||||
}
|
||||
*/
|
||||
|
||||
public void paint(Graphics screen) {
|
||||
public void paintComponent(Graphics screen) {
|
||||
if (inactive == null) {
|
||||
inactive = new Image[BUTTON_COUNT];
|
||||
rollover = new Image[BUTTON_COUNT];
|
||||
active = new Image[BUTTON_COUNT];
|
||||
active = new Image[BUTTON_COUNT];
|
||||
|
||||
state = new int[BUTTON_COUNT];
|
||||
|
||||
for (int i = 0; i < BUTTON_COUNT; i++) {
|
||||
@@ -180,37 +171,6 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
y2[i] = offsetY + BUTTON_HEIGHT;
|
||||
offsetY = y2[i];
|
||||
}
|
||||
|
||||
/*
|
||||
// horizontal alignment
|
||||
x1 = new int[buttonCount];
|
||||
x2 = new int[buttonCount];
|
||||
|
||||
y1 = (height - BUTTON_HEIGHT) / 2;
|
||||
y2 = y1 + BUTTON_HEIGHT;
|
||||
|
||||
int offsetX = 8;
|
||||
//for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
//g.drawImage(stateImage[i], offsetX, offsetY, null);
|
||||
x1[i] = offsetX;
|
||||
x2[i] = offsetX + BUTTON_WIDTH;
|
||||
offsetX += BUTTON_WIDTH + 4;
|
||||
// extra space after play/stop/close
|
||||
if (i == GAP_POSITION) offsetX += 8;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// start from righthand side and move left
|
||||
offsetX = width - 8 - BUTTON_WIDTH;
|
||||
for (int i = buttonCount-1; i >= 2; --i) {
|
||||
//g.drawImage(stateImage[i], offsetX, offsetY, null);
|
||||
x1[i] = offsetX;
|
||||
x2[i] = offsetX + BUTTON_WIDTH;
|
||||
offsetX -= BUTTON_WIDTH + 4;
|
||||
}
|
||||
*/
|
||||
}
|
||||
Graphics g = offscreen.getGraphics();
|
||||
g.setColor(getBackground());
|
||||
@@ -220,28 +180,16 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
//g.drawImage(stateImage[i], x1[i], y1, null);
|
||||
g.drawImage(stateImage[i], x1, y1[i], null);
|
||||
}
|
||||
//g.drawImage(stateImage[i], offsetX, offsetY, null);
|
||||
/*
|
||||
//Dimension dim = size();
|
||||
int offsetY = (height - BUTTON_HEIGHT) / 2;
|
||||
|
||||
int offsetX = 8;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
g.drawImage(stateImage[i], offsetX, offsetY, null);
|
||||
offsetX += BUTTON_WIDTH + 4;
|
||||
}
|
||||
|
||||
// start from righthand side and move left
|
||||
offsetX = width - 8 - BUTTON_WIDTH;
|
||||
for (int i = buttonCount-1; i >= 2; --i) {
|
||||
g.drawImage(stateImage[i], offsetX, offsetY, null);
|
||||
offsetX -= BUTTON_WIDTH + 4;
|
||||
}
|
||||
*/
|
||||
g.setColor(statusColor);
|
||||
g.setFont(statusFont);
|
||||
int statusWidth = g.getFontMetrics().stringWidth(status);
|
||||
int statusX = (getSize().width - statusWidth) / 2;
|
||||
g.drawString(status, statusX, statusY);
|
||||
screen.drawImage(offscreen, 0, 0, null);
|
||||
//screen.fillRect(0, 0, 10, 10);
|
||||
}
|
||||
|
||||
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
// mouse events before paint();
|
||||
if (state == null) return;
|
||||
@@ -251,69 +199,36 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
setState(OPEN, INACTIVE, false);
|
||||
}
|
||||
//System.out.println(e);
|
||||
mouseMove(e);
|
||||
//mouseMove(e);
|
||||
handleMouse(e.getX(), e.getY());
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
//if (state[OPEN] != INACTIVE) {
|
||||
//setState(OPEN, INACTIVE, true);
|
||||
//}
|
||||
//System.out.println(e);
|
||||
//mouseMove(e);
|
||||
}
|
||||
|
||||
public void mouseMove(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
|
||||
//System.out.println(x + ", " + y);
|
||||
|
||||
public void mouseDragged(MouseEvent e) { }
|
||||
|
||||
|
||||
public void handleMouse(int x, int y) {
|
||||
if (currentRollover != -1) {
|
||||
if ((y > y1[currentRollover]) && (x > x1) &&
|
||||
(y < y2[currentRollover]) && (x < x2)) {
|
||||
//if ((x > x1[currentRollover]) && (y > y1) &&
|
||||
// (x < x2[currentRollover]) && (y < y2)) {
|
||||
//System.out.println("same");
|
||||
///return true; // no change
|
||||
return;
|
||||
|
||||
} else {
|
||||
//state[currentRollover] = INACTIVE_STATE;
|
||||
//stateImage[currentRollover] = inactive[currentRollover];
|
||||
setState(currentRollover, INACTIVE, true);
|
||||
messageClear(title[currentRollover]);
|
||||
currentRollover = -1;
|
||||
//update();
|
||||
}
|
||||
}
|
||||
int sel = findSelection(x, y);
|
||||
//if (sel == -1) return true;
|
||||
if (sel == -1) return;
|
||||
|
||||
if (state[sel] != ACTIVE) {
|
||||
//state[sel] = ROLLOVER_STATE;
|
||||
//stateImage[sel] = rollover[sel];
|
||||
setState(sel, ROLLOVER, true);
|
||||
currentRollover = sel;
|
||||
}
|
||||
/*
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
if ((x > x1[i]) && (y > y1) &&
|
||||
(x < x2[i]) && (y < y2)) {
|
||||
//System.out.println(i);
|
||||
if (state[i] != ACTIVE_STATE) {
|
||||
state[i] = ROLLOVER_STATE;
|
||||
stateImage[i] = rollover[i];
|
||||
currentRollover = i;
|
||||
}
|
||||
update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//update();
|
||||
///return true;
|
||||
}
|
||||
|
||||
|
||||
private int findSelection(int x, int y) {
|
||||
// if app loads slowly and cursor is near the buttons
|
||||
// when it comes up, the app may not have time to load
|
||||
@@ -346,30 +261,33 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
message(title[which[slot]]);
|
||||
break;
|
||||
}
|
||||
if (updateAfter) update();
|
||||
if (updateAfter) repaint(); // changed for swing from update();
|
||||
}
|
||||
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
//System.out.println("entered");
|
||||
mouseMove(e);
|
||||
//mouseMove(e);
|
||||
handleMouse(e.getX(), e.getY());
|
||||
}
|
||||
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
if (state[OPEN] != INACTIVE) {
|
||||
setState(OPEN, INACTIVE, true);
|
||||
}
|
||||
//System.out.println("exited");
|
||||
|
||||
// kludge
|
||||
for (int i = 0; i < BUTTON_COUNT; i++) {
|
||||
messageClear(title[i]);
|
||||
}
|
||||
mouseMove(e);
|
||||
//for (int i = 0; i < BUTTON_COUNT; i++) {
|
||||
//messageClear(title[i]);
|
||||
//}
|
||||
status = "";
|
||||
//mouseMove(e);
|
||||
handleMouse(e.getX(), e.getY());
|
||||
}
|
||||
|
||||
int wasDown = -1;
|
||||
|
||||
//public boolean mouseDown(Event e, int x, int y) {
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
@@ -383,145 +301,69 @@ public class PdeEditorButtons extends JPanel implements MouseInputListener {
|
||||
|
||||
if (currentSelection == OPEN) {
|
||||
if (popup == null) {
|
||||
popup = new PopupMenu();
|
||||
//popup = new JPopupMenu();
|
||||
popup = editor.sketchbook.getPopup();
|
||||
add(popup);
|
||||
}
|
||||
//popup.addActionListener(this);
|
||||
editor.base.rebuildSketchbookMenu(popup);
|
||||
//editor.sketchbook.rebuildPopup(popup);
|
||||
popup.show(this, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.err.println(e);
|
||||
if (e.getSource() == popup) {
|
||||
System.err.println("posting bogus mouseup");
|
||||
mouseUp(null, 0, 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
public void mouseClicked(MouseEvent e) { }
|
||||
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
// this space intentionally left blank
|
||||
}
|
||||
|
||||
///public boolean mouseUp(Event e, int x, int y) {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
//System.out.println("mouse is released");
|
||||
|
||||
//switch (which[sel]) {
|
||||
switch (currentSelection) {
|
||||
|
||||
case RUN:
|
||||
editor.doRun(e.isShiftDown());
|
||||
//if (e.shiftDown()) {
|
||||
//editor.doPresent();
|
||||
//} else {
|
||||
//editor.doRun(false);
|
||||
//}
|
||||
break;
|
||||
|
||||
case STOP:
|
||||
setState(RUN, INACTIVE, true);
|
||||
if (editor.presenting) {
|
||||
editor.doClose();
|
||||
} else {
|
||||
editor.doStop();
|
||||
}
|
||||
break;
|
||||
//case CLOSE: editor.doClose(); break;
|
||||
|
||||
//case OPEN: editor.doOpen(); break;
|
||||
|
||||
case OPEN:
|
||||
setState(OPEN, INACTIVE, true);
|
||||
//System.err.println("popup mouseup");
|
||||
//popup.setVisible(false);
|
||||
//remove(popup);
|
||||
// kill the popup?
|
||||
//PopupMenu popup = new PopupMenu();
|
||||
//editor.base.rebuildSketchbookMenu(popup);
|
||||
//popup.show(this, x, y);
|
||||
break;
|
||||
//editor.doOpen(this, BUTTON_WIDTH, OPEN * BUTTON_HEIGHT);
|
||||
|
||||
case NEW: editor.skNew(); break;
|
||||
|
||||
//case SAVE: editor.doSaveAs(); break;
|
||||
case SAVE: editor.doSave(); break;
|
||||
case EXPORT: editor.skExport(); break;
|
||||
//case PRINT: editor.doPrint(); break;
|
||||
//case BEAUTIFY: editor.doBeautify(); break;
|
||||
|
||||
/*
|
||||
case FULL_SCREEN:
|
||||
editor.enableFullScreen();
|
||||
which[buttonCount-1] = DISABLE_FULL_SCREEN;
|
||||
message(title[which[buttonCount-1]]);
|
||||
break;
|
||||
case DISABLE_FULL_SCREEN:
|
||||
editor.disableFullScreen();
|
||||
which[buttonCount-1] = FULL_SCREEN;
|
||||
message(title[which[buttonCount-1]]);
|
||||
break;
|
||||
*/
|
||||
case RUN: editor.doRun(e.isShiftDown()); break;
|
||||
case STOP: setState(RUN, INACTIVE, true); editor.handleStop(); break;
|
||||
case OPEN: setState(OPEN, INACTIVE, true); break;
|
||||
case NEW: editor.skNew(); break;
|
||||
case SAVE: editor.doSave(); break;
|
||||
case EXPORT: editor.skExport(); break;
|
||||
}
|
||||
|
||||
currentSelection = -1;
|
||||
//update();
|
||||
///return true;
|
||||
}
|
||||
|
||||
|
||||
public void clear() { // (int button) {
|
||||
if (inactive == null) return;
|
||||
|
||||
//setState(button, INACTIVE);
|
||||
// skip the run button, do the others
|
||||
for (int i = 1; i < buttonCount; i++) {
|
||||
//state[i] = INACTIVE;
|
||||
//stateImage[i] = inactive[which[i]];
|
||||
setState(i, INACTIVE, false);
|
||||
}
|
||||
update();
|
||||
repaint(); // changed for swing from update();
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
if (inactive == null) return;
|
||||
clear();
|
||||
//setState(0, ACTIVE, true);
|
||||
setState(RUN, ACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
public void running(boolean yesno) {
|
||||
setState(RUN, yesno ? ACTIVE : INACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
public void clearRun() {
|
||||
if (inactive == null) return;
|
||||
//setState(0, INACTIVE, true);
|
||||
setState(RUN, INACTIVE, true);
|
||||
}
|
||||
|
||||
/*
|
||||
public boolean mouseUp(Event e, int x, int y) {
|
||||
if (wasDown == -1) return true;
|
||||
if (which[wasDown] == RUN) return true;
|
||||
|
||||
setState(wasDown, INACTIVE);
|
||||
wasDown = -1;
|
||||
//update();
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
public void message(String msg) { // formerly part of PdeEnvironment
|
||||
status.setText(msg + " "); // don't mind the hack
|
||||
public void message(String msg) {
|
||||
//status.setText(msg + " "); // don't mind the hack
|
||||
status = msg;
|
||||
}
|
||||
|
||||
public void messageClear(String msg) {
|
||||
if (status.getText().equals(msg + " ")) status.setText(PdeEditor.EMPTY);
|
||||
//if (status.getText().equals(msg + " ")) status.setText(PdeEditor.EMPTY);
|
||||
if (status.equals(msg)) status = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+19
-28
@@ -69,14 +69,10 @@ public class PdeEditorConsole extends JScrollPane {
|
||||
consoleDoc.setParagraphAttributes(0, 0, standard, true);
|
||||
|
||||
// build styles for different types of console output
|
||||
Color bgColor = PdePreferences.getColor("editor.console.bgcolor",
|
||||
new Color(0x1A, 0x1A, 0x00));
|
||||
Color fgColorOut = PdePreferences.getColor("editor.console.fgcolor.output",
|
||||
new Color(0xcc, 0xcc, 0xbb));
|
||||
Color fgColorErr = PdePreferences.getColor("editor.console.fgcolor.error",
|
||||
new Color(0xff, 0x30, 0x00));
|
||||
Font font = PdePreferences.getFont("editor.console.font",
|
||||
new Font("Monospaced", Font.PLAIN, 11));
|
||||
Color bgColor = PdePreferences.getColor("console.color");
|
||||
Color fgColorOut = PdePreferences.getColor("console.output.color");
|
||||
Color fgColorErr = PdePreferences.getColor("console.error.color");
|
||||
Font font = PdePreferences.getFont("console.font");
|
||||
|
||||
stdStyle = new SimpleAttributeSet();
|
||||
StyleConstants.setForeground(stdStyle, fgColorOut);
|
||||
@@ -103,7 +99,7 @@ public class PdeEditorConsole extends JScrollPane {
|
||||
// and size window accordingly
|
||||
FontMetrics metrics = this.getFontMetrics(font);
|
||||
int height = metrics.getAscent() + metrics.getDescent();
|
||||
int lines = PdePreferences.getInteger("editor.console.lines", 4);
|
||||
int lines = PdePreferences.getInteger("console.lines"); //, 4);
|
||||
int sizeFudge = 6; //10; // unclear why this is necessary, but it is
|
||||
setPreferredSize(new Dimension(1024, (height * lines) + sizeFudge));
|
||||
setMinimumSize(new Dimension(1024, (height * 4) + sizeFudge));
|
||||
@@ -112,28 +108,20 @@ public class PdeEditorConsole extends JScrollPane {
|
||||
systemOut = System.out;
|
||||
systemErr = System.err;
|
||||
|
||||
// macos9/macosx do this by default, disable for those platforms
|
||||
boolean tod = ((PdeBase.platform != PdeBase.MACOSX) &&
|
||||
(PdeBase.platform != PdeBase.MACOS9));
|
||||
|
||||
if (PdePreferences.getBoolean("editor.console.out.enabled", tod)) {
|
||||
String outFileName =
|
||||
PdePreferences.get("editor.console.out.file", "lib/stdout.txt");
|
||||
try {
|
||||
try {
|
||||
String outFileName = PdePreferences.get("console.output.file");
|
||||
if (outFileName != null) {
|
||||
stdoutFile = new FileOutputStream(outFileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (PdePreferences.getBoolean("editor.console.err.enabled", tod)) {
|
||||
String errFileName =
|
||||
PdePreferences.get("editor.console.err.file", "lib/stderr.txt");
|
||||
try {
|
||||
stderrFile = new FileOutputStream(errFileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
String errFileName = PdePreferences.get("console.error.file");
|
||||
if (errFileName != null) {
|
||||
stderrFile = new FileOutputStream(outFileName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
PdeBase.showWarning("Console Error",
|
||||
"A problem occurred while trying to open the\n" +
|
||||
"files used to store the console output.", e);
|
||||
}
|
||||
|
||||
consoleOut =
|
||||
@@ -141,7 +129,7 @@ public class PdeEditorConsole extends JScrollPane {
|
||||
consoleErr =
|
||||
new PrintStream(new PdeEditorConsoleStream(this, true, stderrFile));
|
||||
|
||||
if (PdePreferences.getBoolean("editor.console.enabled", true)) {
|
||||
if (PdePreferences.getBoolean("console")) {
|
||||
System.setOut(consoleOut);
|
||||
System.setErr(consoleErr);
|
||||
}
|
||||
@@ -175,10 +163,13 @@ public class PdeEditorConsole extends JScrollPane {
|
||||
// under osx, suppress the spew about the serial port
|
||||
// to avoid an error every time someone loads their app
|
||||
// (the error is dealt with in PdeBase with a message dialog)
|
||||
/*
|
||||
// no longer an issue. using a newer rev of rxtx
|
||||
if (PdeBase.platform == PdeBase.MACOSX) {
|
||||
if (what.equals("Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path")) return;
|
||||
if (what.equals("Caught java.lang.UnsatisfiedLinkError: readRegistrySerial while loading driver com.sun.comm.SolarisDriver")) return;
|
||||
}
|
||||
*/
|
||||
|
||||
// to console display
|
||||
appendText(what, err);
|
||||
|
||||
+16
-83
@@ -28,32 +28,20 @@ import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
|
||||
public class PdeEditorHeader extends Panel {
|
||||
static final String SKETCH_TITLER = "sketch";
|
||||
//static final String USER_TITLER = "user";
|
||||
|
||||
//static final Color primaryColor = Color.white;
|
||||
//static final Color secondaryColor = new Color(153, 153, 153);
|
||||
//static final Color backgroundColor = new Color(51, 51, 51);
|
||||
|
||||
static Color primaryColor; // = Color.white;
|
||||
static Color secondaryColor; // = new Color(153, 153, 153);
|
||||
static Color backgroundColor; // = new Color(51, 51, 51);
|
||||
static Color primaryColor;
|
||||
static Color secondaryColor;
|
||||
static Color backgroundColor;
|
||||
|
||||
PdeEditor editor;
|
||||
|
||||
//private String sketch; // name of current file
|
||||
int sketchLeft;
|
||||
int sketchRight;
|
||||
int sketchTitleLeft;
|
||||
//File sketchDir;
|
||||
boolean sketchModified;
|
||||
|
||||
//private String user;
|
||||
//int userLeft;
|
||||
//int userRight;
|
||||
//int userTitleLeft;
|
||||
|
||||
Font font;
|
||||
FontMetrics metrics;
|
||||
int fontAscent;
|
||||
@@ -67,12 +55,9 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
|
||||
this.editor = eddie; // weird name for listener
|
||||
|
||||
if (primaryColor == null) {
|
||||
backgroundColor = PdePreferences.getColor("editor.header.bgcolor",
|
||||
new Color(51, 51, 51));
|
||||
primaryColor = PdePreferences.getColor("editor.header.fgcolor.primary",
|
||||
new Color(255, 255, 255));
|
||||
secondaryColor = PdePreferences.getColor("editor.header.fgcolor.secondary",
|
||||
new Color(153, 153, 153));
|
||||
backgroundColor = PdePreferences.getColor("header.bgcolor");
|
||||
primaryColor = PdePreferences.getColor("header.fgcolor.primary");
|
||||
secondaryColor = PdePreferences.getColor("header.fgcolor.secondary");
|
||||
}
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@@ -93,20 +78,6 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
|
||||
update();
|
||||
}
|
||||
|
||||
/*
|
||||
public void setSketch(String sketch, File sketchDir) {
|
||||
this.sketch = sketch;
|
||||
this.sketchDir = sketchDir;
|
||||
sketchLeft = 0;
|
||||
update();
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
userLeft = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void update() {
|
||||
paint(this.getGraphics());
|
||||
@@ -147,21 +118,20 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
|
||||
|
||||
Graphics g = offscreen.getGraphics();
|
||||
if (font == null) {
|
||||
font = PdePreferences.getFont("editor.header.font",
|
||||
new Font("SansSerif", Font.PLAIN, 12));
|
||||
font = PdePreferences.getFont("header.font");
|
||||
g.setFont(font);
|
||||
metrics = g.getFontMetrics();
|
||||
fontAscent = metrics.getAscent();
|
||||
}
|
||||
|
||||
//if (sketchLeft == 0) {
|
||||
sketchTitleLeft = PdeEditor.INSET_SIZE;
|
||||
sketchTitleLeft = PdePreferences.GUI_SMALL;
|
||||
sketchLeft = sketchTitleLeft +
|
||||
metrics.stringWidth(SKETCH_TITLER) + PdeEditor.INSET_SIZE;
|
||||
metrics.stringWidth(SKETCH_TITLER) + PdePreferences.GUI_SMALL;
|
||||
sketchRight = sketchLeft + metrics.stringWidth(editor.sketchName);
|
||||
int modifiedLeft = sketchRight + PdeEditor.INSET_SIZE;
|
||||
int modifiedLeft = sketchRight + PdePreferences.GUI_SMALL;
|
||||
//int modifiedLeft = sketchLeft +
|
||||
//metrics.stringWidth(editor.sketchName) + PdeEditor.INSET_SIZE;
|
||||
//metrics.stringWidth(editor.sketchName) + PdePreferences.GUI_SMALL;
|
||||
|
||||
//sketch = editor.sketchName;
|
||||
//if (sketch == null) sketch = "";
|
||||
@@ -169,7 +139,7 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
|
||||
|
||||
//if (userLeft == 0) {
|
||||
//userLeft = sizeW - 20 - metrics.stringWidth(editor.userName);
|
||||
//userTitleLeft = userLeft - PdeEditor.INSET_SIZE -
|
||||
//userTitleLeft = userLeft - PdePreferences.GUI_SMALL -
|
||||
//metrics.stringWidth(USER_TITLER);
|
||||
|
||||
//user = editor.userName;
|
||||
@@ -199,58 +169,21 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
|
||||
//if (!boringUser) g.drawString(editor.userName, userLeft, baseline);
|
||||
|
||||
//g.setColor(fgColor[mode]);
|
||||
//g.drawString(message, PdeEditor.INSET_SIZE, (sizeH + fontAscent) / 2);
|
||||
//g.drawString(message, PdePreferences.GUI_SMALL, (sizeH + fontAscent) / 2);
|
||||
|
||||
screen.drawImage(offscreen, 0, 0, null);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected void setButtonBounds() {
|
||||
int top = (sizeH - BUTTON_HEIGHT) / 2;
|
||||
int noLeft = sizeW - PdeEditor.INSET_SIZE - BUTTON_WIDTH;
|
||||
int yesLeft = noLeft - PdeEditor.INSET_SIZE - BUTTON_WIDTH;
|
||||
|
||||
noButton.setBounds(noLeft, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
yesButton.setBounds(yesLeft, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
//return new Dimension(300, PdeEditor.GRID_SIZE);
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(300, PdeEditor.GRID_SIZE);
|
||||
return new Dimension(300, PdePreferences.GRID_SIZE);
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(3000, PdeEditor.GRID_SIZE);
|
||||
return new Dimension(3000, PdePreferences.GRID_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == noButton) {
|
||||
System.out.println("clicked no");
|
||||
|
||||
} else if (e.getSource() == yesButton) {
|
||||
System.out.println("clicked yes");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Color noticeBgColor = new Color(102, 102, 102);
|
||||
Color noticeFgColor = new Color(255, 255, 255);
|
||||
|
||||
Color errorBgColor = new Color(102, 26, 0);
|
||||
Color errorFgColor = new Color(255, 255, 255);
|
||||
|
||||
Color promptBgColor = new Color(204, 153, 0);
|
||||
Color promptFgColor = new COlor(0, 0, 0);
|
||||
*/
|
||||
|
||||
+44
-93
@@ -30,12 +30,7 @@ import javax.swing.*;
|
||||
import sun.awt.AppContext; // from java.awt.Dialog, for blocking
|
||||
|
||||
|
||||
#ifndef SWINGSUCKS
|
||||
public class PdeEditorStatus extends JPanel
|
||||
#else
|
||||
public class PdeEditorStatus extends Panel
|
||||
#endif
|
||||
implements ActionListener /*, Runnable*/ {
|
||||
public class PdeEditorStatus extends JPanel implements ActionListener {
|
||||
static Color bgcolor[];
|
||||
static Color fgcolor[];
|
||||
|
||||
@@ -64,22 +59,13 @@ public class PdeEditorStatus extends Panel
|
||||
int sizeW, sizeH;
|
||||
int imageW, imageH;
|
||||
|
||||
#ifndef SWINGSUCKS
|
||||
JButton yesButton;
|
||||
JButton noButton;
|
||||
JButton cancelButton;
|
||||
JButton okButton;
|
||||
JTextField editField;
|
||||
#else
|
||||
Button yesButton;
|
||||
Button noButton;
|
||||
Button cancelButton;
|
||||
Button okButton;
|
||||
TextField editField;
|
||||
#endif
|
||||
|
||||
//boolean editRename;
|
||||
Thread promptThread;
|
||||
//Thread promptThread;
|
||||
int response;
|
||||
|
||||
|
||||
@@ -89,23 +75,24 @@ public class PdeEditorStatus extends Panel
|
||||
|
||||
if (bgcolor == null) {
|
||||
bgcolor = new Color[4];
|
||||
bgcolor[0] = PdePreferences.getColor("editor.status.notice.bgcolor",
|
||||
new Color(102, 102, 102));
|
||||
bgcolor[1] = PdePreferences.getColor("editor.status.error.bgcolor",
|
||||
new Color(102, 26, 0));
|
||||
bgcolor[2] = PdePreferences.getColor("editor.status.prompt.bgcolor",
|
||||
new Color(204, 153, 0));
|
||||
bgcolor[3] = PdePreferences.getColor("editor.status.prompt.bgcolor",
|
||||
new Color(204, 153, 0));
|
||||
bgcolor[0] = PdePreferences.getColor("editor.status.notice.bgcolor");
|
||||
//new Color(102, 102, 102));
|
||||
bgcolor[1] = PdePreferences.getColor("editor.status.error.bgcolor");
|
||||
//new Color(102, 26, 0));
|
||||
bgcolor[2] = PdePreferences.getColor("editor.status.prompt.bgcolor");
|
||||
//new Color(204, 153, 0));
|
||||
bgcolor[3] = PdePreferences.getColor("editor.status.prompt.bgcolor");
|
||||
//new Color(204, 153, 0));
|
||||
|
||||
fgcolor = new Color[4];
|
||||
fgcolor[0] = PdePreferences.getColor("editor.status.notice.fgcolor",
|
||||
new Color(255, 255, 255));
|
||||
fgcolor[1] = PdePreferences.getColor("editor.status.error.fgcolor",
|
||||
new Color(255, 255, 255));
|
||||
fgcolor[2] = PdePreferences.getColor("editor.status.prompt.fgcolor",
|
||||
new Color(0, 0, 0));
|
||||
fgcolor[3] = PdePreferences.getColor("editor.status.prompt.fgcolor",
|
||||
new Color(0, 0, 0));
|
||||
fgcolor[0] = PdePreferences.getColor("editor.status.notice.fgcolor");
|
||||
//new Color(255, 255, 255));
|
||||
fgcolor[1] = PdePreferences.getColor("editor.status.error.fgcolor");
|
||||
//new Color(255, 255, 255));
|
||||
fgcolor[2] = PdePreferences.getColor("editor.status.prompt.fgcolor");
|
||||
//new Color(0, 0, 0));
|
||||
fgcolor[3] = PdePreferences.getColor("editor.status.prompt.fgcolor");
|
||||
//new Color(0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,8 +407,8 @@ public class PdeEditorStatus extends Panel
|
||||
|
||||
Graphics g = offscreen.getGraphics();
|
||||
if (font == null) {
|
||||
font = PdePreferences.getFont("editor.status.font",
|
||||
new Font("SansSerif", Font.PLAIN, 12));
|
||||
font = PdePreferences.getFont("status.font");
|
||||
//new Font("SansSerif", Font.PLAIN, 12));
|
||||
g.setFont(font);
|
||||
metrics = g.getFontMetrics();
|
||||
ascent = metrics.getAscent();
|
||||
@@ -434,7 +421,7 @@ public class PdeEditorStatus extends Panel
|
||||
|
||||
g.setColor(fgcolor[mode]);
|
||||
g.setFont(font); // needs to be set each time on osx
|
||||
g.drawString(message, PdeEditor.INSET_SIZE, (sizeH + ascent) / 2);
|
||||
g.drawString(message, PdePreferences.GUI_SMALL, (sizeH + ascent) / 2);
|
||||
|
||||
screen.drawImage(offscreen, 0, 0, null);
|
||||
}
|
||||
@@ -442,17 +429,11 @@ public class PdeEditorStatus extends Panel
|
||||
|
||||
protected void setup() {
|
||||
if (yesButton == null) {
|
||||
#ifndef SWINGSUCKS
|
||||
yesButton = new JButton(PROMPT_YES);
|
||||
noButton = new JButton(PROMPT_NO);
|
||||
cancelButton = new JButton(PROMPT_CANCEL);
|
||||
okButton = new JButton(PROMPT_OK);
|
||||
#else
|
||||
yesButton = new Button(PROMPT_YES);
|
||||
noButton = new Button(PROMPT_NO);
|
||||
cancelButton = new Button(PROMPT_CANCEL);
|
||||
okButton = new Button(PROMPT_OK);
|
||||
#endif
|
||||
|
||||
yesButton = new JButton(PdePreferences.PROMPT_YES);
|
||||
noButton = new JButton(PdePreferences.PROMPT_NO);
|
||||
cancelButton = new JButton(PdePreferences.PROMPT_CANCEL);
|
||||
okButton = new JButton(PdePreferences.PROMPT_OK);
|
||||
|
||||
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
|
||||
// os9 seems to work if bg of component is set, but x still a bastard
|
||||
@@ -479,11 +460,7 @@ public class PdeEditorStatus extends Panel
|
||||
cancelButton.setVisible(false);
|
||||
okButton.setVisible(false);
|
||||
|
||||
#ifndef SWINGSUCKS
|
||||
editField = new JTextField();
|
||||
#else
|
||||
editField = new TextField();
|
||||
#endif
|
||||
editField.addActionListener(this);
|
||||
|
||||
//if (PdeBase.platform != PdeBase.MACOSX) {
|
||||
@@ -585,23 +562,24 @@ public class PdeEditorStatus extends Panel
|
||||
|
||||
|
||||
protected void setButtonBounds() {
|
||||
int top = (sizeH - BUTTON_HEIGHT) / 2;
|
||||
int top = (sizeH - PdePreferences.BUTTON_HEIGHT) / 2;
|
||||
int eachButton = PdePreferences.GUI_SMALL + PdePreferences.BUTTON_WIDTH;
|
||||
|
||||
int cancelLeft = sizeW - PdeEditor.INSET_SIZE - PdePreferences.BUTTON_WIDTH;
|
||||
int noLeft = cancelLeft - PdeEditor.INSET_SIZE - PdePreferences.BUTTON_WIDTH;
|
||||
int yesLeft = noLeft - PdeEditor.INSET_SIZE - PdePreferences.BUTTON_WIDTH;
|
||||
int cancelLeft = sizeW - eachButton;
|
||||
int noLeft = cancelLeft - eachButton;
|
||||
int yesLeft = noLeft - eachButton;
|
||||
|
||||
yesButton.setBounds(yesLeft, top,
|
||||
PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
noButton.setBounds(noLeft, top,
|
||||
PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
cancelButton.setBounds(cancelLeft, top,
|
||||
PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
yesButton.setLocation(yesLeft, top);
|
||||
noButton.setLocation(noLeft, top);
|
||||
cancelButton.setLocation(cancelLeft, top);
|
||||
editField.setLocation(yesLeft - PdePreferences.BUTTON_WIDTH, top);
|
||||
okButton.setLocation(noLeft, top);
|
||||
|
||||
editField.setBounds(yesLeft - PdePreferences.BUTTON_WIDTH, top,
|
||||
PdePreferences.BUTTON_WIDTH*2, PdePreferences.BUTTON_HEIGHT);
|
||||
okButton.setBounds(noLeft, top,
|
||||
PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
yesButton.setSize( PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
noButton.setSize( PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
cancelButton.setSize(PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
okButton.setSize( PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
editField.setSize( 2*PdePreferences.BUTTON_WIDTH, PdePreferences.BUTTON_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
@@ -610,11 +588,11 @@ public class PdeEditorStatus extends Panel
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(300, PdeEditor.GRID_SIZE);
|
||||
return new Dimension(300, PdePreferences.GRID_SIZE);
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(3000, PdeEditor.GRID_SIZE);
|
||||
return new Dimension(3000, PdePreferences.GRID_SIZE);
|
||||
}
|
||||
|
||||
|
||||
@@ -642,22 +620,7 @@ public class PdeEditorStatus extends Panel
|
||||
|
||||
} else if (e.getSource() == okButton) {
|
||||
String answer = editField.getText();
|
||||
/*
|
||||
// no longer necessary, better key trapping via keyTyped()
|
||||
if (PdeBase.platform == PdeBase.MACOSX) {
|
||||
char unscrubbed[] = editField.getText().toCharArray();
|
||||
for (int i = 0; i < unscrubbed.length; i++) {
|
||||
if (!(((unscrubbed[i] >= '0') && (unscrubbed[i] <= '9')) ||
|
||||
((unscrubbed[i] >= 'A') && (unscrubbed[i] <= 'Z')) ||
|
||||
((unscrubbed[i] >= 'a') && (unscrubbed[i] <= 'z')))) {
|
||||
unscrubbed[i] = '_';
|
||||
}
|
||||
}
|
||||
answer = new String(unscrubbed);
|
||||
}
|
||||
*/
|
||||
editor.skSaveAs2(answer);
|
||||
//editor.skDuplicateRename2(editField.getText(), editRename);
|
||||
unedit();
|
||||
|
||||
} else if (e.getSource() == editField) {
|
||||
@@ -665,15 +628,3 @@ public class PdeEditorStatus extends Panel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Color noticeBgColor = new Color(102, 102, 102);
|
||||
Color noticeFgColor = new Color(255, 255, 255);
|
||||
|
||||
Color errorBgColor = new Color(102, 26, 0);
|
||||
Color errorFgColor = new Color(255, 255, 255);
|
||||
|
||||
Color promptBgColor = new Color(204, 153, 0);
|
||||
Color promptFgColor = new COlor(0, 0, 0);
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -47,7 +48,7 @@ public class PdeKeywords extends CTokenMarker {
|
||||
static public KeywordMap getKeywords() {
|
||||
if (keywordColoring == null) {
|
||||
try {
|
||||
keywords = new KeywordMap(false);
|
||||
keywordColoring = new KeywordMap(false);
|
||||
keywordToReference = new Hashtable();
|
||||
|
||||
InputStream input = PdeBase.getStream("keywords.txt");
|
||||
@@ -66,24 +67,25 @@ public class PdeKeywords extends CTokenMarker {
|
||||
|
||||
if (coloring.length() > 0) {
|
||||
// text will be KEYWORD or LITERAL
|
||||
boolean isKeyword = (coloring.charAt(0) == 'K');
|
||||
boolean isKey = (coloring.charAt(0) == 'K');
|
||||
// KEYWORD1 -> 0, KEYWORD2 -> 1, etc
|
||||
int num = coloring.charAt(coloring.length() - 1) - '1';
|
||||
int constant = (isKeyword ? KEYWORD : LITERAL) + num;
|
||||
keywordColoring.add(keyword, constant);
|
||||
byte id = (byte) ((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
|
||||
keywordColoring.add(keyword, id);
|
||||
}
|
||||
|
||||
if (htmlFilename.length() > 0) {
|
||||
keywordToReference.put(keyword, htmlFilename);
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
PdeBase.showError("Problem loading keywords",
|
||||
"Could not find keywords.txt,\n" +
|
||||
"please re-install Processing.", e);
|
||||
System.exit(1);
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
return keywordColoring;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public class PdePreferences extends JComponent {
|
||||
|
||||
// value for the size bars, buttons, etc
|
||||
|
||||
//static final int INSET_SIZE = 5;
|
||||
static final int GRID_SIZE = 33;
|
||||
|
||||
// gui variables
|
||||
|
||||
@@ -81,7 +81,7 @@ public class PdePreprocessor {
|
||||
this.programReader = new StringReader(program);
|
||||
this.buildPath = buildPath;
|
||||
|
||||
usingExternal = PdePreferences.getBoolean("play.external", false);
|
||||
usingExternal = PdePreferences.getBoolean("run.external"); //, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ public class PdePreprocessor {
|
||||
// if desired, serialize the parse tree to an XML file. can
|
||||
// be viewed usefully with Mozilla or IE
|
||||
|
||||
if (PdePreferences.getBoolean("compiler.output_parse_tree", false)) {
|
||||
if (PdePreferences.getBoolean("compiler.output_parse_tree")) {
|
||||
|
||||
stream = new PrintStream(new FileOutputStream("parseTree.xml"));
|
||||
stream.println("<?xml version=\"1.0\"?>");
|
||||
|
||||
+17
-10
@@ -46,6 +46,7 @@ public class PdeSketchbook {
|
||||
|
||||
public PdeSketchbook(PdeEditor editor) {
|
||||
this.editor = editor;
|
||||
menu = new JMenu("Open");
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +67,18 @@ public class PdeSketchbook {
|
||||
}
|
||||
|
||||
|
||||
public JPopupMenu getPopup() {
|
||||
return menu.getPopupMenu();
|
||||
}
|
||||
|
||||
//public void rebuildPopup(JPopupMenu popup) {
|
||||
//rebuildMenu();
|
||||
//popup.
|
||||
//}
|
||||
|
||||
|
||||
public JMenu rebuildMenu() {
|
||||
if (menu == null) {
|
||||
menu = new JMenu("Open");
|
||||
} else {
|
||||
menu.removeAll();
|
||||
}
|
||||
menu.removeAll();
|
||||
|
||||
try {
|
||||
//MenuItem newSketchItem = new MenuItem("New Sketch");
|
||||
@@ -87,7 +94,7 @@ public class PdeSketchbook {
|
||||
sketchbookFolder.mkdirs();
|
||||
}
|
||||
|
||||
addSketches(sketchbookFolder);
|
||||
addSketches(menu, sketchbookFolder);
|
||||
|
||||
// TODO add examples folder here too
|
||||
|
||||
@@ -161,7 +168,7 @@ public class PdeSketchbook {
|
||||
}
|
||||
|
||||
|
||||
protected boolean addSketches(Menu menu, File folder) throws IOException {
|
||||
protected boolean addSketches(JMenu menu, File folder) throws IOException {
|
||||
// skip .DS_Store files, etc
|
||||
if (!folder.isDirectory()) return false;
|
||||
|
||||
@@ -180,13 +187,13 @@ public class PdeSketchbook {
|
||||
|
||||
File subfolder = new File(folder, list[i]);
|
||||
if (new File(subfolder, list[i] + ".pde").exists()) {
|
||||
MenuItem item = new MenuItem(list[i]);
|
||||
JMenuItem item = new JMenuItem(list[i]);
|
||||
item.addActionListener(listener);
|
||||
menu.add(item);
|
||||
ifound = true;
|
||||
|
||||
} else { // might contain other dirs, get recursive
|
||||
Menu submenu = new Menu(list[i]);
|
||||
JMenu submenu = new JMenu(list[i]);
|
||||
// needs to be separate var
|
||||
// otherwise would set ifound to false
|
||||
boolean found = addSketches(submenu, subfolder); //, false);
|
||||
@@ -229,7 +236,7 @@ public class PdeSketchbook {
|
||||
// not a .DS_Store file or another random user folder
|
||||
|
||||
if (pde.exists()) {
|
||||
if (calcFolderSize(prey) == 0) {
|
||||
if (PdeBase.calcFolderSize(prey) == 0) {
|
||||
//System.out.println("i want to remove " + prey);
|
||||
PdeBase.removeDir(prey);
|
||||
//} else {
|
||||
|
||||
@@ -16,15 +16,18 @@ com.apple.mrj.application.classpath=lib/build:Contents/Resources/Java/build:Cont
|
||||
|
||||
com.apple.mrj.application.stdin=/dev/null
|
||||
|
||||
com.apple.mrj.application.stdout=lib/stdout.txt
|
||||
com.apple.mrj.application.stdout.append=false
|
||||
com.apple.mrj.application.stdout.file.creator=ttxt
|
||||
com.apple.mrj.application.stdout.unicode=false
|
||||
# this is handled in p5 by the console.output.file and console.error.file
|
||||
# hopefully this can be disabled for mac so it won't be duplicated here
|
||||
|
||||
com.apple.mrj.application.stderr=lib/stderr.txt
|
||||
com.apple.mrj.application.stderr.append=false
|
||||
com.apple.mrj.application.stderr.file.creator=ttxt
|
||||
com.apple.mrj.application.stderr.unicode=false
|
||||
#com.apple.mrj.application.stdout=lib/stdout.txt
|
||||
#com.apple.mrj.application.stdout.append=false
|
||||
#com.apple.mrj.application.stdout.file.creator=ttxt
|
||||
#com.apple.mrj.application.stdout.unicode=false
|
||||
|
||||
#com.apple.mrj.application.stderr=lib/stderr.txt
|
||||
#com.apple.mrj.application.stderr.append=false
|
||||
#com.apple.mrj.application.stderr.file.creator=ttxt
|
||||
#com.apple.mrj.application.stderr.unicode=false
|
||||
|
||||
com.apple.mrj.application.build.version=1.0
|
||||
com.apple.mrj.application.classloading.verbose=false
|
||||
|
||||
@@ -84,34 +84,40 @@ editor.invalid=false
|
||||
editor.invalid.style=#7E7E00,bold
|
||||
|
||||
|
||||
editor.buttons.bgcolor = #999988
|
||||
editor.buttons.status.font = SansSerif,plain,10
|
||||
editor.buttons.status.color = #333322
|
||||
buttons.bgcolor = #999988
|
||||
buttons.status.font = SansSerif,plain,10
|
||||
buttons.status.color = #333322
|
||||
|
||||
editor.header.bgcolor = #333322
|
||||
editor.header.fgcolor.primary = #ffffff
|
||||
editor.header.fgcolor.secondary = #ccccbb
|
||||
editor.header.font = SansSerif,plain,12
|
||||
header.bgcolor = #333322
|
||||
header.fgcolor.primary = #ffffff
|
||||
header.fgcolor.secondary = #ccccbb
|
||||
header.font = SansSerif,plain,12
|
||||
|
||||
console.bgcolor = #1A1A00
|
||||
console.fgcolor.output = #ccccbb
|
||||
console.fgcolor.error = #ff3000
|
||||
console = true
|
||||
console.color = #1A1A00
|
||||
console.output.color = #ccccbb
|
||||
console.output.file = stdout.txt
|
||||
console.error.color = #ff3000
|
||||
console.error.file = stderr.txt
|
||||
console.font = Monospaced,plain,11
|
||||
console.font.macosx = Monaco,plain,10
|
||||
console.lines = 4
|
||||
|
||||
editor.status.notice.fgcolor = #333322
|
||||
editor.status.notice.bgcolor = #bbbbaa
|
||||
editor.status.error.fgcolor = #ffffee
|
||||
editor.status.error.bgcolor = #880000
|
||||
editor.status.prompt.fgcolor = #ffffee
|
||||
editor.status.prompt.bgcolor = #CC9900
|
||||
editor.status.font = SansSerif,plain,12
|
||||
status.notice.fgcolor = #ffffff
|
||||
status.notice.bgcolor = #666666
|
||||
status.error.fgcolor = #ffffff
|
||||
status.error.bgcolor = #662000
|
||||
status.prompt.fgcolor = #000000
|
||||
status.prompt.bgcolor = #cc9900
|
||||
status.font = SansSerif,plain,12
|
||||
|
||||
# convert tabs to spaces? how many spaces?
|
||||
editor.tabs.expand = true
|
||||
editor.tabs.size = 2
|
||||
|
||||
# automatically indent each line
|
||||
editor.indent = true
|
||||
|
||||
# size of divider between editing area and the console
|
||||
editor.divider.size = 0
|
||||
# the larger divider on windows is ugly with the little arrows
|
||||
@@ -119,15 +125,15 @@ editor.divider.size = 0
|
||||
# but keeps it from being annoyingly obtrusive
|
||||
editor.divider.size.windows = 2
|
||||
|
||||
# automatically indent each line
|
||||
editor.indent = true
|
||||
|
||||
# how many lines to scroll for each tick on the wheel mouse
|
||||
editor.wheelmouse.multiplier = 3
|
||||
|
||||
# background color for full-screen presentation mode
|
||||
run.present.bgcolor = #666666
|
||||
|
||||
# set true to just always run externally
|
||||
run.external = false
|
||||
|
||||
# set internally
|
||||
#run.window.bgcolor=
|
||||
|
||||
@@ -151,17 +157,22 @@ history.recording = true
|
||||
export.library = false
|
||||
|
||||
# may be useful when attempting to debug the preprocessor
|
||||
#editor.save_build_files=false
|
||||
compiler.save_build_files=false
|
||||
|
||||
# allows various preprocessor features to be toggled in case they are
|
||||
# causing problems
|
||||
#compiler.color_datatype = true
|
||||
#compiler.substitute_floats = true
|
||||
#compiler.web_colors = true
|
||||
#compiler.enhanced_casting = true
|
||||
#compiler.substitute_image = true
|
||||
#compiler.substitute_font = true
|
||||
# allows various preprocessor features to be toggled
|
||||
# in case they are causing problems
|
||||
|
||||
# preprocessor: pde.g
|
||||
compiler.color_datatype = true
|
||||
compiler.web_colors = true
|
||||
compiler.enhanced_casting = true
|
||||
|
||||
# preprocessor: PdeEmitter.java
|
||||
compiler.substitute_floats = true
|
||||
compiler.substitute_image = false
|
||||
compiler.substitute_font = false
|
||||
|
||||
# PdeCompiler.java
|
||||
# writes out the parse tree as parseTree.xml, which can be usefully
|
||||
# viewed in (at least) Mozilla or IE. useful when debugging the preprocessor.
|
||||
#compiler.output_parse_tree = false
|
||||
compiler.output_parse_tree = false
|
||||
|
||||
Reference in New Issue
Block a user