added custom title format setting (editor.custom_title_format)

This commit is contained in:
Michael michael.sytko 2017-01-30 22:36:33 +01:00 committed by Cristian Maglie
parent d5a73dc419
commit 8943b7ccbe
1 changed files with 19 additions and 5 deletions

View File

@ -38,6 +38,7 @@ import processing.app.helpers.DocumentTextChangeListener;
import processing.app.helpers.Keys; import processing.app.helpers.Keys;
import processing.app.helpers.OSUtils; import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMapException; import processing.app.helpers.PreferencesMapException;
import processing.app.helpers.StringReplacer;
import processing.app.legacy.PApplet; import processing.app.legacy.PApplet;
import processing.app.syntax.PdeKeywords; import processing.app.syntax.PdeKeywords;
import processing.app.syntax.SketchTextArea; import processing.app.syntax.SketchTextArea;
@ -1935,6 +1936,18 @@ public class Editor extends JFrame implements RunnerListener {
return; return;
} }
SketchFile current = getCurrentTab().getSketchFile(); SketchFile current = getCurrentTab().getSketchFile();
String customFormat = PreferencesData.get("editor.custom_title_format");
if (customFormat != null && !customFormat.trim().isEmpty()) {
Map<String, String> titleMap = new HashMap<String, String>();
titleMap.put("file", current.getFileName());
String path = sketch.getFolder().getAbsolutePath();
titleMap.put("folder", path);
titleMap.put("path", path);
titleMap.put("project", sketch.getName());
titleMap.put("version", BaseNoGui.VERSION_NAME_LONG);
setTitle(StringReplacer.replaceFromMapping(customFormat, titleMap));
} else {
if (current.isPrimary()) { if (current.isPrimary()) {
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(), setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
BaseNoGui.VERSION_NAME_LONG)); BaseNoGui.VERSION_NAME_LONG));
@ -1943,6 +1956,7 @@ public class Editor extends JFrame implements RunnerListener {
current.getFileName(), BaseNoGui.VERSION_NAME_LONG)); current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
} }
} }
}
/** /**