When switching between tabs, add the name of the current file/tab to the title. Fixes #2765

This commit is contained in:
Federico Fissore 2015-06-25 12:08:58 +02:00
parent df667756d2
commit 2339049c0f
1 changed files with 15 additions and 3 deletions

View File

@ -1771,7 +1771,7 @@ public class Editor extends JFrame implements RunnerListener {
textarea.requestFocus(); // get the caret blinking
final int position = codeDoc.getScrollPosition();
// invokeLater: Expect the document to be rendered correctly to set the new position
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -1781,7 +1781,8 @@ public class Editor extends JFrame implements RunnerListener {
redoAction.updateRedoState();
}
});
updateTitle();
}
@ -2191,7 +2192,7 @@ public class Editor extends JFrame implements RunnerListener {
return false;
}
header.rebuild();
setTitle(I18n.format(_("{0} | Arduino {1}"), sketch.getName(), BaseNoGui.VERSION_NAME_LONG));
updateTitle();
// Disable untitled setting from previous document, if any
untitled = false;
@ -2205,6 +2206,17 @@ public class Editor extends JFrame implements RunnerListener {
// }
}
private void updateTitle() {
if (sketch == null) {
return;
}
if (sketch.getName().equals(sketch.getCurrentCode().getPrettyName())) {
setTitle(I18n.format(_("{0} | Arduino {1}"), sketch.getName(), BaseNoGui.VERSION_NAME_LONG));
} else {
setTitle(I18n.format(_("{0} - {1} | Arduino {2}"), sketch.getName(), sketch.getCurrentCode().getFileName(), BaseNoGui.VERSION_NAME_LONG));
}
}
/**
* Actually handle the save command. If 'immediately' is set to false,