Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2021-02-26 18:29:50 +0000
committerJonah Graham2021-03-01 23:51:58 +0000
commitfe003208544902646096db658f63d2038a80d40a (patch)
tree9ecb74dda59155e90730f0d0ee10eaf505b064f6
parentafd8342ec00e2b33a7d70b80579ba054a3d9fac2 (diff)
downloadorg.eclipse.cdt-fe003208544902646096db658f63d2038a80d40a.tar.gz
org.eclipse.cdt-fe003208544902646096db658f63d2038a80d40a.tar.xz
org.eclipse.cdt-fe003208544902646096db658f63d2038a80d40a.zip
Bug 341721: Update terminal tab title with ANSI command
All the hard work had been done before, simply no one had actually added the bit of code to update the title based on the listener. Change-Id: Icdbc7b9b0a9b8fccf7d4eddf8d20674e50e0a170
-rw-r--r--terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabTerminalListener.java35
1 files changed, 28 insertions, 7 deletions
diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabTerminalListener.java b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabTerminalListener.java
index fef19e482b2..6df377aa2b3 100644
--- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabTerminalListener.java
+++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabTerminalListener.java
@@ -27,7 +27,8 @@ public class TabTerminalListener implements ITerminalListener2 {
private static final String TAB_TERMINAL_LISTENER = "TabTerminalListener"; //$NON-NLS-1$
/* default */ final TabFolderManager tabFolderManager;
private CTabItem tabItem;
- private final String tabItemTitle;
+ private String tabItemTitle;
+ private TerminalState state;
/**
* Move a TabTerminalListener instance to another item (for DnD).
@@ -53,7 +54,7 @@ public class TabTerminalListener implements ITerminalListener2 {
Assert.isNotNull(tabFolderManager);
Assert.isNotNull(tabItem);
this.tabFolderManager = tabFolderManager;
- // Remember the original tab item title
+ // Remember the tab item title
tabItemTitle = tabItem.getText();
attachTo(tabItem);
@@ -77,6 +78,9 @@ public class TabTerminalListener implements ITerminalListener2 {
@Override
public void setState(final TerminalState state) {
+ this.state = state;
+ updateTitle();
+
// The tab item must have been not yet disposed
final CTabItem item = getTabItem();
if (item == null || item.isDisposed())
@@ -84,11 +88,6 @@ public class TabTerminalListener implements ITerminalListener2 {
// Run asynchronously in the display thread
item.getDisplay().asyncExec(() -> {
- // Update the tab item title
- String newTitle = getTerminalConsoleTabTitle(state);
- if (newTitle != null)
- item.setText(newTitle);
-
// Turn off the command field (if necessary)
TabCommandFieldHandler handler = tabFolderManager.getTabCommandFieldHandler(item);
if (TerminalState.CLOSED.equals(state) && handler != null && handler.hasCommandInputField()) {
@@ -105,6 +104,26 @@ public class TabTerminalListener implements ITerminalListener2 {
});
}
+ private void updateTitle() {
+ if (state == null) {
+ // first setState hasn't happened yet, it will
+ // soon and the title will be update then.
+ return;
+ }
+ final CTabItem item = getTabItem();
+ if (item == null || item.isDisposed()) {
+ return;
+ }
+
+ // Run asynchronously in the display thread
+ item.getDisplay().asyncExec(() -> {
+ // Update the tab item title
+ String newTitle = getTerminalConsoleTabTitle(state);
+ if (newTitle != null)
+ item.setText(newTitle);
+ });
+ }
+
/**
* Returns the title to set to the terminal console tab for the given state.
* <p>
@@ -144,6 +163,8 @@ public class TabTerminalListener implements ITerminalListener2 {
@Override
public void setTerminalTitle(String title) {
+ tabItemTitle = title;
+ updateTitle();
}
/**

Back to the top