Skip to content

Commit 8943b7c

Browse files
MichalSycmaglie
authored andcommitted
added custom title format setting (editor.custom_title_format)
1 parent d5a73dc commit 8943b7c

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

app/src/processing/app/Editor.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import processing.app.helpers.Keys;
3939
import processing.app.helpers.OSUtils;
4040
import processing.app.helpers.PreferencesMapException;
41+
import processing.app.helpers.StringReplacer;
4142
import processing.app.legacy.PApplet;
4243
import processing.app.syntax.PdeKeywords;
4344
import processing.app.syntax.SketchTextArea;
@@ -1935,12 +1936,25 @@ private void updateTitle() {
19351936
return;
19361937
}
19371938
SketchFile current = getCurrentTab().getSketchFile();
1938-
if (current.isPrimary()) {
1939-
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
1940-
BaseNoGui.VERSION_NAME_LONG));
1939+
String customFormat = PreferencesData.get("editor.custom_title_format");
1940+
if (customFormat != null && !customFormat.trim().isEmpty()) {
1941+
Map<String, String> titleMap = new HashMap<String, String>();
1942+
titleMap.put("file", current.getFileName());
1943+
String path = sketch.getFolder().getAbsolutePath();
1944+
titleMap.put("folder", path);
1945+
titleMap.put("path", path);
1946+
titleMap.put("project", sketch.getName());
1947+
titleMap.put("version", BaseNoGui.VERSION_NAME_LONG);
1948+
1949+
setTitle(StringReplacer.replaceFromMapping(customFormat, titleMap));
19411950
} else {
1942-
setTitle(I18n.format(tr("{0} - {1} | Arduino {2}"), sketch.getName(),
1943-
current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
1951+
if (current.isPrimary()) {
1952+
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
1953+
BaseNoGui.VERSION_NAME_LONG));
1954+
} else {
1955+
setTitle(I18n.format(tr("{0} - {1} | Arduino {2}"), sketch.getName(),
1956+
current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
1957+
}
19441958
}
19451959
}
19461960

0 commit comments

Comments
 (0)