mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
fixing auto-indent and random sketchbook error
This commit is contained in:
@@ -200,7 +200,7 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
"Open a PDE program...",
|
||||
FileDialog.LOAD);
|
||||
fd.setDirectory(lastDirectory);
|
||||
fd.setFile(lastFile);
|
||||
//fd.setFile(lastFile);
|
||||
fd.show();
|
||||
|
||||
String directory = fd.getDirectory();
|
||||
@@ -215,7 +215,7 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
FileInputStream input = new FileInputStream(file);
|
||||
int length = (int) file.length();
|
||||
byte data[] = new byte[length];
|
||||
|
||||
|
||||
int count = 0;
|
||||
while (count != length) {
|
||||
data[count++] = (byte) input.read();
|
||||
@@ -224,10 +224,11 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
// the defaults when you try to save again
|
||||
lastDirectory = directory;
|
||||
lastFile = filename;
|
||||
|
||||
|
||||
// once read all the bytes, convert it to the proper
|
||||
// local encoding for this system.
|
||||
//textarea.setText(app.languageEncode(data));
|
||||
// what the hell was i thinking when i wrote this code
|
||||
if (app.encoding == null)
|
||||
textarea.setText(new String(data));
|
||||
else
|
||||
@@ -244,21 +245,36 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
|
||||
|
||||
public void doSave() {
|
||||
// true if lastfile not set, otherwise false, meaning no prompt
|
||||
handleSave(lastFile == null);
|
||||
}
|
||||
|
||||
public void doSaveAs() {
|
||||
handleSave(true);
|
||||
}
|
||||
|
||||
public void handleSave(boolean promptUser) {
|
||||
message("Saving file...");
|
||||
String s = textarea.getText();
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
"Save PDE program as...",
|
||||
FileDialog.SAVE);
|
||||
fd.setDirectory(lastDirectory);
|
||||
fd.setFile(lastFile);
|
||||
fd.show();
|
||||
|
||||
String directory = fd.getDirectory();
|
||||
String filename = fd.getFile();
|
||||
if (filename == null) {
|
||||
message(EMPTY);
|
||||
buttons.clear();
|
||||
return; // user cancelled
|
||||
|
||||
String directory = lastDirectory;
|
||||
String filename = lastFile;
|
||||
|
||||
if (promptUser) {
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
"Save PDE program as...",
|
||||
FileDialog.SAVE);
|
||||
fd.setDirectory(lastDirectory);
|
||||
fd.setFile(lastFile);
|
||||
fd.show();
|
||||
|
||||
directory = fd.getDirectory();
|
||||
filename = fd.getFile();
|
||||
if (filename == null) {
|
||||
message(EMPTY);
|
||||
buttons.clear();
|
||||
return; // user cancelled
|
||||
}
|
||||
}
|
||||
File file = new File(directory, filename);
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ public class PdeEditorButtons extends Panel {
|
||||
case CLOSE: editor.doClose(); break;
|
||||
|
||||
case OPEN: editor.doOpen(); break;
|
||||
case SAVE: editor.doSave(); break;
|
||||
case SAVE: editor.doSaveAs(); break;
|
||||
case EXPORT: editor.doExport(); break;
|
||||
case PRINT: editor.doPrint(); break;
|
||||
case BEAUTIFY: editor.doBeautify(); break;
|
||||
|
||||
@@ -112,7 +112,10 @@ public class PdeEditorListener extends KeyAdapter implements FocusListener {
|
||||
String insertion = newline + spaces.substring(0, spaceCount);
|
||||
int oldCarrot = tc.getSelectionStart();
|
||||
tc.replaceRange(insertion, oldCarrot, tc.getSelectionEnd());
|
||||
tc.setCaretPosition(oldCarrot + insertion.length() - 1);
|
||||
// microsoft vm version:
|
||||
//tc.setCaretPosition(oldCarrot + insertion.length() - 1);
|
||||
// sun vm version:
|
||||
tc.setCaretPosition(oldCarrot + insertion.length());
|
||||
event.consume();
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user