Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgraham committed Aug 18, 2023
1 parent 1aa7ce0 commit 7d6039a
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 47 deletions.
7 changes: 7 additions & 0 deletions NewAndNoteworthy/CDT-11.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ In cases where the configured binary parser does not support the launching of GN

# API Changes, current and planned

## New API to create terminal that blocks updating title from ANSI escape sequence

When calling `ITerminalService.openConsole(Map<String, Object> properties, Done done)` the `properties` understands a new key that allows the option to disable updating titles from ASNI Escape Sequences.
By setting `ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE` to `true` the title of the tab terminal will not be affected by ANSI escape sequences.

## Breaking API changes

Please see [CHANGELOG-API](CHANGELOG-API.md) for details on the breaking API changes in this release as well as future planned API changes.

# Noteworthy Issues and Pull Requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*******************************************************************************/
package org.eclipse.tm.terminal.connector.remote.internal;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.IOException;
import java.io.InputStream;

Expand All @@ -35,6 +33,7 @@
import org.eclipse.remote.core.IRemoteProcessTerminalService;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
import org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum TerminalTitleRequestor {
/**
* Set the title of the terminal.
*
* @param title Termianl title.
* @param title Terminal title.
* @param requestor Item that requests terminal title update.
*/
void setTerminalTitle(String title, TerminalTitleRequestor requestor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
******************************************************************************/
package org.eclipse.tm.internal.terminal.control;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
Expand Down Expand Up @@ -193,6 +192,7 @@ public interface ITerminalViewControl {
void removeMouseListener(ITerminalMouseListener listener);

/**
* @since 5.1
* @deprecated call {@link #setTerminalTitle(String, String)} instead
*/
@Deprecated(forRemoval = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.control.impl;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.OutputStream;

import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import static org.eclipse.tm.terminal.model.TerminalColor.RED;
import static org.eclipse.tm.terminal.model.TerminalColor.WHITE;
import static org.eclipse.tm.terminal.model.TerminalColor.YELLOW;
import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.IOException;
import java.io.Reader;
Expand All @@ -46,6 +45,7 @@
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
Expand Down Expand Up @@ -101,6 +99,7 @@
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
import org.eclipse.tm.internal.terminal.control.ITerminalListener2;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.provisional.api;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;

/**
* Represents the terminal view as seen by a terminal connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.connector;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.OutputStream;
import java.nio.charset.Charset;

import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.connector;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.OutputStream;
import java.nio.charset.Charset;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tm.internal.terminal.connector.TerminalConnector.Factory;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.speedtest;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;

import org.eclipse.swt.widgets.Display;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.speedtest;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;

import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*******************************************************************************/
package org.eclipse.tm.internal.terminal.test.ui;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
Expand All @@ -27,6 +25,7 @@
import java.io.Reader;
import java.nio.charset.StandardCharsets;

import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ public interface ITerminalsConnectorConstants {
public static final String PROP_TITLE = "title"; //$NON-NLS-1$

/**
* Property: Flag to set terminal title either using terminal API only or
* using terminal API and ANSI command.
* Property: Flag to disable updating the terminal title from ANSI escape sequences.
* <p>
* Property Type: {@link String}
* Property Type: {@link Boolean}
* @since 4.10
*/
public static final String PROP_TITLE_UPDATE_API = "titleUpdateAPI"; //$NON-NLS-1$
public static final String PROP_TITLE_DISABLE_ANSI_TITLE = "titleDisableAnsiTitle"; //$NON-NLS-1$

/**
* Property: The encoding of the terminal tab to open.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.view.ui;singleton:=true
Bundle-Version: 4.11.100.qualifier
Bundle-Version: 4.11.200.qualifier
Bundle-Activator: org.eclipse.tm.terminal.view.ui.activator.UIPlugin
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

package org.eclipse.tm.terminal.view.ui.actions;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.Window;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction;
import org.eclipse.tm.terminal.view.ui.nls.Messages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ public void doRun(String id, String secondaryId, String title, ITerminalConnecto
flags.put(ITerminalsConnectorConstants.PROP_DATA_NO_RECONNECT,
(Boolean) properties.get(ITerminalsConnectorConstants.PROP_DATA_NO_RECONNECT));
}
if (properties.get(ITerminalsConnectorConstants.PROP_TITLE_UPDATE_API) instanceof Boolean) {
flags.put(ITerminalsConnectorConstants.PROP_TITLE_UPDATE_API,
(Boolean) properties.get(ITerminalsConnectorConstants.PROP_TITLE_UPDATE_API));
if (properties.get(ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE) instanceof Boolean) {
flags.put(ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE,
(Boolean) properties.get(ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE));
} else {
flags.put(ITerminalsConnectorConstants.PROP_TITLE_UPDATE_API, false);
flags.put(ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE, false);
}
// Open the new console
CTabItem item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.tm.terminal.view.ui.tabs;

import static org.eclipse.tm.internal.terminal.control.ITerminalListener3.*;

import java.util.Map;

import org.eclipse.core.runtime.Assert;
Expand Down Expand Up @@ -121,16 +119,22 @@ private void updateTitle(final String title, final TerminalTitleRequestor reques
}
// Run asynchronously in the display thread
item.getDisplay().asyncExec(() -> {
Boolean flag = false;
if (item.isDisposed()) {
// tab has been closed
return;
}

// Get the original terminal properties associated with the tab item
@SuppressWarnings({ "unchecked" })
final Map<String, Object> properties = (Map<String, Object>) item.getData("properties"); //$NON-NLS-1$
if (properties.containsKey(ITerminalsConnectorConstants.PROP_TITLE_UPDATE_API)) {
flag = (Boolean) properties.get(ITerminalsConnectorConstants.PROP_TITLE_UPDATE_API);
}
// Check if terminal should be updated either using API only (flag == true)
// or using API and ANSI command (flag == false).
if (flag == true && requestor != null && requestor == TerminalTitleRequestor.ANSI) {
return;
if (properties.containsKey(ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE)) {
if (properties.get(
ITerminalsConnectorConstants.PROP_TITLE_DISABLE_ANSI_TITLE) instanceof Boolean disableAnsi) {
// Check if terminal title can be updated from ANSI escape sequence
if (disableAnsi && requestor == TerminalTitleRequestor.ANSI) {
return;
}
}
}

// New title must have value.
Expand Down Expand Up @@ -188,9 +192,9 @@ public void setTerminalTitle(final String title) {
}

/**
* Sets Terminal tilte and checks if originator is ANSI command.
* Sets Terminal title and checks if originator is ANSI command.
* If originator is ANSI command in terminal and user does not want to use
* ANSI command to upate terminal then return else update title.
* ANSI command to update terminal then return else update title.
* @param title Title to update.
* @param requestor Item that requests terminal title update.
*/
Expand Down

0 comments on commit 7d6039a

Please sign in to comment.