Merge pull request #2452 from jdf/master

Permit Modes to specify different default file extension for auxilliary (not main pde) files created in new tabs.
This commit is contained in:
Ben Fry
2014-04-15 12:54:10 -04:00
2 changed files with 13 additions and 4 deletions
+12
View File
@@ -1046,6 +1046,18 @@ public abstract class Mode {
abstract public String getDefaultExtension();
/**
* Returns the appropriate file extension to use for auxilliary source files in a sketch.
* For example, in a Java-mode sketch, auxilliary files should be name "Foo.java"; in
* Python mode, they should be named "foo.py".
*
* <p>Modes that do not override this function will get the default behavior of returning the
* default extension.
*/
public String getModuleExtension() {
return getDefaultExtension();
}
/**
* Returns a String[] array of proper extensions.
+1 -4
View File
@@ -333,9 +333,6 @@ public class Sketch {
/**
* This is called upon return from entering a new file name.
* (that is, from either newCode or renameCode after the prompt)
* This code is almost identical for both the newCode and renameCode
* cases, so they're kept merged except for right in the middle
* where they diverge.
*/
protected void nameCode(String newName) {
newName = newName.trim();
@@ -348,7 +345,7 @@ public class Sketch {
// Add the extension here, this simplifies some of the logic below.
if (newName.indexOf('.') == -1) {
newName += "." + mode.getDefaultExtension();
newName += "." + (renamingCode ? mode.getDefaultExtension() : mode.getModuleExtension());
}
// if renaming to the same thing as before, just ignore.