Skip to content
This repository
Browse code

Syncing with Processing 1.0.9 (revision 5766).

  • Loading branch information...
commit 2e26a2d994d6a082f4a83ddc7bcdb7f29d9b69b6 1 parent 7f58e22
David A. Mellis authored October 22, 2009

Showing 38 changed files with 16,809 additions and 892 deletions. Show diff stats Hide diff stats

  1. 153  app/src/processing/app/Base.java
  2. 65  app/src/processing/app/Editor.java
  3. 174  app/src/processing/app/Preferences.java
  4. 36  app/src/processing/app/Sketch.java
  5. 6  app/src/processing/app/debug/Runner.java
  6. 2  app/src/processing/app/macosx/Platform.java
  7. 407  app/src/processing/app/preproc/PdePreprocessor.java
  8. 30  build/macosx/dist/Arduino.app/Contents/Info.plist
  9. 6  build/macosx/make.sh
  10. 1  build/shared/lib/preferences.txt
  11. 5  build/shared/libraries/howto.txt
  12. 6  build/shared/libraries/javascript/library/export.txt
  13. BIN  build/shared/libraries/javascript/library/javascript.jar
  14. BIN  build/shared/libraries/minim/library/jl1.0.jar
  15. BIN  build/shared/libraries/minim/library/jsminim.jar
  16. BIN  build/shared/libraries/minim/library/minim-spi.jar
  17. BIN  build/shared/libraries/minim/library/minim.jar
  18. BIN  build/shared/libraries/minim/library/mp3spi1.9.4.jar
  19. BIN  build/shared/libraries/minim/library/tritonus_aos.jar
  20. BIN  build/shared/libraries/minim/library/tritonus_share.jar
  21. 339  build/shared/libraries/minim/license.txt
  22. 1  build/shared/libraries/minim/version.txt
  23. 89  build/shared/revisions.txt
  24. 26  core/done.txt
  25. 7  core/preproc/.classpath
  26. 17  core/preproc/.project
  27. 22  core/preproc/build.xml
  28. 8,155  core/preproc/demo/PApplet.java
  29. 5,043  core/preproc/demo/PGraphics.java
  30. 2,713  core/preproc/demo/PImage.java
  31. BIN  core/preproc/preproc.jar
  32. 236  core/preproc/src/processing/build/PAppletMethods.java
  33. 86  core/src/processing/core/PApplet.java
  34. 2  core/src/processing/core/PGraphics.java
  35. 26  core/src/processing/core/PGraphics3D.java
  36. 3  core/src/processing/core/PImage.java
  37. 5  core/src/processing/core/PVector.java
  38. 40  core/todo.txt
