mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
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:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user