From 01db63297233e7b31459a0a9af92f3372d6c8a66 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 16 Apr 2005 20:23:17 +0000 Subject: [PATCH] repackaging for beta --- app/{PdeBase.java => Base.java} | 62 ++--- app/{PdeCompiler.java => Compiler.java} | 50 ++-- app/{PdeEditor.java => Editor.java} | 206 ++++++++-------- ...eEditorButtons.java => EditorButtons.java} | 22 +- ...eEditorConsole.java => EditorConsole.java} | 50 ++-- ...PdeEditorHeader.java => EditorHeader.java} | 50 ++-- ...rLineStatus.java => EditorLineStatus.java} | 20 +- app/EditorListener.java | 170 ++++++++++++++ ...PdeEditorStatus.java => EditorStatus.java} | 60 ++--- app/{PdeEditorFind.java => FindReplace.java} | 14 +- ...sageConsumer.java => MessageConsumer.java} | 6 +- ...eMessageSiphon.java => MessageSiphon.java} | 16 +- ...eMessageStream.java => MessageStream.java} | 20 +- app/{PdePreferences.java => Preferences.java} | 38 +-- app/PresentMode.java | 6 +- app/{PdeRuntime.java => Runner.java} | 58 ++--- ...lassLoader.java => RunnerClassLoader.java} | 8 +- ...PdeException.java => RunnerException.java} | 14 +- app/{PdeSketch.java => Sketch.java} | 222 +++++++++--------- app/{PdeCode.java => SketchCode.java} | 18 +- app/{PdeHistory.java => SketchHistory.java} | 22 +- app/{PdeSketchbook.java => Sketchbook.java} | 60 ++--- todo.txt | 48 ++-- 23 files changed, 704 insertions(+), 536 deletions(-) rename app/{PdeBase.java => Base.java} (94%) rename app/{PdeCompiler.java => Compiler.java} (93%) rename app/{PdeEditor.java => Editor.java} (89%) rename app/{PdeEditorButtons.java => EditorButtons.java} (93%) rename app/{PdeEditorConsole.java => EditorConsole.java} (86%) rename app/{PdeEditorHeader.java => EditorHeader.java} (88%) rename app/{PdeEditorLineStatus.java => EditorLineStatus.java} (82%) create mode 100644 app/EditorListener.java rename app/{PdeEditorStatus.java => EditorStatus.java} (85%) rename app/{PdeEditorFind.java => FindReplace.java} (96%) rename app/{PdeMessageConsumer.java => MessageConsumer.java} (87%) rename app/{PdeMessageSiphon.java => MessageSiphon.java} (84%) rename app/{PdeMessageStream.java => MessageStream.java} (76%) rename app/{PdePreferences.java => Preferences.java} (95%) rename app/{PdeRuntime.java => Runner.java} (90%) rename app/{PdeClassLoader.java => RunnerClassLoader.java} (96%) mode change 100755 => 100644 rename app/{PdeException.java => RunnerException.java} (83%) rename app/{PdeSketch.java => Sketch.java} (91%) rename app/{PdeCode.java => SketchCode.java} (84%) rename app/{PdeHistory.java => SketchHistory.java} (94%) rename app/{PdeSketchbook.java => Sketchbook.java} (92%) diff --git a/app/PdeBase.java b/app/Base.java similarity index 94% rename from app/PdeBase.java rename to app/Base.java index c5ab768f9..df7efd5d8 100644 --- a/app/PdeBase.java +++ b/app/Base.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeBase - base class for the main processing application + Base - base class for the main processing application Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and @@ -48,7 +48,7 @@ import processing.core.*; * general interaction with the system (launching URLs, loading * files and images, etc) that comes from that. */ -public class PdeBase { +public class Base { static final String VERSION = "0083 Alpha"; /** @@ -57,7 +57,7 @@ public class PdeBase { */ static String openedAtStartup; - PdeEditor editor; + Editor editor; static public void main(String args[]) { @@ -66,7 +66,7 @@ public class PdeBase { if (PApplet.javaVersion < 1.4f) { //System.err.println("no way man"); - PdeBase.showError("Need to install Java 1.4", + Base.showError("Need to install Java 1.4", "This version of Processing requires \n" + "Java 1.4 or later to run properly.\n" + "Please visit java.com to upgrade.", null); @@ -76,36 +76,36 @@ public class PdeBase { // grab any opened file from the command line if (args.length == 1) { - PdeBase.openedAtStartup = args[0]; + Base.openedAtStartup = args[0]; } // register a temporary/early version of the mrj open document handler, // because the event may be lost (sometimes, not always) by the time - // that PdeEditor is properly constructed. + // that Editor is properly constructed. MRJOpenDocumentHandler startupOpen = new MRJOpenDocumentHandler() { public void handleOpenFile(File file) { // this will only get set once.. later will be handled - // by the PdeEditor version of this fella - if (PdeBase.openedAtStartup == null) { + // by the Editor version of this fella + if (Base.openedAtStartup == null) { //System.out.println("handling outside open file: " + file); - PdeBase.openedAtStartup = file.getAbsolutePath(); + Base.openedAtStartup = file.getAbsolutePath(); } } }; MRJApplicationUtils.registerOpenDocumentHandler(startupOpen); - PdeBase app = new PdeBase(); + Base app = new Base(); } - public PdeBase() { + public Base() { // set the look and feel before opening the window try { - if (PdeBase.isLinux()) { + if (Base.isLinux()) { // linux is by default (motif?) even uglier than metal // actually, i'm using native menus, so they're ugly and // motif-looking. ick. need to fix this. @@ -119,7 +119,7 @@ public class PdeBase { // build the editor object - editor = new PdeEditor(); + editor = new Editor(); // get things rawkin editor.pack(); @@ -175,11 +175,11 @@ public class PdeBase { static public File getProcessingDataFolder() { File dataFolder = null; - String pref = PdePreferences.get("settings.path"); + String pref = Preferences.get("settings.path"); if (pref != null) { dataFolder = new File(pref); - } else if (PdeBase.isMacOS()) { + } else if (Base.isMacOS()) { // carbon folder constants // http://developer.apple.com/documentation/Carbon/Reference // /Folder_Manager/folder_manager_ref/constant_6.html#/ @@ -225,7 +225,7 @@ public class PdeBase { "Error getting the Processing data folder.", e); } - } else if (PdeBase.isWindows()) { + } else if (Base.isWindows()) { // looking for Documents and Settings/blah/Application Data/Processing // this is just based on the other documentation, and eyeballing @@ -272,7 +272,7 @@ public class PdeBase { if (!result) { // try the fallback location - String fallback = PdePreferences.get("settings.path.fallback"); + String fallback = Preferences.get("settings.path.fallback"); dataFolder = new File(fallback); if (!dataFolder.exists()) { result = dataFolder.mkdirs(); @@ -318,7 +318,7 @@ public class PdeBase { static public File getDefaultSketchbookFolder() { File sketchbookFolder = null; - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { // looking for /Users/blah/Documents/Processing // carbon folder constants @@ -408,7 +408,7 @@ public class PdeBase { if (!result) { // try the fallback location - String fallback = PdePreferences.get("sketchbook.path.fallback"); + String fallback = Preferences.get("sketchbook.path.fallback"); sketchbookFolder = new File(fallback); if (!sketchbookFolder.exists()) { result = sketchbookFolder.mkdirs(); @@ -446,7 +446,7 @@ public class PdeBase { static public void openURL(String url) { //System.out.println("opening url " + url); try { - if (PdeBase.isWindows()) { + if (Base.isWindows()) { // this is not guaranteed to work, because who knows if the // path will always be c:\progra~1 et al. also if the user has // a different browser set as their default (which would @@ -475,7 +475,7 @@ public class PdeBase { Runtime.getRuntime().exec("cmd /c \"" + url + "\""); } - } else if (PdeBase.isMacOS()) { + } else if (Base.isMacOS()) { //com.apple.eio.FileManager.openURL(url); if (!url.startsWith("http://")) { @@ -501,10 +501,10 @@ public class PdeBase { } com.apple.mrj.MRJFileUtils.openURL(url); - } else if (PdeBase.isLinux()) { + } else if (Base.isLinux()) { // how's mozilla sound to ya, laddie? //Runtime.getRuntime().exec(new String[] { "mozilla", url }); - String browser = PdePreferences.get("browser"); + String browser = Preferences.get("browser"); Runtime.getRuntime().exec(new String[] { browser, url }); } else { @@ -512,7 +512,7 @@ public class PdeBase { } } catch (IOException e) { - PdeBase.showWarning("Could not open URL", + Base.showWarning("Could not open URL", "An error occurred while trying to open\n" + url, e); } } @@ -526,7 +526,7 @@ public class PdeBase { try { String folder = file.getAbsolutePath(); - if (PdeBase.isWindows()) { + if (Base.isWindows()) { // doesn't work //Runtime.getRuntime().exec("cmd /c \"" + folder + "\""); @@ -536,7 +536,7 @@ public class PdeBase { // not tested //Runtime.getRuntime().exec("start explorer \"" + folder + "\""); - } else if (PdeBase.isMacOS()) { + } else if (Base.isMacOS()) { openURL(folder); // handles char replacement, etc } @@ -594,8 +594,8 @@ public class PdeBase { Image image = null; Toolkit tk = Toolkit.getDefaultToolkit(); - //if ((PdeBase.platform == PdeBase.MACOSX) || - //(PdeBase.platform == PdeBase.MACOS9)) { + //if ((Base.platform == Base.MACOSX) || + //(Base.platform == Base.MACOS9)) { image = tk.getImage("lib/" + name); //} else { //image = tk.getImage(who.getClass().getResource(name)); @@ -616,7 +616,7 @@ public class PdeBase { static public InputStream getStream(String filename) throws IOException { - //if (PdeBase.platform == PdeBase.MACOSX) { + //if (Base.platform == Base.MACOSX) { // macos doesn't seem to think that files in the lib folder // are part of the resources, unlike windows or linux. // actually, this is only the case when running as a .app, @@ -626,7 +626,7 @@ public class PdeBase { // all other, more reasonable operating systems //return cls.getResource(filename).openStream(); - //return PdeBase.class.getResource(filename).openStream(); + //return Base.class.getResource(filename).openStream(); } @@ -757,7 +757,7 @@ public class PdeBase { if (files[i].equals(".") || files[i].equals("..")) continue; File dead = new File(dir, files[i]); if (!dead.isDirectory()) { - if (!PdePreferences.getBoolean("compiler.save_build_files")) { + if (!Preferences.getBoolean("compiler.save_build_files")) { if (!dead.delete()) { // temporarily disabled //System.err.println("couldn't delete " + dead); diff --git a/app/PdeCompiler.java b/app/Compiler.java similarity index 93% rename from app/PdeCompiler.java rename to app/Compiler.java index 06cdd1664..e1b736636 100644 --- a/app/PdeCompiler.java +++ b/app/Compiler.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeCompiler - default compiler class that connects to jikes + Compiler - default compiler class that connects to jikes Part of the Processing project - http://processing.org Copyright (c) 2001-03 @@ -32,24 +32,24 @@ import java.util.*; import java.util.zip.*; import javax.swing.*; -public class PdeCompiler implements PdeMessageConsumer { +public class Compiler implements MessageConsumer { static final String BUGS_URL = "http://processing.org/bugs/"; static final String SUPER_BADNESS = "Compiler error, please submit this code to " + BUGS_URL; - PdeSketch sketch; + Sketch sketch; String buildPath; //String buildPath; //String className; //File includeFolder; - PdeException exception; - //PdeEditor editor; + RunnerException exception; + //Editor editor; /* - public PdeCompiler(String buildPath, String className, - File includeFolder, PdeEditor editor) { + public Compiler(String buildPath, String className, + File includeFolder, Editor editor) { this.buildPath = buildPath; this.includeFolder = includeFolder; this.className = className; @@ -60,23 +60,23 @@ public class PdeCompiler implements PdeMessageConsumer { public boolean compile(PrintStream leechErr) { */ - public PdeCompiler() { } // consider this a warning, you werkin soon. + public Compiler() { } // consider this a warning, you werkin soon. - public boolean compile(PdeSketch sketch, String buildPath) - throws PdeException { + public boolean compile(Sketch sketch, String buildPath) + throws RunnerException { this.sketch = sketch; this.buildPath = buildPath; // the pms object isn't used for anything but storage - PdeMessageStream pms = new PdeMessageStream(this); + MessageStream pms = new MessageStream(this); String baseCommand[] = new String[] { // user.dir is folder containing P5 (and therefore jikes) // macosx needs the extra path info. linux doesn't like it, though // windows doesn't seem to care. write once, headache anywhere. - ((!PdeBase.isMacOS()) ? "jikes" : + ((!Base.isMacOS()) ? "jikes" : System.getProperty("user.dir") + File.separator + "jikes"), // this doesn't help much.. also java 1.4 seems to not support @@ -90,7 +90,7 @@ public class PdeCompiler implements PdeMessageConsumer { // necessary to make output classes compatible with 1.1 // i.e. so that exported applets can work with ms jvm on the web "-target", - PdePreferences.get("preproc.jdk_version"), //"1.1", + Preferences.get("preproc.jdk_version"), //"1.1", // let the incompatability headache begin // used when run without a vm ("expert" mode) @@ -150,8 +150,8 @@ public class PdeCompiler implements PdeMessageConsumer { // with the input and error streams // Process process = Runtime.getRuntime().exec(command); - new PdeMessageSiphon(process.getInputStream(), this); - new PdeMessageSiphon(process.getErrorStream(), this); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); // wait for the process to finish. if interrupted // before waitFor returns, continue waiting @@ -169,7 +169,7 @@ public class PdeCompiler implements PdeMessageConsumer { String msg = e.getMessage(); if ((msg != null) && (msg.indexOf("jikes: not found") != -1)) { //System.err.println("jikes is missing"); - PdeBase.showWarning("Compiler error", + Base.showWarning("Compiler error", "Could not find the compiler.\n" + "jikes is missing from your PATH,\n" + "see readme.txt for help.", null); @@ -182,7 +182,7 @@ public class PdeCompiler implements PdeMessageConsumer { } // an error was queued up by message(), barf this back to build() - // which will barf it back to PdeEditor. if you're having trouble + // which will barf it back to Editor. if you're having trouble // discerning the imagery, consider how cows regurgitate their food // to digest it, and the fact that they have five stomaches. // @@ -193,10 +193,10 @@ public class PdeCompiler implements PdeMessageConsumer { // is fairly wrong, one possibility is that jikes has crashed. // if (result != 0 && result != 1 ) { - //exception = new PdeException(SUPER_BADNESS); + //exception = new RunnerException(SUPER_BADNESS); //editor.error(exception); // this will instead be thrown - PdeBase.openURL(BUGS_URL); - throw new PdeException(SUPER_BADNESS); + Base.openURL(BUGS_URL); + throw new RunnerException(SUPER_BADNESS); } // success would mean that 'result' is set to zero @@ -208,10 +208,10 @@ public class PdeCompiler implements PdeMessageConsumer { boolean secondErrorFound; /** - * Part of the PdeMessageConsumer interface, this is called + * Part of the MessageConsumer interface, this is called * whenever a piece (usually a line) of error message is spewed * out from the compiler. The errors are parsed for their contents - * and line number, which is then reported back to PdeEditor. + * and line number, which is then reported back to Editor. */ public void message(String s) { // This receives messages as full lines, so a newline needs @@ -260,7 +260,7 @@ public class PdeCompiler implements PdeMessageConsumer { if (fileIndex == 0) { // main class, figure out which tab for (int i = 1; i < sketch.codeCount; i++) { - if (sketch.code[i].flavor == PdeSketch.PDE) { + if (sketch.code[i].flavor == Sketch.PDE) { if (sketch.code[i].lineOffset < lineNumber) { fileIndex = i; //System.out.println("i'm thinkin file " + i); @@ -330,7 +330,7 @@ public class PdeCompiler implements PdeMessageConsumer { //System.out.println("description = " + description); //System.out.println("creating exception " + exception); - exception = new PdeException(description, fileIndex, lineNumber-1, -1); + exception = new RunnerException(description, fileIndex, lineNumber-1, -1); // NOTE!! major change here, this exception will be queued // here to be thrown by the compile() function @@ -361,7 +361,7 @@ public class PdeCompiler implements PdeMessageConsumer { static public String calcBootClassPath() { if (bootClassPath == null) { String additional = ""; - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { additional = contentsToClassPath(new File("/System/Library/Java/Extensions/")); } diff --git a/app/PdeEditor.java b/app/Editor.java similarity index 89% rename from app/PdeEditor.java rename to app/Editor.java index ab793684f..2b918041c 100644 --- a/app/PdeEditor.java +++ b/app/Editor.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditor - main editor panel for the processing development environment + Editor - main editor panel for the processing development environment Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and @@ -46,12 +46,12 @@ import com.oroinc.text.regex.*; import com.apple.mrj.*; -public class PdeEditor extends JFrame +public class Editor extends JFrame implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler, MRJOpenDocumentHandler //, MRJOpenApplicationHandler { // yeah - static final String WINDOW_TITLE = "Processing" + " - " + PdeBase.VERSION; + static final String WINDOW_TITLE = "Processing" + " - " + Base.VERSION; // p5 icon for the window Image icon; @@ -74,10 +74,10 @@ public class PdeEditor extends JFrame boolean handleNewShift; boolean handleNewLibrary; - PdeEditorButtons buttons; - PdeEditorHeader header; - PdeEditorStatus status; - PdeEditorConsole console; + EditorButtons buttons; + EditorHeader header; + EditorStatus status; + EditorConsole console; JSplitPane splitPane; JPanel consolePanel; @@ -85,19 +85,19 @@ public class PdeEditor extends JFrame JLabel lineNumberComponent; // currently opened program - public PdeSketch sketch; + public Sketch sketch; - PdeEditorLineStatus lineStatus; + EditorLineStatus lineStatus; public JEditTextArea textarea; - PdeEditorListener listener; + EditorListener listener; // runtime information and window placement Point appletLocation; //Point presentLocation; //Window presentationWindow; RunButtonWatcher watcher; - PdeRuntime runtime; + Runner runtime; JMenuItem exportAppItem; JMenuItem saveMenuItem; @@ -116,15 +116,15 @@ public class PdeEditor extends JFrame // - //PdeHistory history; // TODO re-enable history - PdeSketchbook sketchbook; - //PdePreferences preferences; - PdeEditorFind find; + //SketchHistory history; // TODO re-enable history + Sketchbook sketchbook; + //Preferences preferences; + FindReplace find; //static Properties keywords; // keyword -> reference html lookup - public PdeEditor() { + public Editor() { super(WINDOW_TITLE); // #@$*(@#$ apple.. always gotta think different @@ -134,11 +134,11 @@ public class PdeEditor extends JFrame MRJApplicationUtils.registerOpenDocumentHandler(this); // run static initialization that grabs all the prefs - PdePreferences.init(); + Preferences.init(); // set the window icon try { - icon = PdeBase.getImage("icon.gif", this); + icon = Base.getImage("icon.gif", this); setIconImage(icon); } catch (Exception e) { } // fail silently, no big whup @@ -151,7 +151,7 @@ public class PdeEditor extends JFrame }); PdeKeywords keywords = new PdeKeywords(); - sketchbook = new PdeSketchbook(this); + sketchbook = new Sketchbook(this); JMenuBar menubar = new JMenuBar(); menubar.add(buildFileMenu()); @@ -165,7 +165,7 @@ public class PdeEditor extends JFrame setJMenuBar(menubar); // doesn't matter when this is created, just make it happen at some point - find = new PdeEditorFind(PdeEditor.this); + find = new FindReplace(Editor.this); Container pain = getContentPane(); pain.setLayout(new BorderLayout()); @@ -173,10 +173,10 @@ public class PdeEditor extends JFrame Box box = Box.createVerticalBox(); Box upper = Box.createVerticalBox(); - buttons = new PdeEditorButtons(this); + buttons = new EditorButtons(this); upper.add(buttons); - header = new PdeEditorHeader(this); + header = new EditorHeader(this); //header.setBorder(null); upper.add(header); @@ -189,15 +189,15 @@ public class PdeEditor extends JFrame consolePanel = new JPanel(); consolePanel.setLayout(new BorderLayout()); - status = new PdeEditorStatus(this); + status = new EditorStatus(this); consolePanel.add(status, BorderLayout.NORTH); - console = new PdeEditorConsole(this); + console = new EditorConsole(this); // windows puts an ugly border on this guy console.setBorder(null); consolePanel.add(console, BorderLayout.CENTER); - lineStatus = new PdeEditorLineStatus(textarea); + lineStatus = new EditorLineStatus(textarea); consolePanel.add(lineStatus, BorderLayout.SOUTH); upper.add(textarea); @@ -217,7 +217,7 @@ public class PdeEditor extends JFrame splitPane.setBorder(null); // the default size on windows is too small and kinda ugly - int dividerSize = PdePreferences.getInteger("editor.divider.size"); + int dividerSize = Preferences.getInteger("editor.divider.size"); if (dividerSize != 0) { splitPane.setDividerSize(dividerSize); } @@ -227,7 +227,7 @@ public class PdeEditor extends JFrame // hopefully these are no longer needed w/ swing // (har har har.. that was wishful thinking) - listener = new PdeEditorListener(this, textarea); + listener = new EditorListener(this, textarea); pain.add(box); // set the undo stuff for this feller @@ -260,17 +260,17 @@ public class PdeEditor extends JFrame Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); boolean windowPositionValid = true; - if (PdePreferences.get("last.screen.height") != null) { + if (Preferences.get("last.screen.height") != null) { // if screen size has changed, the window coordinates no longer // make sense, so don't use them unless they're identical - int screenW = PdePreferences.getInteger("last.screen.width"); - int screenH = PdePreferences.getInteger("last.screen.height"); + int screenW = Preferences.getInteger("last.screen.width"); + int screenH = Preferences.getInteger("last.screen.height"); if ((screen.width != screenW) || (screen.height != screenH)) { windowPositionValid = false; } - int windowX = PdePreferences.getInteger("last.window.x"); - int windowY = PdePreferences.getInteger("last.window.y"); + int windowX = Preferences.getInteger("last.window.x"); + int windowY = Preferences.getInteger("last.window.y"); if ((windowX < 0) || (windowY < 0) || (windowX > screenW) || (windowY > screenH)) { windowPositionValid = false; @@ -282,31 +282,31 @@ public class PdeEditor extends JFrame if (!windowPositionValid) { //System.out.println("using default size"); - int windowH = PdePreferences.getInteger("default.window.height"); - int windowW = PdePreferences.getInteger("default.window.width"); + int windowH = Preferences.getInteger("default.window.height"); + int windowW = Preferences.getInteger("default.window.width"); setBounds((screen.width - windowW) / 2, (screen.height - windowH) / 2, windowW, windowH); // this will be invalid as well, so grab the new value - PdePreferences.setInteger("last.divider.location", + Preferences.setInteger("last.divider.location", splitPane.getDividerLocation()); } else { - setBounds(PdePreferences.getInteger("last.window.x"), - PdePreferences.getInteger("last.window.y"), - PdePreferences.getInteger("last.window.width"), - PdePreferences.getInteger("last.window.height")); + setBounds(Preferences.getInteger("last.window.x"), + Preferences.getInteger("last.window.y"), + Preferences.getInteger("last.window.width"), + Preferences.getInteger("last.window.height")); } // last sketch that was in use, or used to launch the app - if (PdeBase.openedAtStartup != null) { - handleOpen2(PdeBase.openedAtStartup); + if (Base.openedAtStartup != null) { + handleOpen2(Base.openedAtStartup); } else { - //String sketchName = PdePreferences.get("last.sketch.name"); - String sketchPath = PdePreferences.get("last.sketch.path"); - //PdeSketch sketchTemp = new PdeSketch(sketchPath); + //String sketchName = Preferences.get("last.sketch.name"); + String sketchPath = Preferences.get("last.sketch.path"); + //Sketch sketchTemp = new Sketch(sketchPath); if ((sketchPath != null) && (new File(sketchPath)).exists()) { // don't check modified because nothing is open yet @@ -320,7 +320,7 @@ public class PdeEditor extends JFrame // location for the console/editor area divider - int location = PdePreferences.getInteger("last.divider.location"); + int location = Preferences.getInteger("last.divider.location"); splitPane.setDividerLocation(location); @@ -338,7 +338,7 @@ public class PdeEditor extends JFrame public void applyPreferences() { // apply the setting for 'use external editor' - boolean external = PdePreferences.getBoolean("editor.external"); + boolean external = Preferences.getBoolean("editor.external"); textarea.setEditable(!external); saveMenuItem.setEnabled(!external); @@ -348,22 +348,22 @@ public class PdeEditor extends JFrame TextAreaPainter painter = textarea.getPainter(); if (external) { // disable line highlight and turn off the caret when disabling - Color color = PdePreferences.getColor("editor.external.bgcolor"); + Color color = Preferences.getColor("editor.external.bgcolor"); painter.setBackground(color); painter.setLineHighlightEnabled(false); textarea.setCaretVisible(false); } else { - Color color = PdePreferences.getColor("editor.bgcolor"); + Color color = Preferences.getColor("editor.bgcolor"); painter.setBackground(color); - boolean highlight = PdePreferences.getBoolean("editor.linehighlight"); + boolean highlight = Preferences.getBoolean("editor.linehighlight"); painter.setLineHighlightEnabled(highlight); textarea.setCaretVisible(true); } // apply changes to the font size for the editor //TextAreaPainter painter = textarea.getPainter(); - painter.setFont(PdePreferences.getFont("editor.font")); + painter.setFont(Preferences.getFont("editor.font")); //Font font = painter.getFont(); //textarea.getPainter().setFont(new Font("Courier", Font.PLAIN, 36)); @@ -384,23 +384,23 @@ public class PdeEditor extends JFrame // window location information Rectangle bounds = getBounds(); - PdePreferences.setInteger("last.window.x", bounds.x); - PdePreferences.setInteger("last.window.y", bounds.y); - PdePreferences.setInteger("last.window.width", bounds.width); - PdePreferences.setInteger("last.window.height", bounds.height); + Preferences.setInteger("last.window.x", bounds.x); + Preferences.setInteger("last.window.y", bounds.y); + Preferences.setInteger("last.window.width", bounds.width); + Preferences.setInteger("last.window.height", bounds.height); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - PdePreferences.setInteger("last.screen.width", screen.width); - PdePreferences.setInteger("last.screen.height", screen.height); + Preferences.setInteger("last.screen.width", screen.width); + Preferences.setInteger("last.screen.height", screen.height); // last sketch that was in use - //PdePreferences.set("last.sketch.name", sketchName); - //PdePreferences.set("last.sketch.name", sketch.name); - PdePreferences.set("last.sketch.path", sketch.getMainFilePath()); + //Preferences.set("last.sketch.name", sketchName); + //Preferences.set("last.sketch.name", sketch.name); + Preferences.set("last.sketch.path", sketch.getMainFilePath()); // location for the console/editor area divider int location = splitPane.getDividerLocation(); - PdePreferences.setInteger("last.divider.location", location); + Preferences.setInteger("last.divider.location", location); } @@ -420,7 +420,7 @@ public class PdeEditor extends JFrame }); */ - if (!PdePreferences.getBoolean("export.library")) { + if (!Preferences.getBoolean("export.library")) { item = newJMenuItem("New", 'N'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -491,7 +491,7 @@ public class PdeEditor extends JFrame menu.add(item); // macosx already has its own preferences and quit menu - if (!PdeBase.isMacOS()) { + if (!Base.isMacOS()) { menu.addSeparator(); item = newJMenuItem("Preferences", ','); @@ -556,14 +556,14 @@ public class PdeEditor extends JFrame menu.add(sketchbook.getImportMenu()); - if (PdeBase.isWindows() || PdeBase.isMacOS()) { + if (Base.isWindows() || Base.isMacOS()) { // no way to do an 'open in file browser' on other platforms // since there isn't any sort of standard item = new JMenuItem("Show Sketch Folder"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //PdeBase.openFolder(sketchDir); - PdeBase.openFolder(sketch.folder); + //Base.openFolder(sketchDir); + Base.openFolder(sketch.folder); } }); menu.add(item); @@ -582,7 +582,7 @@ public class PdeEditor extends JFrame item = new JMenuItem("Auto Format"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //new AutoFormat(PdeEditor.this).show(); + //new AutoFormat(Editor.this).show(); handleBeautify(); } }); @@ -592,7 +592,7 @@ public class PdeEditor extends JFrame item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //new CreateFont().show(sketch.dataFolder); - new CreateFont(PdeEditor.this).show(); + new CreateFont(Editor.this).show(); } }); menu.add(item); @@ -600,9 +600,9 @@ public class PdeEditor extends JFrame item = new JMenuItem("Archive Sketch"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - new Archiver(PdeEditor.this).show(); + new Archiver(Editor.this).show(); //Archiver archiver = new Archiver(); - //archiver.setup(PdeEditor.this); + //archiver.setup(Editor.this); //archiver.show(); } }); @@ -619,7 +619,7 @@ public class PdeEditor extends JFrame item = new JMenuItem("Environment"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - PdeBase.openURL(System.getProperty("user.dir") + File.separator + + Base.openURL(System.getProperty("user.dir") + File.separator + "reference" + File.separator + "environment" + File.separator + "index.html"); } @@ -629,7 +629,7 @@ public class PdeEditor extends JFrame item = new JMenuItem("Reference"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - PdeBase.openURL(System.getProperty("user.dir") + File.separator + + Base.openURL(System.getProperty("user.dir") + File.separator + "reference" + File.separator + "index.html"); } }); @@ -648,7 +648,7 @@ public class PdeEditor extends JFrame if (referenceFile == null) { message("No reference available for \"" + text + "\""); } else { - PdeBase.showReference(referenceFile); + Base.showReference(referenceFile); } } } @@ -659,13 +659,13 @@ public class PdeEditor extends JFrame item = newJMenuItem("Visit Processing.org", '5'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - PdeBase.openURL("http://processing.org/"); + Base.openURL("http://processing.org/"); } }); menu.add(item); // macosx already has its own about menu - if (!PdeBase.isMacOS()) { + if (!Base.isMacOS()) { menu.addSeparator(); item = new JMenuItem("About Processing"); item.addActionListener(new ActionListener() { @@ -861,7 +861,7 @@ public class PdeEditor extends JFrame // so used internally for everything else public void handleAbout() { - final Image image = PdeBase.getImage("about.jpg", this); + final Image image = Base.getImage("about.jpg", this); int w = image.getWidth(this); int h = image.getHeight(this); final Window window = new Window(this) { @@ -874,7 +874,7 @@ public class PdeEditor extends JFrame g.setFont(new Font("SansSerif", Font.PLAIN, 11)); g.setColor(Color.white); - g.drawString(PdeBase.VERSION, 50, 30); + g.drawString(Base.VERSION, 50, 30); } }; window.addMouseListener(new MouseAdapter() { @@ -892,7 +892,7 @@ public class PdeEditor extends JFrame * Show the preferences window. */ public void handlePrefs() { - PdePreferences preferences = new PdePreferences(); + Preferences preferences = new Preferences(); preferences.showFrame(this); // since this can't actually block, it'll hide @@ -913,7 +913,7 @@ public class PdeEditor extends JFrame /** - * Get the contents of the current buffer. Used by the PdeSketch class. + * Get the contents of the current buffer. Used by the Sketch class. */ public String getText() { return textarea.getText(); @@ -921,7 +921,7 @@ public class PdeEditor extends JFrame /** - * Called by PdeEditorHeader when the tab is changed + * Called by EditorHeader when the tab is changed * (or a new set of files are opened). * @param discardUndo true if undo info to this point should be ignored */ @@ -944,9 +944,9 @@ public class PdeEditor extends JFrame for (int i = 0; i < 10; i++) System.out.println(); // clear the console on each run, unless the user doesn't want to - //if (PdeBase.getBoolean("console.auto_clear", true)) { - //if (PdePreferences.getBoolean("console.auto_clear", true)) { - if (PdePreferences.getBoolean("console.auto_clear")) { + //if (Base.getBoolean("console.auto_clear", true)) { + //if (Preferences.getBoolean("console.auto_clear", true)) { + if (Preferences.getBoolean("console.auto_clear")) { console.clear(); } @@ -962,11 +962,11 @@ public class PdeEditor extends JFrame try { if (!sketch.handleRun()) return; - runtime = new PdeRuntime(sketch, PdeEditor.this); + runtime = new Runner(sketch, Editor.this); runtime.start(appletLocation); watcher = new RunButtonWatcher(); - } catch (PdeException e) { + } catch (RunnerException e) { error(e); } catch (Exception e) { @@ -980,11 +980,11 @@ public class PdeEditor extends JFrame try { if (!sketch.handleRun()) return null; - runtime = new PdeRuntime(sketch, PdeEditor.this); + runtime = new Runner(sketch, Editor.this); runtime.start(presenting ? presentLocation : appletLocation); watcher = new RunButtonWatcher(); - } catch (PdeException e) { + } catch (RunnerException e) { error(e); } catch (Exception e) { @@ -1077,7 +1077,7 @@ public class PdeEditor extends JFrame try { // the window will also be null the process was running // externally. so don't even try setting if window is null - // since PdeRuntime will set the appletLocation when an + // since Runner will set the appletLocation when an // external process is in use. if (runtime.window != null) { appletLocation = runtime.window.getLocation(); @@ -1163,7 +1163,7 @@ public class PdeEditor extends JFrame /** - * Called by PdeEditorStatus to complete the job. + * Called by EditorStatus to complete the job. */ public void checkModified2() { switch (checkModifiedMode) { @@ -1191,7 +1191,7 @@ public class PdeEditor extends JFrame /** - * Extra public method so that PdeSketch can call + * Extra public method so that Sketch can call * this when a sketch is selected to be deleted, * and it won't prompt for save as. */ @@ -1232,7 +1232,7 @@ public class PdeEditor extends JFrame // not sure why this would happen, but since there's no way to // recover (outside of creating another new setkch, which might // just cause more trouble), then they've gotta quit. - PdeBase.showError("Problem creating a new sketch", + Base.showError("Problem creating a new sketch", "An error occurred while creating\n" + "a new sketch. Processing must now quit.", e); } @@ -1273,9 +1273,9 @@ public class PdeEditor extends JFrame if (sketch != null) { // if leaving an empty sketch (i.e. the default) do an // auto-clean right away - if (PdeBase.calcFolderSize(sketch.folder) == 0) { + if (Base.calcFolderSize(sketch.folder) == 0) { //System.err.println("removing empty poopster"); - PdeBase.removeDir(sketch.folder); + Base.removeDir(sketch.folder); sketchbook.rebuildMenus(); } //} else { @@ -1305,7 +1305,7 @@ public class PdeEditor extends JFrame //System.out.println("found alt file in same folder"); } else if (!path.endsWith(".pde")) { - PdeBase.showWarning("Bad file selected", + Base.showWarning("Bad file selected", "Processing can only open its own sketches\n" + "and other files ending in .pde", null); return; @@ -1333,7 +1333,7 @@ public class PdeEditor extends JFrame // create properly named folder File properFolder = new File(file.getParent(), properParent); if (properFolder.exists()) { - PdeBase.showWarning("Error", + Base.showWarning("Error", "A folder named \"" + properParent + "\" " + "already exists. Can't open sketch.", null); return; @@ -1344,7 +1344,7 @@ public class PdeEditor extends JFrame // copy the sketch inside File properPdeFile = new File(properFolder, file.getName()); File origPdeFile = new File(path); - PdeBase.copyFile(origPdeFile, properPdeFile); + Base.copyFile(origPdeFile, properPdeFile); // remove the original file, so user doesn't get confused origPdeFile.delete(); @@ -1357,12 +1357,12 @@ public class PdeEditor extends JFrame } } - sketch = new PdeSketch(this, path); + sketch = new Sketch(this, path); // TODO re-enable this once export application works exportAppItem.setEnabled(false && !sketch.isLibrary()); buttons.disableRun(sketch.isLibrary()); header.rebuild(); - if (PdePreferences.getBoolean("console.auto_clear")) { + if (Preferences.getBoolean("console.auto_clear")) { console.clear(); } @@ -1462,7 +1462,7 @@ public class PdeEditor extends JFrame /** * Quit, but first ask user if it's ok. Also store preferences * to disk just in case they want to quit. Final exit() happens - * in PdeEditor since it has the callback from PdeEditorStatus. + * in Editor since it has the callback from EditorStatus. */ public void handleQuit() { // stop isn't sufficient with external vm & quit @@ -1481,7 +1481,7 @@ public class PdeEditor extends JFrame */ protected void handleQuit2() { storePreferences(); - PdePreferences.save(); + Preferences.save(); sketchbook.clean(); @@ -1507,9 +1507,9 @@ public class PdeEditor extends JFrame String prog = textarea.getText(); // TODO re-enable history - //history.record(prog, PdeHistory.BEAUTIFY); + //history.record(prog, SketchHistory.BEAUTIFY); - int tabSize = PdePreferences.getInteger("editor.tabs.size"); + int tabSize = Preferences.getInteger("editor.tabs.size"); char program[] = prog.toCharArray(); StringBuffer buffer = new StringBuffer(); @@ -1674,7 +1674,7 @@ public class PdeEditor extends JFrame } - public void error(PdeException e) { + public void error(RunnerException e) { //System.out.println("ERORROOROROR 2"); if (e.file >= 0) sketch.setCurrent(e.file); if (e.line >= 0) highlightLine(e.line); @@ -1770,7 +1770,7 @@ public class PdeEditor extends JFrame referenceItem = new JMenuItem("Find in Reference"); referenceItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - PdeBase.showReference(referenceFile); + Base.showReference(referenceFile); } }); this.add(referenceItem); diff --git a/app/PdeEditorButtons.java b/app/EditorButtons.java similarity index 93% rename from app/PdeEditorButtons.java rename to app/EditorButtons.java index c04c75ebb..5f17012b9 100644 --- a/app/PdeEditorButtons.java +++ b/app/EditorButtons.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditorButtons - run/stop/etc buttons for the ide + EditorButtons - run/stop/etc buttons for the ide Part of the Processing project - http://processing.org Copyright (c) 2004 Ben Fry and the Processing project. @@ -34,7 +34,7 @@ import javax.swing.*; import javax.swing.event.*; -public class PdeEditorButtons extends JComponent implements MouseInputListener { +public class EditorButtons extends JComponent implements MouseInputListener { static final String title[] = { "Run", "Stop", "New", "Open", "Save", "Export" @@ -42,8 +42,8 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener { }; static final int BUTTON_COUNT = title.length; - static final int BUTTON_WIDTH = 27; //PdePreferences.GRID_SIZE; - static final int BUTTON_HEIGHT = 32; //PdePreferences.GRID_SIZE; + static final int BUTTON_WIDTH = 27; //Preferences.GRID_SIZE; + static final int BUTTON_HEIGHT = 32; //Preferences.GRID_SIZE; static final int BUTTON_GAP = 15; //BUTTON_WIDTH / 2; static final int RUN = 0; @@ -58,7 +58,7 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener { static final int ROLLOVER = 1; static final int ACTIVE = 2; - PdeEditor editor; + Editor editor; boolean disableRun; //Label status; @@ -90,9 +90,9 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener { //int statusY; - public PdeEditorButtons(PdeEditor editor) { + public EditorButtons(Editor editor) { this.editor = editor; - buttons = PdeBase.getImage("buttons.gif", this); + buttons = Base.getImage("buttons.gif", this); buttonCount = 0; which = new int[BUTTON_COUNT]; @@ -107,12 +107,12 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener { currentRollover = -1; - bgcolor = PdePreferences.getColor("buttons.bgcolor"); + bgcolor = Preferences.getColor("buttons.bgcolor"); status = ""; - statusFont = PdePreferences.getFont("buttons.status.font"); - statusColor = PdePreferences.getColor("buttons.status.color"); + statusFont = Preferences.getFont("buttons.status.font"); + statusColor = Preferences.getColor("buttons.status.color"); //statusY = (BUTTON_COUNT + 1) * BUTTON_HEIGHT; @@ -383,7 +383,7 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener { public void messageClear(String msg) { - //if (status.getText().equals(msg + " ")) status.setText(PdeEditor.EMPTY); + //if (status.getText().equals(msg + " ")) status.setText(Editor.EMPTY); if (status.equals(msg)) status = ""; } diff --git a/app/PdeEditorConsole.java b/app/EditorConsole.java similarity index 86% rename from app/PdeEditorConsole.java rename to app/EditorConsole.java index 49ccd5e9c..9e6dba9c2 100644 --- a/app/PdeEditorConsole.java +++ b/app/EditorConsole.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditorConsole - message console that sits below the program area + EditorConsole - message console that sits below the program area Part of the Processing project - http://Proce55ing.net Except where noted, code is written by Ben Fry and @@ -36,8 +36,8 @@ import javax.swing.text.*; // while watching just System.out // or just write directly to systemOut or systemErr -public class PdeEditorConsole extends JScrollPane { - PdeEditor editor; +public class EditorConsole extends JScrollPane { + Editor editor; JTextPane consoleTextPane; StyledDocument consoleDoc; @@ -60,10 +60,10 @@ public class PdeEditorConsole extends JScrollPane { static OutputStream stderrFile; - public PdeEditorConsole(PdeEditor editor) { + public EditorConsole(Editor editor) { this.editor = editor; - maxLineCount = PdePreferences.getInteger("console.length"); + maxLineCount = Preferences.getInteger("console.length"); consoleTextPane = new JTextPane(); consoleTextPane.setEditable(false); @@ -75,10 +75,10 @@ public class PdeEditorConsole extends JScrollPane { consoleDoc.setParagraphAttributes(0, 0, standard, true); // build styles for different types of console output - 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"); + Color bgColor = Preferences.getColor("console.color"); + Color fgColorOut = Preferences.getColor("console.output.color"); + Color fgColorErr = Preferences.getColor("console.error.color"); + Font font = Preferences.getFont("console.font"); stdStyle = new SimpleAttributeSet(); StyleConstants.setForeground(stdStyle, fgColorOut); @@ -105,7 +105,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("console.lines"); //, 4); + int lines = Preferences.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)); @@ -115,27 +115,27 @@ public class PdeEditorConsole extends JScrollPane { systemErr = System.err; try { - String outFileName = PdePreferences.get("console.output.file"); + String outFileName = Preferences.get("console.output.file"); if (outFileName != null) { stdoutFile = new FileOutputStream(outFileName); } - String errFileName = PdePreferences.get("console.error.file"); + String errFileName = Preferences.get("console.error.file"); if (errFileName != null) { stderrFile = new FileOutputStream(outFileName); } } catch (IOException e) { - PdeBase.showWarning("Console Error", + Base.showWarning("Console Error", "A problem occurred while trying to open the\n" + "files used to store the console output.", e); } consoleOut = - new PrintStream(new PdeEditorConsoleStream(this, false, stdoutFile)); + new PrintStream(new EditorConsoleStream(this, false, stdoutFile)); consoleErr = - new PrintStream(new PdeEditorConsoleStream(this, true, stderrFile)); + new PrintStream(new EditorConsoleStream(this, true, stderrFile)); - if (PdePreferences.getBoolean("console")) { + if (Preferences.getBoolean("console")) { try { System.setOut(consoleOut); System.setErr(consoleErr); @@ -147,7 +147,7 @@ public class PdeEditorConsole extends JScrollPane { // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { setBorder(null); } } @@ -172,10 +172,10 @@ public class PdeEditorConsole extends JScrollPane { public void message(String what, boolean err, boolean advance) { // 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) + // (the error is dealt with in Base with a message dialog) /* // no longer an issue. using a newer rev of rxtx - if (PdeBase.platform == PdeBase.MACOSX) { + if (Base.platform == Base.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; } @@ -205,10 +205,10 @@ public class PdeEditorConsole extends JScrollPane { /** * append a piece of text to the console. * - * Swing components are NOT thread-safe, and since the PdeMessageSiphon + * Swing components are NOT thread-safe, and since the MessageSiphon * instantiates new threads, and in those callbacks, they often print - * output to stdout and stderr, which are wrapped by PdeEditorConsoleStream - * and eventually leads to PdeEditorConsole.appendText(), which directly + * output to stdout and stderr, which are wrapped by EditorConsoleStream + * and eventually leads to EditorConsole.appendText(), which directly * updates the Swing text components, causing deadlock. * * A quick hack from Francis Li (who found this to be a problem) @@ -267,13 +267,13 @@ public class PdeEditorConsole extends JScrollPane { } -class PdeEditorConsoleStream extends OutputStream { - PdeEditorConsole parent; +class EditorConsoleStream extends OutputStream { + EditorConsole parent; boolean err; // whether stderr or stdout byte single[] = new byte[1]; OutputStream echo; - public PdeEditorConsoleStream(PdeEditorConsole parent, + public EditorConsoleStream(EditorConsole parent, boolean err, OutputStream echo) { this.parent = parent; this.err = err; diff --git a/app/PdeEditorHeader.java b/app/EditorHeader.java similarity index 88% rename from app/PdeEditorHeader.java rename to app/EditorHeader.java index fb3755e89..24ce8528b 100644 --- a/app/PdeEditorHeader.java +++ b/app/EditorHeader.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditorHeader - sketch tabs at the top of the screen + EditorHeader - sketch tabs at the top of the screen Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and @@ -32,11 +32,11 @@ import javax.swing.*; import javax.swing.event.*; -public class PdeEditorHeader extends JComponent { +public class EditorHeader extends JComponent { static Color backgroundColor; static Color textColor[] = new Color[2]; - PdeEditor editor; + Editor editor; int tabLeft[]; int tabRight[]; @@ -76,24 +76,24 @@ public class PdeEditorHeader extends JComponent { int imageW, imageH; - public PdeEditorHeader(PdeEditor eddie) { + public EditorHeader(Editor eddie) { this.editor = eddie; // weird name for listener pieces = new Image[STATUS.length][WHERE.length]; for (int i = 0; i < STATUS.length; i++) { for (int j = 0; j < WHERE.length; j++) { - pieces[i][j] = PdeBase.getImage("tab-" + STATUS[i] + "-" + + pieces[i][j] = Base.getImage("tab-" + STATUS[i] + "-" + WHERE[j] + ".gif", this); } } if (backgroundColor == null) { backgroundColor = - PdePreferences.getColor("header.bgcolor"); + Preferences.getColor("header.bgcolor"); textColor[SELECTED] = - PdePreferences.getColor("header.text.selected.color"); + Preferences.getColor("header.text.selected.color"); textColor[UNSELECTED] = - PdePreferences.getColor("header.text.unselected.color"); + Preferences.getColor("header.text.unselected.color"); } addMouseListener(new MouseAdapter() { @@ -102,7 +102,7 @@ public class PdeEditorHeader extends JComponent { int y = e.getY(); if ((x > menuLeft) && (x < menuRight)) { - popup.show(PdeEditorHeader.this, x, y); + popup.show(EditorHeader.this, x, y); } else { for (int i = 0; i < editor.sketch.codeCount; i++) { @@ -120,7 +120,7 @@ public class PdeEditorHeader extends JComponent { public void paintComponent(Graphics screen) { if (screen == null) return; - PdeSketch sketch = editor.sketch; + Sketch sketch = editor.sketch; if (sketch == null) return; // ?? Dimension size = getSize(); @@ -149,7 +149,7 @@ public class PdeEditorHeader extends JComponent { Graphics g = offscreen.getGraphics(); if (font == null) { - font = PdePreferences.getFont("header.text.font"); + font = Preferences.getFont("header.text.font"); } g.setFont(font); // need to set this each time through metrics = g.getFontMetrics(); @@ -173,13 +173,13 @@ public class PdeEditorHeader extends JComponent { // disable hide on the first tab hideItem.setEnabled(sketch.current != sketch.code[0]); - //int x = 0; //PdePreferences.GUI_SMALL; - //int x = (PdeBase.platform == PdeBase.MACOSX) ? 0 : 1; + //int x = 0; //Preferences.GUI_SMALL; + //int x = (Base.platform == Base.MACOSX) ? 0 : 1; int x = 6; // offset from left edge of the component for (int i = 0; i < sketch.codeCount; i++) { - PdeCode code = sketch.code[i]; + SketchCode code = sketch.code[i]; - String codeName = (code.flavor == PdeSketch.PDE) ? + String codeName = (code.flavor == Sketch.PDE) ? code.name : code.file.getName(); // if modified, add the li'l glyph next to the name @@ -259,10 +259,10 @@ public class PdeEditorHeader extends JComponent { // maybe this shouldn't have a command key anyways.. // since we're not trying to make this a full ide.. - //item = PdeEditor.newJMenuItem("New", 'T'); + //item = Editor.newJMenuItem("New", 'T'); /* - item = PdeEditor.newJMenuItem("Previous", KeyEvent.VK_PAGE_UP); + item = Editor.newJMenuItem("Previous", KeyEvent.VK_PAGE_UP); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("prev"); @@ -273,7 +273,7 @@ public class PdeEditorHeader extends JComponent { } menu.add(item); - item = PdeEditor.newJMenuItem("Next", KeyEvent.VK_PAGE_DOWN); + item = Editor.newJMenuItem("Next", KeyEvent.VK_PAGE_DOWN); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("ext"); @@ -327,7 +327,7 @@ public class PdeEditorHeader extends JComponent { rebuildMenu(); } }; - PdeSketch sketch = editor.sketch; + Sketch sketch = editor.sketch; if (sketch != null) { for (int i = 0; i < sketch.hiddenCount; i++) { item = new JMenuItem(sketch.hidden[i].name); @@ -368,16 +368,16 @@ public class PdeEditorHeader extends JComponent { } public Dimension getMinimumSize() { - if (PdeBase.isMacOS()) { - return new Dimension(300, PdePreferences.GRID_SIZE); + if (Base.isMacOS()) { + return new Dimension(300, Preferences.GRID_SIZE); } - return new Dimension(300, PdePreferences.GRID_SIZE - 1); + return new Dimension(300, Preferences.GRID_SIZE - 1); } public Dimension getMaximumSize() { - if (PdeBase.isMacOS()) { - return new Dimension(3000, PdePreferences.GRID_SIZE); + if (Base.isMacOS()) { + return new Dimension(3000, Preferences.GRID_SIZE); } - return new Dimension(3000, PdePreferences.GRID_SIZE - 1); + return new Dimension(3000, Preferences.GRID_SIZE - 1); } } diff --git a/app/PdeEditorLineStatus.java b/app/EditorLineStatus.java similarity index 82% rename from app/PdeEditorLineStatus.java rename to app/EditorLineStatus.java index 09f65b8b6..c319f6ef3 100644 --- a/app/PdeEditorLineStatus.java +++ b/app/EditorLineStatus.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditorLineStatus - li'l status bar fella that shows the line number + EditorLineStatus - li'l status bar fella that shows the line number Part of the Processing project - http://processing.org Copyright (c) 2005 Ben Fry and Casey Reas @@ -32,7 +32,7 @@ import javax.swing.*; import javax.swing.event.*; -public class PdeEditorLineStatus extends JComponent { +public class EditorLineStatus extends JComponent { JEditTextArea textarea; int start = -1, stop; @@ -46,17 +46,17 @@ public class PdeEditorLineStatus extends JComponent { String text = ""; - public PdeEditorLineStatus(JEditTextArea textarea) { + public EditorLineStatus(JEditTextArea textarea) { this.textarea = textarea; textarea.editorLineStatus = this; - background = PdePreferences.getColor("linestatus.bgcolor"); - font = PdePreferences.getFont("linestatus.font"); - foreground = PdePreferences.getColor("linestatus.color"); - high = PdePreferences.getInteger("linestatus.height"); + background = Preferences.getColor("linestatus.bgcolor"); + font = Preferences.getFont("linestatus.font"); + foreground = Preferences.getColor("linestatus.color"); + high = Preferences.getInteger("linestatus.height"); - if (PdeBase.isMacOS()) { - resize = PdeBase.getImage("resize.gif", this); + if (Base.isMacOS()) { + resize = Base.getImage("resize.gif", this); } //linestatus.bgcolor = #000000 //linestatus.font = SansSerif,plain,10 @@ -97,7 +97,7 @@ public class PdeEditorLineStatus extends JComponent { int baseline = (high + g.getFontMetrics().getAscent()) / 2; g.drawString(text, 6, baseline); - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { g.drawImage(resize, size.width - 20, 0, this); } } diff --git a/app/EditorListener.java b/app/EditorListener.java new file mode 100644 index 000000000..f3a2ab006 --- /dev/null +++ b/app/EditorListener.java @@ -0,0 +1,170 @@ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + EditorListener - filter key events for tab expansion/indent/etc + Part of the Processing project - http://processing.org + + Except where noted, code is written by Ben Fry and + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package processing.app; + +import processing.app.syntax.*; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; +import javax.swing.text.*; +import javax.swing.event.*; + + +public class EditorListener { + Editor editor; + JEditTextArea textarea; + + boolean externalEditor; + boolean expandTabs; + String tabString; + boolean autoIndent; + + int selectionStart, selectionEnd; + int position; + + + public EditorListener(Editor editor, JEditTextArea textarea) { + this.editor = editor; + this.textarea = textarea; + + // let him know that i'm leechin' + textarea.editorListener = this; + + applyPreferences(); + } + + + public void applyPreferences() { + expandTabs = Preferences.getBoolean("editor.tabs.expand"); + int tabSize = Preferences.getInteger("editor.tabs.size"); + tabString = Editor.EMPTY.substring(0, tabSize); + autoIndent = Preferences.getBoolean("editor.indent"); + externalEditor = Preferences.getBoolean("editor.external"); + } + + + //public void setExternalEditor(boolean externalEditor) { + //this.externalEditor = externalEditor; + //} + + + // called by JEditTextArea inside processKeyEvent + public boolean keyPressed(KeyEvent event) { + // don't do things if the textarea isn't editable + if (externalEditor) return false; + + //deselect(); // this is for paren balancing + char c = event.getKeyChar(); + int code = event.getKeyCode(); + + //System.out.println(c + " " + code + " " + event); + //System.out.println(); + + if ((event.getModifiers() & KeyEvent.META_MASK) != 0) { + //event.consume(); // does nothing + return false; + } + + // TODO i don't like these accessors. clean em up later. + if (!editor.sketch.current.modified) { + if ((code == KeyEvent.VK_BACK_SPACE) || (code == KeyEvent.VK_TAB) || + (code == KeyEvent.VK_ENTER) || ((c >= 32) && (c < 128))) { + editor.sketch.setModified(); + } + } + + switch ((int) c) { + + case 9: // expand tabs + if (expandTabs) { + //tc.replaceSelection(tabString); + textarea.setSelectedText(tabString); + event.consume(); + return true; + } + break; + + case 10: // auto-indent + case 13: + if (autoIndent) { + char contents[] = textarea.getText().toCharArray(); + + // this is the position of the caret, if the textarea + // only used a single kind of line ending + int origIndex = textarea.getCaretPosition() - 1; + + // walk through the array to the current caret position, + // and count how many weirdo windows line endings there are, + // which would be throwing off the caret position number + int offset = 0; + int realIndex = origIndex; + for (int i = 0; i < realIndex-1; i++) { + if ((contents[i] == 13) && (contents[i+1] == 10)) { + offset++; + realIndex++; + } + } + + // back up until \r \r\n or \n.. @#($* cross platform + + //System.out.println(origIndex + " offset = " + offset); + origIndex += offset; // ARGH!#(* WINDOWS#@($* + + int index = origIndex; + int spaceCount = 0; + boolean finished = false; + while ((index != -1) && (!finished)) { + if ((contents[index] == 10) || + (contents[index] == 13)) { + finished = true; + index++; // maybe ? + } else { + index--; // new + } + } + while ((index < contents.length) && (index >= 0) && + (contents[index++] == ' ')) { + spaceCount++; + } + + // seems that \r is being inserted anyway + // so no need to insert the platform's line separator + String insertion = "\n" + Editor.EMPTY.substring(0, spaceCount); + //tc.replaceSelection(insertion); + textarea.setSelectedText(insertion); + // microsoft vm version: + //tc.setCaretPosition(oldCarrot + insertion.length() - 1); + // sun vm version: + // tc.setCaretPosition(oldCarrot + insertion.length()); + event.consume(); + return true; + } + break; + } + return false; + } +} diff --git a/app/PdeEditorStatus.java b/app/EditorStatus.java similarity index 85% rename from app/PdeEditorStatus.java rename to app/EditorStatus.java index d0ab6a5cc..bcf482ecc 100644 --- a/app/PdeEditorStatus.java +++ b/app/EditorStatus.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditorStatus - panel containing status messages + EditorStatus - panel containing status messages Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and @@ -31,7 +31,7 @@ import javax.swing.*; import sun.awt.AppContext; // from java.awt.Dialog, for blocking -public class PdeEditorStatus extends JPanel implements ActionListener { +public class EditorStatus extends JPanel implements ActionListener { static Color bgcolor[]; static Color fgcolor[]; @@ -47,7 +47,7 @@ public class PdeEditorStatus extends JPanel implements ActionListener { static final String NO_MESSAGE = ""; - PdeEditor editor; + Editor editor; int mode; String message; @@ -70,22 +70,22 @@ public class PdeEditorStatus extends JPanel implements ActionListener { int response; - public PdeEditorStatus(PdeEditor editor) { + public EditorStatus(Editor editor) { this.editor = editor; empty(); if (bgcolor == null) { bgcolor = new Color[4]; - bgcolor[0] = PdePreferences.getColor("status.notice.bgcolor"); - bgcolor[1] = PdePreferences.getColor("status.error.bgcolor"); - bgcolor[2] = PdePreferences.getColor("status.prompt.bgcolor"); - bgcolor[3] = PdePreferences.getColor("status.prompt.bgcolor"); + bgcolor[0] = Preferences.getColor("status.notice.bgcolor"); + bgcolor[1] = Preferences.getColor("status.error.bgcolor"); + bgcolor[2] = Preferences.getColor("status.prompt.bgcolor"); + bgcolor[3] = Preferences.getColor("status.prompt.bgcolor"); fgcolor = new Color[4]; - fgcolor[0] = PdePreferences.getColor("status.notice.fgcolor"); - fgcolor[1] = PdePreferences.getColor("status.error.fgcolor"); - fgcolor[2] = PdePreferences.getColor("status.prompt.fgcolor"); - fgcolor[3] = PdePreferences.getColor("status.prompt.fgcolor"); + fgcolor[0] = Preferences.getColor("status.notice.fgcolor"); + fgcolor[1] = Preferences.getColor("status.error.fgcolor"); + fgcolor[2] = Preferences.getColor("status.prompt.fgcolor"); + fgcolor[3] = Preferences.getColor("status.prompt.fgcolor"); } } @@ -211,7 +211,7 @@ public class PdeEditorStatus extends JPanel implements ActionListener { Graphics g = offscreen.getGraphics(); if (font == null) { - font = PdePreferences.getFont("status.font"); + font = Preferences.getFont("status.font"); //new Font("SansSerif", Font.PLAIN, 12)); g.setFont(font); metrics = g.getFontMetrics(); @@ -225,7 +225,7 @@ public class PdeEditorStatus extends JPanel implements ActionListener { g.setColor(fgcolor[mode]); g.setFont(font); // needs to be set each time on osx - g.drawString(message, PdePreferences.GUI_SMALL, (sizeH + ascent) / 2); + g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2); screen.drawImage(offscreen, 0, 0, null); } @@ -233,14 +233,14 @@ public class PdeEditorStatus extends JPanel implements ActionListener { protected void setup() { if (yesButton == null) { - yesButton = new JButton(PdePreferences.PROMPT_YES); - noButton = new JButton(PdePreferences.PROMPT_NO); - cancelButton = new JButton(PdePreferences.PROMPT_CANCEL); - okButton = new JButton(PdePreferences.PROMPT_OK); + yesButton = new JButton(Preferences.PROMPT_YES); + noButton = new JButton(Preferences.PROMPT_NO); + cancelButton = new JButton(Preferences.PROMPT_CANCEL); + okButton = new JButton(Preferences.PROMPT_OK); // !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)( // os9 seems to work if bg of component is set, but x still a bastard - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { yesButton.setBackground(bgcolor[PROMPT]); noButton.setBackground(bgcolor[PROMPT]); cancelButton.setBackground(bgcolor[PROMPT]); @@ -266,7 +266,7 @@ public class PdeEditorStatus extends JPanel implements ActionListener { editField = new JTextField(); editField.addActionListener(this); - //if (PdeBase.platform != PdeBase.MACOSX) { + //if (Base.platform != Base.MACOSX) { editField.addKeyListener(new KeyAdapter() { // no-op implemented because of a jikes bug //protected void noop() { } @@ -366,8 +366,8 @@ public class PdeEditorStatus extends JPanel implements ActionListener { protected void setButtonBounds() { - int top = (sizeH - PdePreferences.BUTTON_HEIGHT) / 2; - int eachButton = PdePreferences.GUI_SMALL + PdePreferences.BUTTON_WIDTH; + int top = (sizeH - Preferences.BUTTON_HEIGHT) / 2; + int eachButton = Preferences.GUI_SMALL + Preferences.BUTTON_WIDTH; int cancelLeft = sizeW - eachButton; int noLeft = cancelLeft - eachButton; @@ -376,14 +376,14 @@ public class PdeEditorStatus extends JPanel implements ActionListener { yesButton.setLocation(yesLeft, top); noButton.setLocation(noLeft, top); cancelButton.setLocation(cancelLeft, top); - editField.setLocation(yesLeft - PdePreferences.BUTTON_WIDTH, top); + editField.setLocation(yesLeft - Preferences.BUTTON_WIDTH, top); okButton.setLocation(noLeft, top); - 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); + yesButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); + noButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); + cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); + okButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); + editField.setSize( 2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); } @@ -392,11 +392,11 @@ public class PdeEditorStatus extends JPanel implements ActionListener { } public Dimension getMinimumSize() { - return new Dimension(300, PdePreferences.GRID_SIZE); + return new Dimension(300, Preferences.GRID_SIZE); } public Dimension getMaximumSize() { - return new Dimension(3000, PdePreferences.GRID_SIZE); + return new Dimension(3000, Preferences.GRID_SIZE); } diff --git a/app/PdeEditorFind.java b/app/FindReplace.java similarity index 96% rename from app/PdeEditorFind.java rename to app/FindReplace.java index 5e6ec9943..f54a5f7d8 100644 --- a/app/PdeEditorFind.java +++ b/app/FindReplace.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeEditorFind - find/replace window for processing + FindReplace - find/replace window for processing Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and is @@ -29,13 +29,13 @@ import java.awt.event.*; import javax.swing.*; -public class PdeEditorFind extends JFrame +public class FindReplace extends JFrame implements ActionListener, KeyListener { static final int BIG = 13; static final int SMALL = 6; - PdeEditor editor; + Editor editor; JTextField findField; JTextField replaceField; @@ -52,7 +52,7 @@ public class PdeEditorFind extends JFrame boolean found; - public PdeEditorFind(PdeEditor editor) { + public FindReplace(Editor editor) { super("Find"); setResizable(false); this.editor = editor; @@ -96,7 +96,7 @@ public class PdeEditorFind extends JFrame buttons.setLayout(new FlowLayout()); // ordering is different on mac versus pc - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { buttons.add(replaceButton = new JButton("Replace")); buttons.add(replaceAllButton = new JButton("Replace All")); buttons.add(findButton = new JButton("Find")); @@ -113,8 +113,8 @@ public class PdeEditorFind extends JFrame // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. - //if (PdeBase.platform == PdeBase.MACOSX) { - if (PdeBase.isMacOS()) { + //if (Base.platform == Base.MACOSX) { + if (Base.isMacOS()) { buttons.setBorder(null); } diff --git a/app/PdeMessageConsumer.java b/app/MessageConsumer.java similarity index 87% rename from app/PdeMessageConsumer.java rename to app/MessageConsumer.java index 40d9c21a3..176585ef6 100644 --- a/app/PdeMessageConsumer.java +++ b/app/MessageConsumer.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeMessageConsumer - interface for dealing with parser/compiler output + MessageConsumer - interface for dealing with parser/compiler output Part of the Processing project - http://Proce55ing.net Except where noted, code is written by Ben Fry and @@ -24,7 +24,7 @@ package processing.app; -// Different instances of PdeMessageStream need to do different things with +// Different instances of MessageStream need to do different things with // messages. In particular, a stream instance used for parsing output from // the compiler compiler has to interpret its messages differently than one // parsing output from the runtime. @@ -32,7 +32,7 @@ package processing.app; // Classes which consume messages and do something with them should implement // this interface. // -public interface PdeMessageConsumer { +public interface MessageConsumer { public void message(String s); diff --git a/app/PdeMessageSiphon.java b/app/MessageSiphon.java similarity index 84% rename from app/PdeMessageSiphon.java rename to app/MessageSiphon.java index 1a70483f3..e77f56e4e 100644 --- a/app/PdeMessageSiphon.java +++ b/app/MessageSiphon.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeMessageSiphon - slurps up messages from compiler + MessageSiphon - slurps up messages from compiler Part of the Processing project - http://processing.org Earlier portions of this code are Copyright (c) 2001-04 MIT @@ -27,13 +27,13 @@ package processing.app; import java.io.*; -class PdeMessageSiphon implements Runnable { +class MessageSiphon implements Runnable { BufferedReader streamReader; Thread thread; - PdeMessageConsumer consumer; + MessageConsumer consumer; - public PdeMessageSiphon(InputStream stream, PdeMessageConsumer consumer) { + public MessageSiphon(InputStream stream, MessageConsumer consumer) { this.streamReader = new BufferedReader(new InputStreamReader(stream)); this.consumer = consumer; @@ -54,11 +54,11 @@ class PdeMessageSiphon implements Runnable { String currentLine; while ((currentLine = streamReader.readLine()) != null) { // \n is added again because readLine() strips it out - //PdeEditorConsole.systemOut.println("messaging in"); + //EditorConsole.systemOut.println("messaging in"); consumer.message(currentLine + "\n"); - //PdeEditorConsole.systemOut.println("messaging out"); + //EditorConsole.systemOut.println("messaging out"); } - //PdeEditorConsole.systemOut.println("messaging thread done"); + //EditorConsole.systemOut.println("messaging thread done"); thread = null; } catch (NullPointerException npe) { @@ -73,7 +73,7 @@ class PdeMessageSiphon implements Runnable { if ((mess != null) && (mess.indexOf("Bad file descriptor") != -1)) { //if (e.getMessage().indexOf("Bad file descriptor") == -1) { - //System.err.println("PdeMessageSiphon err " + e); + //System.err.println("MessageSiphon err " + e); //e.printStackTrace(); } thread = null; diff --git a/app/PdeMessageStream.java b/app/MessageStream.java similarity index 76% rename from app/PdeMessageStream.java rename to app/MessageStream.java index 413700a2c..0f14f9b03 100644 --- a/app/PdeMessageStream.java +++ b/app/MessageStream.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeMessageStream - outputstream to handle stdout/stderr messages + MessageStream - outputstream to handle stdout/stderr messages Part of the Processing project - http://Proce55ing.net Except where noted, code is written by Ben Fry and @@ -28,23 +28,23 @@ import java.io.*; /** - * this is used by PdeEditor, System.err is set to - * new PrintStream(new PdeMessageStream()) + * this is used by Editor, System.err is set to + * new PrintStream(new MessageStream()) * - * it's also used by PdeCompiler + * it's also used by Compiler */ -class PdeMessageStream extends OutputStream { +class MessageStream extends OutputStream { - //PdeEditor editor; - PdeMessageConsumer messageConsumer; + //Editor editor; + MessageConsumer messageConsumer; - public PdeMessageStream(/*PdeEditor editor,*/ - PdeMessageConsumer messageConsumer) { + public MessageStream(/*Editor editor,*/ + MessageConsumer messageConsumer) { //this.editor = editor; this.messageConsumer = messageConsumer; } - //public void setMessageConsumer(PdeMessageConsumer messageConsumer) { + //public void setMessageConsumer(MessageConsumer messageConsumer) { //this.messageConsumer = messageConsumer; //} diff --git a/app/PdePreferences.java b/app/Preferences.java similarity index 95% rename from app/PdePreferences.java rename to app/Preferences.java index 5fb636d9a..0dcc629b6 100644 --- a/app/PdePreferences.java +++ b/app/Preferences.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdePreferences - controls user preferences and environment settings + Preferences - controls user preferences and environment settings Part of the Processing project - http://Processing.org Except where noted, code is written by Ben Fry and is @@ -50,7 +50,7 @@ import processing.core.PApplet; * properties files are iso8859-1, which is highly likely to * be a problem when trying to save sketch folders and locations. */ -public class PdePreferences extends JComponent { +public class Preferences extends JComponent { // what to call the feller @@ -104,7 +104,7 @@ public class PdePreferences extends JComponent { // the calling editor, so updates can be applied - PdeEditor editor; + Editor editor; // data model @@ -120,10 +120,10 @@ public class PdePreferences extends JComponent { // important was deleted from the user prefs try { - load(PdeBase.getStream("preferences.txt")); + load(Base.getStream("preferences.txt")); } catch (Exception e) { - PdeBase.showError(null, "Could not read default settings.\n" + + Base.showError(null, "Could not read default settings.\n" + "You'll need to reinstall Processing.", e); } @@ -155,7 +155,7 @@ public class PdePreferences extends JComponent { //File home = new File(System.getProperty("user.home")); //File processingHome = new File(home, "Processing"); //preferencesFile = new File(home, PREFS_FILE); - preferencesFile = PdeBase.getProcessingDataFile(PREFS_FILE); + preferencesFile = Base.getProcessingDataFile(PREFS_FILE); if (!preferencesFile.exists()) { // create a new preferences file if none exists @@ -169,7 +169,7 @@ public class PdePreferences extends JComponent { load(new FileInputStream(preferencesFile)); } catch (Exception ex) { - PdeBase.showError("Error reading preferences", + Base.showError("Error reading preferences", "Error reading the preferences file. " + "Please delete (or move)\n" + preferencesFile.getAbsolutePath() + @@ -179,7 +179,7 @@ public class PdePreferences extends JComponent { } - public PdePreferences() { + public Preferences() { // setup frame for the prefs @@ -279,7 +279,7 @@ public class PdePreferences extends JComponent { pain.add(box); d = box.getPreferredSize(); box.setBounds(left, top, d.width, d.height); - Font editorFont = PdePreferences.getFont("editor.font"); + Font editorFont = Preferences.getFont("editor.font"); fontSizeField.setText(String.valueOf(editorFont.getSize())); top += d.height + GUI_BETWEEN; @@ -316,7 +316,7 @@ public class PdePreferences extends JComponent { "in the file " + preferencesFile.getAbsolutePath(); //"More preferences are in the 'lib' folder inside text files\n" + //"named preferences.txt and pde_" + - //PdeBase.platforms[PdeBase.platform] + ".properties"; + //Base.platforms[Base.platform] + ".properties"; JTextArea textarea = new JTextArea(blather); textarea.setEditable(false); @@ -336,7 +336,7 @@ public class PdePreferences extends JComponent { label = new JLabel(preferencesFile.getAbsolutePath()); label.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { - PdeBase.openURL(preferencesFile.getAbsolutePath()); + Base.openURL(preferencesFile.getAbsolutePath()); } }); label.setForeground(new Color(51, 25, 153)); @@ -412,7 +412,7 @@ public class PdePreferences extends JComponent { addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { - KeyStroke wc = PdeEditor.WINDOW_CLOSE_KEYSTROKE; + KeyStroke wc = Editor.WINDOW_CLOSE_KEYSTROKE; if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) || (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) { disposeFrame(); @@ -469,7 +469,7 @@ public class PdePreferences extends JComponent { } - public void showFrame(PdeEditor editor) { + public void showFrame(Editor editor) { // hide the editor window so it can't be messed with this.editor = editor; //editor.hide(); @@ -530,8 +530,8 @@ public class PdePreferences extends JComponent { /* FileOutputStream output = null; - if ((PdeBase.platform == PdeBase.MACOSX) || - (PdeBase.platform == PdeBase.MACOS9)) { + if ((Base.platform == Base.MACOSX) || + (Base.platform == Base.MACOS9)) { output = new FileOutputStream("lib/preferences.txt"); } else { // win95/98/ME doesn't set cwd properly @@ -548,7 +548,7 @@ public class PdePreferences extends JComponent { Properties skprops = new Properties(); - //Rectangle window = PdeBase.frame.getBounds(); + //Rectangle window = Base.frame.getBounds(); Rectangle window = editor.getBounds(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); @@ -571,7 +571,7 @@ public class PdePreferences extends JComponent { skprops.put("editor.external", externalEditor ? "true" : "false"); - //skprops.put("serial.port", PdePreferences.get("serial.port", "unspecified")); + //skprops.put("serial.port", Preferences.get("serial.port", "unspecified")); // save() is deprecated, and didn't properly // throw exceptions when it wasn't working @@ -583,7 +583,7 @@ public class PdePreferences extends JComponent { */ } catch (IOException ex) { - PdeBase.showWarning(null, "Error while saving the settings file", ex); + Base.showWarning(null, "Error while saving the settings file", ex); //e.printStackTrace(); } } @@ -742,7 +742,7 @@ public class PdePreferences extends JComponent { combo.setEnabled(false); } else { - String defaultName = PdePreferences.get("serial.port", "unspecified"); + String defaultName = Preferences.get("serial.port", "unspecified"); combo.setSelectedItem(defaultName); } diff --git a/app/PresentMode.java b/app/PresentMode.java index 3186e3ace..0cccf74bd 100644 --- a/app/PresentMode.java +++ b/app/PresentMode.java @@ -72,14 +72,14 @@ public class PresentMode { public void actionPerformed(ActionEvent e) { int index = selector.getSelectedIndex(); //device = devices[index]; - PdePreferences.setInteger("run.present.display", index + 1); + Preferences.setInteger("run.present.display", index + 1); } }); } static public JComboBox getSelector() { - int deviceIndex = PdePreferences.getInteger("run.present.display") - 1; + int deviceIndex = Preferences.getInteger("run.present.display") - 1; selector.setSelectedIndex(deviceIndex); return selector; } @@ -89,7 +89,7 @@ public class PresentMode { static public JFrame create() { int deviceIndex = PrePreferences.getInteger("run.present.display") - 1; if ((deviceIndex < 0) || (deviceIndex >= devices.length)) { - PdeBase.showWarning("Display doesn't exist", + Base.showWarning("Display doesn't exist", "Present Mode is set to use display " + (deviceIndex+1) + " but that doesn't seem to exist. \n" + diff --git a/app/PdeRuntime.java b/app/Runner.java similarity index 90% rename from app/PdeRuntime.java rename to app/Runner.java index 470da9b95..8acbb38d2 100644 --- a/app/PdeRuntime.java +++ b/app/Runner.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeRuntime - runs a compiled java applet + Runner - runs a compiled java applet Part of the Processing project - http://processing.org Copyright (c) 2004-05 Ben Fry and Casey Reas @@ -34,16 +34,16 @@ import java.lang.reflect.*; import com.oroinc.text.regex.*; -public class PdeRuntime implements PdeMessageConsumer { +public class Runner implements MessageConsumer { PApplet applet; - PdeException exception; + RunnerException exception; Window window; PrintStream leechErr; //String className; - PdeEditor editor; - PdeSketch sketch; + Editor editor; + Sketch sketch; boolean newMessage; int messageLineCount; @@ -52,18 +52,18 @@ public class PdeRuntime implements PdeMessageConsumer { Process process; SystemOutSiphon processInput; OutputStream processOutput; - PdeMessageSiphon processError; + MessageSiphon processError; - public PdeRuntime(PdeSketch sketch, PdeEditor editor) { + public Runner(Sketch sketch, Editor editor) { this.sketch = sketch; this.editor = editor; } - public void start(Point windowLocation) throws PdeException { + public void start(Point windowLocation) throws RunnerException { //System.out.println(" externalRuntime is " + sketch.externalRuntime); - this.leechErr = new PrintStream(new PdeMessageStream(this)); + this.leechErr = new PrintStream(new MessageStream(this)); try { if (editor.presenting) { @@ -97,14 +97,14 @@ public class PdeRuntime implements PdeMessageConsumer { sketch.libraryPath + File.pathSeparator + System.getProperty("java.library.path"), "-cp", - sketch.classPath + PdeSketchbook.librariesClassPath, + sketch.classPath + Sketchbook.librariesClassPath, "processing.core.PApplet", PApplet.ARGS_EXTERNAL, PApplet.ARGS_PRESENT, PApplet.ARGS_PRESENT_BGCOLOR + "=" + - PdePreferences.get("run.present.bgcolor"), + Preferences.get("run.present.bgcolor"), PApplet.ARGS_DISPLAY + "=" + - PdePreferences.get("run.display"), + Preferences.get("run.display"), PApplet.ARGS_SKETCH_FOLDER + "=" + sketch.folder.getAbsolutePath(), sketch.mainClassName @@ -112,7 +112,7 @@ public class PdeRuntime implements PdeMessageConsumer { process = Runtime.getRuntime().exec(command); processInput = new SystemOutSiphon(process.getInputStream()); - processError = new PdeMessageSiphon(process.getErrorStream(), this); + processError = new MessageSiphon(process.getErrorStream(), this); processOutput = process.getOutputStream(); } @@ -142,11 +142,11 @@ public class PdeRuntime implements PdeMessageConsumer { sketch.libraryPath + File.pathSeparator + System.getProperty("java.library.path"), "-cp", - sketch.classPath + PdeSketchbook.librariesClassPath, + sketch.classPath + Sketchbook.librariesClassPath, "processing.core.PApplet", location, PApplet.ARGS_EXTERNAL, - PApplet.ARGS_DISPLAY + "=" + PdePreferences.get("run.display"), + PApplet.ARGS_DISPLAY + "=" + Preferences.get("run.display"), PApplet.ARGS_SKETCH_FOLDER + "=" + sketch.folder.getAbsolutePath(), sketch.mainClassName }; @@ -155,7 +155,7 @@ public class PdeRuntime implements PdeMessageConsumer { process = Runtime.getRuntime().exec(command); processInput = new SystemOutSiphon(process.getInputStream()); - processError = new PdeMessageSiphon(process.getErrorStream(), this); + processError = new MessageSiphon(process.getErrorStream(), this); processOutput = process.getOutputStream(); } @@ -167,7 +167,7 @@ public class PdeRuntime implements PdeMessageConsumer { int windowX = editorLocation.x; int windowY = editorLocation.y + editor.getInsets().top; - PdeClassLoader loader = new PdeClassLoader(); + RunnerClassLoader loader = new RunnerClassLoader(); Class c = loader.loadClass(sketch.mainClassName); applet = (PApplet) c.newInstance(); @@ -180,7 +180,7 @@ public class PdeRuntime implements PdeMessageConsumer { while ((applet.width == 0) && !applet.finished) { try { if (applet.exception != null) { - throw new PdeException(applet.exception.getMessage()); + throw new RunnerException(applet.exception.getMessage()); } Thread.sleep(5); } catch (InterruptedException e) { } @@ -217,8 +217,8 @@ public class PdeRuntime implements PdeMessageConsumer { window.setLayout(null); Insets insets = window.getInsets(); - int minW = PdePreferences.getInteger("run.window.width.minimum"); - int minH = PdePreferences.getInteger("run.window.height.minimum"); + int minW = Preferences.getInteger("run.window.width.minimum"); + int minH = Preferences.getInteger("run.window.height.minimum"); int windowW = Math.max(applet.width, minW) + insets.left + insets.right; int windowH = @@ -228,11 +228,11 @@ public class PdeRuntime implements PdeMessageConsumer { window.setBounds(windowX - windowW, windowY, windowW, windowH); } else { // if it fits inside the editor window - windowX = editorLocation.x + PdePreferences.GRID_SIZE * 2; // 66 - windowY = editorLocation.y + PdePreferences.GRID_SIZE * 2; // 66 + windowX = editorLocation.x + Preferences.GRID_SIZE * 2; // 66 + windowY = editorLocation.y + Preferences.GRID_SIZE * 2; // 66 - if ((windowX + windowW > screen.width - PdePreferences.GRID_SIZE) || - (windowY + windowH > screen.height - PdePreferences.GRID_SIZE)) { + if ((windowX + windowW > screen.width - Preferences.GRID_SIZE) || + (windowY + windowH > screen.height - Preferences.GRID_SIZE)) { // otherwise center on screen windowX = (screen.width - windowW) / 2; windowY = (screen.height - windowH) / 2; @@ -240,7 +240,7 @@ public class PdeRuntime implements PdeMessageConsumer { window.setBounds(windowX, windowY, windowW, windowH); //ww, wh); } - Color windowBgColor = PdePreferences.getColor("run.window.bgcolor"); + Color windowBgColor = Preferences.getColor("run.window.bgcolor"); window.setBackground(windowBgColor); int usableH = windowH - insets.top - insets.bottom; @@ -357,7 +357,7 @@ public class PdeRuntime implements PdeMessageConsumer { //if (newMessage && s.length() > 2) { if (newMessage) { - exception = new PdeException(s); // type of java ex + exception = new RunnerException(s); // type of java ex exception.hideStackTrace = true; //System.out.println("setting ex type to " + s); newMessage = false; @@ -421,7 +421,7 @@ java.lang.NullPointerException if (codeIndex != -1) { // lineIndex is 1-indexed, but editor wants zero-indexed lineIndex = Integer.parseInt(fileAndLine.substring(colonIndex + 1)); - exception = new PdeException(exception.getMessage(), + exception = new RunnerException(exception.getMessage(), codeIndex, lineIndex - 1, -1); exception.hideStackTrace = true; foundMessageSource = true; @@ -459,7 +459,7 @@ java.lang.NullPointerException if (index != -1) { functionStr = functionStr.substring(0, index); } - exception = new PdeException(//"inside \"" + functionStr + "()\": " + + exception = new RunnerException(//"inside \"" + functionStr + "()\": " + exception.getMessage() + " inside " + functionStr + "() " + "[add Compiler.disable() to setup()]"); @@ -478,7 +478,7 @@ java.lang.NullPointerException // error, but needs to make it through anyway. // so if five lines have gone past, might as well signal messageLineCount = -100; - exception = new PdeException(exception.getMessage()); + exception = new RunnerException(exception.getMessage()); exception.hideStackTrace = true; editor.error(exception); diff --git a/app/PdeClassLoader.java b/app/RunnerClassLoader.java old mode 100755 new mode 100644 similarity index 96% rename from app/PdeClassLoader.java rename to app/RunnerClassLoader.java index 5cf9025b3..9183a3d40 --- a/app/PdeClassLoader.java +++ b/app/RunnerClassLoader.java @@ -29,23 +29,23 @@ import java.util.jar.*; * loading with new delegation model in Java 1.2. * */ -public class PdeClassLoader extends ClassLoader { +public class RunnerClassLoader extends ClassLoader { String buildFolderPath; /* - PdeClassLoader(ClassLoader parent) { + RunnerClassLoader(ClassLoader parent) { super(parent); init(); } */ - PdeClassLoader() { + RunnerClassLoader() { //super(); // uses system class loader //init(); //} //private void init() { - buildFolderPath = PdeBase.getBuildFolder().getAbsolutePath(); + buildFolderPath = Base.getBuildFolder().getAbsolutePath(); /* FileInputStream fi = null; diff --git a/app/PdeException.java b/app/RunnerException.java similarity index 83% rename from app/PdeException.java rename to app/RunnerException.java index befaea525..95838a896 100644 --- a/app/PdeException.java +++ b/app/RunnerException.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeException - an exception with a line number attached + RunnerException - an exception with a line number attached Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and is @@ -24,30 +24,30 @@ package processing.app; -public class PdeException extends Exception { +public class RunnerException extends Exception { public int file = -1; public int line = -1; public int column = -1; public boolean hideStackTrace; - public PdeException() { } + public RunnerException() { } - public PdeException(String message) { + public RunnerException(String message) { super(massage(message)); } - public PdeException(String message, int line) { + public RunnerException(String message, int line) { super(massage(message)); this.line = line; } - public PdeException(String message, int line, int column) { + public RunnerException(String message, int line, int column) { super(massage(message)); this.line = line; this.column = column; } - public PdeException(String message, int file, int line, int column) { + public RunnerException(String message, int file, int line, int column) { super(massage(message)); this.file = file; this.line = line; diff --git a/app/PdeSketch.java b/app/Sketch.java similarity index 91% rename from app/PdeSketch.java rename to app/Sketch.java index 734500472..71de83c2c 100644 --- a/app/PdeSketch.java +++ b/app/Sketch.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeSketch - stores information about files in the current sketch + Sketch - stores information about files in the current sketch Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry @@ -37,11 +37,11 @@ import javax.swing.JOptionPane; import com.oroinc.text.regex.*; -public class PdeSketch { +public class Sketch { //static String TEMP_BUILD_PATH = "lib" + File.separator + "build"; static File tempBuildFolder; - PdeEditor editor; + Editor editor; // name of sketch, which is the name of main file // (without .pde or .java extension) @@ -63,12 +63,12 @@ public class PdeSketch { static final int PDE = 0; static final int JAVA = 1; - public PdeCode current; + public SketchCode current; int codeCount; - PdeCode code[]; + SketchCode code[]; int hiddenCount; - PdeCode hidden[]; + SketchCode hidden[]; // all these set each time build() is called String mainClassName; @@ -81,7 +81,7 @@ public class PdeSketch { * path is location of the main .pde file, because this is also * simplest to use when opening the file from the finder/explorer. */ - public PdeSketch(PdeEditor editor, String path) throws IOException { + public Sketch(Editor editor, String path) throws IOException { this.editor = editor; File mainFile = new File(path); @@ -101,21 +101,21 @@ public class PdeSketch { // lib/build must exist when the application is started // it is added to the CLASSPATH by default, but if it doesn't // exist when the application is started, then java will remove - // the entry from the CLASSPATH, causing PdeRuntime to fail. + // the entry from the CLASSPATH, causing Runner to fail. // /* tempBuildFolder = new File(TEMP_BUILD_PATH); if (!tempBuildFolder.exists()) { tempBuildFolder.mkdirs(); - PdeBase.showError("Required folder missing", + Base.showError("Required folder missing", "A required folder was missing from \n" + "from your installation of Processing.\n" + "It has now been replaced, please restart \n" + "the application to complete the repair.", null); } */ - tempBuildFolder = PdeBase.getBuildFolder(); - //PdeBase.addBuildFolderToClassPath(); + tempBuildFolder = Base.getBuildFolder(); + //Base.addBuildFolderToClassPath(); folder = new File(new File(path).getParent()); //System.out.println("sketch dir is " + folder); @@ -157,8 +157,8 @@ public class PdeSketch { else if (list[i].endsWith(".java.x")) hiddenCount++; } - code = new PdeCode[codeCount]; - hidden = new PdeCode[hiddenCount]; + code = new SketchCode[codeCount]; + hidden = new SketchCode[hiddenCount]; int codeCounter = 0; int hiddenCounter = 0; @@ -166,25 +166,25 @@ public class PdeSketch { for (int i = 0; i < list.length; i++) { if (list[i].endsWith(".pde")) { code[codeCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 4), + new SketchCode(list[i].substring(0, list[i].length() - 4), new File(folder, list[i]), PDE); } else if (list[i].endsWith(".java")) { code[codeCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 5), + new SketchCode(list[i].substring(0, list[i].length() - 5), new File(folder, list[i]), JAVA); } else if (list[i].endsWith(".pde.x")) { hidden[hiddenCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 6), + new SketchCode(list[i].substring(0, list[i].length() - 6), new File(folder, list[i]), PDE); } else if (list[i].endsWith(".java.x")) { hidden[hiddenCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 7), + new SketchCode(list[i].substring(0, list[i].length() - 7), new File(folder, list[i]), JAVA); } @@ -216,7 +216,7 @@ public class PdeSketch { for (int i = 1; i < codeCount; i++) { if (code[i].file.getName().equals(mainFilename)) { //System.out.println("found main code at slot " + i); - PdeCode temp = code[0]; + SketchCode temp = code[0]; code[0] = code[i]; code[i] = temp; break; @@ -232,10 +232,10 @@ public class PdeSketch { } - protected void insertCode(PdeCode newCode) { + protected void insertCode(SketchCode newCode) { // add file to the code/codeCount list, resort the list if (codeCount == code.length) { - PdeCode temp[] = new PdeCode[codeCount+1]; + SketchCode temp[] = new SketchCode[codeCount+1]; System.arraycopy(code, 0, temp, 0, codeCount); code = temp; } @@ -254,7 +254,7 @@ public class PdeSketch { } } if (who != i) { // swap with someone if changes made - PdeCode temp = code[who]; + SketchCode temp = code[who]; code[who] = code[i]; code[i] = temp; } @@ -320,7 +320,7 @@ public class PdeSketch { } else if (newName.endsWith(".java")) { if (code[0] == current) { - PdeBase.showWarning("Problem with rename", + Base.showWarning("Problem with rename", "The main .pde file cannot be .java file.\n" + "(It may be time for your to graduate to a\n" + "\"real\" programming environment)", null); @@ -340,14 +340,14 @@ public class PdeSketch { // so make sure the user didn't name things poo.time.pde // or something like that (nothing against poo time) if (newName.indexOf('.') != -1) { - newName = PdeSketchbook.sanitizedName(newName); + newName = Sketchbook.sanitizedName(newName); newFilename = newName + ((newFlavor == PDE) ? ".pde" : ".java"); } - // create the new file, new PdeCode object and load it + // create the new file, new SketchCode object and load it File newFile = new File(folder, newFilename); if (newFile.exists()) { // yay! users will try anything - PdeBase.showMessage("Nope", + Base.showMessage("Nope", "A file named \"" + newFile + "\" already exists\n" + "in \"" + folder.getAbsolutePath() + "\""); return; @@ -355,7 +355,7 @@ public class PdeSketch { if (renamingCode) { if (!current.file.renameTo(newFile)) { - PdeBase.showWarning("Error", + Base.showWarning("Error", "Could not rename \"" + current.file.getName() + "\" to \"" + newFile.getName() + "\"", null); return; @@ -384,12 +384,12 @@ public class PdeSketch { try { newFile.createNewFile(); // TODO returns a boolean } catch (IOException e) { - PdeBase.showWarning("Error", + Base.showWarning("Error", "Could not create the file \"" + newFile + "\"\n" + "in \"" + folder.getAbsolutePath() + "\"", e); return; } - PdeCode newCode = new PdeCode(newName, newFile, newFlavor); + SketchCode newCode = new SketchCode(newName, newFile, newFlavor); insertCode(newCode); } @@ -412,7 +412,7 @@ public class PdeSketch { // TODO maybe gray out the menu on setCurrent(0) /* if (current == code[0]) { - PdeBase.showMessage("Can't do that", + Base.showMessage("Can't do that", "You cannot delete the main " + ".pde file from a sketch\n"); return; @@ -435,7 +435,7 @@ public class PdeSketch { if (result == JOptionPane.YES_OPTION) { if (current == code[0]) { // delete the entire sketch - PdeBase.removeDir(folder); + Base.removeDir(folder); // get the changes into the sketchbook menu //sketchbook.rebuildMenus(); @@ -446,7 +446,7 @@ public class PdeSketch { } else { // delete the file if (!current.file.delete()) { - PdeBase.showMessage("Couldn't do it", + Base.showMessage("Couldn't do it", "Could not delete \"" + current.name + "\"."); return; } @@ -464,7 +464,7 @@ public class PdeSketch { } - protected void removeCode(PdeCode which) { + protected void removeCode(SketchCode which) { // remove it from the internal list of files // resort internal list of files for (int i = 0; i < codeCount; i++) { @@ -484,7 +484,7 @@ public class PdeSketch { // don't allow hide of the main code // TODO maybe gray out the menu on setCurrent(0) if (current == code[0]) { - PdeBase.showMessage("Can't do that", + Base.showMessage("Can't do that", "You cannot hide the main " + ".pde file from a sketch\n"); return; @@ -493,7 +493,7 @@ public class PdeSketch { // rename the file File newFile = new File(current.file.getAbsolutePath() + ".x"); if (!current.file.renameTo(newFile)) { - PdeBase.showWarning("Error", + Base.showWarning("Error", "Could not hide " + "\"" + current.file.getName() + "\".", null); return; @@ -502,7 +502,7 @@ public class PdeSketch { // move it to the hidden list if (hiddenCount == hidden.length) { - PdeCode temp[] = new PdeCode[hiddenCount+1]; + SketchCode temp[] = new SketchCode[hiddenCount+1]; System.arraycopy(hidden, 0, temp, 0, hiddenCount); hidden = temp; } @@ -536,9 +536,9 @@ public class PdeSketch { System.err.println("internal error: could find " + what + " to unhide."); return; } - PdeCode unhideCode = hidden[unhideIndex]; + SketchCode unhideCode = hidden[unhideIndex]; if (!unhideCode.file.exists()) { - PdeBase.showMessage("Can't unhide", + Base.showMessage("Can't unhide", "The file \"" + what + "\" no longer exists."); //System.out.println(unhideCode.file); return; @@ -548,7 +548,7 @@ public class PdeSketch { new File(unhidePath.substring(0, unhidePath.length() - 2)); if (!unhideCode.file.renameTo(unhideFile)) { - PdeBase.showMessage("Can't unhide", + Base.showMessage("Can't unhide", "The file \"" + what + "\" could not be" + "renamed and unhidden."); return; @@ -605,7 +605,7 @@ public class PdeSketch { // check if the files are read-only. // if so, need to first do a "save as". if (isReadOnly()) { - PdeBase.showMessage("Sketch is read-only", + Base.showMessage("Sketch is read-only", "Some files are marked \"read-only\", so you'll\n" + "need to re-save this sketch to another location."); // if the user cancels, give up on the save() @@ -644,7 +644,7 @@ public class PdeSketch { FileDialog.SAVE); if (isReadOnly()) { // default to the sketchbook folder - fd.setDirectory(PdePreferences.get("sketchbook.path")); + fd.setDirectory(Preferences.get("sketchbook.path")); } else { fd.setDirectory(folder.getParent()); } @@ -661,14 +661,14 @@ public class PdeSketch { // user cancelled selection if (newName == null) return false; - newName = PdeSketchbook.sanitizeName(newName); + newName = Sketchbook.sanitizeName(newName); // new sketch folder File newFolder = new File(newParentDir, newName); // make sure the paths aren't the same if (newFolder.equals(folder)) { - PdeBase.showWarning("You can't fool me", + Base.showWarning("You can't fool me", "The new sketch name and location are the same as\n" + "the old. I ain't not doin nuthin' not now.", null); return false; @@ -683,7 +683,7 @@ public class PdeSketch { //System.out.println(oldPath); if (newPath.indexOf(oldPath) == 0) { - PdeBase.showWarning("How very Borges of you", + Base.showWarning("How very Borges of you", "You cannot save the sketch into a folder\n" + "inside itself. This would go on forever.", null); return false; @@ -691,9 +691,9 @@ public class PdeSketch { } catch (IOException e) { } // copy the entire contents of the sketch folder - PdeBase.copyDir(folder, newFolder); + Base.copyDir(folder, newFolder); - // change the references to the dir location in PdeCode files + // change the references to the dir location in SketchCode files for (int i = 0; i < codeCount; i++) { code[i].file = new File(newFolder, code[i].file.getName()); } @@ -721,9 +721,9 @@ public class PdeSketch { // remove the 'applet', 'application', 'library' folders // from the copied version. // otherwise their .class and .jar files can cause conflicts. - PdeBase.removeDir(new File(folder, "applet")); - PdeBase.removeDir(new File(folder, "application")); - PdeBase.removeDir(new File(folder, "library")); + Base.removeDir(new File(folder, "applet")); + Base.removeDir(new File(folder, "application")); + Base.removeDir(new File(folder, "library")); // do a "save" // this will take care of the unsaved changes in each of the tabs @@ -731,12 +731,12 @@ public class PdeSketch { // get the changes into the sketchbook menu //sketchbook.rebuildMenu(); - // done inside PdeEditor instead + // done inside Editor instead // update the tabs for the name change editor.header.repaint(); - // let PdeEditor know that the save was successful + // let Editor know that the save was successful return true; } @@ -790,7 +790,7 @@ public class PdeSketch { // make sure they aren't the same file if (!addingCode && sourceFile.equals(destFile)) { - PdeBase.showWarning("You can't fool me", + Base.showWarning("You can't fool me", "This file has already been copied to the\n" + "location where you're trying to add it.\n" + "I ain't not doin nuthin'.", null); @@ -801,9 +801,9 @@ public class PdeSketch { // to update the sketch's tabs if (!sourceFile.equals(destFile)) { try { - PdeBase.copyFile(sourceFile, destFile); + Base.copyFile(sourceFile, destFile); } catch (IOException e) { - PdeBase.showWarning("Error adding file", + Base.showWarning("Error adding file", "Could not add '" + filename + "' to the sketch.", e); } @@ -822,7 +822,7 @@ public class PdeSketch { } // see also "nameCode" for identical situation - PdeCode newCode = new PdeCode(newName, destFile, newFlavor); + SketchCode newCode = new SketchCode(newName, destFile, newFlavor); insertCode(newCode); sortCode(); setCurrent(newName); @@ -832,7 +832,7 @@ public class PdeSketch { public void addLibrary(String jarPath) { - String list[] = PdeCompiler.packageListFromClassPath(jarPath); + String list[] = Compiler.packageListFromClassPath(jarPath); // import statements into the main sketch file (code[0]) // if the current code is a .java file, insert into current @@ -908,13 +908,13 @@ public class PdeSketch { System.gc(); // note that we can't remove the builddir itself, otherwise - // the next time we start up, internal runs using PdeRuntime won't + // the next time we start up, internal runs using Runner won't // work because the build dir won't exist at startup, so the classloader // will ignore the fact that that dir is in the CLASSPATH in run.sh // //File dirObject = new File(TEMP_BUILD_PATH); - //PdeBase.removeDescendants(dirObject); - PdeBase.removeDescendants(tempBuildFolder); + //Base.removeDescendants(dirObject); + Base.removeDescendants(tempBuildFolder); } @@ -944,16 +944,16 @@ public class PdeSketch { * * X. afterwards, some of these steps need a cleanup function */ - //public void run() throws PdeException { - public boolean handleRun() throws PdeException { + //public void run() throws RunnerException { + public boolean handleRun() throws RunnerException { current.program = editor.getText(); // TODO record history here - //current.history.record(program, PdeHistory.RUN); + //current.history.record(program, SketchHistory.RUN); // if an external editor is being used, need to grab the // latest version of the code from the file. - if (PdePreferences.getBoolean("editor.external")) { + if (Preferences.getBoolean("editor.external")) { // history gets screwed by the open.. //String historySaved = history.lastRecorded; //handleOpen(sketch); @@ -985,13 +985,13 @@ public class PdeSketch { // copy contents of data dir into lib/build if (dataFolder.exists()) { // just drop the files in the build folder (pre-68) - //PdeBase.copyDir(dataDir, buildDir); + //Base.copyDir(dataDir, buildDir); // drop the files into a 'data' subfolder of the build dir try { - PdeBase.copyDir(dataFolder, new File(tempBuildFolder, "data")); + Base.copyDir(dataFolder, new File(tempBuildFolder, "data")); } catch (IOException e) { e.printStackTrace(); - throw new PdeException("Problem copying files from data folder"); + throw new RunnerException("Problem copying files from data folder"); } } } @@ -1002,12 +1002,12 @@ public class PdeSketch { /* if (externalPaths == null) { externalPaths = - PdeCompiler.calcClassPath(null) + File.pathSeparator + + Compiler.calcClassPath(null) + File.pathSeparator + tempBuildPath; } else { externalPaths = tempBuildPath + File.pathSeparator + - PdeCompiler.calcClassPath(null) + File.pathSeparator + + Compiler.calcClassPath(null) + File.pathSeparator + externalPaths; } */ @@ -1022,7 +1022,7 @@ public class PdeSketch { */ // create a runtime object -// runtime = new PdeRuntime(this, editor); +// runtime = new Runner(this, editor); // if programType is ADVANCED // or the code/ folder is not empty -> or just exists (simpler) @@ -1033,7 +1033,7 @@ public class PdeSketch { // use the runtime object to consume the errors now // no need to bother recycling the old guy - //PdeMessageStream messageStream = new PdeMessageStream(runtime); + //MessageStream messageStream = new MessageStream(runtime); // start the applet // runtime.start(presenting ? presentLocation : appletLocation); //, @@ -1066,12 +1066,12 @@ public class PdeSketch { * * In an advanced program, the returned classname could be different, * which is why the className is set based on the return value. - * A compilation error will burp up a PdeException. + * A compilation error will burp up a RunnerException. * * @return null if compilation failed, main class name if not */ protected String build(String buildPath, String suggestedClassName) - throws PdeException { + throws RunnerException { String codeFolderPackages[] = null; @@ -1082,7 +1082,7 @@ public class PdeSketch { } classPath = buildPath + - File.pathSeparator + PdeSketchbook.librariesClassPath + + File.pathSeparator + Sketchbook.librariesClassPath + File.pathSeparator + javaClassPath; //System.out.println("cp = " + classPath); @@ -1093,22 +1093,22 @@ public class PdeSketch { externalRuntime = true; //classPath += File.pathSeparator + - //PdeCompiler.contentsToClassPath(codeFolder); + //Compiler.contentsToClassPath(codeFolder); classPath = - PdeCompiler.contentsToClassPath(codeFolder) + + Compiler.contentsToClassPath(codeFolder) + File.pathSeparator + classPath; - //codeFolderPackages = PdeCompiler.packageListFromClassPath(classPath); - //codeFolderPackages = PdeCompiler.packageListFromClassPath(codeFolder); + //codeFolderPackages = Compiler.packageListFromClassPath(classPath); + //codeFolderPackages = Compiler.packageListFromClassPath(codeFolder); libraryPath = codeFolder.getAbsolutePath(); // get a list of .jar files in the "code" folder // (class files in subfolders should also be picked up) String codeFolderClassPath = - PdeCompiler.contentsToClassPath(codeFolder); + Compiler.contentsToClassPath(codeFolder); // get list of packages found in those jars codeFolderPackages = - PdeCompiler.packageListFromClassPath(codeFolderClassPath); + Compiler.packageListFromClassPath(codeFolderClassPath); //PApplet.println(libraryPath); //PApplet.println("packages:"); //PApplet.printarr(codeFolderPackages); @@ -1130,7 +1130,7 @@ public class PdeSketch { // if 'data' folder is large, set to external runtime if (dataFolder.exists() && - PdeBase.calcFolderSize(dataFolder) > 768 * 1024) { // if > 768k + Base.calcFolderSize(dataFolder) > 768 * 1024) { // if > 768k externalRuntime = true; } @@ -1159,7 +1159,7 @@ public class PdeSketch { } // if running in opengl mode, this is gonna be external - //if (PdePreferences.get("renderer").equals("opengl")) { + //if (Preferences.get("renderer").equals("opengl")) { //externalRuntime = true; //} @@ -1176,7 +1176,7 @@ public class PdeSketch { preprocessor.write(bigCode.toString(), buildPath, suggestedClassName, codeFolderPackages); if (className == null) { - throw new PdeException("Could not find main class"); + throw new RunnerException("Could not find main class"); // this situation might be perfectly fine, // (i.e. if the file is empty) //System.out.println("No class found in " + code[i].name); @@ -1209,7 +1209,7 @@ public class PdeSketch { } errorLine -= code[errorFile].lineOffset; - throw new PdeException(re.getMessage(), errorFile, + throw new RunnerException(re.getMessage(), errorFile, errorLine, re.getColumn()); } catch (antlr.TokenStreamRecognitionException tsre) { @@ -1225,7 +1225,7 @@ public class PdeSketch { try { pattern = compiler.compile(mess); } catch (MalformedPatternException e) { - PdeBase.showWarning("Internal Problem", + Base.showWarning("Internal Problem", "An internal error occurred while trying\n" + "to compile the sketch. Please report\n" + "this online at http://processing.org/bugs", e); @@ -1247,16 +1247,16 @@ public class PdeSketch { } errorLine -= code[errorFile].lineOffset; - throw new PdeException(tsre.getMessage(), + throw new RunnerException(tsre.getMessage(), errorFile, errorLine, errorColumn); } else { // this is bad, defaults to the main class.. hrm. - throw new PdeException(tsre.toString(), 0, -1, -1); + throw new RunnerException(tsre.toString(), 0, -1, -1); } - } catch (PdeException pe) { - // PdeExceptions are caught here and re-thrown, so that they don't + } catch (RunnerException pe) { + // RunnerExceptions are caught here and re-thrown, so that they don't // get lost in the more general "Exception" handler below. throw pe; @@ -1264,7 +1264,7 @@ public class PdeSketch { // TODO better method for handling this? System.err.println("Uncaught exception type:" + ex.getClass()); ex.printStackTrace(); - throw new PdeException(ex.toString()); + throw new RunnerException(ex.toString()); } // grab the imports from the code just preproc'd @@ -1275,10 +1275,10 @@ public class PdeSketch { // remove things up to the last dot String entry = imports[i].substring(0, imports[i].lastIndexOf('.')); //System.out.println("found package " + entry); - File libFolder = (File) PdeSketchbook.importToLibraryTable.get(entry); + File libFolder = (File) Sketchbook.importToLibraryTable.get(entry); if (libFolder == null) { - //throw new PdeException("Could not find library for " + entry); + //throw new RunnerException("Could not find library for " + entry); continue; } @@ -1311,20 +1311,20 @@ public class PdeSketch { // shtuff so that unicode bunk is properly handled String filename = code[i].name + ".java"; try { - PdeBase.saveFile(code[i].program, new File(buildPath, filename)); + Base.saveFile(code[i].program, new File(buildPath, filename)); } catch (IOException e) { e.printStackTrace(); - throw new PdeException("Problem moving " + filename + + throw new RunnerException("Problem moving " + filename + " to the build folder"); } code[i].preprocName = filename; } } - // compile the program. errors will happen as a PdeException + // compile the program. errors will happen as a RunnerException // that will bubble up to whomever called build(). // - PdeCompiler compiler = new PdeCompiler(); + Compiler compiler = new Compiler(); boolean success = compiler.compile(this, buildPath); //System.out.println("success = " + success + " ... " + primaryClassName); return success ? primaryClassName : null; @@ -1342,7 +1342,7 @@ public class PdeSketch { /** - * Called by PdeEditor to handle someone having selected 'export'. + * Called by Editor to handle someone having selected 'export'. * Pops up a dialog box for export options, and then calls the * necessary function with the parameters from the window. * @@ -1455,7 +1455,7 @@ public class PdeSketch { // if name != exportSketchName, then that's weirdness // BUG unfortunately, that can also be a bug in the preproc :( if (!name.equals(foundName)) { - PdeBase.showWarning("Error during export", + Base.showWarning("Error during export", "Sketch name is " + name + " but the sketch\n" + "name in the code was " + foundName, null); return false; @@ -1498,7 +1498,7 @@ public class PdeSketch { "determined from your code. You'll have to edit the\n" + "HTML file to set the size of the applet."; - PdeBase.showWarning("Could not find applet size", message, null); + Base.showWarning("Could not find applet size", message, null); } } // else no size() command found @@ -1554,7 +1554,7 @@ public class PdeSketch { is = new FileInputStream(customHtml); } if (is == null) { - is = PdeBase.getStream("applet.html"); + is = Base.getStream("applet.html"); } BufferedReader reader = new BufferedReader(new InputStreamReader(is)); @@ -1601,7 +1601,7 @@ public class PdeSketch { // to encourage people to share their code for (int i = 0; i < codeCount; i++) { try { - PdeBase.copyFile(code[i].file, + Base.copyFile(code[i].file, new File(appletDir, code[i].file.getName())); } catch (IOException e) { @@ -1618,7 +1618,7 @@ public class PdeSketch { // unpacks all jar files //File codeFolder = new File(folder, "code"); if (codeFolder.exists()) { - String includes = PdeCompiler.contentsToClassPath(codeFolder); + String includes = Compiler.contentsToClassPath(codeFolder); packClassPathIntoZipFile(includes, zos); } @@ -1635,7 +1635,7 @@ public class PdeSketch { File exportSettings = new File(libraryFolder, "export.txt"); String exportList[] = null; if (exportSettings.exists()) { - String info[] = PdeBase.loadStrings(exportSettings); + String info[] = Base.loadStrings(exportSettings); for (int i = 0; i < info.length; i++) { if (info[i].startsWith("applet")) { int idx = info[i].indexOf('='); // get applet= or applet = @@ -1665,7 +1665,7 @@ public class PdeSketch { packClassPathIntoZipFile(exportFile.getAbsolutePath(), zos); } else { // just copy the file over.. prolly a .dll or something - PdeBase.copyFile(exportFile, + Base.copyFile(exportFile, new File(appletDir, exportFile.getName())); } } @@ -1673,7 +1673,7 @@ public class PdeSketch { // add the appropriate bagel to the classpath /* - String jdkVersion = PdePreferences.get("compiler.jdk_version"); + String jdkVersion = Preferences.get("compiler.jdk_version"); String bagelJar = "lib/export11.jar"; // default if (jdkVersion.equals("1.3") || jdkVersion.equals("1.4")) { bagelJar = "lib/export13.jar"; @@ -1696,7 +1696,7 @@ public class PdeSketch { if (!bagelClasses[i].endsWith(".class")) continue; entry = new ZipEntry(bagelClasses[i]); zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(exportDir + bagelClasses[i]))); + zos.write(Base.grabFile(new File(exportDir + bagelClasses[i]))); zos.closeEntry(); } */ @@ -1717,7 +1717,7 @@ public class PdeSketch { entry = new ZipEntry(dataFiles[i]); zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(dataFolder, dataFiles[i]))); + zos.write(Base.grabFile(new File(dataFolder, dataFiles[i]))); zos.closeEntry(); } } @@ -1731,7 +1731,7 @@ public class PdeSketch { if (classfiles[i].endsWith(".class")) { entry = new ZipEntry(classfiles[i]); zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(appletDir, classfiles[i]))); + zos.write(Base.grabFile(new File(appletDir, classfiles[i]))); zos.closeEntry(); } } @@ -1743,7 +1743,7 @@ public class PdeSketch { if (classfiles[i].endsWith(".class")) { File deadguy = new File(appletDir, classfiles[i]); if (!deadguy.delete()) { - PdeBase.showWarning("Could not delete", + Base.showWarning("Could not delete", classfiles[i] + " could not \n" + "be deleted from the applet folder. \n" + "You'll need to remove it by hand.", null); @@ -1755,7 +1755,7 @@ public class PdeSketch { zos.flush(); zos.close(); - PdeBase.openFolder(appletDir); + Base.openFolder(appletDir); //} catch (Exception e) { //e.printStackTrace(); @@ -1867,7 +1867,7 @@ public class PdeSketch { files[i].charAt(0) != '.') { ZipEntry entry = new ZipEntry(nowfar); zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(sub)); + zos.write(Base.grabFile(sub)); zos.closeEntry(); } } @@ -1882,8 +1882,8 @@ public class PdeSketch { */ public boolean isReadOnly() { String apath = folder.getAbsolutePath(); - if (apath.startsWith(PdeSketchbook.examplesPath) || - apath.startsWith(PdeSketchbook.librariesPath)) { + if (apath.startsWith(Sketchbook.examplesPath) || + apath.startsWith(Sketchbook.librariesPath)) { return true; // this doesn't work on directories diff --git a/app/PdeCode.java b/app/SketchCode.java similarity index 84% rename from app/PdeCode.java rename to app/SketchCode.java index 06777f0b3..d19c44ee4 100644 --- a/app/PdeCode.java +++ b/app/SketchCode.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeCode - data class for a single file inside a sketch + SketchCode - data class for a single file inside a sketch Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and is @@ -27,20 +27,20 @@ package processing.app; import java.io.*; -public class PdeCode { +public class SketchCode { String name; // pretty name (no extension), not the full file name File file; int flavor; String program; public boolean modified; - //PdeHistory history; // TODO add history information + //SketchHistory history; // TODO add history information String preprocName; // name of .java file after preproc int lineOffset; // where this code starts relative to the concat'd code - public PdeCode(String name, File file, int flavor) { + public SketchCode(String name, File file, int flavor) { this.name = name; this.file = file; this.flavor = flavor; @@ -54,12 +54,12 @@ public class PdeCode { public void load() throws IOException { - program = PdeBase.loadFile(file); + program = Base.loadFile(file); //program = null; /* } catch (IOException e) { - PdeBase.showWarning("Error loading file", + Base.showWarning("Error loading file", "Error while opening the file\n" + file.getPath(), e); program = null; // just in case @@ -73,17 +73,17 @@ public class PdeCode { public void save() throws IOException { // TODO re-enable history - //history.record(s, PdeHistory.SAVE); + //history.record(s, SketchHistory.SAVE); //try { //System.out.println("saving to " + file); //System.out.println("stuff to save: " + program); //System.out.println("-------"); - PdeBase.saveFile(program, file); + Base.saveFile(program, file); modified = false; //} catch (Exception e) { - //PdeBase.showWarning("Error saving file", + //Base.showWarning("Error saving file", // "Could not save '" + file.getName() + "'\n" + // "to '" + file.getParent() + "'\n" + // "because of an error.", e); diff --git a/app/PdeHistory.java b/app/SketchHistory.java similarity index 94% rename from app/PdeHistory.java rename to app/SketchHistory.java index 06fa37890..9730e53bb 100644 --- a/app/PdeHistory.java +++ b/app/SketchHistory.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeHistory - handler for storing history information about a project + SketchHistory - handler for storing history information about a project Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry @@ -34,8 +34,8 @@ import java.util.zip.*; import javax.swing.*; -public class PdeHistory { - PdeEditor editor; +public class SketchHistory { + Editor editor; // why things have been saved for history static final int RUN = 5; @@ -58,11 +58,11 @@ public class PdeHistory { ActionListener menuListener; - //public PdeHistory(PdeEditor editor) { + //public SketchHistory(Editor editor) { //this.editor = editor; //} - public PdeHistory(Sketch sketch) { + public SketchHistory(Sketch sketch) { menu = new JMenu("History"); menuListener = new ActionListener() { @@ -85,12 +85,12 @@ public class PdeHistory { public void attachMenu(JMenu parent) { - //if (PdePreferences.getBoolean("history.recording")) { + //if (Preferences.getBoolean("history.recording")) { parent.add(menu); // should leave enabled, since can still get old history // even if the new stuff isn't being recorded - //menu.setEnabled(PdePreferences.getBoolean("history.recording")); + //menu.setEnabled(Preferences.getBoolean("history.recording")); //} } @@ -100,7 +100,7 @@ public class PdeHistory { public void record(String program, int mode) { if (readOnlySketch) return; - if (!PdePreferences.getBoolean("history.recording")) return; + if (!Preferences.getBoolean("history.recording")) return; if ((lastRecorded != null) && (lastRecorded.equals(program))) return; @@ -268,7 +268,7 @@ public class PdeHistory { //public void rebuildHistoryMenu(Menu menu, String path) { public void rebuildMenu() { //String path) { //if (!recordingHistory) return; - //if (!PdePreferences.getBoolean("history.recording")) return; + //if (!Preferences.getBoolean("history.recording")) return; menu.removeAll(); @@ -281,11 +281,11 @@ public class PdeHistory { public void actionPerformed(ActionEvent e) { if (!historyFile.delete()) { //System.err.println("couldn't erase history"); - PdeBase.showWarning("History Problem", + Base.showWarning("History Problem", "Could not erase history", null); } rebuildMenu(); - //PdeHistory.this.rebuildMenu(historyFile.getPath()); + //SketchHistory.this.rebuildMenu(historyFile.getPath()); } }); menu.add(item); diff --git a/app/PdeSketchbook.java b/app/Sketchbook.java similarity index 92% rename from app/PdeSketchbook.java rename to app/Sketchbook.java index 041e386d8..f126b246f 100644 --- a/app/PdeSketchbook.java +++ b/app/Sketchbook.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - PdeSketchbook - handles sketchbook mechanics for the sketch menu + Sketchbook - handles sketchbook mechanics for the sketch menu Part of the Processing project - http://processing.org Except where noted, code is written by Ben Fry and is @@ -40,8 +40,8 @@ import javax.swing.undo.*; import com.apple.mrj.*; -public class PdeSketchbook { - PdeEditor editor; +public class Sketchbook { + Editor editor; JMenu openMenu; JMenu popupMenu; @@ -60,7 +60,7 @@ public class PdeSketchbook { // opted against this.. in imovie, apple always goes // to the "Movies" folder, even if that wasn't the last used - // these are static because they're used by PdeSketch + // these are static because they're used by Sketch static File examplesFolder; static String examplesPath; // canonical path (for comparison) @@ -76,7 +76,7 @@ public class PdeSketchbook { static String librariesClassPath; - public PdeSketchbook(PdeEditor editor) { + public Sketchbook(Editor editor) { this.editor = editor; // this shouldn't change throughout.. it may as well be static @@ -87,32 +87,32 @@ public class PdeSketchbook { librariesFolder = new File(System.getProperty("user.dir"), "libraries"); librariesPath = librariesFolder.getAbsolutePath(); - //String sketchbookPath = PdePreferences.get("sketchbook.path"); + //String sketchbookPath = Preferences.get("sketchbook.path"); //if (sketchbookPath == null) { - if (PdePreferences.get("sketchbook.path") == null) { + if (Preferences.get("sketchbook.path") == null) { // by default, set default sketchbook path to the user's // home folder with 'sketchbook' as a subdirectory of that /* File home = new File(System.getProperty("user.home")); - if (PdeBase.platform == PdeBase.MACOSX) { + if (Base.platform == Base.MACOSX) { // on macosx put the sketchbook in the "Documents" folder home = new File(home, "Documents"); - } else if (PdeBase.platform == PdeBase.WINDOWS) { + } else if (Base.platform == Base.WINDOWS) { // on windows put the sketchbook in the "My Documents" folder home = new File(home, "My Documents"); } */ // use a subfolder called 'sketchbook' - //File home = PdePreferences.getProcessingHome(); - //String folderName = PdePreferences.get("sketchbook.name.default"); + //File home = Preferences.getProcessingHome(); + //String folderName = Preferences.get("sketchbook.name.default"); //File sketchbookFolder = new File(home, folderName); - File sketchbookFolder = PdeBase.getDefaultSketchbookFolder(); - PdePreferences.set("sketchbook.path", + File sketchbookFolder = Base.getDefaultSketchbookFolder(); + Preferences.set("sketchbook.path", sketchbookFolder.getAbsolutePath()); if (!sketchbookFolder.exists()) sketchbookFolder.mkdirs(); @@ -124,7 +124,7 @@ public class PdeSketchbook { static public String getSketchbookPath() { - return PdePreferences.get("sketchbook.path"); + return Preferences.get("sketchbook.path"); } @@ -138,7 +138,7 @@ public class PdeSketchbook { File newbieDir = null; String newbieName = null; - boolean prompt = PdePreferences.getBoolean("sketchbook.prompt"); + boolean prompt = Preferences.getBoolean("sketchbook.prompt"); if (shift) prompt = !prompt; // reverse behavior if shift is down // no sketch has been started, don't prompt for the name if it's @@ -201,7 +201,7 @@ public class PdeSketchbook { // jdk13 on osx, or jdk11 // though apparently still available for 1.4 - if (PdeBase.isMacOS()) { + if (Base.isMacOS()) { MRJFileUtils.setFileTypeAndCreator(newbieFile, MRJOSType.kTypeTEXT, new MRJOSType("Pde1")); @@ -227,7 +227,7 @@ public class PdeSketchbook { String newName = sanitizedName(origName); if (!newName.equals(origName)) { - PdeBase.showMessage("Naming issue", + Base.showMessage("Naming issue", "The sketch name had to be modified.\n" + "You can only use basic letters and numbers\n" + "to name a sketch (ascii only and no spaces,\n" + @@ -272,7 +272,7 @@ public class PdeSketchbook { FileDialog fd = new FileDialog(editor, //new Frame(), "Open a Processing sketch...", FileDialog.LOAD); - //fd.setDirectory(PdePreferences.get("sketchbook.path")); + //fd.setDirectory(Preferences.get("sketchbook.path")); fd.setDirectory(getSketchbookPath()); // only show .pde files as eligible bachelors @@ -330,7 +330,7 @@ public class PdeSketchbook { //System.out.println("libraries cp is now " + librariesClassPath); } catch (IOException e) { - PdeBase.showWarning("Problem while building sketchbook menu", + Base.showWarning("Problem while building sketchbook menu", "There was a problem with building the\n" + "sketchbook menu. Things might get a little\n" + "kooky around here.", e); @@ -345,7 +345,7 @@ public class PdeSketchbook { menu.removeAll(); //item = new JMenuItem("Open..."); - item = PdeEditor.newJMenuItem("Open...", 'O', false); + item = Editor.newJMenuItem("Open...", 'O', false); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editor.handleOpen(null); @@ -374,7 +374,7 @@ public class PdeSketchbook { // don't do this until it's finished // libraries don't show up as proper sketches anyway try { - if (PdePreferences.getBoolean("export.library")) { + if (Preferences.getBoolean("export.library")) { JMenu librariesMenu = new JMenu("Libraries"); addSketches(librariesMenu, librariesFolder); menu.add(librariesMenu); @@ -456,7 +456,7 @@ public class PdeSketchbook { "The sketch \"" + list[i] + "\" cannot be used.\n" + "Sketch names must contain only basic letters and numbers.\n" + "(ascii only and no spaces, and it cannot start with a number)"; - PdeBase.showMessage("Ignoring bad sketch name", mess); + Base.showMessage("Ignoring bad sketch name", mess); } continue; } @@ -532,20 +532,20 @@ public class PdeSketchbook { "The library \"" + list[i] + "\" 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)"; - PdeBase.showMessage("Ignoring bad sketch name", mess); + Base.showMessage("Ignoring bad sketch name", mess); continue; } // get the path for all .jar files in this code folder String libraryClassPath = - PdeCompiler.contentsToClassPath(exported); + Compiler.contentsToClassPath(exported); // grab all jars and classes from this folder, // and append them to the library classpath librariesClassPath += File.pathSeparatorChar + libraryClassPath; // need to associate each import with a library folder String packages[] = - PdeCompiler.packageListFromClassPath(libraryClassPath); + Compiler.packageListFromClassPath(libraryClassPath); for (int k = 0; k < packages.length; k++) { importToLibraryTable.put(packages[k], exported); } @@ -575,7 +575,7 @@ public class PdeSketchbook { * Clear out projects that are empty. */ public void clean() { - //if (!PdePreferences.getBoolean("sketchbook.auto_clean")) return; + //if (!Preferences.getBoolean("sketchbook.auto_clean")) return; File sketchbookFolder = new File(getSketchbookPath()); if (!sketchbookFolder.exists()) return; @@ -595,11 +595,11 @@ public class PdeSketchbook { // not a .DS_Store file or another random user folder if (pde.exists() && - (PdeBase.calcFolderSize(prey) == 0)) { + (Base.calcFolderSize(prey) == 0)) { //System.out.println("i want to remove " + prey); - if (PdePreferences.getBoolean("sketchbook.auto_clean")) { - PdeBase.removeDir(prey); + if (Preferences.getBoolean("sketchbook.auto_clean")) { + Base.removeDir(prey); } else { // otherwise prompt the user String prompt = @@ -616,7 +616,7 @@ public class PdeSketchbook { options, options[0]); if (result == JOptionPane.YES_OPTION) { - PdeBase.removeDir(prey); + Base.removeDir(prey); } } } diff --git a/todo.txt b/todo.txt index fbff2fbc4..a37d5436d 100644 --- a/todo.txt +++ b/todo.txt @@ -12,6 +12,7 @@ X add serial.stop() just like client/server X border weirdness in PdeEditor panels on windows (fixed in 82) o fix macos readme about how to boost memory size, and 1.3 vs 1.4 X actually, this was already in there +o add prompt() method to serial camera o setting the camera should be an index from list() @@ -26,33 +27,28 @@ o and then use the indices (or the str i guess) to choose X format(NTSC) or PAL or SECAM X source(COMPOSITE) or SVIDEO or COMPONENT X settings() brings up settings dialog +o add prompt() method to Camera ("" means default, null is prompt) +o let them pass in prompt(), not use null +o null is only bringing up settings dialog, that's wrong -_ rename video.Camera to video.Video ? -_ VideoInput VideoOutput, SoundInput, SoundOutput or AudioInput/AudioOutput +_ move packaging around +_ remove PdeXxx prefixes on names, make PdeBase into just "Processing" +_ update .exe to use new class/package +_ update .app to use new class/package -_ add prompt() method to Camera ("" means default, null is prompt) -_ let them pass in prompt(), not use null -_ null is only bringing up settings dialog, that's wrong - -_ port DbnRecorder? -_ do this after beta, not likely to work with java 1.4 on macosx - -_ add prompt() method to serial - -_ remove PdeXxx prefixes on names, make PdeBase into just "Processing" - -_ update .exe to use new class/package -_ update .app to use new class/package -_ update linux build and shell scripts for new package - -_ make a linux version +_ setup linux box and build a linux version _ need to fix up the make/dist scripts for linux - +_ update runner script for the new package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -MUST BE COMPLETE FOR BETA +pending +_ get simon's new lighting code +_ rename video.Camera to video.Video ? +_ VideoInput VideoOutput, SoundInput, SoundOutput or AudioInput/AudioOutput +_ should loadPixels be grabPixels? + non-coding tasks (for beta) _ new bboard? archive the old one, remove bugs sections @@ -68,11 +64,10 @@ _ and queue events by registering for draw or whatever they'd like _ lib could call queueEvent with the args _ then call them inside post() _ scrubbing all the code to include proper license and copyright info - -things that will be broken for beta -_ opengl set() functions.. though get() probably ok -_ stop button with external apps -_ java 1.1 support +_ documenting things that will be broken for beta +_ opengl set() functions.. though get() probably ok +_ stop button with external apps +_ java 1.1 support // @@ -146,6 +141,9 @@ space, it will show you the last line, but then pops the scrollbar back to the top. I think the only way to stop it is to quit out of processing and relaunch. +_ saveFrame() directly to quicktime via port of DbnRecorder +_ do this after beta, not likely to work with java 1.4 on macosx + _ saved window positions.. if displays has changed, becomes a problem _ record the display that it was on? _ GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();