recursive sketch folders now work

but coloring seems to be pretty flakey
This commit is contained in:
benfry
2002-10-23 01:45:43 +00:00
parent 3b300df5f1
commit ad8d541d63
4 changed files with 78 additions and 26 deletions

View File

@@ -513,7 +513,7 @@ public class PdeBase extends Frame implements ActionListener {
menu.addSeparator();
// other available subdirectories
/*
String toplevel[] = sketchbookFolder.list();
added = false;
for (int i = 0; i < toplevel.length; i++) {
@@ -550,10 +550,17 @@ public class PdeBase extends Frame implements ActionListener {
menu.add(subMenu);
}
if (added) menu.addSeparator();
*/
addSketches(menu, sketchbookFolder, true);
/*
// doesn't seem that refresh is worthy of its own menu item
// people can stop and restart p5 if they want to muck with it
menu.addSeparator();
MenuItem item = new MenuItem("Refresh");
item.addActionListener(this);
menu.add(item);
*/
} catch (IOException e) {
e.printStackTrace();
@@ -561,6 +568,35 @@ public class PdeBase extends Frame implements ActionListener {
}
protected void addSketches(Menu menu, File folder, boolean root)
throws IOException {
String list[] = folder.list();
SketchbookMenuListener listener =
new SketchbookMenuListener(folder.getCanonicalPath());
for (int i = 0; i < list.length; i++) {
if (list[i].equals(editor.userName) && root) continue;
if (list[i].equals(".") ||
list[i].equals("..") ||
list[i].equals("CVS") ||
list[i].equals(".cvsignore")) continue;
File subfolder = new File(folder, list[i]);
if (new File(subfolder, list[i] + ".pde").exists()) {
MenuItem item = new MenuItem(list[i]);
item.addActionListener(listener);
menu.add(item);
} else { // might contain other dirs, get recursive
Menu submenu = new Menu(list[i]);
menu.add(submenu);
addSketches(submenu, subfolder, false);
}
}
}
/*
class HistoryMenuListener implements ActionListener {
public void actionPerformed(ActionEvent e) {