mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-20 21:01:25 +03:00
Syncing with Processing 1.0.7 (5692); needs testing.
Also, the Sketchbook and Examples menus are currently disabled on the Mac to work-around a bug in Apple's implementation of Java. I think this bug may have been solved, so I should try re-enabling the menus and see what happens (on 10.4 and 10.5 and 10.6). Also, I may still need to update the jre / jdk on Linux.
This commit is contained in:
@ -3,13 +3,12 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -44,14 +43,14 @@ public class Base {
|
||||
static final int REVISION = 18;
|
||||
static String VERSION_NAME = "0018";
|
||||
|
||||
static HashMap<Integer, String> platformNames = new HashMap();
|
||||
static HashMap<Integer, String> platformNames = new HashMap<Integer, String>();
|
||||
static {
|
||||
platformNames.put(PConstants.WINDOWS, "windows");
|
||||
platformNames.put(PConstants.MACOSX, "macosx");
|
||||
platformNames.put(PConstants.LINUX, "linux");
|
||||
}
|
||||
|
||||
static HashMap<String, Integer> platformIndices = new HashMap();
|
||||
static HashMap<String, Integer> platformIndices = new HashMap<String, Integer>();
|
||||
static {
|
||||
platformIndices.put("windows", PConstants.WINDOWS);
|
||||
platformIndices.put("macosx", PConstants.MACOSX);
|
||||
@ -75,7 +74,7 @@ public class Base {
|
||||
static private File librariesFolder;
|
||||
static private File toolsFolder;
|
||||
static private File hardwareFolder;
|
||||
|
||||
|
||||
static HashSet<File> libraries;
|
||||
|
||||
// maps imported packages to their library folder
|
||||
@ -90,7 +89,7 @@ public class Base {
|
||||
static File untitledFolder;
|
||||
|
||||
// p5 icon for the window
|
||||
static Image icon;
|
||||
// static Image icon;
|
||||
|
||||
// int editorCount;
|
||||
// Editor[] editors;
|
||||
@ -102,8 +101,24 @@ public class Base {
|
||||
// int nextEditorX;
|
||||
// int nextEditorY;
|
||||
|
||||
// import com.sun.jna.Library;
|
||||
// import com.sun.jna.Native;
|
||||
|
||||
// public interface CLibrary extends Library {
|
||||
// CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
|
||||
// int setenv(String name, String value, int overwrite);
|
||||
// String getenv(String name);
|
||||
// int unsetenv(String name);
|
||||
// int putenv(String string);
|
||||
// }
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
// /Users/fry/coconut/sketchbook/libraries/gsvideo/library
|
||||
// CLibrary clib = CLibrary.INSTANCE;
|
||||
// clib.setenv("DYLD_LIBRARY_PATH", "/Users/fry/coconut/sketchbook/libraries/gsvideo/library", 1);
|
||||
// System.out.println("env is now " + clib.getenv("DYLD_LIBRARY_PATH"));
|
||||
|
||||
try {
|
||||
File versionFile = getContentFile("lib/version.txt");
|
||||
if (versionFile.exists()) {
|
||||
@ -188,12 +203,14 @@ public class Base {
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
"</style> </head> <body>" +
|
||||
"<b>The standard menu bar has been disabled.</b>" +
|
||||
"<p>Due to an Apple bug, the Arduino menu bar " +
|
||||
"is unusable on Mac OS X 10.5. <br>" +
|
||||
"As a workaround, the menu bar will be placed inside " +
|
||||
"the editor window. This <br>setting can be changed in the " +
|
||||
"Preferences window. If this bug makes you sad, <br>" +
|
||||
"<b>Some menus have been disabled.</b>" +
|
||||
"<p>Due to an Apple bug, the Sketchbook and Example menus " +
|
||||
"are unusable. <br>" +
|
||||
"As a workaround, these items will be disabled from the " +
|
||||
"standard menu bar, <br>" +
|
||||
"but you can use the Open button on " +
|
||||
"the toolbar to access the same items. <br>" +
|
||||
"If this bug makes you sad, " +
|
||||
"please contact Apple via bugreporter.apple.com.</p>" +
|
||||
"</body> </html>";
|
||||
Object[] options = { "OK", "More Info" };
|
||||
@ -210,13 +227,18 @@ public class Base {
|
||||
// But don't bother setting the preference in the file
|
||||
} else {
|
||||
// Shut off in the preferences for next time
|
||||
Preferences.set(properMenuBar, "false");
|
||||
//Preferences.set(properMenuBar, "false");
|
||||
// For 1.0.4, we'll stick with the Apple menu bar,
|
||||
// and just disable the sketchbook and examples sub-menus.
|
||||
Preferences.set(properMenuBar, "true");
|
||||
if (result == 1) { // More Info
|
||||
Base.openURL("http://dev.processing.org/bugs/show_bug.cgi?id=786");
|
||||
}
|
||||
}
|
||||
// Whether or not canceled, set to false (right now) if we're on 10.5
|
||||
System.setProperty(properMenuBar, "false");
|
||||
//System.setProperty(properMenuBar, "false");
|
||||
// Changing this behavior for 1.0.4
|
||||
System.setProperty(properMenuBar, "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -711,13 +733,17 @@ public class Base {
|
||||
|
||||
|
||||
protected Editor handleOpen(String path, int[] location) {
|
||||
// System.err.println("entering handleOpen " + path);
|
||||
|
||||
File file = new File(path);
|
||||
if (!file.exists()) return null;
|
||||
|
||||
// System.err.println(" editors: " + editors);
|
||||
// Cycle through open windows to make sure that it's not already open.
|
||||
for (Editor editor : editors) {
|
||||
if (editor.getSketch().getMainFilePath().equals(path)) {
|
||||
editor.toFront();
|
||||
// System.err.println(" handleOpen: already opened");
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
@ -736,10 +762,23 @@ public class Base {
|
||||
// }
|
||||
// }
|
||||
|
||||
// System.err.println(" creating new editor");
|
||||
Editor editor = new Editor(this, path, location);
|
||||
// Editor editor = null;
|
||||
// try {
|
||||
// editor = new Editor(this, path, location);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// System.err.flush();
|
||||
// System.out.flush();
|
||||
// System.exit(1);
|
||||
// }
|
||||
// System.err.println(" done creating new editor");
|
||||
// EditorConsole.systemErr.println(" done creating new editor");
|
||||
|
||||
// Make sure that the sketch actually loaded
|
||||
if (editor.getSketch() == null) {
|
||||
// System.err.println("sketch was null, getting out of handleOpen");
|
||||
return null; // Just walk away quietly
|
||||
}
|
||||
|
||||
@ -763,6 +802,8 @@ public class Base {
|
||||
// (don't do earlier, cuz we might move it based on a window being closed)
|
||||
editor.setVisible(true);
|
||||
|
||||
// System.err.println("exiting handleOpen");
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
@ -952,9 +993,16 @@ public class Base {
|
||||
protected void rebuildSketchbookMenu(JMenu menu) {
|
||||
//System.out.println("rebuilding sketchbook menu");
|
||||
//new Exception().printStackTrace();
|
||||
boolean nativeButBroken = Base.isMacOS() ?
|
||||
Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
|
||||
|
||||
try {
|
||||
menu.removeAll();
|
||||
addSketches(menu, getSketchbookFolder(), false);
|
||||
if (nativeButBroken) { // osx workaround
|
||||
menu.setEnabled(false);
|
||||
} else {
|
||||
menu.removeAll();
|
||||
addSketches(menu, getSketchbookFolder(), false);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -964,40 +1012,52 @@ public class Base {
|
||||
public void rebuildImportMenu(JMenu importMenu) {
|
||||
//System.out.println("rebuilding import menu");
|
||||
importMenu.removeAll();
|
||||
|
||||
|
||||
// reset the set of libraries
|
||||
libraries = new HashSet<File>();
|
||||
|
||||
// reset the table mapping imports to libraries
|
||||
importToLibraryTable = new HashMap<String, File>();
|
||||
|
||||
// Add libraries found in the sketchbook folder
|
||||
try {
|
||||
File sketchbookLibraries = getSketchbookLibrariesFolder();
|
||||
boolean found = addLibraries(importMenu, sketchbookLibraries);
|
||||
if (found) importMenu.addSeparator();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Add from the "libraries" subfolder in the Processing directory
|
||||
try {
|
||||
addLibraries(importMenu, librariesFolder);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Add libraries found in the sketchbook folder
|
||||
int separatorIndex = importMenu.getItemCount();
|
||||
try {
|
||||
File sketchbookLibraries = getSketchbookLibrariesFolder();
|
||||
boolean found = addLibraries(importMenu, sketchbookLibraries);
|
||||
if (found) {
|
||||
JMenuItem contrib = new JMenuItem("Contributed");
|
||||
contrib.setEnabled(false);
|
||||
importMenu.insert(contrib, separatorIndex);
|
||||
importMenu.insertSeparator(separatorIndex);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void rebuildExamplesMenu(JMenu menu) {
|
||||
//System.out.println("rebuilding examples menu");
|
||||
boolean nativeButBroken = Base.isMacOS() ?
|
||||
Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
|
||||
|
||||
try {
|
||||
menu.removeAll();
|
||||
boolean found = addSketches(menu, examplesFolder, false);
|
||||
if (found) menu.addSeparator();
|
||||
found = addSketches(menu, getSketchbookLibrariesFolder(), false);
|
||||
if (found) menu.addSeparator();
|
||||
addSketches(menu, librariesFolder, false);
|
||||
if (nativeButBroken) { // osx workaround
|
||||
menu.setEnabled(false);
|
||||
} else {
|
||||
menu.removeAll();
|
||||
boolean found = addSketches(menu, examplesFolder, false);
|
||||
if (found) menu.addSeparator();
|
||||
found = addSketches(menu, getSketchbookLibrariesFolder(), false);
|
||||
if (found) menu.addSeparator();
|
||||
addSketches(menu, librariesFolder, false);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1084,18 +1144,18 @@ public class Base {
|
||||
boolean found = addSketches(menu, subfolder, openReplaces); //, false);
|
||||
if (found) ifound = true;
|
||||
} else {
|
||||
// not a sketch folder, but maybe a subfolder containing sketches
|
||||
JMenu submenu = new JMenu(list[i]);
|
||||
// needs to be separate var
|
||||
// otherwise would set ifound to false
|
||||
boolean found = addSketches(submenu, subfolder, openReplaces); //, false);
|
||||
if (found) {
|
||||
menu.add(submenu);
|
||||
ifound = true;
|
||||
}
|
||||
// not a sketch folder, but maybe a subfolder containing sketches
|
||||
JMenu submenu = new JMenu(list[i]);
|
||||
// needs to be separate var
|
||||
// otherwise would set ifound to false
|
||||
boolean found = addSketches(submenu, subfolder, openReplaces); //, false);
|
||||
if (found) {
|
||||
menu.add(submenu);
|
||||
ifound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ifound; // actually ignored, but..
|
||||
}
|
||||
|
||||
@ -1126,23 +1186,24 @@ public class Base {
|
||||
|
||||
boolean ifound = false;
|
||||
|
||||
for (String libraryName : list) {
|
||||
File subfolder = new File(folder, libraryName);
|
||||
for (String potentialName : list) {
|
||||
File subfolder = new File(folder, potentialName);
|
||||
// File libraryFolder = new File(subfolder, "library");
|
||||
// File libraryJar = new File(libraryFolder, libraryName + ".jar");
|
||||
// File libraryJar = new File(libraryFolder, potentialName + ".jar");
|
||||
// // If a .jar file of the same prefix as the folder exists
|
||||
// // inside the 'library' subfolder of the sketch
|
||||
// if (libraryJar.exists()) {
|
||||
String sanityCheck = Sketch.sanitizeName(libraryName);
|
||||
if (!sanityCheck.equals(libraryName)) {
|
||||
String sanityCheck = Sketch.sanitizeName(potentialName);
|
||||
if (!sanityCheck.equals(potentialName)) {
|
||||
String mess =
|
||||
"The library \"" + libraryName + "\" cannot be used.\n" +
|
||||
"The library \"" + potentialName + "\" cannot be used.\n" +
|
||||
"Library names must contain only basic letters and numbers.\n" +
|
||||
"(ascii only and no spaces, and it cannot start with a number)";
|
||||
"(ASCII only and no spaces, and it cannot start with a number)";
|
||||
Base.showMessage("Ignoring bad library name", mess);
|
||||
continue;
|
||||
}
|
||||
|
||||
String libraryName = potentialName;
|
||||
// // get the path for all .jar files in this code folder
|
||||
// String libraryClassPath =
|
||||
// Compiler.contentsToClassPath(libraryFolder);
|
||||
@ -1399,8 +1460,8 @@ public class Base {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public Set<File> getLibraries() {
|
||||
return libraries;
|
||||
}
|
||||
@ -1424,8 +1485,8 @@ public class Base {
|
||||
static public String getToolsPath() {
|
||||
return toolsFolder.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public File getHardwareFolder() {
|
||||
// calculate on the fly because it's needed by Preferences.init() to find
|
||||
// the boards.txt and programmers.txt preferences files (which happens
|
||||
@ -1457,8 +1518,8 @@ public class Base {
|
||||
static public File getSketchbookLibrariesFolder() {
|
||||
return new File(getSketchbookFolder(), "libraries");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public String getSketchbookLibrariesPath() {
|
||||
return getSketchbookLibrariesFolder().getAbsolutePath();
|
||||
}
|
||||
@ -1658,7 +1719,7 @@ public class Base {
|
||||
File referenceFile = new File(referenceFolder, filename);
|
||||
openURL(referenceFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
static public void showGettingStarted() {
|
||||
if (Base.isMacOS()) {
|
||||
Base.showReference("Guide_MacOSX.html");
|
||||
@ -1687,8 +1748,8 @@ public class Base {
|
||||
static public void showTroubleshooting() {
|
||||
showReference("Guide_Troubleshooting.html");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public void showFAQ() {
|
||||
showReference("faq.html");
|
||||
}
|
||||
|
@ -3,13 +3,12 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -81,7 +80,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
JMenu fileMenu;
|
||||
JMenu sketchMenu;
|
||||
JMenu toolsMenu;
|
||||
|
||||
|
||||
int numTools = 0;
|
||||
|
||||
EditorToolbar toolbar;
|
||||
@ -91,7 +90,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
static JMenu sketchbookMenu;
|
||||
static JMenu examplesMenu;
|
||||
static JMenu importMenu;
|
||||
|
||||
|
||||
// these menus are shared so that the board and serial port selections
|
||||
// are the same for all windows (since the board and serial port that are
|
||||
// actually used are determined by the preferences, which are shared)
|
||||
@ -161,8 +160,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// When bringing a window to front, let the Base know
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowActivated(WindowEvent e) {
|
||||
// System.err.println("activate"); // not coming through
|
||||
base.handleActivated(Editor.this);
|
||||
|
||||
// re-add the sub-menus that are shared by all windows
|
||||
fileMenu.insert(sketchbookMenu, 2);
|
||||
fileMenu.insert(examplesMenu, 3);
|
||||
@ -170,11 +169,22 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
toolsMenu.insert(boardsMenu, numTools);
|
||||
toolsMenu.insert(serialMenu, numTools + 1);
|
||||
}
|
||||
|
||||
// added for 1.0.5
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
// System.err.println("deactivate"); // not coming through
|
||||
fileMenu.remove(sketchbookMenu);
|
||||
fileMenu.remove(examplesMenu);
|
||||
sketchMenu.remove(importMenu);
|
||||
toolsMenu.remove(boardsMenu);
|
||||
toolsMenu.remove(serialMenu);
|
||||
}
|
||||
});
|
||||
|
||||
//PdeKeywords keywords = new PdeKeywords();
|
||||
//sketchbook = new Sketchbook(this);
|
||||
|
||||
|
||||
if (serialMonitor == null)
|
||||
serialMonitor = new SerialMonitor(Preferences.get("serial.port"));
|
||||
|
||||
@ -717,7 +727,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
URL[] urlList = new URL[archives.length];
|
||||
for (int j = 0; j < urlList.length; j++) {
|
||||
urlList[j] = archives[j].toURL();
|
||||
urlList[j] = archives[j].toURI().toURL();
|
||||
}
|
||||
URLClassLoader loader = new URLClassLoader(urlList);
|
||||
|
||||
@ -819,7 +829,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
final Tool tool = (Tool) toolClass.newInstance();
|
||||
|
||||
JMenuItem item = new JMenuItem(tool.getMenuTitle());
|
||||
|
||||
|
||||
tool.init(Editor.this);
|
||||
|
||||
item.addActionListener(new ActionListener() {
|
||||
@ -828,14 +838,14 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
});
|
||||
return item;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected JMenu addInternalTools(JMenu menu) {
|
||||
JMenuItem item;
|
||||
|
||||
@ -963,7 +973,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
|
||||
protected JMenu buildHelpMenu() {
|
||||
JMenu menu = new JMenu("Help");
|
||||
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
|
||||
// so that the OS doesn't try to insert its slow help menu.
|
||||
JMenu menu = new JMenu("Help ");
|
||||
JMenuItem item;
|
||||
|
||||
/*
|
||||
@ -1764,7 +1776,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
sketch.compile(new Target(
|
||||
Base.getHardwarePath() + File.separator + "cores",
|
||||
Preferences.get("boards." + Preferences.get("board") + ".build.core")),
|
||||
@ -1776,10 +1788,10 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
toolbar.deactivate(EditorToolbar.RUN);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -2237,8 +2249,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void handleSerial() {
|
||||
if (uploading) return;
|
||||
serialMonitor.setVisible(true);
|
||||
|
@ -305,16 +305,17 @@ public class EditorConsole extends JScrollPane {
|
||||
public void flush() { }
|
||||
|
||||
public void write(byte b[]) { // appears never to be used
|
||||
// if (currentConsole.isDisplayable()) {
|
||||
currentConsole.write(b, 0, b.length, err);
|
||||
// } else {
|
||||
// systemOut.println("not displayable");
|
||||
// if (err) {
|
||||
// systemErr.write(b, 0, b.length);
|
||||
// } else {
|
||||
// systemOut.write(b, 0, b.length);
|
||||
// }
|
||||
// }
|
||||
if (currentConsole != null) {
|
||||
currentConsole.write(b, 0, b.length, err);
|
||||
} else {
|
||||
try {
|
||||
if (err) {
|
||||
systemErr.write(b);
|
||||
} else {
|
||||
systemOut.write(b);
|
||||
}
|
||||
} catch (IOException e) { } // just ignore, where would we write?
|
||||
}
|
||||
|
||||
OutputStream echo = err ? stderrFile : stdoutFile;
|
||||
if (echo != null) {
|
||||
@ -329,18 +330,17 @@ public class EditorConsole extends JScrollPane {
|
||||
}
|
||||
|
||||
public void write(byte b[], int offset, int length) {
|
||||
currentConsole.write(b, offset, length, err);
|
||||
// if (currentConsole.isDisplayable()) {
|
||||
// systemOut.println("is displayable");
|
||||
// currentConsole.write(b, offset, length, err);
|
||||
// } else {
|
||||
// systemOut.println("not displayable");
|
||||
// if (err) {
|
||||
// systemErr.write(b, offset, length);
|
||||
// } else {
|
||||
// systemOut.write(b, offset, length);
|
||||
// }
|
||||
// }
|
||||
if (currentConsole != null) {
|
||||
currentConsole.write(b, offset, length, err);
|
||||
} else {
|
||||
try {
|
||||
if (err) {
|
||||
systemErr.write(b);
|
||||
} else {
|
||||
systemOut.write(b);
|
||||
}
|
||||
} catch (IOException e) { } // just ignore, where would we write?
|
||||
}
|
||||
|
||||
OutputStream echo = err ? stderrFile : stdoutFile;
|
||||
if (echo != null) {
|
||||
@ -356,7 +356,12 @@ public class EditorConsole extends JScrollPane {
|
||||
|
||||
public void write(int b) {
|
||||
single[0] = (byte)b;
|
||||
currentConsole.write(single, 0, 1, err);
|
||||
if (currentConsole != null) {
|
||||
currentConsole.write(single, 0, 1, err);
|
||||
} else {
|
||||
// redirect for all the extra handling above
|
||||
write(new byte[] { (byte) b }, 0, 1);
|
||||
}
|
||||
|
||||
OutputStream echo = err ? stderrFile : stdoutFile;
|
||||
if (echo != null) {
|
||||
|
@ -53,7 +53,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener {
|
||||
static final int OPEN = 3;
|
||||
static final int SAVE = 4;
|
||||
static final int EXPORT = 5;
|
||||
|
||||
|
||||
static final int SERIAL = 6;
|
||||
|
||||
static final int INACTIVE = 0;
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-06 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -34,8 +34,6 @@ import processing.app.syntax.*;
|
||||
import processing.core.*;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Storage class for user preferences and environment settings.
|
||||
* <P>
|
||||
@ -144,9 +142,9 @@ public class Preferences {
|
||||
|
||||
// data model
|
||||
|
||||
static Hashtable defaults;
|
||||
static Hashtable table = new Hashtable();;
|
||||
static Hashtable prefixes = new Hashtable();
|
||||
static HashMap<String,String> defaults;
|
||||
static HashMap<String,String> table = new HashMap<String,String>();;
|
||||
static HashMap<String,HashMap<String,String>> prefixes = new HashMap<String,HashMap<String,String>>();
|
||||
static File preferencesFile;
|
||||
|
||||
|
||||
@ -161,22 +159,8 @@ public class Preferences {
|
||||
"You'll need to reinstall Arduino.", e);
|
||||
}
|
||||
|
||||
// check for platform-specific properties in the defaults
|
||||
String platformExt = "." + PConstants.platformNames[PApplet.platform];
|
||||
int platformExtLength = platformExt.length();
|
||||
Enumeration e = table.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
String key = (String) e.nextElement();
|
||||
if (key.endsWith(platformExt)) {
|
||||
// this is a key specific to a particular platform
|
||||
String actualKey = key.substring(0, key.length() - platformExtLength);
|
||||
String value = get(key);
|
||||
table.put(actualKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
// clone the hash table
|
||||
defaults = (Hashtable) table.clone();
|
||||
defaults = (HashMap<String, String>) table.clone();
|
||||
|
||||
// other things that have to be set explicitly for the defaults
|
||||
setColor("run.window.bgcolor", SystemColor.control);
|
||||
@ -231,8 +215,8 @@ public class Preferences {
|
||||
"Error reading the board definitions file (" +
|
||||
new File(Base.getHardwareFolder(), "boards.txt").getAbsolutePath() + "). " +
|
||||
"Please re-download or re-unzip Arduino.\n", ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
load(new FileInputStream(new File(Base.getHardwareFolder(), "programmers.txt")),
|
||||
"programmers");
|
||||
@ -445,6 +429,20 @@ public class Preferences {
|
||||
top += d.height; // + GUI_SMALL;
|
||||
|
||||
label = new JLabel(preferencesFile.getAbsolutePath());
|
||||
final JLabel clickable = label;
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Base.openFolder(Base.getSettingsFolder());
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
clickable.setForeground(new Color(0, 0, 140));
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
clickable.setForeground(Color.BLACK);
|
||||
}
|
||||
});
|
||||
pain.add(label);
|
||||
d = label.getPreferredSize();
|
||||
label.setBounds(left, top, d.width, d.height);
|
||||
@ -678,12 +676,16 @@ public class Preferences {
|
||||
}
|
||||
|
||||
static protected void load(InputStream input, String prefix) throws IOException {
|
||||
Map table = new LinkedHashMap();
|
||||
LinkedHashMap<String,String> table = new LinkedHashMap<String,String>();
|
||||
prefixes.put(prefix, table);
|
||||
load(input, table);
|
||||
}
|
||||
|
||||
static protected void load(InputStream input, Map table) throws IOException {
|
||||
// check for platform-specific properties in the defaults
|
||||
String platformExt = "." + PConstants.platformNames[PApplet.platform];
|
||||
int platformExtLength = platformExt.length();
|
||||
|
||||
String[] lines = PApplet.loadStrings(input); // Reads as UTF-8
|
||||
for (String line : lines) {
|
||||
if ((line.length() == 0) ||
|
||||
@ -693,6 +695,12 @@ public class Preferences {
|
||||
int equals = line.indexOf('=');
|
||||
if (equals != -1) {
|
||||
String key = line.substring(0, equals).trim();
|
||||
|
||||
// check if this is a platform-specific key, and if so, shave things
|
||||
if (key.endsWith(platformExt)) {
|
||||
// this is a key specific to this platform
|
||||
key = key.substring(0, key.length() - platformExtLength);
|
||||
}
|
||||
String value = line.substring(equals + 1).trim();
|
||||
table.put(key, value);
|
||||
}
|
||||
@ -713,10 +721,8 @@ public class Preferences {
|
||||
// Fix for 0163 to properly use Unicode when writing preferences.txt
|
||||
PrintWriter writer = PApplet.createWriter(preferencesFile);
|
||||
|
||||
Enumeration e = table.keys(); //properties.propertyNames();
|
||||
while (e.hasMoreElements()) {
|
||||
String key = (String) e.nextElement();
|
||||
writer.println(key + "=" + ((String) table.get(key)));
|
||||
for (String key : table.keySet()) {
|
||||
writer.println(key + "=" + table.get(key));
|
||||
}
|
||||
|
||||
writer.flush();
|
||||
@ -742,15 +748,15 @@ public class Preferences {
|
||||
// preference files, look up the attribute in that file's Hashtable
|
||||
// (don't override with or fallback to the main file). otherwise,
|
||||
// look up the attribute in the main file's Hashtable.
|
||||
Map table = Preferences.table;
|
||||
HashMap<String,String> table = Preferences.table;
|
||||
if (attribute.indexOf('.') != -1) {
|
||||
String prefix = attribute.substring(0, attribute.indexOf('.'));
|
||||
if (prefixes.containsKey(prefix)) {
|
||||
table = (Map) prefixes.get(prefix);
|
||||
table = prefixes.get(prefix);
|
||||
attribute = attribute.substring(attribute.indexOf('.') + 1);
|
||||
}
|
||||
}
|
||||
return (String) table.get(attribute);
|
||||
return table.get(attribute);
|
||||
/*
|
||||
//String value = (properties != null) ?
|
||||
//properties.getProperty(attribute) : applet.getParameter(attribute);
|
||||
@ -785,7 +791,7 @@ public class Preferences {
|
||||
|
||||
|
||||
static public String getDefault(String attribute) {
|
||||
return (String) defaults.get(attribute);
|
||||
return defaults.get(attribute);
|
||||
}
|
||||
|
||||
|
||||
@ -845,7 +851,7 @@ public class Preferences {
|
||||
|
||||
|
||||
static public Color getColor(String name) {
|
||||
Color parsed = Color.GRAY; // set a default
|
||||
Color parsed = Color.GRAY; // set a default
|
||||
String s = get(name);
|
||||
if ((s != null) && (s.indexOf("#") == 0)) {
|
||||
try {
|
||||
@ -857,11 +863,6 @@ public class Preferences {
|
||||
|
||||
|
||||
static public void setColor(String attr, Color what) {
|
||||
// String r = Integer.toHexString(what.getRed());
|
||||
// String g = Integer.toHexString(what.getGreen());
|
||||
// String b = Integer.toHexString(what.getBlue());
|
||||
// set(attr, "#" + r.substring(r.length() - 2) +
|
||||
// g.substring(g.length() - 2) + b.substring(b.length() - 2));
|
||||
set(attr, "#" + PApplet.hex(what.getRGB() & 0xffffff, 6));
|
||||
}
|
||||
|
||||
@ -911,7 +912,7 @@ public class Preferences {
|
||||
|
||||
String s = st.nextToken();
|
||||
if (s.indexOf("#") == 0) s = s.substring(1);
|
||||
Color color = Color.DARK_GRAY;
|
||||
Color color = Color.DARK_GRAY;
|
||||
try {
|
||||
color = new Color(Integer.parseInt(s, 16));
|
||||
} catch (Exception e) { }
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2005-06 Ben Fry and Casey Reas
|
||||
Copyright (c) 2005-09 Ben Fry and Casey Reas
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -59,7 +59,7 @@ public class PresentMode {
|
||||
devices = environment.getScreenDevices();
|
||||
GraphicsDevice defaultDevice = environment.getDefaultScreenDevice();
|
||||
|
||||
Vector names = new Vector();
|
||||
Vector<String> names = new Vector<String>();
|
||||
for (int i = 0; i < devices.length; i++) {
|
||||
String name = String.valueOf(i + 1);
|
||||
if (devices[i] == defaultDevice) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -1431,7 +1431,7 @@ public class Sketch {
|
||||
upload(appletFolder.getPath(), foundName, verbose);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void size(String buildPath, String suggestedClassName)
|
||||
@ -1439,23 +1439,23 @@ public class Sketch {
|
||||
long size = 0;
|
||||
long maxsize = Preferences.getInteger("boards." + Preferences.get("board") + ".upload.maximum_size");
|
||||
Sizer sizer = new Sizer(buildPath, suggestedClassName);
|
||||
try {
|
||||
try {
|
||||
size = sizer.computeSize();
|
||||
System.out.println("Binary sketch size: " + size + " bytes (of a " +
|
||||
maxsize + " byte maximum)");
|
||||
} catch (RunnerException e) {
|
||||
System.err.println("Couldn't determine program size: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (size > maxsize)
|
||||
throw new RunnerException(
|
||||
"Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String upload(String buildPath, String suggestedClassName, boolean verbose)
|
||||
throws RunnerException {
|
||||
|
||||
|
||||
Uploader uploader;
|
||||
|
||||
// download the program
|
||||
@ -1466,7 +1466,7 @@ public class Sketch {
|
||||
verbose);
|
||||
|
||||
return success ? suggestedClassName : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all commented portions of a given String as spaces.
|
||||
@ -1528,8 +1528,8 @@ public class Sketch {
|
||||
* Export to application via GUI.
|
||||
*/
|
||||
protected boolean exportApplication() throws IOException, RunnerException {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1537,8 +1537,8 @@ public class Sketch {
|
||||
*/
|
||||
public boolean exportApplication(String destPath,
|
||||
int exportPlatform) throws IOException, RunnerException {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected void addManifest(ZipOutputStream zos) throws IOException {
|
||||
@ -1558,8 +1558,8 @@ public class Sketch {
|
||||
* Read from a file with a bunch of attribute/value pairs
|
||||
* that are separated by = and ignore comments with #.
|
||||
*/
|
||||
protected Hashtable readSettings(File inputFile) {
|
||||
Hashtable outgoing = new Hashtable();
|
||||
protected HashMap<String,String> readSettings(File inputFile) {
|
||||
HashMap<String,String> outgoing = new HashMap<String,String>();
|
||||
if (!inputFile.exists()) return outgoing; // return empty hash
|
||||
|
||||
String lines[] = PApplet.loadStrings(inputFile);
|
||||
@ -1589,7 +1589,7 @@ public class Sketch {
|
||||
*/
|
||||
protected void packClassPathIntoZipFile(String path,
|
||||
ZipOutputStream zos,
|
||||
Hashtable zipFileContents)
|
||||
HashMap<String,Object> zipFileContents)
|
||||
throws IOException {
|
||||
String[] pieces = PApplet.split(path, File.pathSeparatorChar);
|
||||
|
||||
@ -1601,7 +1601,7 @@ public class Sketch {
|
||||
pieces[i].toLowerCase().endsWith(".zip")) {
|
||||
try {
|
||||
ZipFile file = new ZipFile(pieces[i]);
|
||||
Enumeration entries = file.entries();
|
||||
Enumeration<?> entries = file.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = (ZipEntry) entries.nextElement();
|
||||
if (entry.isDirectory()) {
|
||||
@ -1887,8 +1887,8 @@ public class Sketch {
|
||||
}
|
||||
return codeFolder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ArrayList<File> getImportedLibraries() {
|
||||
return importedLibraries;
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ import processing.core.*;
|
||||
public class Theme {
|
||||
|
||||
/** Copy of the defaults in case the user mangles a preference. */
|
||||
static Hashtable defaults;
|
||||
static HashMap<String,String> defaults;
|
||||
/** Table of attributes/values for the theme. */
|
||||
static Hashtable table = new Hashtable();;
|
||||
static HashMap<String,String> table = new HashMap<String,String>();;
|
||||
|
||||
|
||||
static protected void init() {
|
||||
@ -55,9 +55,7 @@ public class Theme {
|
||||
// check for platform-specific properties in the defaults
|
||||
String platformExt = "." + Base.getPlatformName();
|
||||
int platformExtLength = platformExt.length();
|
||||
Enumeration e = table.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
String key = (String) e.nextElement();
|
||||
for (String key : table.keySet()) {
|
||||
if (key.endsWith(platformExt)) {
|
||||
// this is a key specific to a particular platform
|
||||
String actualKey = key.substring(0, key.length() - platformExtLength);
|
||||
@ -70,7 +68,7 @@ public class Theme {
|
||||
setColor("run.window.bgcolor", SystemColor.control);
|
||||
|
||||
// clone the hash table
|
||||
defaults = (Hashtable) table.clone();
|
||||
defaults = (HashMap<String, String>) table.clone();
|
||||
}
|
||||
|
||||
|
||||
@ -142,11 +140,7 @@ public class Theme {
|
||||
|
||||
|
||||
static public void setColor(String attr, Color what) {
|
||||
String r = Integer.toHexString(what.getRed());
|
||||
String g = Integer.toHexString(what.getGreen());
|
||||
String b = Integer.toHexString(what.getBlue());
|
||||
set(attr, "#" + r.substring(r.length() - 2) +
|
||||
g.substring(g.length() - 2) + b.substring(b.length() - 2));
|
||||
set(attr, "#" + PApplet.hex(what.getRGB() & 0xffffff, 6));
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class Compiler implements MessageConsumer {
|
||||
MessageStream pms = new MessageStream(this);
|
||||
|
||||
String avrBasePath = Base.getAvrBasePath();
|
||||
|
||||
|
||||
List<File> objectFiles = new ArrayList<File>();
|
||||
|
||||
List includePaths = new ArrayList();
|
||||
@ -99,15 +99,15 @@ public class Compiler implements MessageConsumer {
|
||||
List commandAR = new ArrayList(baseCommandAR);
|
||||
commandAR.add(file.getAbsolutePath());
|
||||
execAsynchronously(commandAR);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||
|
||||
|
||||
// use library directories as include paths for all libraries
|
||||
for (File file : sketch.getImportedLibraries()) {
|
||||
includePaths.add(file.getPath());
|
||||
}
|
||||
|
||||
|
||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||
createFolder(outputFolder);
|
||||
@ -125,17 +125,17 @@ public class Compiler implements MessageConsumer {
|
||||
findFilesInFolder(new File(libraryFolder, "utility"), "cpp", false)));
|
||||
// other libraries should not see this library's utility/ folder
|
||||
includePaths.remove(includePaths.size() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 3. compile the sketch (already in the buildPath)
|
||||
|
||||
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(buildPath, "c", false),
|
||||
findFilesInPath(buildPath, "cpp", false)));
|
||||
|
||||
|
||||
// 4. link it all together into the .elf file
|
||||
|
||||
|
||||
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
||||
avrBasePath + "avr-gcc",
|
||||
"-Os",
|
||||
@ -144,7 +144,7 @@ public class Compiler implements MessageConsumer {
|
||||
"-o",
|
||||
buildPath + File.separator + primaryClassName + ".elf"
|
||||
}));
|
||||
|
||||
|
||||
for (File file : objectFiles) {
|
||||
baseCommandLinker.add(file.getAbsolutePath());
|
||||
}
|
||||
@ -185,14 +185,14 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(commandObjcopy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<File> compileFiles(String avrBasePath,
|
||||
String buildPath, List<File> includePaths,
|
||||
List<File> cSources, List<File> cppSources)
|
||||
throws RunnerException {
|
||||
|
||||
|
||||
List<File> objectPaths = new ArrayList<File>();
|
||||
|
||||
for (File file : cSources) {
|
||||
@ -201,7 +201,7 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
|
||||
file.getAbsolutePath(),
|
||||
objectPath));
|
||||
}
|
||||
}
|
||||
|
||||
for (File file : cppSources) {
|
||||
String objectPath = buildPath + File.separator + file.getName() + ".o";
|
||||
@ -209,12 +209,12 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
|
||||
file.getAbsolutePath(),
|
||||
objectPath));
|
||||
}
|
||||
}
|
||||
|
||||
return objectPaths;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
boolean firstErrorFound;
|
||||
boolean secondErrorFound;
|
||||
|
||||
@ -229,9 +229,9 @@ public class Compiler implements MessageConsumer {
|
||||
if (verbose || Preferences.getBoolean("build.verbose")) {
|
||||
for(int j = 0; j < command.length; j++) {
|
||||
System.out.print(command[j] + " ");
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
firstErrorFound = false; // haven't found any errors yet
|
||||
secondErrorFound = false;
|
||||
@ -244,8 +244,8 @@ public class Compiler implements MessageConsumer {
|
||||
RunnerException re = new RunnerException(e.getMessage());
|
||||
re.hideStackTrace();
|
||||
throw re;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MessageSiphon in = new MessageSiphon(process.getInputStream(), this);
|
||||
MessageSiphon err = new MessageSiphon(process.getErrorStream(), this);
|
||||
|
||||
@ -263,7 +263,7 @@ public class Compiler implements MessageConsumer {
|
||||
compiling = false;
|
||||
} catch (InterruptedException ignored) { }
|
||||
}
|
||||
|
||||
|
||||
// an error was queued up by message(), barf this back to compile(),
|
||||
// which will barf it back to Editor. if you're having trouble
|
||||
// discerning the imagery, consider how cows regurgitate their food
|
||||
@ -271,18 +271,18 @@ public class Compiler implements MessageConsumer {
|
||||
//
|
||||
//System.out.println("throwing up " + exception);
|
||||
if (exception != null) { throw exception; }
|
||||
|
||||
|
||||
if (result > 1) {
|
||||
// a failure in the tool (e.g. unable to locate a sub-executable)
|
||||
System.err.println(command[0] + " returned " + result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
RunnerException re = new RunnerException("Error compiling.");
|
||||
re.hideStackTrace();
|
||||
throw re;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -312,14 +312,14 @@ public class Compiler implements MessageConsumer {
|
||||
String partialTempPath = null;
|
||||
int partialStartIndex = -1; //s.indexOf(partialTempPath);
|
||||
int fileIndex = -1; // use this to build a better exception
|
||||
|
||||
|
||||
// check the main sketch file first.
|
||||
partialTempPath = buildPathSubst + primaryClassName;
|
||||
partialStartIndex = s.indexOf(partialTempPath);
|
||||
|
||||
if (partialStartIndex != -1) {
|
||||
fileIndex = 0;
|
||||
} else {
|
||||
} else {
|
||||
// wasn't there, check the other (non-pde) files in the sketch.
|
||||
// iterate through the project files to see who's causing the trouble
|
||||
for (int i = 0; i < sketch.getCodeCount(); i++) {
|
||||
@ -332,7 +332,7 @@ public class Compiler implements MessageConsumer {
|
||||
fileIndex = i;
|
||||
//System.out.println("fileIndex is " + fileIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//+ className + ".java";
|
||||
}
|
||||
@ -353,7 +353,7 @@ public class Compiler implements MessageConsumer {
|
||||
System.err.print(s1);
|
||||
//firstErrorFound = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int lineNumber;
|
||||
try {
|
||||
@ -361,7 +361,7 @@ public class Compiler implements MessageConsumer {
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.print(s1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println("pde / line number: " + lineNumber);
|
||||
|
||||
@ -372,15 +372,15 @@ public class Compiler implements MessageConsumer {
|
||||
if (sketch.getCode(i).getPreprocOffset() < lineNumber) {
|
||||
fileIndex = i;
|
||||
//System.out.println("i'm thinkin file " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// XXX: DAM: if the lineNumber is less than sketch.getCode(0).getPreprocOffset()
|
||||
// we shouldn't subtract anything from it, as the error is above the
|
||||
// location where the function prototypes and #include "WProgram.h"
|
||||
// were inserted.
|
||||
lineNumber -= sketch.getCode(fileIndex).getPreprocOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//String s2 = s1.substring(colon + 2);
|
||||
int err = s1.indexOf(":");
|
||||
@ -391,7 +391,7 @@ public class Compiler implements MessageConsumer {
|
||||
if (firstErrorFound) {
|
||||
secondErrorFound = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if executing at this point, this is *at least* the first error
|
||||
firstErrorFound = true;
|
||||
@ -421,13 +421,13 @@ public class Compiler implements MessageConsumer {
|
||||
// are probably associated with the first error message,
|
||||
// which is already in the status bar, and are likely to be
|
||||
// of interest to the user, so spit them to the console.
|
||||
//
|
||||
//
|
||||
if (!secondErrorFound) {
|
||||
System.err.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static private List getCommandCompilerC(String avrBasePath, List includePaths,
|
||||
@ -447,13 +447,13 @@ public class Compiler implements MessageConsumer {
|
||||
for (int i = 0; i < includePaths.size(); i++) {
|
||||
baseCommandCompiler.add("-I" + (String) includePaths.get(i));
|
||||
}
|
||||
|
||||
|
||||
baseCommandCompiler.add(sourceName);
|
||||
baseCommandCompiler.add("-o"+ objectName);
|
||||
|
||||
|
||||
return baseCommandCompiler;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static private List getCommandCompilerCPP(String avrBasePath,
|
||||
List includePaths, String sourceName, String objectName) {
|
||||
@ -472,15 +472,15 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
for (int i = 0; i < includePaths.size(); i++) {
|
||||
baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
baseCommandCompilerCPP.add(sourceName);
|
||||
baseCommandCompilerCPP.add("-o"+ objectName);
|
||||
|
||||
|
||||
return baseCommandCompilerCPP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -40,31 +40,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jdi.Field;
|
||||
import com.sun.jdi.IncompatibleThreadStateException;
|
||||
import com.sun.jdi.ThreadReference;
|
||||
import com.sun.jdi.VMDisconnectedException;
|
||||
import com.sun.jdi.Value;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import com.sun.jdi.event.ClassPrepareEvent;
|
||||
import com.sun.jdi.event.Event;
|
||||
import com.sun.jdi.event.EventIterator;
|
||||
import com.sun.jdi.event.EventQueue;
|
||||
import com.sun.jdi.event.EventSet;
|
||||
import com.sun.jdi.event.ExceptionEvent;
|
||||
import com.sun.jdi.event.MethodEntryEvent;
|
||||
import com.sun.jdi.event.MethodExitEvent;
|
||||
import com.sun.jdi.event.ModificationWatchpointEvent;
|
||||
import com.sun.jdi.event.StepEvent;
|
||||
import com.sun.jdi.event.ThreadDeathEvent;
|
||||
import com.sun.jdi.event.VMDeathEvent;
|
||||
import com.sun.jdi.event.VMDisconnectEvent;
|
||||
import com.sun.jdi.event.VMStartEvent;
|
||||
import com.sun.jdi.request.EventRequest;
|
||||
import com.sun.jdi.request.EventRequestManager;
|
||||
import com.sun.jdi.request.ExceptionRequest;
|
||||
import com.sun.jdi.request.ModificationWatchpointRequest;
|
||||
import com.sun.jdi.request.StepRequest;
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.*;
|
||||
import com.sun.jdi.request.*;
|
||||
|
||||
/**
|
||||
* This class processes incoming JDI events and displays them
|
||||
@ -132,8 +110,9 @@ public class EventThread extends Thread {
|
||||
// deathReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
|
||||
// deathReq.enable();
|
||||
|
||||
// want all exceptions
|
||||
// get only the uncaught exceptions
|
||||
ExceptionRequest excReq = mgr.createExceptionRequest(null, false, true);
|
||||
// this version reports all exceptions, caught or uncaught
|
||||
//ExceptionRequest excReq = mgr.createExceptionRequest(null, true, true);
|
||||
// suspend so we can step
|
||||
excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
|
||||
@ -380,7 +359,7 @@ public class EventThread extends Thread {
|
||||
}
|
||||
|
||||
private void exceptionEvent(ExceptionEvent event) {
|
||||
// ObjectReference or = event.exception();
|
||||
// com.sun.jdi.ObjectReference or = event.exception();
|
||||
// System.out.println("exceptionEvent() fired " + or);
|
||||
// System.out.println("catch location " + event.catchLocation());
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -379,11 +379,16 @@ public class Runner implements MessageConsumer {
|
||||
//String addr = "localhost:" + (8000 + (int) (Math.random() * 1000));
|
||||
//String addr = "" + (8000 + (int) (Math.random() * 1000));
|
||||
|
||||
String commandArgs = Base.isWindows() ?
|
||||
"java -Xrunjdwp:transport=dt_shmem,address=" + addr + ",suspend=y " :
|
||||
String commandArgs =
|
||||
"java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
|
||||
//String commandArgs = "java -agentlib:jdwp=transport=dt_socket,address=" + addr + ",suspend=y ";
|
||||
//String commandArgs = "java -agentlib:jdwp=transport=dt_socket,address=" + addr + ",server=n,suspend=y ";
|
||||
if (Base.isWindows()) {
|
||||
commandArgs =
|
||||
"java -Xrunjdwp:transport=dt_shmem,address=" + addr + ",suspend=y ";
|
||||
} else if (Base.isMacOS()) {
|
||||
commandArgs =
|
||||
"java -d32 -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
|
||||
}
|
||||
|
||||
for (int i = 0; i < vmParams.length; i++) {
|
||||
commandArgs = addArgument(commandArgs, vmParams[i], ' ');
|
||||
}
|
||||
@ -519,11 +524,13 @@ public class Runner implements MessageConsumer {
|
||||
// Shutdown begins when event thread terminates
|
||||
try {
|
||||
if (eventThread != null) eventThread.join();
|
||||
// System.out.println("in here");
|
||||
// Bug #852 tracked to this next line in the code.
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=852
|
||||
errThread.join(); // Make sure output is forwarded
|
||||
// System.out.println("and then");
|
||||
outThread.join(); // before we exit
|
||||
//System.out.println("out of it");
|
||||
// System.out.println("out of it");
|
||||
|
||||
// At this point, disable the run button.
|
||||
// This happens when the sketch is exited by hitting ESC,
|
||||
@ -573,6 +580,7 @@ public class Runner implements MessageConsumer {
|
||||
|
||||
|
||||
public void exception(ExceptionEvent event) {
|
||||
// System.out.println(event);
|
||||
ObjectReference or = event.exception();
|
||||
ReferenceType rt = or.referenceType();
|
||||
String exceptionName = rt.name();
|
||||
@ -644,7 +652,7 @@ public class Runner implements MessageConsumer {
|
||||
// message to the console.
|
||||
List<StackFrame> frames = thread.frames();
|
||||
for (StackFrame frame : frames) {
|
||||
//System.out.println("frame: " + frame);
|
||||
// System.out.println("frame: " + frame);
|
||||
Location location = frame.location();
|
||||
String filename = null;
|
||||
filename = location.sourceName();
|
||||
|
@ -86,13 +86,14 @@ public class ThinkDifferent implements ApplicationListener {
|
||||
throw new IllegalStateException("handlePreferences: Base instance detached from listener");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void handleOpenApplication(ApplicationEvent ae) {
|
||||
}
|
||||
|
||||
|
||||
public void handleOpenFile(ApplicationEvent ae) {
|
||||
// System.out.println("got open file event " + ae.getFilename());
|
||||
String filename = ae.getFilename();
|
||||
base.handleOpen(filename);
|
||||
ae.setHandled(true);
|
||||
|
@ -51,7 +51,7 @@ import java.util.Vector;
|
||||
* + "}");</pre>
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: JEditTextArea.java 5343 2008-11-29 17:22:59Z fry $
|
||||
* @version $Id: JEditTextArea.java 5625 2009-06-07 21:08:59Z fry $
|
||||
*/
|
||||
public class JEditTextArea extends JComponent
|
||||
{
|
||||
@ -103,6 +103,9 @@ public class JEditTextArea extends JComponent
|
||||
painter.addMouseListener(new MouseHandler());
|
||||
painter.addMouseMotionListener(new DragHandler());
|
||||
addFocusListener(new FocusHandler());
|
||||
// send tab keys through to the text area
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1267
|
||||
setFocusTraversalKeysEnabled(false);
|
||||
|
||||
// Load the defaults
|
||||
setInputHandler(defaults.inputHandler);
|
||||
@ -145,9 +148,9 @@ public class JEditTextArea extends JComponent
|
||||
* Returns if this component can be traversed by pressing
|
||||
* the Tab key. This returns false.
|
||||
*/
|
||||
public final boolean isManagingFocus() {
|
||||
return true;
|
||||
}
|
||||
// public final boolean isManagingFocus() {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns the object responsible for painting this text area.
|
||||
@ -1028,8 +1031,8 @@ public class JEditTextArea extends JComponent
|
||||
{
|
||||
select(selectionStart,selectionEnd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public final boolean isSelectionActive()
|
||||
{
|
||||
return(selectionStart != selectionEnd);
|
||||
|
@ -30,6 +30,8 @@ implements TabExpander, Printable
|
||||
{
|
||||
/** True if inside printing, will handle disabling the highlight */
|
||||
boolean printing;
|
||||
/** Current setting for editor.antialias preference */
|
||||
boolean antialias;
|
||||
|
||||
/**
|
||||
* Creates a new repaint manager. This should be not be called
|
||||
@ -54,6 +56,8 @@ implements TabExpander, Printable
|
||||
setForeground(defaults.fgcolor);
|
||||
setBackground(defaults.bgcolor);
|
||||
|
||||
antialias = Preferences.getBoolean("editor.antialias");
|
||||
|
||||
blockCaret = defaults.blockCaret;
|
||||
styles = defaults.styles;
|
||||
cols = defaults.cols;
|
||||
@ -73,10 +77,10 @@ implements TabExpander, Printable
|
||||
* Returns if this component can be traversed by pressing the
|
||||
* Tab key. This returns false.
|
||||
*/
|
||||
public final boolean isManagingFocus()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// public final boolean isManagingFocus()
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns the syntax styles used to paint colorized text. Entry <i>n</i>
|
||||
@ -366,11 +370,11 @@ implements TabExpander, Printable
|
||||
*/
|
||||
public void paint(Graphics gfx)
|
||||
{
|
||||
if (Base.isMacOS()) {
|
||||
Graphics2D g2 = (Graphics2D) gfx;
|
||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) gfx;
|
||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
antialias ?
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON :
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||
|
||||
tabSize = fm.charWidth(' ') * ((Integer)textArea.getDocument().getProperty(PlainDocument.tabSizeAttribute)).intValue();
|
||||
|
||||
|
@ -3,13 +3,14 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2005-06 Ben Fry and Casey Reas
|
||||
Copyright (c) 2003 Martin Gomez, Ateneo de Manila University
|
||||
Original Copyright (c) 1997, 1998 Van Di-Han HO. All Rights Reserved.
|
||||
Updates Copyright (c) 2001 Jason Pell.
|
||||
Further updates Copyright (c) 2003 Martin Gomez, Ateneo de Manila University
|
||||
Bug fixes Copyright (c) 2005-09 Ben Fry and Casey Reas
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -24,13 +25,21 @@
|
||||
package processing.app.tools;
|
||||
|
||||
import processing.app.*;
|
||||
import processing.core.PApplet;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* Alternate handler for dealing with auto format.
|
||||
* Handler for dealing with auto format.
|
||||
* Contributed by Martin Gomez, additional bug fixes by Ben Fry.
|
||||
*
|
||||
* After some further digging, this code in fact appears to be a modified
|
||||
* version of Jason Pell's GPLed "Java Beautifier" class found here:
|
||||
* http://www.geocities.com/jasonpell/programs.html
|
||||
* Which is itself based on code from Van Di-Han Ho:
|
||||
* http://www.geocities.com/~starkville/vancbj_idx.html
|
||||
* [Ben Fry, August 2009]
|
||||
*/
|
||||
public class AutoFormat implements Tool {
|
||||
Editor editor;
|
||||
@ -38,15 +47,12 @@ public class AutoFormat implements Tool {
|
||||
static final int BLOCK_MAXLEN = 1024;
|
||||
|
||||
StringBuffer strOut;
|
||||
//String formattedText;
|
||||
int indentValue;
|
||||
String indentChar;
|
||||
//String uhOh = null;
|
||||
//String theStuff;
|
||||
int EOF;
|
||||
BufferedInputStream bin = null;
|
||||
int nBytesRead, indexBlock, lineLength, lineNumber;
|
||||
byte bArray[];
|
||||
CharArrayReader reader;
|
||||
int readCount, indexBlock, lineLength, lineNumber;
|
||||
char chars[];
|
||||
String strBlock;
|
||||
int s_level[];
|
||||
int c_level;
|
||||
@ -64,23 +70,17 @@ public class AutoFormat implements Tool {
|
||||
String w_if_, w_else, w_for, w_ds, w_case, w_cpp_comment, w_jdoc;
|
||||
int jdoc, j;
|
||||
char string[];
|
||||
byte bstring[];
|
||||
byte bblank;
|
||||
char cc;
|
||||
int s_flg, b_flg;
|
||||
int s_flg;
|
||||
int peek;
|
||||
char peekc;
|
||||
int tabs;
|
||||
char next_char, last_char;
|
||||
char lastc0, lastc1;
|
||||
char c, c0;
|
||||
char w_kptr;
|
||||
char last_char;
|
||||
char c;
|
||||
|
||||
String line_feed;
|
||||
|
||||
//static int outfil; // temporary
|
||||
|
||||
|
||||
|
||||
public void init(Editor editor) {
|
||||
this.editor = editor;
|
||||
}
|
||||
@ -236,6 +236,7 @@ public class AutoFormat implements Tool {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cpp_comment() throws IOException
|
||||
{
|
||||
c = getchr();
|
||||
@ -283,32 +284,26 @@ public class AutoFormat implements Tool {
|
||||
indexBlock++;
|
||||
if (indexBlock >= lineLength)
|
||||
{
|
||||
for (int ib=0; ib<nBytesRead; ib++) bArray[ib] = '\0';
|
||||
for (int ib=0; ib<readCount; ib++) chars[ib] = '\0';
|
||||
|
||||
lineLength = nBytesRead = 0;
|
||||
//try /* to get the next block */
|
||||
//{
|
||||
if (bin.available() > 0)
|
||||
{
|
||||
nBytesRead = bin.read(bArray);
|
||||
lineLength = nBytesRead;
|
||||
strBlock = new String(bArray);
|
||||
indexBlock = 0;
|
||||
last_char = strBlock.charAt(indexBlock);
|
||||
peek = -1;
|
||||
peekc = '`';
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("eof a");
|
||||
EOF = 1;
|
||||
peekc = '\0';
|
||||
}
|
||||
//}
|
||||
//catch(IOException ioe)
|
||||
//{
|
||||
//System.out.println(ioe.toString());
|
||||
//}
|
||||
lineLength = readCount = 0;
|
||||
reader.mark(1);
|
||||
if (reader.read() != -1)
|
||||
{
|
||||
reader.reset(); // back to the mark
|
||||
readCount = reader.read(chars);
|
||||
lineLength = readCount;
|
||||
strBlock = new String(chars);
|
||||
indexBlock = 0;
|
||||
last_char = strBlock.charAt(indexBlock);
|
||||
peek = -1;
|
||||
peekc = '`';
|
||||
}
|
||||
else
|
||||
{
|
||||
EOF = 1;
|
||||
peekc = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -446,13 +441,11 @@ public class AutoFormat implements Tool {
|
||||
indentChar = new String(" ");
|
||||
|
||||
lineNumber = 0;
|
||||
//BLOCK_MAXLEN = 256;
|
||||
c_level = if_lev = level = e_flg = paren = 0;
|
||||
a_flg = q_flg = j = b_flg = tabs = 0;
|
||||
a_flg = q_flg = j = tabs = 0;
|
||||
if_flg = peek = -1;
|
||||
peekc = '`';
|
||||
s_flg = 1;
|
||||
bblank = ' ';
|
||||
jdoc = 0;
|
||||
|
||||
s_level = new int[10];
|
||||
@ -476,24 +469,23 @@ public class AutoFormat implements Tool {
|
||||
// read as long as there is something to read
|
||||
EOF = 0; // = 1 set in getchr when EOF
|
||||
|
||||
bArray = new byte[BLOCK_MAXLEN];
|
||||
chars = new char[BLOCK_MAXLEN];
|
||||
string = new char[BLOCK_MAXLEN];
|
||||
try { // the whole process
|
||||
// open for input
|
||||
ByteArrayInputStream in =
|
||||
new ByteArrayInputStream(originalText.getBytes());
|
||||
reader = new CharArrayReader(originalText.toCharArray());
|
||||
|
||||
// add buffering to that InputStream
|
||||
bin = new BufferedInputStream(in);
|
||||
// bin = new BufferedInputStream(in);
|
||||
|
||||
for (int ib = 0; ib < BLOCK_MAXLEN; ib++) bArray[ib] = '\0';
|
||||
for (int ib = 0; ib < BLOCK_MAXLEN; ib++) chars[ib] = '\0';
|
||||
|
||||
lineLength = nBytesRead = 0;
|
||||
lineLength = readCount = 0;
|
||||
// read up a block - remember how many bytes read
|
||||
nBytesRead = bin.read(bArray);
|
||||
strBlock = new String(bArray);
|
||||
readCount = reader.read(chars);
|
||||
strBlock = new String(chars);
|
||||
|
||||
lineLength = nBytesRead;
|
||||
lineLength = readCount;
|
||||
lineNumber = 1;
|
||||
indexBlock = -1;
|
||||
j = 0;
|
||||
@ -561,6 +553,10 @@ public class AutoFormat implements Tool {
|
||||
|
||||
case '{':
|
||||
if(lookup(w_else) == 1)gotelse();
|
||||
if (s_if_lev.length == c_level) {
|
||||
s_if_lev = PApplet.expand(s_if_lev);
|
||||
s_if_flg = PApplet.expand(s_if_flg);
|
||||
}
|
||||
s_if_lev[c_level] = if_lev;
|
||||
s_if_flg[c_level] = if_flg;
|
||||
if_lev = if_flg = 0;
|
||||
@ -736,7 +732,6 @@ public class AutoFormat implements Tool {
|
||||
peekc = getchr();
|
||||
if(peekc == ';')
|
||||
{
|
||||
//fprintf(outfil,";");
|
||||
fprintf(";");
|
||||
peek = -1;
|
||||
peekc = '`';
|
||||
@ -747,13 +742,11 @@ public class AutoFormat implements Tool {
|
||||
}
|
||||
getnl();
|
||||
indent_puts();
|
||||
//fprintf(outfil,"\n");
|
||||
fprintf("\n");
|
||||
s_flg = 1;
|
||||
break;
|
||||
|
||||
case '/':
|
||||
c0 = string[j];
|
||||
string[j++] = c;
|
||||
peekc = getchr();
|
||||
|
||||
@ -912,7 +905,7 @@ public class AutoFormat implements Tool {
|
||||
selectionEnd = strOut.length() - 1;
|
||||
}
|
||||
|
||||
bin.close(); // close buff
|
||||
reader.close(); // close buff
|
||||
|
||||
String formattedText = strOut.toString();
|
||||
if (formattedText.equals(originalText)) {
|
||||
|
Reference in New Issue
Block a user