X added 'rename' command

X   also the default for clicking on the sketch's title
This commit is contained in:
benfry
2002-11-19 06:33:16 +00:00
parent 21a744060d
commit d6e903658a
5 changed files with 70 additions and 32 deletions
+5 -1
View File
@@ -216,6 +216,7 @@ public class PdeBase extends Frame implements ActionListener {
saveAsMenuItem = new MenuItem("Save as...", new MenuShortcut('S', true));
menu.add(saveMenuItem);
menu.add(saveAsMenuItem);
menu.add(new MenuItem("Rename..."));
//menu.add(new MenuItem("Save", new MenuShortcut('S')));
//menu.add(new MenuItem("Save as...", new MenuShortcut('S', true)));
//menu.add(new MenuItem("Rename", new MenuShortcut('S', true)));
@@ -750,7 +751,10 @@ public class PdeBase extends Frame implements ActionListener {
editor.doSave();
} else if (command.equals("Save as...")) {
editor.skSaveAs();
editor.skSaveAs(false);
} else if (command.equals("Rename...")) {
editor.skSaveAs(true);
/*
} else if (command.equals("Rename")) {
+39 -18
View File
@@ -79,6 +79,7 @@ public class PdeEditor extends Panel {
boolean running;
boolean presenting;
boolean renaming;
PdeBase base;
@@ -507,12 +508,13 @@ public class PdeEditor extends Panel {
// read lines until the next separator
//textarea.editorSetText("");
line = reader.readLine(); // ignored
String sep = System.getProperty("line.separator");
//String sep = System.getProperty("line.separator");
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
if (line.equals(PdeEditor.HISTORY_SEPARATOR)) break;
//textarea.append(line + sep);
buffer.append(line + sep);
//buffer.append(line + sep); // JTextPane wants only \n going in
buffer.append(line + "\n");
//System.out.println("'" + line + "'");
}
textarea.editorSetText(buffer.toString());
@@ -893,17 +895,29 @@ afterwards, some of these steps need a cleanup function
//System.err.println("made it");
try {
//if (true) throw new IOException("blah");
String program = null;
FileInputStream input = new FileInputStream(isketchFile);
int length = (int) isketchFile.length();
String program = "";
if (length != 0) {
byte data[] = new byte[length];
int count = 0;
while (count != length) {
data[count++] = (byte) input.read();
if (isketchFile.length() != 0) {
FileInputStream input = new FileInputStream(isketchFile);
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
StringBuffer buffer = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
buffer.append(line);
buffer.append('\n');
}
program = buffer.toString();
textarea.editorSetText(program);
/*
int length = (int) isketchFile.length();
if (length != 0) {
byte data[] = new byte[length];
int count = 0;
while (count != length) {
data[count++] = (byte) input.read();
}
// set the last dir and file, so that they're
// the defaults when you try to save again
//lastDirectory = file.getCanonicalPath(); //directory;
@@ -914,13 +928,14 @@ afterwards, some of these steps need a cleanup function
//textarea.editorSetText(app.languageEncode(data));
// what the hell was i thinking when i wrote this code
//if (app.encoding == null)
program = new String(data);
program = new String(data);
//textarea.editorSetText(new String(data));
//System.out.println(" loading program = " + new String(data));
//else
//textarea.editorSetText(new String(data, app.encoding));
textarea.editorSetText(program);
*/
// may be needed because settext fires an event
//setSketchModified(false);
@@ -1017,9 +1032,15 @@ afterwards, some of these steps need a cleanup function
}
public void skSaveAs() {
public void skSaveAs(boolean rename) {
doStop();
status.edit("Save sketch as...", sketchName);
this.renaming = rename;
if (rename) {
status.edit("Rename sketch to...", sketchName);
} else {
status.edit("Save sketch as...", sketchName);
}
}
public void skSaveAs2(String newSketchName) {
@@ -1047,9 +1068,9 @@ afterwards, some of these steps need a cleanup function
new File(newSketchDir, sketchName + ".pde").delete();
// remove the old dir (!)
//if (rename) removeDir(sketchDir);
// oops.. has to be done before opening, otherwise the new
// dir is set to sketchDir.. duh..
if (renaming) removeDir(sketchDir);
// (important!) has to be done before opening,
// otherwise the new dir is set to sketchDir..
base.rebuildSketchbookMenu();
+1 -1
View File
@@ -64,7 +64,7 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
//System.out.println("got mouse");
if ((sketchRight != 0) &&
(e.getX() > sketchLeft) && (e.getX() < sketchRight)) {
editor.skSaveAs();
editor.skSaveAs(true);
}
}
});
+2 -1
View File
@@ -156,8 +156,9 @@ public class PdeEditorStatus extends Panel
response = 0;
okButton.setVisible(true);
cancelButton.setVisible(true);
editField.setText(dflt);
editField.setVisible(true);
editField.setText(dflt);
editField.selectAll();
editField.requestFocus();
update();
+23 -11
View File
@@ -41,6 +41,12 @@ X "color.jpg" -> "int.jpg" causes trouble
X why does this line cause an error?
// String url = "http:\u002f\u002fwww.Proce55ing.net";
X it's not in the preprocessor, but kopi seems to be having trouble
X seems that file i/o may be picking up lots of extra \r
X perhaps when doing setText, it's goobering things up
X when renaming a sketch, select the text in the field,
X so you can type the new name immediately.
X added 'rename' command
X also the default for clicking on the sketch's title
bagel
_ images don't load during setup()
@@ -53,12 +59,8 @@ _ make into oval function
_ font smoothing (unless hint SMOOTH_IMAGES enabled) is broken
pde
_ seems that file i/o may be picking up lots of extra \r
_ perhaps when doing setText, it's goobering things up
_ better default size than 300x300 when starting up first time
_ set frame title of launched window to the name of the sketch
_ when renaming a sketch, select the text in the field,
so you can type the new name immediately.
_ option to rename when doing a 'save as' (remove old files)
_ remove .class files on save as [dimitre]
When I am working in a project and I save it with another name,
all the old files are copyied to new directory, and some of the old
@@ -66,9 +68,6 @@ unused .class files and images remains inside new project JAR files.
_ use date in the sketch name sketch_021104
_ with a _2 if needed or '021104a' '021104b' etc
_ when using save as, allow to remove the old (numbered) sketch
_ preprocessor problems -> switch to java cup (one day's work)
_ subst Image -> BImage, Font -> BFont
_ serial port
_ better message for PortInUseException (full explanation)
_ better message for when serial port code not available/not installed
@@ -76,11 +75,17 @@ _ lots of problems with the console [maybe this needs to be a textarea?]
_ long lines seem to be trouble
_ also printing of objects, esp when null, in jdk 14
_ exception when trying to write to stdout
_ support 'classes' folder, through the use of a classloader
_ could also be done by launching external java app
_ all .jar files etc are added from this folder automatically
_ split KjcEngine into three parts
_ how to communicate with other applet/jre when it's been launched
_ support 'classes' folder, through the use of a classloader
_ all .jar files etc are added from this folder automatically
_ preprocessor problems -> switch to java cup (one day's work)
_ subst Image -> BImage, Font -> BFont
_ line endings joy
_ is setText goobering up on beautify?
_ how are line endings working during save?
_ get syntax coloring debugged?
_ talk to casey about better default colors
@@ -91,7 +96,14 @@ _ ME seems to be very broken
_ lockup/freezes (mKoser and zeitgeist)
_ jre icon not appearing in the systray
macos9
_ update build/dist scripts to work with new layout
_ check to see if swing is working properly
macosx
_ better default size than 300x300 when starting up first time
_ update build/dist scripts to work with new layout
_ check to see if swing is working properly
_ put mac rxtx inside the p5 folder (hide it?)