153  app/src/processing/app/Base.java
@@ -180,71 +180,7 @@ static public void main(String args[]) {
180 180
     // setup the theme coloring fun
181 181
     Theme.init();
182 182
 
183  
-    if (Base.isMacOS()) {
184  
-      String properMenuBar = "apple.laf.useScreenMenuBar";
185  
-      String menubar = Preferences.get(properMenuBar);
186  
-      if (menubar != null) {
187  
-        // Get the current menu bar setting and use it
188  
-        System.setProperty(properMenuBar, menubar);
189  
-
190  
-      } else {
191  
-        // 10.4 is not affected, 10.5 (and prolly 10.6) are
192  
-        if (System.getProperty("os.version").startsWith("10.4")) {
193  
-          // Don't bother checking next time
194  
-          Preferences.set(properMenuBar, "true");
195  
-          // Also set the menubar now
196  
-          System.setProperty(properMenuBar, "true");
197  
-
198  
-        } else {
199  
-          // Running 10.5 or 10.6 or whatever, give 'em the business
200  
-          String warning =
201  
-            "<html>" +
202  
-            "<head> <style type=\"text/css\">"+
203  
-            "b { font: 13pt \"Lucida Grande\" }"+
204  
-            "p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
205  
-            "</style> </head> <body>" +
206  
-            "<b>Some menus have been disabled.</b>" +
207  
-            "<p>Due to an Apple bug, the Sketchbook and Example menus " +
208  
-            "are unusable. <br>" +
209  
-            "As a workaround, these items will be disabled from the " +
210  
-            "standard menu bar, <br>" +
211  
-            "but you can use the Open button on " +
212  
-            "the toolbar to access the same items. <br>" +
213  
-            "If this bug makes you sad, " +
214  
-            "please contact Apple via bugreporter.apple.com.</p>" +
215  
-            "</body> </html>";
216  
-          Object[] options = { "OK", "More Info" };
217  
-          int result = JOptionPane.showOptionDialog(new Frame(),
218  
-                                                    warning,
219  
-                                                    "Menu Bar Problem",
220  
-                                                    JOptionPane.YES_NO_OPTION,
221  
-                                                    JOptionPane.WARNING_MESSAGE,
222  
-                                                    null,
223  
-                                                    options,
224  
-                                                    options[0]);
225  
-          if (result == -1) {
226  
-            // They hit ESC or closed the window, so just hide it for now
227  
-            // But don't bother setting the preference in the file
228  
-          } else {
229  
-            // Shut off in the preferences for next time
230  
-            //Preferences.set(properMenuBar, "false");
231  
-            // For 1.0.4, we'll stick with the Apple menu bar,
232  
-            // and just disable the sketchbook and examples sub-menus.
233  
-            Preferences.set(properMenuBar, "true");
234  
-            if (result == 1) {  // More Info
235  
-              Base.openURL("http://dev.processing.org/bugs/show_bug.cgi?id=786");
236  
-            }
237  
-          }
238  
-          // Whether or not canceled, set to false (right now) if we're on 10.5
239  
-          //System.setProperty(properMenuBar, "false");
240  
-          // Changing this behavior for 1.0.4
241  
-          System.setProperty(properMenuBar, "true");
242  
-        }
243  
-      }
244  
-    }
245  
-
246 183
     // Set the look and feel before opening the window
247  
-    // For 0158, moving it lower so that the apple.laf.useScreenMenuBar stuff works
248 184
     try {
249 185
       platform.setLookAndFeel();
250 186
     } catch (Exception e) {
@@ -815,7 +751,8 @@ protected Editor handleOpen(String path, int[] location) {
815 751
    */
816 752
   public boolean handleClose(Editor editor) {
817 753
     // Check if modified
818  
-    if (!editor.checkModified(false)) {
  754
+    boolean immediate = editors.size() == 1;
  755
+    if (!editor.checkModified(immediate)) {
819 756
       return false;
820 757
     }
821 758
 
@@ -993,17 +930,9 @@ public void actionPerformed(ActionEvent e) {
993 930
   protected void rebuildSketchbookMenu(JMenu menu) {
994 931
     //System.out.println("rebuilding sketchbook menu");
995 932
     //new Exception().printStackTrace();
996  
-    //boolean nativeButBroken = Base.isMacOS() ?
997  
-      //Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
998  
-    boolean nativeButBroken = false;
999  
-
1000 933
     try {
1001  
-      if (nativeButBroken) {  // osx workaround
1002  
-        menu.setEnabled(false);
1003  
-      } else {
1004 934
         menu.removeAll();
1005 935
         addSketches(menu, getSketchbookFolder(), false);
1006  
-      }
1007 936
     } catch (IOException e) {
1008 937
       e.printStackTrace();
1009 938
     }
@@ -1045,21 +974,13 @@ public void rebuildImportMenu(JMenu importMenu) {
1045 974
 
1046 975
   public void rebuildExamplesMenu(JMenu menu) {
1047 976
     //System.out.println("rebuilding examples menu");
1048  
-    //boolean nativeButBroken = Base.isMacOS() ?
1049  
-      //Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
1050  
-    boolean nativeButBroken = false;
1051  
-
1052 977
     try {
1053  
-      if (nativeButBroken) {  // osx workaround
1054  
-        menu.setEnabled(false);
1055  
-      } else {
1056  
-        menu.removeAll();
1057  
-        boolean found = addSketches(menu, examplesFolder, false);
1058  
-        if (found) menu.addSeparator();
1059  
-        found = addSketches(menu, getSketchbookLibrariesFolder(), false);
1060  
-        if (found) menu.addSeparator();
1061  
-        addSketches(menu, librariesFolder, false);
1062  
-      }
  978
+      menu.removeAll();
  979
+      boolean found = addSketches(menu, examplesFolder, false);
  980
+      if (found) menu.addSeparator();
  981
+      found = addSketches(menu, getSketchbookLibrariesFolder(), false);
  982
+      if (found) menu.addSeparator();
  983
+      addSketches(menu, librariesFolder, false);
1063 984
     } catch (IOException e) {
1064 985
       e.printStackTrace();
1065 986
     }
@@ -1965,56 +1886,30 @@ static public void copyFile(File sourceFile,
1965 1886
    * Grab the contents of a file as a string.
1966 1887
    */
1967 1888
   static public String loadFile(File file) throws IOException {
1968  
-    return PApplet.join(PApplet.loadStrings(file), "\n");
1969  
-
1970  
-    /*
1971  
-    // empty code file.. no worries, might be getting filled up later
1972  
-    if (file.length() == 0) return "";
1973  
-
1974  
-    //FileInputStream fis = new FileInputStream(file);
1975  
-    //InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
1976  
-    //BufferedReader reader = new BufferedReader(isr);
1977  
-    BufferedReader reader = PApplet.createReader(file);
1978  
-
1979  
-    StringBuffer buffer = new StringBuffer();
1980  
-    String line = null;
1981  
-    while ((line = reader.readLine()) != null) {
1982  
-//      char[] cc = line.toCharArray();
1983  
-//      for (int i = 0; i < cc.length; i++) {
1984  
-//        char c = cc[i];
1985  
-//        if (c < 32 || c > 126) System.out.println("found " + c + " " + ((int) c));
1986  
-//      }
1987  
-//
1988  
-      buffer.append(line);
1989  
-      buffer.append('\n');
  1889
+    String[] contents = PApplet.loadStrings(file);
  1890
+    if (contents == null) return null;
  1891
+    return PApplet.join(contents, "\n");
1990 1892
     }
1991  
-    reader.close();
1992  
-    return buffer.toString();
1993  
-    */
1994  
-  }
1995 1893
 
1996 1894
 
1997 1895
   /**
1998 1896
    * Spew the contents of a String object out to a file.
1999 1897
    */
2000 1898
   static public void saveFile(String str, File file) throws IOException {
2001  
-    PApplet.saveStrings(file, new String[] { str });
2002  
-    /*
2003  
-    ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
2004  
-    InputStreamReader isr = new InputStreamReader(bis);
2005  
-    BufferedReader reader = new BufferedReader(isr);
2006  
-
2007  
-    FileOutputStream fos = new FileOutputStream(file);
2008  
-    OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
2009  
-    PrintWriter writer = new PrintWriter(osw);
2010  
-
2011  
-    String line = null;
2012  
-    while ((line = reader.readLine()) != null) {
2013  
-      writer.println(line);
  1899
+    File temp = File.createTempFile(file.getName(), null, file.getParentFile());
  1900
+    PApplet.saveStrings(temp, new String[] { str });
  1901
+    if (file.exists()) {
  1902
+      boolean result = file.delete();
  1903
+      if (!result) {
  1904
+        throw new IOException("Could not remove old version of " +
  1905
+                              file.getAbsolutePath());
  1906
+    }
  1907
+  }
  1908
+    boolean result = temp.renameTo(file);
  1909
+    if (!result) {
  1910
+      throw new IOException("Could not replace " +
  1911
+                            file.getAbsolutePath());
2014 1912
     }
2015  
-    writer.flush();
2016  
-    writer.close();
2017  
-    */
2018 1913
   }
2019 1914
 
2020 1915
 
65  app/src/processing/app/Editor.java
@@ -114,6 +114,9 @@
114 114
 
115 115
   EditorLineStatus lineStatus;
116 116
 
  117
+  boolean newEditor = true;
  118
+  JEditorPane editorPane;
  119
+  
117 120
   JEditTextArea textarea;
118 121
   EditorListener listener;
119 122
 
@@ -229,7 +232,22 @@ public void windowDeactivated(WindowEvent e) {
229 232
     lineStatus = new EditorLineStatus(textarea);
230 233
     consolePanel.add(lineStatus, BorderLayout.SOUTH);
231 234
 
  235
+//    if (newEditor) {
  236
+//      try {
  237
+//        setupEditorPane();
  238
+//        upper.add(editorPane);
  239
+//      } catch (Exception e1) {
  240
+//        PrintWriter w = PApplet.createWriter(new File("/Users/fry/Desktop/blah.txt"));
  241
+//        w.println(e1.getMessage());
  242
+//        e1.printStackTrace(w);
  243
+//        w.flush();
  244
+//        w.close();
  245
+////        e1.printStackTrace());
  246
+////        e1.printStackTrace(System.out);
  247
+//      }
  248
+//    } else {
232 249
     upper.add(textarea);
  250
+//    }
233 251
     splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
234 252
                                upper, consolePanel);
235 253
 
@@ -345,6 +363,46 @@ public boolean importData(JComponent src, Transferable transferable) {
345 363
   }
346 364
 
347 365
 
  366
+  /*
  367
+  // http://wiki.netbeans.org/DevFaqEditorCodeCompletionAnyJEditorPane
  368
+  void setupEditorPane() throws IOException {
  369
+    editorPane = new JEditorPane();
  370
+
  371
+    // This will find the Java editor kit and associate it with
  372
+    // our editor pane. But that does not give us code completion 
  373
+    // just yet because we have no Java context (i.e. no class path, etc.).
  374
+    // However, this does give us syntax coloring.
  375
+    EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-java");
  376
+    editorPane.setEditorKit(kit);
  377
+    
  378
+    // You can specify any ".java" file.
  379
+    // If the file does not exist, it will be created.
  380
+    // The contents of the file does not matter.
  381
+    // The extension must be ".java", however.
  382
+//    String newSourcePath = "/Users/fry/Desktop/tmp.java";
  383
+
  384
+//    File tmpFile = new File(newSourcePath);
  385
+//    System.out.println(tmpFile.getParent() + " " + tmpFile.getName());
  386
+//  FileObject fob = FileUtil.createData(tmpFile);
  387
+    File tmpFile = File.createTempFile("temp", ".java");
  388
+    FileObject fob = FileUtil.toFileObject(FileUtil.normalizeFile(tmpFile));
  389
+
  390
+    DataObject dob = DataObject.find(fob);
  391
+    editorPane.getDocument().putProperty(Document.StreamDescriptionProperty, dob);
  392
+
  393
+    // This sets up a default class path for us so that
  394
+    // we can find all the JDK classes via code completion.
  395
+    DialogBinding.bindComponentToFile(fob, 0, 0, editorPane);
  396
+
  397
+    // Last but not least, we need to fill the editor pane with
  398
+    // some initial dummy code - as it seems somehow required to
  399
+    // kick-start code completion.
  400
+    // A simple dummy package declaration will do.
  401
+    editorPane.setText("package dummy;");
  402
+  }
  403
+  */
  404
+  
  405
+  
348 406
   protected void setPlacement(int[] location) {
349 407
     setBounds(location[0], location[1], location[2], location[3]);
350 408
     if (location[4] != 0) {
@@ -859,6 +917,13 @@ protected JMenu addInternalTools(JMenu menu) {
859 917
     menu.add(createToolMenuItem("processing.app.tools.Archiver"));
860 918
     menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
861 919
 
  920
+    /*
  921
+    //menu.add(createToolMenuItem("processing.app.tools.android.Build"));
  922
+    item = createToolMenuItem("processing.app.tools.android.Build");
  923
+    item.setAccelerator(KeyStroke.getKeyStroke('D', modifiers));
  924
+    menu.add(item);
  925
+    */
  926
+
862 927
     return menu;
863 928
   }
864 929
 
174  app/src/processing/app/Preferences.java
@@ -34,6 +34,8 @@
34 34
 import processing.core.*;
35 35
 
36 36
 
  37
+
  38
+
37 39
 /**
38 40
  * Storage class for user preferences and environment settings.
39 41
  * <P>
@@ -68,13 +70,6 @@
68 70
   static final String PREFS_FILE = "preferences.txt";
69 71
 
70 72
 
71  
-  // platform strings (used to get settings for specific platforms)
72  
-
73  
-  //static final String platforms[] = {
74  
-  //  "other", "windows", "macosx", "linux"
75  
-  //};
76  
-
77  
-
78 73
   // prompt text stuff
79 74
 
80 75
   static final String PROMPT_YES     = "Yes";
@@ -97,12 +92,6 @@
97 92
    * inside a static block.
98 93
    */
99 94
   static public int BUTTON_HEIGHT = 24;
100  
-  /*
101  
-  // remove this for 0121, because quaqua takes care of it
102  
-  static {
103  
-    if (Base.isMacOS()) BUTTON_HEIGHT = 29;
104  
-  }
105  
-  */
106 95
 
107 96
   // value for the size bars, buttons, etc
108 97
 
@@ -125,14 +114,12 @@
125 114
   JTextField sketchbookLocationField;
126 115
   JCheckBox exportSeparateBox;
127 116
   JCheckBox deletePreviousBox;
128  
-//  JCheckBox closingLastQuitsBox;
129 117
   JCheckBox externalEditorBox;
130 118
   JCheckBox memoryOverrideBox;
131 119
   JTextField memoryField;
132 120
   JCheckBox checkUpdatesBox;
133 121
   JTextField fontSizeField;
134 122
   JCheckBox autoAssociateBox;
135  
-  JCheckBox menubarWorkaroundBox;
136 123
 
137 124
 
138 125
   // the calling editor, so updates can be applied
@@ -142,9 +129,9 @@
142 129
 
143 130
   // data model
144 131
 
145  
-  static HashMap<String,String> defaults;
146  
-  static HashMap<String,String> table = new HashMap<String,String>();;
147  
-  static HashMap<String,HashMap<String,String>> prefixes = new HashMap<String,HashMap<String,String>>();
  132
+  static Hashtable defaults;
  133
+  static Hashtable table = new Hashtable();;
  134
+  static Hashtable prefixes = new Hashtable();
148 135
   static File preferencesFile;
149 136
 
150 137
 
@@ -159,8 +146,22 @@ static protected void init(String commandLinePrefs) {
159 146
                            "You'll need to reinstall Arduino.", e);
160 147
     }
161 148
 
  149
+    // check for platform-specific properties in the defaults
  150
+    String platformExt = "." + PConstants.platformNames[PApplet.platform];
  151
+    int platformExtLength = platformExt.length();
  152
+    Enumeration e = table.keys();
  153
+    while (e.hasMoreElements()) {
  154
+      String key = (String) e.nextElement();
  155
+      if (key.endsWith(platformExt)) {
  156
+        // this is a key specific to a particular platform
  157
+        String actualKey = key.substring(0, key.length() - platformExtLength);
  158
+        String value = get(key);
  159
+        table.put(actualKey, value);
  160
+      }
  161
+    }
  162
+
162 163
     // clone the hash table
163  
-    defaults = (HashMap<String, String>) table.clone();
  164
+    defaults = (Hashtable) table.clone();
164 165
 
165 166
     // other things that have to be set explicitly for the defaults
166 167
     setColor("run.window.bgcolor", SystemColor.control);
@@ -197,14 +198,6 @@ static protected void init(String commandLinePrefs) {
197 198
                          " and restart Arduino.", ex);
198 199
         }
199 200
       }
200  
-
201  
-      // Theme settings always override preferences
202  
-//      try {
203  
-//        load(Base.getStream("theme/theme.txt"));
204  
-//      } catch (Exception te) {
205  
-//        Base.showError(null, "Could not read color theme settings.\n" +
206  
-//                             "You'll need to reinstall Processing.", te);
207  
-//      }
208 201
     }
209 202
     
210 203
     try {
@@ -250,43 +243,6 @@ public Preferences() {
250 243
     int h, vmax;
251 244
 
252 245
 
253  
-    // [ ] Quit after closing last sketch window
254  
-    /*
255  
-    closingLastQuitsBox =
256  
-      new JCheckBox("Quit after closing last sketch window");
257  
-    pain.add(closingLastQuitsBox);
258  
-    d = closingLastQuitsBox.getPreferredSize();
259  
-    closingLastQuitsBox.setBounds(left, top, d.width + 10, d.height);
260  
-    right = Math.max(right, left + d.width);
261  
-    top += d.height + GUI_BETWEEN;
262  
-    */
263  
-
264  
-
265  
-    /*
266  
-    // [ ] Prompt for name and folder when creating new sketch
267  
-
268  
-    sketchPromptBox =
269  
-      new JCheckBox("Prompt for name when opening or creating a sketch");
270  
-    pain.add(sketchPromptBox);
271  
-    d = sketchPromptBox.getPreferredSize();
272  
-    sketchPromptBox.setBounds(left, top, d.width + 10, d.height);
273  
-    right = Math.max(right, left + d.width);
274  
-    top += d.height + GUI_BETWEEN;
275  
-    */
276  
-
277  
-
278  
-    // [ ] Delete empty sketches on Quit
279  
-
280  
-    /*
281  
-    sketchCleanBox = new JCheckBox("Delete empty sketches on Quit");
282  
-    pain.add(sketchCleanBox);
283  
-    d = sketchCleanBox.getPreferredSize();
284  
-    sketchCleanBox.setBounds(left, top, d.width + 10, d.height);
285  
-    right = Math.max(right, left + d.width);
286  
-    top += d.height + GUI_BETWEEN;
287  
-    */
288  
-
289  
-
290 246
     // Sketchbook location:
291 247
     // [...............................]  [ Browse ]
292 248
 
@@ -303,17 +259,6 @@ public Preferences() {
303 259
     button = new JButton(PROMPT_BROWSE);
304 260
     button.addActionListener(new ActionListener() {
305 261
         public void actionPerformed(ActionEvent e) {
306  
-          /*
307  
-          JFileChooser fc = new JFileChooser();
308  
-          fc.setSelectedFile(new File(sketchbookLocationField.getText()));
309  
-          fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
310  
-
311  
-          int returned = fc.showOpenDialog(new JDialog());
312  
-          if (returned == JFileChooser.APPROVE_OPTION) {
313  
-            File file = fc.getSelectedFile();
314  
-            sketchbookLocationField.setText(file.getAbsolutePath());
315  
-          }
316  
-          */
317 262
           File dflt = new File(sketchbookLocationField.getText());
318 263
           File file =
319 264
             Base.selectFolder("Select new sketchbook location", dflt, dialog);
@@ -327,13 +272,9 @@ public void actionPerformed(ActionEvent e) {
327 272
 
328 273
     // take max height of all components to vertically align em
329 274
     vmax = Math.max(d.height, d2.height);
330  
-    //label.setBounds(left, top + (vmax-d.height)/2,
331  
-    //              d.width, d.height);
332  
-
333  
-    //h = left + d.width + GUI_BETWEEN;
334 275
     sketchbookLocationField.setBounds(left, top + (vmax-d.height)/2,
335 276
                                       d.width, d.height);
336  
-    h = left + d.width + GUI_SMALL; //GUI_BETWEEN;
  277
+    h = left + d.width + GUI_SMALL;
337 278
     button.setBounds(h, top + (vmax-d2.height)/2,
338 279
                      d2.width, d2.height);
339 280
 
@@ -402,22 +343,6 @@ public void actionPerformed(ActionEvent e) {
402 343
     }
403 344
 
404 345
 
405  
-    // [ ] Place menu bar inside
406  
-
407  
-    if (Base.isMacOS()) {
408  
-      if (System.getProperty("os.version").startsWith("10.5")) {
409  
-        menubarWorkaroundBox =
410  
-          new JCheckBox("Place menus inside editor window to avoid " +
411  
-                        "Apple Java bug (requires restart)");
412  
-        pain.add(menubarWorkaroundBox);
413  
-        d = menubarWorkaroundBox.getPreferredSize();
414  
-        menubarWorkaroundBox.setBounds(left, top, d.width + 10, d.height);
415  
-        right = Math.max(right, left + d.width);
416  
-        top += d.height + GUI_BETWEEN;
417  
-      }
418  
-    }
419  
-
420  
-
421 346
     // More preferences are in the ...
422 347
 
423 348
     label = new JLabel("More preferences can be edited directly in the file");
@@ -491,7 +416,6 @@ public void actionPerformed(ActionEvent e) {
491 416
 
492 417
     wide = right + GUI_BIG;
493 418
     high = top + GUI_SMALL;
494  
-    //setSize(wide, high);
495 419
 
496 420
 
497 421
     // closing the window is same as hitting cancel button
@@ -535,26 +459,6 @@ public void keyPressed(KeyEvent e) {
535 459
   }
536 460
 
537 461
 
538  
-  /*
539  
-  protected JRootPane createRootPane() {
540  
-    System.out.println("creating root pane esc received");
541  
-
542  
-    ActionListener actionListener = new ActionListener() {
543  
-        public void actionPerformed(ActionEvent actionEvent) {
544  
-          //setVisible(false);
545  
-          System.out.println("esc received");
546  
-        }
547  
-      };
548  
-
549  
-    JRootPane rootPane = new JRootPane();
550  
-    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
551  
-    rootPane.registerKeyboardAction(actionListener, stroke,
552  
-                                    JComponent.WHEN_IN_FOCUSED_WINDOW);
553  
-    return rootPane;
554  
-  }
555  
-  */
556  
-
557  
-
558 462
   public Dimension getPreferredSize() {
559 463
     return new Dimension(wide, high);
560 464
   }
@@ -624,11 +528,6 @@ protected void applyFrame() {
624 528
                  autoAssociateBox.isSelected());
625 529
     }
626 530
 
627  
-    if (menubarWorkaroundBox != null) {
628  
-      setBoolean("apple.laf.useScreenMenuBar",
629  
-                 !menubarWorkaroundBox.isSelected());
630  
-    }
631  
-
632 531
     editor.applyPreferences();
633 532
   }
634 533
 
@@ -659,11 +558,6 @@ protected void showFrame(Editor editor) {
659 558
         setSelected(getBoolean("platform.auto_file_type_associations"));
660 559
     }
661 560
 
662  
-    if (menubarWorkaroundBox != null) {
663  
-      menubarWorkaroundBox.
664  
-        setSelected(!getBoolean("apple.laf.useScreenMenuBar"));
665  
-    }
666  
-
667 561
     dialog.setVisible(true);
668 562
   }
669 563
 
@@ -676,16 +570,12 @@ static protected void load(InputStream input) throws IOException {
676 570
   }
677 571
   
678 572
   static protected void load(InputStream input, String prefix) throws IOException {
679  
-    LinkedHashMap<String,String> table = new LinkedHashMap<String,String>();
  573
+    LinkedHashMap table = new LinkedHashMap();
680 574
     prefixes.put(prefix, table);
681 575
     load(input, table);
682 576
   }
683 577
   
684 578
   static protected void load(InputStream input, Map table) throws IOException {  
685  
-    // check for platform-specific properties in the defaults
686  
-    String platformExt = "." + PConstants.platformNames[PApplet.platform];
687  
-    int platformExtLength = platformExt.length();
688  
-    
689 579
     String[] lines = PApplet.loadStrings(input);  // Reads as UTF-8
690 580
     for (String line : lines) {
691 581
       if ((line.length() == 0) ||
@@ -695,12 +585,6 @@ static protected void load(InputStream input, Map table) throws IOException {
695 585
       int equals = line.indexOf('=');
696 586
       if (equals != -1) {
697 587
         String key = line.substring(0, equals).trim();
698  
-        
699  
-        // check if this is a platform-specific key, and if so, shave things
700  
-        if (key.endsWith(platformExt)) {
701  
-          // this is a key specific to this platform
702  
-          key = key.substring(0, key.length() - platformExtLength);
703  
-        }
704 588
         String value = line.substring(equals + 1).trim();
705 589
         table.put(key, value);
706 590
       }
@@ -721,8 +605,10 @@ static protected void save() {
721 605
     // Fix for 0163 to properly use Unicode when writing preferences.txt
722 606
     PrintWriter writer = PApplet.createWriter(preferencesFile);
723 607
 
724  
-    for (String key : table.keySet()) {
725  
-      writer.println(key + "=" + table.get(key));
  608
+    Enumeration e = table.keys(); //properties.propertyNames();
  609
+    while (e.hasMoreElements()) {
  610
+      String key = (String) e.nextElement();
  611
+      writer.println(key + "=" + ((String) table.get(key)));
726 612
     }
727 613
 
728 614
     writer.flush();
@@ -748,15 +634,15 @@ static public String get(String attribute /*, String defaultValue */) {
748 634
     // preference files, look up the attribute in that file's Hashtable
749 635
     // (don't override with or fallback to the main file).  otherwise,
750 636
     // look up the attribute in the main file's Hashtable. 
751  
-    HashMap<String,String> table = Preferences.table;
  637
+    Map table = Preferences.table;
752 638
     if (attribute.indexOf('.') != -1) {
753 639
       String prefix = attribute.substring(0, attribute.indexOf('.'));
754 640
       if (prefixes.containsKey(prefix)) {
755  
-        table = prefixes.get(prefix);
  641
+        table = (Map) prefixes.get(prefix);
756 642
         attribute = attribute.substring(attribute.indexOf('.') + 1);
757 643
       }
758 644
     }
759  
-    return table.get(attribute);
  645
+    return (String) table.get(attribute);
760 646
     /*
761 647
     //String value = (properties != null) ?
762 648
     //properties.getProperty(attribute) : applet.getParameter(attribute);
@@ -791,7 +677,7 @@ static public Iterator getSubKeys(String prefix) {
791 677
 
792 678
 
793 679
   static public String getDefault(String attribute) {
794  
-    return defaults.get(attribute);
  680
+    return (String) defaults.get(attribute);
795 681
   }
796 682
 
797 683
 
36  app/src/processing/app/Sketch.java
@@ -233,11 +233,12 @@ protected void insertCode(SketchCode newCode) {
233 233
     ensureExistence();
234 234
 
235 235
     // add file to the code/codeCount list, resort the list
236  
-    if (codeCount == code.length) {
  236
+    //if (codeCount == code.length) {
237 237
       code = (SketchCode[]) PApplet.append(code, newCode);
  238
+    codeCount++;
  239
+    //}
  240
+    //code[codeCount++] = newCode;
238 241
     }
239  
-    code[codeCount++] = newCode;
240  
-  }
241 242
 
242 243
 
243 244
   protected void sortCode() {
@@ -390,7 +391,7 @@ protected void nameCode(String newName) {
390 391
     // Make sure no .pde *and* no .java files with the same name already exist
391 392
     // http://dev.processing.org/bugs/show_bug.cgi?id=543
392 393
     for (SketchCode c : code) {
393  
-      if (sanitaryName.equals(c.getPrettyName())) {
  394
+      if (sanitaryName.equalsIgnoreCase(c.getPrettyName())) {
394 395
         Base.showMessage("Nope",
395 396
                          "A file named \"" + c.getFileName() + "\" already exists\n" +
396 397
                          "in \"" + folder.getAbsolutePath() + "\"");
@@ -599,6 +600,7 @@ protected void removeCode(SketchCode which) {
599 600
           code[j] = code[j+1];
600 601
         }
601 602
         codeCount--;
  603
+        code = (SketchCode[]) PApplet.shorten(code);
602 604
         return;
603 605
       }
604 606
     }
@@ -759,7 +761,7 @@ protected boolean saveAs() throws IOException {
759 761
     // but ignore this situation for the first tab, since it's probably being
760 762
     // resaved (with the same name) to another location/folder.
761 763
     for (int i = 1; i < codeCount; i++) {
762  
-      if (newName.equals(code[i].getPrettyName())) {
  764
+      if (newName.equalsIgnoreCase(code[i].getPrettyName())) {
763 765
         Base.showMessage("Nope",
764 766
                          "You can't save the sketch as \"" + newName + "\"\n" +
765 767
                          "because the sketch already has a tab with that name.");
@@ -1198,6 +1200,10 @@ protected String compile(Target target, boolean verbose)
1198 1200
    * @return null if compilation failed, main class name if not
1199 1201
    */
1200 1202
   public String preprocess(String buildPath, Target target) throws RunnerException {
  1203
+    return preprocess(buildPath, new PdePreprocessor(), target);
  1204
+  }
  1205
+
  1206
+  public String preprocess(String buildPath, PdePreprocessor preprocessor, Target target) throws RunnerException {
1201 1207
     // make sure the user didn't hide the sketch folder
1202 1208
     ensureExistence();
1203 1209
 
@@ -1268,7 +1274,18 @@ public String preprocess(String buildPath, Target target) throws RunnerException
1268 1274
     // Note that the headerOffset isn't applied until compile and run, because
1269 1275
     // it only applies to the code after it's been written to the .java file.
1270 1276
     int headerOffset = 0;
1271  
-    PdePreprocessor preprocessor = new PdePreprocessor();
  1277
+    //PdePreprocessor preprocessor = new PdePreprocessor();
  1278
+    try {
  1279
+      headerOffset = preprocessor.writePrefix(bigCode.toString(),
  1280
+                                              buildPath,
  1281
+                                              name,
  1282
+                                              codeFolderPackages,
  1283
+                                              target);
  1284
+    } catch (FileNotFoundException fnfe) {
  1285
+      fnfe.printStackTrace();
  1286
+      String msg = "Build folder disappeared or could not be written";
  1287
+      throw new RunnerException(msg);
  1288
+    }
1272 1289
 
1273 1290
     // 2. run preproc on that code using the sugg class name
1274 1291
     //    to create a single .java file and write to buildpath
@@ -1278,12 +1295,7 @@ public String preprocess(String buildPath, Target target) throws RunnerException
1278 1295
     try {
1279 1296
       // if (i != 0) preproc will fail if a pde file is not
1280 1297
       // java mode, since that's required
1281  
-      String className = preprocessor.write(bigCode.toString(),
1282  
-                                            buildPath,
1283  
-                                            name,
1284  
-					    codeFolderPackages,
1285  
-					    target);
1286  
-      headerOffset = preprocessor.headerCount + preprocessor.prototypeCount;
  1298
+      String className = preprocessor.write();
1287 1299
 
1288 1300
       if (className == null) {
1289 1301
         throw new RunnerException("Could not find main class");
6  app/src/processing/app/debug/Runner.java
@@ -385,9 +385,15 @@ protected VirtualMachine launchVirtualMachine(String[] vmParams,
385 385
       commandArgs =
386 386
         "java -Xrunjdwp:transport=dt_shmem,address=" + addr + ",suspend=y ";
387 387
     } else if (Base.isMacOS()) {
  388
+      if (System.getProperty("os.version").startsWith("10.4")) {
  389
+        // -d32 not understood by 10.4 (and not needed)
388 390
       commandArgs =
  391
+          "java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
  392
+      } else {
  393
+        commandArgs =
389 394
         "java -d32 -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
390 395
     }
  396
+    }
391 397
 
392 398
     for (int i = 0; i < vmParams.length; i++) {
393 399
       commandArgs = addArgument(commandArgs, vmParams[i], ' ');
2  app/src/processing/app/macosx/Platform.java
@@ -48,6 +48,7 @@ public void setLookAndFeel() throws Exception {
48 48
 
49 49
 
50 50
   public void init(Base base) {
  51
+    System.setProperty("apple.laf.useScreenMenuBar", "true");
51 52
     ThinkDifferent.init(base);
52 53
     /*
53 54
     try {
@@ -129,6 +130,7 @@ public void openURL(String url) throws Exception {
129 130
       }
130 131
       */
131 132
     }
  133
+    // for Java 1.6, replace with java.awt.Desktop.browse() and java.awt.Desktop.open()
132 134
     com.apple.eio.FileManager.openURL(url);
133 135
   }
134 136
 
407  app/src/processing/app/preproc/PdePreprocessor.java
@@ -34,58 +34,222 @@ Processing version Copyright (c) 2004-05 Ben Fry and Casey Reas
34 34
 import processing.core.*;
35 35
 
36 36
 import java.io.*;
37  
-import java.util.ArrayList;
38  
-import java.util.List;
39  
-
40  
-import antlr.*;
41  
-import antlr.collections.*;
42  
-import antlr.collections.impl.*;
  37
+import java.util.*;
43 38
 
44 39
 import com.oroinc.text.regex.*;
45 40
 
46 41
 
  42
+/**
  43
+ * Class that orchestrates preprocessing p5 syntax into straight Java.
  44
+ */
47 45
 public class PdePreprocessor {
  46
+  // stores number of built user-defined function prototypes
  47
+  public int prototypeCount = 0;
  48
+
  49
+  // stores number of included library headers written
  50
+  // we always write one header: WProgram.h
  51
+  public int headerCount = 1;
  52
+  
  53
+  Target target;
  54
+  List prototypes;
  55
+
48 56
 
49  
-  static final int JDK11 = 0;
50  
-  static final int JDK13 = 1;
51  
-  static final int JDK14 = 2;
52 57
 
53  
-  //static String defaultImports[][] = new String[3][];
54 58
 
55  
-  // these ones have the .* at the end, since a class name
56  
-  // might be at the end instead of .* whcih would make trouble
57  
-  // other classes using this can lop of the . and anything after
58  
-  // it to produce a package name consistently.
  59
+  String[] defaultImports;
  60
+
  61
+  // these ones have the .* at the end, since a class name might be at the end
  62
+  // instead of .* which would make trouble other classes using this can lop
  63
+  // off the . and anything after it to produce a package name consistently.
59 64
   //public String extraImports[];
60 65
   ArrayList<String> programImports;
61 66
 
62  
-  static public final int STATIC = 0;  // formerly BEGINNER
63  
-  static public final int ACTIVE = 1;  // formerly INTERMEDIATE
64  
-  static public final int JAVA   = 2;  // formerly ADVANCED
65  
-  // static to make it easier for the antlr preproc to get at it
66  
-  static public int programType = -1;
  67
+  // imports just from the code folder, treated differently
  68
+  // than the others, since the imports are auto-generated.
  69
+  ArrayList<String> codeFolderImports;
  70
+
  71
+  String indent;
67 72
 
68  
-  Reader programReader;
  73
+  PrintStream stream;
  74
+  String program;
69 75
   String buildPath;
  76
+  String name;
70 77
 
71  
-  // stores number of built user-defined function prototypes
72  
-  public int prototypeCount = 0;
73  
-
74  
-  // stores number of included library headers written
75  
-  // we always write one header: WProgram.h
76  
-  public int headerCount = 1;
77 78
 
78 79
   /**
79  
-   * These may change in-between (if the prefs panel adds this option)
80  
-   * so grab them here on construction.
  80
+   * Setup a new preprocessor.
81 81
    */
82  
-  public PdePreprocessor() {}
  82
+  public PdePreprocessor() { }
  83
+
  84
+  public int writePrefix(String program, String buildPath,
  85
+                         String name, String codeFolderPackages[],
  86
+                         Target target)
  87
+    throws FileNotFoundException {
  88
+    this.buildPath = buildPath;
  89
+    this.name = name;
  90
+    this.target = target;
  91
+
  92
+    int tabSize = Preferences.getInteger("editor.tabs.size");
  93
+    char[] indentChars = new char[tabSize];
  94
+    Arrays.fill(indentChars, ' ');
  95
+    indent = new String(indentChars);
  96
+
  97
+    // if the program ends with no CR or LF an OutOfMemoryError will happen.
  98
+    // not gonna track down the bug now, so here's a hack for it:
  99
+    // http://dev.processing.org/bugs/show_bug.cgi?id=5
  100
+    program += "\n";
  101
+
  102
+    // if the program ends with an unterminated multi-line comment,
  103
+    // an OutOfMemoryError or NullPointerException will happen.
  104
+    // again, not gonna bother tracking this down, but here's a hack.
  105
+    // http://dev.processing.org/bugs/show_bug.cgi?id=16
  106
+    Sketch.scrubComments(program);
  107
+    // this returns the scrubbed version, but more important for this
  108
+    // function, it'll check to see if there are errors with the comments.
  109
+
  110
+    if (Preferences.getBoolean("preproc.substitute_unicode")) {
  111
+      // check for non-ascii chars (these will be/must be in unicode format)
  112
+      char p[] = program.toCharArray();
  113
+      int unicodeCount = 0;
  114
+      for (int i = 0; i < p.length; i++) {
  115
+        if (p[i] > 127) unicodeCount++;
  116
+      }
  117
+      // if non-ascii chars are in there, convert to unicode escapes
  118
+      if (unicodeCount != 0) {
  119
+        // add unicodeCount * 5.. replacing each unicode char
  120
+        // with six digit uXXXX sequence (xxxx is in hex)
  121
+        // (except for nbsp chars which will be a replaced with a space)
  122
+        int index = 0;
  123
+        char p2[] = new char[p.length + unicodeCount*5];
  124
+        for (int i = 0; i < p.length; i++) {
  125
+          if (p[i] < 128) {
  126
+            p2[index++] = p[i];
  127
+
  128
+          } else if (p[i] == 160) {  // unicode for non-breaking space
  129
+            p2[index++] = ' ';
  130
+
  131
+          } else {
  132
+            int c = p[i];
  133
+            p2[index++] = '\\';
  134
+            p2[index++] = 'u';
  135
+            char str[] = Integer.toHexString(c).toCharArray();
  136
+            // add leading zeros, so that the length is 4
  137
+            //for (int i = 0; i < 4 - str.length; i++) p2[index++] = '0';
  138
+            for (int m = 0; m < 4 - str.length; m++) p2[index++] = '0';
  139
+            System.arraycopy(str, 0, p2, index, str.length);
  140
+            index += str.length;
  141
+          }
  142
+        }
  143
+        program = new String(p2, 0, index);
  144
+      }
  145
+    }
  146
+
  147
+    // These may change in-between (if the prefs panel adds this option)
  148
+    // so grab them here on construction.
  149
+    String prefsLine = Preferences.get("preproc.imports");
  150
+    defaultImports = PApplet.splitTokens(prefsLine, ", ");
  151
+
  152
+    //String importRegexp = "(?:^|\\s|;)(import\\s+)(\\S+)(\\s*;)";
  153
+    String importRegexp = "^\\s*#include\\s+[<\"](\\S+)[\">]";
  154
+    programImports = new ArrayList<String>();
  155
+
  156
+    String[][] pieces = PApplet.matchAll(program, importRegexp);
  157
+
  158
+    if (pieces != null)
  159
+      for (int i = 0; i < pieces.length; i++)
  160
+        programImports.add(pieces[i][1]);  // the package name
  161
+
  162
+    codeFolderImports = new ArrayList<String>();
  163
+//    if (codeFolderPackages != null) {
  164
+//      for (String item : codeFolderPackages) {
  165
+//        codeFolderImports.add(item + ".*");
  166
+//      }
  167
+//    }
  168
+
  169
+    prototypes = new ArrayList();
  170
+    
  171
+    try {
  172
+      prototypes = prototypes(program);
  173
+    } catch (MalformedPatternException e) {
  174
+      System.out.println("Internal error while pre-processing; " +
  175
+        "not generating function prototypes.\n\n" + e);
  176
+    }
  177
+    
  178
+    // store # of prototypes so that line number reporting can be adjusted
  179
+    prototypeCount = prototypes.size();
  180
+  
  181
+    // do this after the program gets re-combobulated
  182
+    this.program = program;
  183
+    
  184
+    // output the code
  185
+    File streamFile = new File(buildPath, name + ".cpp");
  186
+    stream = new PrintStream(new FileOutputStream(streamFile));
  187
+    
  188
+    return headerCount + prototypeCount;
  189
+  }
83 190
 
84 191
   /**
85  
-   * Used by PdeEmitter.dumpHiddenTokens()
  192
+   * preprocesses a pde file and write out a java file
  193
+   * @return the classname of the exported Java
86 194
    */
87  
-  //public static TokenStreamCopyingHiddenTokenFilter filter;
  195
+  //public String write(String program, String buildPath, String name,
  196
+  //                  String extraImports[]) throws java.lang.Exception {
  197
+  public String write() throws java.lang.Exception {
  198
+    writeProgram(stream, program, prototypes);
  199
+    writeFooter(stream, target);
  200
+    stream.close();
  201
+    
  202
+    return name;
  203
+  }
  204
+
  205
+  // Write the pde program to the cpp file
  206
+  protected void writeProgram(PrintStream out, String program, List prototypes) {
  207
+    int prototypeInsertionPoint = firstStatement(program);
88 208
   
  209
+    out.print(program.substring(0, prototypeInsertionPoint));
  210
+    out.print("#include \"WProgram.h\"\n");    
  211
+    
  212
+    // print user defined prototypes
  213
+    for (int i = 0; i < prototypes.size(); i++) {
  214
+      out.print(prototypes.get(i) + "\n");
  215
+    }
  216
+    
  217
+    out.print(program.substring(prototypeInsertionPoint));
  218
+  }
  219
+
  220
+
  221
+  /**
  222
+   * Write any necessary closing text.
  223
+   *
  224
+   * @param out         PrintStream to write it to.
  225
+   */
  226
+  protected void writeFooter(PrintStream out, Target target) throws java.lang.Exception {
  227
+    // Open the file main.cxx and copy its entire contents to the bottom of the
  228
+    // generated sketch .cpp file...
  229
+
  230
+    String mainFileName = target.getPath() + File.separator + "main.cxx";
  231
+    FileReader reader = null;
  232
+    reader = new FileReader(mainFileName);
  233
+
  234
+    LineNumberReader mainfile = new LineNumberReader(reader);
  235
+
  236
+    String line;
  237
+    while ((line = mainfile.readLine()) != null) {
  238
+        out.print(line + "\n");
  239
+    }
  240
+
  241
+    mainfile.close();
  242
+  }
  243
+
  244
+
  245
+  public ArrayList<String> getExtraImports() {
  246
+    return programImports;
  247
+  }
  248
+
  249
+
  250
+
  251
+
  252
+
89 253
   /**
90 254
    * Returns the index of the first character that's not whitespace, a comment
91 255
    * or a pre-processor directive.
@@ -204,185 +368,4 @@ public List prototypes(String in) throws MalformedPatternException {
204 368
     
205 369
     return matches;
206 370
   }
207  
-
208  
-
209  
-  /**
210  
-   * preprocesses a pde file and write out a java file
211  
-   * @param pretty true if should also space out/indent lines
212  
-   * @return the classname of the exported Java
213  
-   */
214  
-  //public String write(String program, String buildPath, String name,
215  
-  //                  String extraImports[]) throws java.lang.Exception {
216  
-  public String write(String program, String buildPath,
217  
-                      String name, String codeFolderPackages[],
218  
-                      Target target)
219  
-    throws java.lang.Exception {
220  
-    // if the program ends with no CR or LF an OutOfMemoryError will happen.
221  
-    // not gonna track down the bug now, so here's a hack for it:
222  
-    // bug filed at http://dev.processing.org/bugs/show_bug.cgi?id=5
223  
-    //if ((program.length() > 0) &&
224  
-    //program.charAt(program.length()-1) != '\n') {
225  
-      program += "\n";
226  
-    //}
227  
-
228  
-    // if the program ends with an unterminated multiline comment,
229  
-    // an OutOfMemoryError or NullPointerException will happen.
230  
-    // again, not gonna bother tracking this down, but here's a hack.
231  
-    // http://dev.processing.org/bugs/show_bug.cgi?id=16
232  
-    Sketch.scrubComments(program);
233  
-    // this returns the scrubbed version, but more important for this
234  
-    // function, it'll check to see if there are errors with the comments.
235  
-
236  
-    if (Preferences.getBoolean("preproc.substitute_unicode")) {
237  
-      // check for non-ascii chars (these will be/must be in unicode format)
238  
-      char p[] = program.toCharArray();
239  
-      int unicodeCount = 0;
240  
-      for (int i = 0; i < p.length; i++) {
241  
-        if (p[i] > 127) unicodeCount++;
242  
-      }
243  
-      // if non-ascii chars are in there, convert to unicode escapes
244  
-      if (unicodeCount != 0) {
245  
-        // add unicodeCount * 5.. replacing each unicode char
246  
-        // with six digit uXXXX sequence (xxxx is in hex)
247  
-        // (except for nbsp chars which will be a replaced with a space)
248  
-        int index = 0;
249  
-        char p2[] = new char[p.length + unicodeCount*5];
250  
-        for (int i = 0; i < p.length; i++) {
251  
-          if (p[i] < 128) {
252  
-            p2[index++] = p[i];
253  
-
254  
-          } else if (p[i] == 160) {  // unicode for non-breaking space
255  
-            p2[index++] = ' ';
256  
-
257  
-          } else {
258  
-            int c = p[i];
259  
-            p2[index++] = '\\';
260  
-            p2[index++] = 'u';
261  
-            char str[] = Integer.toHexString(c).toCharArray();
262  
-            // add leading zeros, so that the length is 4
263  
-            //for (int i = 0; i < 4 - str.length; i++) p2[index++] = '0';
264  
-            for (int m = 0; m < 4 - str.length; m++) p2[index++] = '0';
265  
-            System.arraycopy(str, 0, p2, index, str.length);
266  
-            index += str.length;
267  
-          }
268  
-        }
269  
-        program = new String(p2, 0, index);
270  
-      }
271  
-    }
272  
-    
273  
-    // if this guy has his own imports, need to remove them
274