mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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
This commit is contained in:
parent
afd8342ec0
commit
fe00320854
1 changed files with 28 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue