mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 559474: Format all TM.terminal code to CDT standard
This is applying the per-project code formatting rules that would be applied on save in the JDT editor See also Bug 540373 Change-Id: Id04c972c3b3cb0a6ed1ab8581185359b7cf43f91
This commit is contained in:
parent
213770265a
commit
c58c28b9cc
243 changed files with 8230 additions and 7835 deletions
|
@ -114,7 +114,8 @@ public class Activator extends AbstractUIPlugin {
|
||||||
if (exception instanceof CoreException) {
|
if (exception instanceof CoreException) {
|
||||||
log(((CoreException) exception).getStatus());
|
log(((CoreException) exception).getStatus());
|
||||||
} else {
|
} else {
|
||||||
log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), exception.getLocalizedMessage(), exception));
|
log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), exception.getLocalizedMessage(),
|
||||||
|
exception));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,13 +246,10 @@ public class SerialSettingsPage extends AbstractSettingsPage {
|
||||||
settings.setStopBits(StopBits.fromStringIndex(stopBitsCombo.getSelectionIndex()));
|
settings.setStopBits(StopBits.fromStringIndex(stopBitsCombo.getSelectionIndex()));
|
||||||
|
|
||||||
dialogSettings.put(SerialSettings.PORT_NAME_ATTR, portCombo.getText());
|
dialogSettings.put(SerialSettings.PORT_NAME_ATTR, portCombo.getText());
|
||||||
dialogSettings.put(SerialSettings.BAUD_RATE_ATTR,
|
dialogSettings.put(SerialSettings.BAUD_RATE_ATTR, BaudRate.getStrings()[baudRateCombo.getSelectionIndex()]);
|
||||||
BaudRate.getStrings()[baudRateCombo.getSelectionIndex()]);
|
dialogSettings.put(SerialSettings.BYTE_SIZE_ATTR, ByteSize.getStrings()[byteSizeCombo.getSelectionIndex()]);
|
||||||
dialogSettings.put(SerialSettings.BYTE_SIZE_ATTR,
|
|
||||||
ByteSize.getStrings()[byteSizeCombo.getSelectionIndex()]);
|
|
||||||
dialogSettings.put(SerialSettings.PARITY_ATTR, Parity.getStrings()[parityCombo.getSelectionIndex()]);
|
dialogSettings.put(SerialSettings.PARITY_ATTR, Parity.getStrings()[parityCombo.getSelectionIndex()]);
|
||||||
dialogSettings.put(SerialSettings.STOP_BITS_ATTR,
|
dialogSettings.put(SerialSettings.STOP_BITS_ATTR, StopBits.getStrings()[stopBitsCombo.getSelectionIndex()]);
|
||||||
StopBits.getStrings()[stopBitsCombo.getSelectionIndex()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -66,7 +66,8 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
setEncoding("UTF-8"); //$NON-NLS-1$
|
setEncoding("UTF-8"); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
String encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
|
String encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
|
||||||
if (encoding != null && !"".equals(encoding)) setEncoding(encoding); //$NON-NLS-1$
|
if (encoding != null && !"".equals(encoding)) //$NON-NLS-1$
|
||||||
|
setEncoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the rest of the panel with a label to be able to
|
// Fill the rest of the panel with a label to be able to
|
||||||
|
@ -90,10 +91,12 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setupData(Map<String, Object> data) {
|
public void setupData(Map<String, Object> data) {
|
||||||
if (data == null) return;
|
if (data == null)
|
||||||
|
return;
|
||||||
|
|
||||||
String value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
String value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
||||||
if (value != null) setEncoding(value);
|
if (value != null)
|
||||||
|
setEncoding(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -102,7 +105,8 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
@Override
|
@Override
|
||||||
public void extractData(Map<String, Object> data) {
|
public void extractData(Map<String, Object> data) {
|
||||||
// set the terminal connector id for local terminal
|
// set the terminal connector id for local terminal
|
||||||
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.local.LocalConnector"); //$NON-NLS-1$
|
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID,
|
||||||
|
"org.eclipse.tm.terminal.connector.local.LocalConnector"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Store the encoding
|
// Store the encoding
|
||||||
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
||||||
|
@ -188,7 +192,8 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
return ((org.eclipse.core.resources.IResource) element);
|
return ((org.eclipse.core.resources.IResource) element);
|
||||||
}
|
}
|
||||||
if (element instanceof IAdaptable) {
|
if (element instanceof IAdaptable) {
|
||||||
return (org.eclipse.core.resources.IResource) ((IAdaptable) element).getAdapter(org.eclipse.core.resources.IResource.class);
|
return (org.eclipse.core.resources.IResource) ((IAdaptable) element)
|
||||||
|
.getAdapter(org.eclipse.core.resources.IResource.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -104,7 +104,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
} else {
|
} else {
|
||||||
encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
|
encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
|
||||||
}
|
}
|
||||||
if (encoding != null && !"".equals(encoding)) properties.put(ITerminalsConnectorConstants.PROP_ENCODING, encoding); //$NON-NLS-1$
|
if (encoding != null && !"".equals(encoding)) //$NON-NLS-1$
|
||||||
|
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For local terminals, force a new terminal tab each time it is launched,
|
// For local terminals, force a new terminal tab each time it is launched,
|
||||||
|
@ -115,9 +116,11 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
// Initialize the local terminal working directory.
|
// Initialize the local terminal working directory.
|
||||||
// By default, start the local terminal in the users home directory
|
// By default, start the local terminal in the users home directory
|
||||||
String initialCwd = org.eclipse.tm.terminal.view.ui.activator.UIPlugin.getScopedPreferences().getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
|
String initialCwd = org.eclipse.tm.terminal.view.ui.activator.UIPlugin.getScopedPreferences()
|
||||||
|
.getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
|
||||||
String cwd = null;
|
String cwd = null;
|
||||||
if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd) || "".equals(initialCwd.trim())) { //$NON-NLS-1$
|
if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd)
|
||||||
|
|| "".equals(initialCwd.trim())) { //$NON-NLS-1$
|
||||||
cwd = System.getProperty("user.home"); //$NON-NLS-1$
|
cwd = System.getProperty("user.home"); //$NON-NLS-1$
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
|
||||||
String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
|
String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
|
||||||
|
@ -126,7 +129,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
URI uri = URIUtil.fromString(eclipseHomeLocation);
|
URI uri = URIUtil.fromString(eclipseHomeLocation);
|
||||||
File f = URIUtil.toFile(uri);
|
File f = URIUtil.toFile(uri);
|
||||||
cwd = f.getAbsolutePath();
|
cwd = f.getAbsolutePath();
|
||||||
} catch (URISyntaxException ex) { /* ignored on purpose */ }
|
} catch (URISyntaxException ex) {
|
||||||
|
/* ignored on purpose */ }
|
||||||
}
|
}
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
|
@ -134,7 +138,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
||||||
cwd = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
|
cwd = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation()
|
||||||
|
.toOSString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,9 +166,11 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
// If the current selection resolved to an folder, default the working directory
|
// If the current selection resolved to an folder, default the working directory
|
||||||
// to that folder and update the terminal title
|
// to that folder and update the terminal title
|
||||||
ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
|
ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
|
||||||
if ((service != null && service.getSelection() != null) || properties.containsKey(ITerminalsConnectorConstants.PROP_SELECTION)) {
|
if ((service != null && service.getSelection() != null)
|
||||||
|
|| properties.containsKey(ITerminalsConnectorConstants.PROP_SELECTION)) {
|
||||||
ISelection selection = (ISelection) properties.get(ITerminalsConnectorConstants.PROP_SELECTION);
|
ISelection selection = (ISelection) properties.get(ITerminalsConnectorConstants.PROP_SELECTION);
|
||||||
if (selection == null) selection = service.getSelection();
|
if (selection == null)
|
||||||
|
selection = service.getSelection();
|
||||||
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
||||||
String dir = null;
|
String dir = null;
|
||||||
Iterator<?> iter = ((IStructuredSelection) selection).iterator();
|
Iterator<?> iter = ((IStructuredSelection) selection).iterator();
|
||||||
|
@ -171,18 +178,27 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
Object element = iter.next();
|
Object element = iter.next();
|
||||||
|
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED
|
||||||
|
&& bundle.getState() != Bundle.STOPPING) {
|
||||||
// If the element is not an IResource, try to adapt to IResource
|
// If the element is not an IResource, try to adapt to IResource
|
||||||
if (!(element instanceof org.eclipse.core.resources.IResource)) {
|
if (!(element instanceof org.eclipse.core.resources.IResource)) {
|
||||||
Object adapted = element instanceof IAdaptable ? ((IAdaptable)element).getAdapter(org.eclipse.core.resources.IResource.class) : null;
|
Object adapted = element instanceof IAdaptable
|
||||||
if (adapted == null) adapted = Platform.getAdapterManager().getAdapter(element, org.eclipse.core.resources.IResource.class);
|
? ((IAdaptable) element).getAdapter(org.eclipse.core.resources.IResource.class)
|
||||||
if (adapted != null) element = adapted;
|
: null;
|
||||||
|
if (adapted == null)
|
||||||
|
adapted = Platform.getAdapterManager().getAdapter(element,
|
||||||
|
org.eclipse.core.resources.IResource.class);
|
||||||
|
if (adapted != null)
|
||||||
|
element = adapted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof org.eclipse.core.resources.IResource && ((org.eclipse.core.resources.IResource)element).exists()) {
|
if (element instanceof org.eclipse.core.resources.IResource
|
||||||
|
&& ((org.eclipse.core.resources.IResource) element).exists()) {
|
||||||
IPath location = ((org.eclipse.core.resources.IResource) element).getLocation();
|
IPath location = ((org.eclipse.core.resources.IResource) element).getLocation();
|
||||||
if (location == null) continue;
|
if (location == null)
|
||||||
if (location.toFile().isFile()) location = location.removeLastSegments(1);
|
continue;
|
||||||
|
if (location.toFile().isFile())
|
||||||
|
location = location.removeLastSegments(1);
|
||||||
if (location.toFile().isDirectory() && location.toFile().canRead()) {
|
if (location.toFile().isDirectory() && location.toFile().canRead()) {
|
||||||
dir = location.toFile().getAbsolutePath();
|
dir = location.toFile().getAbsolutePath();
|
||||||
break;
|
break;
|
||||||
|
@ -225,14 +241,16 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
private String getTerminalTitle(Map<String, Object> properties) {
|
private String getTerminalTitle(Map<String, Object> properties) {
|
||||||
// Try to see if the user set a title explicitly via the properties map.
|
// Try to see if the user set a title explicitly via the properties map.
|
||||||
String title = getDefaultTerminalTitle(properties);
|
String title = getDefaultTerminalTitle(properties);
|
||||||
if (title != null) return title;
|
if (title != null)
|
||||||
|
return title;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String hostname = InetAddress.getLocalHost().getHostName();
|
String hostname = InetAddress.getLocalHost().getHostName();
|
||||||
if (hostname != null && !"".equals(hostname.trim())) { //$NON-NLS-1$
|
if (hostname != null && !"".equals(hostname.trim())) { //$NON-NLS-1$
|
||||||
return hostname;
|
return hostname;
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) { /* ignored on purpose */ }
|
} catch (UnknownHostException e) {
|
||||||
|
/* ignored on purpose */ }
|
||||||
|
|
||||||
return "Local"; //$NON-NLS-1$
|
return "Local"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -264,7 +282,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shell == null) {
|
if (shell == null) {
|
||||||
shell = org.eclipse.tm.terminal.view.ui.activator.UIPlugin.getScopedPreferences().getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_DEFAULT_SHELL_UNIX);
|
shell = org.eclipse.tm.terminal.view.ui.activator.UIPlugin.getScopedPreferences()
|
||||||
|
.getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_DEFAULT_SHELL_UNIX);
|
||||||
if (shell == null || "".equals(shell)) { //$NON-NLS-1$
|
if (shell == null || "".equals(shell)) { //$NON-NLS-1$
|
||||||
if (System.getenv("SHELL") != null && !"".equals(System.getenv("SHELL").trim())) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
if (System.getenv("SHELL") != null && !"".equals(System.getenv("SHELL").trim())) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
shell = System.getenv("SHELL").trim(); //$NON-NLS-1$
|
shell = System.getenv("SHELL").trim(); //$NON-NLS-1$
|
||||||
|
@ -286,7 +305,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
// Check for the terminal connector id
|
// Check for the terminal connector id
|
||||||
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
||||||
if (connectorId == null) connectorId = "org.eclipse.tm.terminal.connector.local.LocalConnector"; //$NON-NLS-1$
|
if (connectorId == null)
|
||||||
|
connectorId = "org.eclipse.tm.terminal.connector.local.LocalConnector"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Extract the process properties using defaults
|
// Extract the process properties using defaults
|
||||||
String image;
|
String image;
|
||||||
|
@ -300,11 +320,13 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
String arguments = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS);
|
String arguments = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS);
|
||||||
if (arguments == null && !Platform.OS_WIN32.equals(Platform.getOS())) {
|
if (arguments == null && !Platform.OS_WIN32.equals(Platform.getOS())) {
|
||||||
arguments = org.eclipse.tm.terminal.view.ui.activator.UIPlugin.getScopedPreferences().getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_DEFAULT_SHELL_UNIX_ARGS);
|
arguments = org.eclipse.tm.terminal.view.ui.activator.UIPlugin.getScopedPreferences()
|
||||||
|
.getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_DEFAULT_SHELL_UNIX_ARGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if a PTY will be used
|
// Determine if a PTY will be used
|
||||||
boolean isUsingPTY = (properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ) == null && PTY.isSupported(PTY.Mode.TERMINAL))
|
boolean isUsingPTY = (properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ) == null
|
||||||
|
&& PTY.isSupported(PTY.Mode.TERMINAL))
|
||||||
|| properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ) instanceof PTY;
|
|| properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ) instanceof PTY;
|
||||||
|
|
||||||
boolean localEcho = false;
|
boolean localEcho = false;
|
||||||
|
@ -323,7 +345,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|| !(properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) instanceof String)) {
|
|| !(properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) instanceof String)) {
|
||||||
// No line separator will be set if a PTY is used
|
// No line separator will be set if a PTY is used
|
||||||
if (!isUsingPTY) {
|
if (!isUsingPTY) {
|
||||||
lineSeparator = Platform.OS_WIN32.equals(Platform.getOS()) ? ILineSeparatorConstants.LINE_SEPARATOR_CRLF : ILineSeparatorConstants.LINE_SEPARATOR_LF;
|
lineSeparator = Platform.OS_WIN32.equals(Platform.getOS()) ? ILineSeparatorConstants.LINE_SEPARATOR_CRLF
|
||||||
|
: ILineSeparatorConstants.LINE_SEPARATOR_LF;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lineSeparator = (String) properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
|
lineSeparator = (String) properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
|
||||||
|
@ -331,20 +354,23 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
Process process = (Process) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ);
|
Process process = (Process) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ);
|
||||||
PTY pty = (PTY) properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ);
|
PTY pty = (PTY) properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ);
|
||||||
ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS);
|
ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
|
||||||
ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS);
|
.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS);
|
||||||
|
ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
|
||||||
|
.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS);
|
||||||
String workingDir = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
|
String workingDir = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
|
||||||
|
|
||||||
String[] envp = null;
|
String[] envp = null;
|
||||||
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) &&
|
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT)
|
||||||
properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null &&
|
&& properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null
|
||||||
properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]){
|
&& properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]) {
|
||||||
envp = (String[]) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT);
|
envp = (String[]) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the ECLIPSE_HOME and ECLIPSE_WORKSPACE environment variables
|
// Set the ECLIPSE_HOME and ECLIPSE_WORKSPACE environment variables
|
||||||
List<String> envpList = new ArrayList<String>();
|
List<String> envpList = new ArrayList<String>();
|
||||||
if (envp != null) envpList.addAll(Arrays.asList(envp));
|
if (envp != null)
|
||||||
|
envpList.addAll(Arrays.asList(envp));
|
||||||
|
|
||||||
// ECLIPSE_HOME
|
// ECLIPSE_HOME
|
||||||
String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
|
String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
|
||||||
|
@ -353,7 +379,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
URI uri = URIUtil.fromString(eclipseHomeLocation);
|
URI uri = URIUtil.fromString(eclipseHomeLocation);
|
||||||
File f = URIUtil.toFile(uri);
|
File f = URIUtil.toFile(uri);
|
||||||
envpList.add("ECLIPSE_HOME=" + f.getAbsolutePath()); //$NON-NLS-1$
|
envpList.add("ECLIPSE_HOME=" + f.getAbsolutePath()); //$NON-NLS-1$
|
||||||
} catch (URISyntaxException e) { /* ignored on purpose */ }
|
} catch (URISyntaxException e) {
|
||||||
|
/* ignored on purpose */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECLIPSE_WORKSPACE
|
// ECLIPSE_WORKSPACE
|
||||||
|
@ -362,7 +389,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
||||||
envpList.add("ECLIPSE_WORKSPACE=" + org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); //$NON-NLS-1$
|
envpList.add("ECLIPSE_WORKSPACE=" + org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() //$NON-NLS-1$
|
||||||
|
.getLocation().toOSString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +417,8 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) {
|
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) {
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT);
|
||||||
processSettings.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean)value).booleanValue() : false);
|
processSettings
|
||||||
|
.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean) value).booleanValue() : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And save the settings to the store
|
// And save the settings to the store
|
||||||
|
|
|
@ -48,8 +48,10 @@ public class LocalLauncherHandler extends AbstractHandler {
|
||||||
if (input instanceof IPathEditorInput) {
|
if (input instanceof IPathEditorInput) {
|
||||||
IPath path = ((IPathEditorInput) input).getPath();
|
IPath path = ((IPathEditorInput) input).getPath();
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
if (path.toFile().isFile()) path = path.removeLastSegments(1);
|
if (path.toFile().isFile())
|
||||||
if (path.toFile().isDirectory() && path.toFile().canRead()) selection = new StructuredSelection(path);
|
path = path.removeLastSegments(1);
|
||||||
|
if (path.toFile().isDirectory() && path.toFile().canRead())
|
||||||
|
selection = new StructuredSelection(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,8 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the process
|
// Execute the process
|
||||||
process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), envp, workingDir, pty);
|
process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), envp, workingDir,
|
||||||
|
pty);
|
||||||
} else {
|
} else {
|
||||||
// No PTY -> just execute via the standard Java Runtime implementation.
|
// No PTY -> just execute via the standard Java Runtime implementation.
|
||||||
process = Runtime.getRuntime().exec(command.toString(), envp, workingDir);
|
process = Runtime.getRuntime().exec(command.toString(), envp, workingDir);
|
||||||
|
@ -177,11 +178,9 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
|
lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
if ("\r".equals(lineSeparator)) { //$NON-NLS-1$
|
if ("\r".equals(lineSeparator)) { //$NON-NLS-1$
|
||||||
lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CR;
|
lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CR;
|
||||||
}
|
} else if ("\n".equals(lineSeparator)) { //$NON-NLS-1$
|
||||||
else if ("\n".equals(lineSeparator)) { //$NON-NLS-1$
|
|
||||||
lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_LF;
|
lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_LF;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CRLF;
|
lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CRLF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +195,8 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
control.setVT100LineWrapping(true);
|
control.setVT100LineWrapping(true);
|
||||||
|
|
||||||
// connect the streams
|
// connect the streams
|
||||||
connectStreams(control, process.getOutputStream(), process.getInputStream(), (pty == null ? process.getErrorStream() : null), settings.isLocalEcho(), lineSeparator);
|
connectStreams(control, process.getOutputStream(), process.getInputStream(),
|
||||||
|
(pty == null ? process.getErrorStream() : null), settings.isLocalEcho(), lineSeparator);
|
||||||
|
|
||||||
// Set the terminal control state to CONNECTED
|
// Set the terminal control state to CONNECTED
|
||||||
control.setState(TerminalState.CONNECTED);
|
control.setState(TerminalState.CONNECTED);
|
||||||
|
@ -209,7 +209,8 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
disconnect();
|
disconnect();
|
||||||
// Lookup the tab item
|
// Lookup the tab item
|
||||||
CTabItem item = ConsoleManager.getInstance().findConsole(control);
|
CTabItem item = ConsoleManager.getInstance().findConsole(control);
|
||||||
if (item != null) item.dispose();
|
if (item != null)
|
||||||
|
item.dispose();
|
||||||
// Get the error message from the exception
|
// Get the error message from the exception
|
||||||
String msg = e.getLocalizedMessage() != null ? e.getLocalizedMessage() : ""; //$NON-NLS-1$
|
String msg = e.getLocalizedMessage() != null ? e.getLocalizedMessage() : ""; //$NON-NLS-1$
|
||||||
Assert.isNotNull(msg);
|
Assert.isNotNull(msg);
|
||||||
|
@ -252,7 +253,10 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
|
|
||||||
if (!isWindows) {
|
if (!isWindows) {
|
||||||
// Destroy the process first, except on windows (Bug 465674)
|
// Destroy the process first, except on windows (Bug 465674)
|
||||||
if (process != null) { process.destroy(); process = null; }
|
if (process != null) {
|
||||||
|
process.destroy();
|
||||||
|
process = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose the streams
|
// Dispose the streams
|
||||||
|
@ -260,7 +264,10 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
// On Windows destroy the process after closing streams
|
// On Windows destroy the process after closing streams
|
||||||
if (process != null) { process.destroy(); process = null; }
|
if (process != null) {
|
||||||
|
process.destroy();
|
||||||
|
process = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the terminal control state to CLOSED.
|
// Set the terminal control state to CLOSED.
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class ProcessLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
// Check for the terminal connector id
|
// Check for the terminal connector id
|
||||||
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
||||||
if (connectorId == null) connectorId = "org.eclipse.tm.terminal.connector.process.ProcessConnector"; //$NON-NLS-1$
|
if (connectorId == null)
|
||||||
|
connectorId = "org.eclipse.tm.terminal.connector.process.ProcessConnector"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Extract the process properties
|
// Extract the process properties
|
||||||
String image = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
|
String image = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
|
||||||
|
@ -83,14 +84,16 @@ public class ProcessLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
|
||||||
boolean localEcho = value instanceof Boolean ? ((Boolean) value).booleanValue() : false;
|
boolean localEcho = value instanceof Boolean ? ((Boolean) value).booleanValue() : false;
|
||||||
String lineSeparator = (String) properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
|
String lineSeparator = (String) properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
|
||||||
ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS);
|
ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
|
||||||
ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS);
|
.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS);
|
||||||
|
ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
|
||||||
|
.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS);
|
||||||
String workingDir = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
|
String workingDir = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
|
||||||
|
|
||||||
String[] envp = null;
|
String[] envp = null;
|
||||||
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) &&
|
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT)
|
||||||
properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null &&
|
&& properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null
|
||||||
properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]){
|
&& properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]) {
|
||||||
envp = (String[]) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT);
|
envp = (String[]) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +117,8 @@ public class ProcessLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) {
|
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) {
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT);
|
value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT);
|
||||||
processSettings.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean)value).booleanValue() : false);
|
processSettings
|
||||||
|
.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean) value).booleanValue() : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And save the settings to the store
|
// And save the settings to the store
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.tm.terminal.connector.process;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process monitor implementation.
|
* Process monitor implementation.
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +26,6 @@ public class ProcessMonitor {
|
||||||
// Flag to mark the monitor disposed
|
// Flag to mark the monitor disposed
|
||||||
private boolean disposed;
|
private boolean disposed;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -50,7 +48,8 @@ public class ProcessMonitor {
|
||||||
// Set the disposed status
|
// Set the disposed status
|
||||||
disposed = true;
|
disposed = true;
|
||||||
// Not initialized -> return immediately
|
// Not initialized -> return immediately
|
||||||
if (thread == null) return;
|
if (thread == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Copy the reference
|
// Copy the reference
|
||||||
final Thread oldThread = thread;
|
final Thread oldThread = thread;
|
||||||
|
@ -65,7 +64,8 @@ public class ProcessMonitor {
|
||||||
*/
|
*/
|
||||||
public void startMonitoring() {
|
public void startMonitoring() {
|
||||||
// If already initialized -> return immediately
|
// If already initialized -> return immediately
|
||||||
if (thread != null) return;
|
if (thread != null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Create a new runnable which is constantly reading from the stream
|
// Create a new runnable which is constantly reading from the stream
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
|
@ -91,7 +91,8 @@ public class ProcessMonitor {
|
||||||
*/
|
*/
|
||||||
public void monitorProcess() {
|
public void monitorProcess() {
|
||||||
// If already disposed -> return immediately
|
// If already disposed -> return immediately
|
||||||
if (disposed) return;
|
if (disposed)
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Wait for the monitored process to terminate
|
// Wait for the monitored process to terminate
|
||||||
|
|
|
@ -113,7 +113,8 @@ public class ProcessSettings {
|
||||||
public void setPTY(PTY pty) {
|
public void setPTY(PTY pty) {
|
||||||
this.pty = pty;
|
this.pty = pty;
|
||||||
// If the PTY is set to "null", the local echo will be set to "true"
|
// If the PTY is set to "null", the local echo will be set to "true"
|
||||||
if (pty == null) setLocalEcho(true);
|
if (pty == null)
|
||||||
|
setLocalEcho(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,14 +266,17 @@ public class ProcessSettings {
|
||||||
image = store.get("Path", null);//$NON-NLS-1$
|
image = store.get("Path", null);//$NON-NLS-1$
|
||||||
arguments = store.get("Arguments", null); //$NON-NLS-1$
|
arguments = store.get("Arguments", null); //$NON-NLS-1$
|
||||||
localEcho = Boolean.parseBoolean(store.get("LocalEcho", Boolean.FALSE.toString())); //$NON-NLS-1$
|
localEcho = Boolean.parseBoolean(store.get("LocalEcho", Boolean.FALSE.toString())); //$NON-NLS-1$
|
||||||
mergeWithNativeEnvironment = Boolean.parseBoolean(store.get("MergeWithNativeEnvironment", Boolean.FALSE.toString())); //$NON-NLS-1$
|
mergeWithNativeEnvironment = Boolean
|
||||||
|
.parseBoolean(store.get("MergeWithNativeEnvironment", Boolean.FALSE.toString())); //$NON-NLS-1$
|
||||||
lineSeparator = store.get("LineSeparator", null); //$NON-NLS-1$
|
lineSeparator = store.get("LineSeparator", null); //$NON-NLS-1$
|
||||||
workingDir = store.get("WorkingDir", null); //$NON-NLS-1$
|
workingDir = store.get("WorkingDir", null); //$NON-NLS-1$
|
||||||
if (store instanceof SettingsStore) {
|
if (store instanceof SettingsStore) {
|
||||||
process = (Process) ((SettingsStore) store).getSettings().get("Process"); //$NON-NLS-1$
|
process = (Process) ((SettingsStore) store).getSettings().get("Process"); //$NON-NLS-1$
|
||||||
pty = (PTY) ((SettingsStore) store).getSettings().get("PTY"); //$NON-NLS-1$
|
pty = (PTY) ((SettingsStore) store).getSettings().get("PTY"); //$NON-NLS-1$
|
||||||
stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[])((SettingsStore)store).getSettings().get("StdOutListeners"); //$NON-NLS-1$
|
stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[]) ((SettingsStore) store).getSettings()
|
||||||
stderrListeners = (ITerminalServiceOutputStreamMonitorListener[])((SettingsStore)store).getSettings().get("StdErrListeners"); //$NON-NLS-1$
|
.get("StdOutListeners"); //$NON-NLS-1$
|
||||||
|
stderrListeners = (ITerminalServiceOutputStreamMonitorListener[]) ((SettingsStore) store).getSettings()
|
||||||
|
.get("StdErrListeners"); //$NON-NLS-1$
|
||||||
environment = (String[]) ((SettingsStore) store).getSettings().get("Environment"); //$NON-NLS-1$
|
environment = (String[]) ((SettingsStore) store).getSettings().get("Environment"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@ public class ProcessSettingsPage extends AbstractSettingsPage {
|
||||||
// The entry fields shall be properly aligned
|
// The entry fields shall be properly aligned
|
||||||
Composite panel = new Composite(composite, SWT.NONE);
|
Composite panel = new Composite(composite, SWT.NONE);
|
||||||
GridLayout layout = new GridLayout(2, false);
|
GridLayout layout = new GridLayout(2, false);
|
||||||
layout.marginWidth = 0; layout.marginHeight = 0;
|
layout.marginWidth = 0;
|
||||||
|
layout.marginHeight = 0;
|
||||||
panel.setLayout(layout);
|
panel.setLayout(layout);
|
||||||
panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
|
||||||
|
@ -80,7 +81,8 @@ public class ProcessSettingsPage extends AbstractSettingsPage {
|
||||||
// Text field and browse button are aligned it their own panel
|
// Text field and browse button are aligned it their own panel
|
||||||
Composite innerPanel = new Composite(panel, SWT.NONE);
|
Composite innerPanel = new Composite(panel, SWT.NONE);
|
||||||
layout = new GridLayout(2, false);
|
layout = new GridLayout(2, false);
|
||||||
layout.marginWidth = 0; layout.marginHeight = 0;
|
layout.marginWidth = 0;
|
||||||
|
layout.marginHeight = 0;
|
||||||
innerPanel.setLayout(layout);
|
innerPanel.setLayout(layout);
|
||||||
innerPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
innerPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
|
||||||
|
@ -127,7 +129,8 @@ public class ProcessSettingsPage extends AbstractSettingsPage {
|
||||||
*/
|
*/
|
||||||
protected void onBrowseButtonSelected(SelectionEvent e) {
|
protected void onBrowseButtonSelected(SelectionEvent e) {
|
||||||
// Determine the shell
|
// Determine the shell
|
||||||
Shell shell = e != null ? e.widget.getDisplay().getActiveShell() : PlatformUI.getWorkbench().getDisplay().getActiveShell();
|
Shell shell = e != null ? e.widget.getDisplay().getActiveShell()
|
||||||
|
: PlatformUI.getWorkbench().getDisplay().getActiveShell();
|
||||||
|
|
||||||
// create a standard file dialog
|
// create a standard file dialog
|
||||||
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
|
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
|
||||||
|
@ -141,7 +144,8 @@ public class ProcessSettingsPage extends AbstractSettingsPage {
|
||||||
IPath filePath = new Path(selectedFile);
|
IPath filePath = new Path(selectedFile);
|
||||||
// If the selected file points to an directory, use the directory as is
|
// If the selected file points to an directory, use the directory as is
|
||||||
IPath filterPath = filePath.toFile().isDirectory() ? filePath : filePath.removeLastSegments(1);
|
IPath filterPath = filePath.toFile().isDirectory() ? filePath : filePath.removeLastSegments(1);
|
||||||
String filterFileName = filePath.toFile().isDirectory() || !filePath.toFile().exists() ? null : filePath.lastSegment();
|
String filterFileName = filePath.toFile().isDirectory() || !filePath.toFile().exists() ? null
|
||||||
|
: filePath.lastSegment();
|
||||||
|
|
||||||
if (!filterPath.isEmpty()) {
|
if (!filterPath.isEmpty()) {
|
||||||
dialog.setFilterPath(filterPath.toString());
|
dialog.setFilterPath(filterPath.toString());
|
||||||
|
@ -152,7 +156,8 @@ public class ProcessSettingsPage extends AbstractSettingsPage {
|
||||||
} else {
|
} else {
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
dialog.setFilterPath(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
|
dialog.setFilterPath(
|
||||||
|
org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.tm.terminal.connector.process.help;
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.connector.process.activator.UIPlugin;
|
import org.eclipse.tm.terminal.connector.process.activator.UIPlugin;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context help id definitions.
|
* Context help id definitions.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -103,7 +103,8 @@ public class ArgumentParser {
|
||||||
* string. Allows escaping.
|
* string. Allows escaping.
|
||||||
*/
|
*/
|
||||||
iterator.next(); // Skip quote
|
iterator.next(); // Skip quote
|
||||||
quoted_reader: while ((iterator.current() != CharacterIterator.DONE) && (iterator.current() != '"')) {
|
quoted_reader: while ((iterator.current() != CharacterIterator.DONE)
|
||||||
|
&& (iterator.current() != '"')) {
|
||||||
char innerChar = iterator.current();
|
char innerChar = iterator.current();
|
||||||
switch (innerChar) {
|
switch (innerChar) {
|
||||||
case '\\':
|
case '\\':
|
||||||
|
|
|
@ -79,15 +79,15 @@ public class RemoteConnectionManager extends Job {
|
||||||
remoteConnection = connType.getConnection(connector.getRemoteSettings().getConnectionName());
|
remoteConnection = connType.getConnection(connector.getRemoteSettings().getConnectionName());
|
||||||
}
|
}
|
||||||
if (remoteConnection == null) {
|
if (remoteConnection == null) {
|
||||||
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
|
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), NLS
|
||||||
NLS.bind(Messages.RemoteConnectionManager_0, connector.getRemoteSettings().getConnectionName()));
|
.bind(Messages.RemoteConnectionManager_0, connector.getRemoteSettings().getConnectionName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!remoteConnection.isOpen()) {
|
if (!remoteConnection.isOpen()) {
|
||||||
remoteConnection.open(monitor);
|
remoteConnection.open(monitor);
|
||||||
if (!remoteConnection.isOpen()) {
|
if (!remoteConnection.isOpen()) {
|
||||||
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
|
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), NLS.bind(
|
||||||
NLS.bind(Messages.RemoteConnectionManager_1, connector.getRemoteSettings().getConnectionName()));
|
Messages.RemoteConnectionManager_1, connector.getRemoteSettings().getConnectionName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,8 @@ public class RemoteConnectionManager extends Job {
|
||||||
String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$
|
String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$
|
||||||
if ("".equals(terminalShellCommand) //$NON-NLS-1$
|
if ("".equals(terminalShellCommand) //$NON-NLS-1$
|
||||||
&& remoteConnection.hasService(IRemoteCommandShellService.class)) {
|
&& remoteConnection.hasService(IRemoteCommandShellService.class)) {
|
||||||
IRemoteCommandShellService cmdShellSvc = remoteConnection.getService(IRemoteCommandShellService.class);
|
IRemoteCommandShellService cmdShellSvc = remoteConnection
|
||||||
|
.getService(IRemoteCommandShellService.class);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
|
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,8 @@ public class RemoteConnectionManager extends Job {
|
||||||
.getProcessBuilder(new ArgumentParser(terminalShellCommand).getTokenList());
|
.getProcessBuilder(new ArgumentParser(terminalShellCommand).getTokenList());
|
||||||
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
|
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
|
||||||
} else {
|
} else {
|
||||||
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), Messages.RemoteConnectionManager_2);
|
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
|
||||||
|
Messages.RemoteConnectionManager_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
||||||
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
|
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
|
||||||
if (fRemoteConnectionWidget.getConnection() != null) {
|
if (fRemoteConnectionWidget.getConnection() != null) {
|
||||||
if (fRemoteConnectionWidget.getConnection().getConnectionType() != null) {
|
if (fRemoteConnectionWidget.getConnection().getConnectionType() != null) {
|
||||||
fTerminalSettings.setConnectionTypeId(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
|
fTerminalSettings
|
||||||
|
.setConnectionTypeId(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
|
||||||
}
|
}
|
||||||
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
|
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
|
||||||
}
|
}
|
||||||
|
@ -50,7 +51,8 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings() {
|
public void loadSettings() {
|
||||||
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
|
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
|
||||||
fRemoteConnectionWidget.setConnection(fTerminalSettings.getConnectionTypeId(), fTerminalSettings.getConnectionName());
|
fRemoteConnectionWidget.setConnection(fTerminalSettings.getConnectionTypeId(),
|
||||||
|
fTerminalSettings.getConnectionName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,8 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
private String getTerminalTitle(Map<String, Object> properties) {
|
private String getTerminalTitle(Map<String, Object> properties) {
|
||||||
// Try to see if the user set a title explicitly via the properties map.
|
// Try to see if the user set a title explicitly via the properties map.
|
||||||
String title = getDefaultTerminalTitle(properties);
|
String title = getDefaultTerminalTitle(properties);
|
||||||
if (title != null) return title;
|
if (title != null)
|
||||||
|
return title;
|
||||||
|
|
||||||
String connection = (String) properties.get(IRemoteSettings.CONNECTION_NAME);
|
String connection = (String) properties.get(IRemoteSettings.CONNECTION_NAME);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class RemoteMementoHandler implements IMementoHandler {
|
||||||
// Do not write the terminal title to the memento -> needs to
|
// Do not write the terminal title to the memento -> needs to
|
||||||
// be recreated at the time of restoration.
|
// be recreated at the time of restoration.
|
||||||
memento.putString(IRemoteSettings.CONNECTION_NAME, (String) properties.get(IRemoteSettings.CONNECTION_NAME));
|
memento.putString(IRemoteSettings.CONNECTION_NAME, (String) properties.get(IRemoteSettings.CONNECTION_NAME));
|
||||||
memento.putString(IRemoteSettings.CONNECTION_TYPE_ID, (String) properties.get(IRemoteSettings.CONNECTION_TYPE_ID));
|
memento.putString(IRemoteSettings.CONNECTION_TYPE_ID,
|
||||||
|
(String) properties.get(IRemoteSettings.CONNECTION_TYPE_ID));
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING,
|
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING,
|
||||||
(String) properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
|
(String) properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,7 @@ public class RemoteMementoHandler implements IMementoHandler {
|
||||||
// Restore the terminal properties from the memento
|
// Restore the terminal properties from the memento
|
||||||
properties.put(IRemoteSettings.CONNECTION_NAME, memento.getString(IRemoteSettings.CONNECTION_NAME));
|
properties.put(IRemoteSettings.CONNECTION_NAME, memento.getString(IRemoteSettings.CONNECTION_NAME));
|
||||||
properties.put(IRemoteSettings.CONNECTION_TYPE_ID, memento.getString(IRemoteSettings.CONNECTION_TYPE_ID));
|
properties.put(IRemoteSettings.CONNECTION_TYPE_ID, memento.getString(IRemoteSettings.CONNECTION_TYPE_ID));
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
properties.put(ITerminalsConnectorConstants.PROP_ENCODING,
|
||||||
|
memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.terminal.connector.ssh.connector;
|
package org.eclipse.tm.terminal.connector.ssh.connector;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the constants used by the terminal.ssh Plugin
|
* Defines the constants used by the terminal.ssh Plugin
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -57,13 +57,8 @@ public class KeyboardInteractiveDialog extends TrayDialog {
|
||||||
* @param prompt the titles for textfields
|
* @param prompt the titles for textfields
|
||||||
* @param echo '*' should be used or not
|
* @param echo '*' should be used or not
|
||||||
*/
|
*/
|
||||||
public KeyboardInteractiveDialog(Shell parentShell,
|
public KeyboardInteractiveDialog(Shell parentShell, String connectionId, String destination, String name,
|
||||||
String connectionId,
|
String instruction, String[] prompt, boolean[] echo) {
|
||||||
String destination,
|
|
||||||
String name,
|
|
||||||
String instruction,
|
|
||||||
String[] prompt,
|
|
||||||
boolean[] echo){
|
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
this.domain = connectionId;
|
this.domain = connectionId;
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
|
@ -71,8 +66,10 @@ public class KeyboardInteractiveDialog extends TrayDialog {
|
||||||
this.instruction = instruction;
|
this.instruction = instruction;
|
||||||
this.prompt = prompt;
|
this.prompt = prompt;
|
||||||
this.echo = echo;
|
this.echo = echo;
|
||||||
this.message=NLS.bind(SshMessages.KeyboardInteractiveDialog_message, new String[] { destination+(name!=null && name.length()>0 ? ": "+name : "") }); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
|
this.message = NLS.bind(SshMessages.KeyboardInteractiveDialog_message,
|
||||||
|
new String[] { destination + (name != null && name.length() > 0 ? ": " + name : "") }); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Window#configureShell
|
* @see Window#configureShell
|
||||||
*/
|
*/
|
||||||
|
@ -81,6 +78,7 @@ protected void configureShell(Shell newShell) {
|
||||||
super.configureShell(newShell);
|
super.configureShell(newShell);
|
||||||
newShell.setText(message);
|
newShell.setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Window#create
|
* @see Window#create
|
||||||
*/
|
*/
|
||||||
|
@ -91,6 +89,7 @@ public void create() {
|
||||||
texts[0].setFocus();
|
texts[0].setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Dialog#createDialogArea
|
* @see Dialog#createDialogArea
|
||||||
*/
|
*/
|
||||||
|
@ -129,6 +128,7 @@ protected Control createDialogArea(Composite parent) {
|
||||||
createPasswordFields(main);
|
createPasswordFields(main);
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the widgets that represent the entry area.
|
* Creates the widgets that represent the entry area.
|
||||||
*
|
*
|
||||||
|
@ -152,6 +152,7 @@ protected void createPasswordFields(Composite parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entered values, or null
|
* Returns the entered values, or null
|
||||||
* if the user cancelled.
|
* if the user cancelled.
|
||||||
|
@ -161,6 +162,7 @@ protected void createPasswordFields(Composite parent) {
|
||||||
public String[] getResult() {
|
public String[] getResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies that the ok button of this dialog has been pressed.
|
* Notifies that the ok button of this dialog has been pressed.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -177,6 +179,7 @@ protected void okPressed() {
|
||||||
}
|
}
|
||||||
super.okPressed();
|
super.okPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies that the cancel button of this dialog has been pressed.
|
* Notifies that the cancel button of this dialog has been pressed.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class SshConnection extends Thread {
|
||||||
private final SshConnector fConn;
|
private final SshConnector fConn;
|
||||||
private Session fSession;
|
private Session fSession;
|
||||||
private boolean fDisconnectHasBeenCalled;
|
private boolean fDisconnectHasBeenCalled;
|
||||||
|
|
||||||
protected SshConnection(SshConnector conn, ITerminalControl control) {
|
protected SshConnection(SshConnector conn, ITerminalControl control) {
|
||||||
super("SshConnection-" + fgNo++); //$NON-NLS-1$
|
super("SshConnection-" + fgNo++); //$NON-NLS-1$
|
||||||
fControl = control;
|
fControl = control;
|
||||||
|
@ -72,7 +73,8 @@ public class SshConnection extends Thread {
|
||||||
* the Jsch config (for instance, in order to switch off strict
|
* the Jsch config (for instance, in order to switch off strict
|
||||||
* host key checking or in order to add specific ciphers).
|
* host key checking or in order to add specific ciphers).
|
||||||
*/
|
*/
|
||||||
protected Session createSession(String username, String password, String hostname, int port, UserInfo wrapperUI, IProgressMonitor monitor) throws JSchException {
|
protected Session createSession(String username, String password, String hostname, int port, UserInfo wrapperUI,
|
||||||
|
IProgressMonitor monitor) throws JSchException {
|
||||||
IJSchService service = UIPlugin.getDefault().getJSchService();
|
IJSchService service = UIPlugin.getDefault().getJSchService();
|
||||||
if (service == null)
|
if (service == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -109,8 +111,7 @@ public class SshConnection extends Thread {
|
||||||
|
|
||||||
UserInfo ui = new MyUserInfo(null, user, password);
|
UserInfo ui = new MyUserInfo(null, user, password);
|
||||||
|
|
||||||
Session session = createSession(user, password, host, port,
|
Session session = createSession(user, password, host, port, ui, new NullProgressMonitor());
|
||||||
ui, new NullProgressMonitor());
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
fSession = session;
|
fSession = session;
|
||||||
}
|
}
|
||||||
|
@ -207,6 +208,7 @@ public class SshConnection extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the data from the ssh connection and display it in the terminal.
|
* Read the data from the ssh connection and display it in the terminal.
|
||||||
* @param in
|
* @param in
|
||||||
|
@ -242,10 +244,12 @@ public class SshConnection extends Thread {
|
||||||
fUser = user;
|
fUser = user;
|
||||||
fPassword = password;
|
fPassword = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return fPassword;
|
return fPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean promptYesNo(final String str) {
|
public boolean promptYesNo(final String str) {
|
||||||
//need to switch to UI thread for prompting
|
//need to switch to UI thread for prompting
|
||||||
|
@ -267,6 +271,7 @@ public class SshConnection extends Thread {
|
||||||
});
|
});
|
||||||
return retval[0];
|
return retval[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private String promptSecret(final String message) {
|
private String promptSecret(final String message) {
|
||||||
final String[] retval = new String[1];
|
final String[] retval = new String[1];
|
||||||
getStandardDisplay().syncExec(new Runnable() {
|
getStandardDisplay().syncExec(new Runnable() {
|
||||||
|
@ -287,15 +292,18 @@ public class SshConnection extends Thread {
|
||||||
});
|
});
|
||||||
return retval[0];
|
return retval[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPassphrase() {
|
public String getPassphrase() {
|
||||||
return fPassphrase;
|
return fPassphrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean promptPassphrase(String message) {
|
public boolean promptPassphrase(String message) {
|
||||||
fPassphrase = promptSecret(message);
|
fPassphrase = promptSecret(message);
|
||||||
return (fPassphrase != null);
|
return (fPassphrase != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean promptPassword(final String message) {
|
public boolean promptPassword(final String message) {
|
||||||
String _password = promptSecret(message);
|
String _password = promptSecret(message);
|
||||||
|
@ -305,6 +313,7 @@ public class SshConnection extends Thread {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMessage(final String message) {
|
public void showMessage(final String message) {
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(new Runnable() {
|
||||||
|
@ -321,17 +330,17 @@ public class SshConnection extends Thread {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] promptKeyboardInteractive(final String destination,
|
public String[] promptKeyboardInteractive(final String destination, final String name, final String instruction,
|
||||||
final String name, final String instruction,
|
final String[] prompt, final boolean[] echo) {
|
||||||
final String[] prompt, final boolean[] echo)
|
|
||||||
{
|
|
||||||
if (prompt.length == 0) {
|
if (prompt.length == 0) {
|
||||||
// No need to prompt, just return an empty String array
|
// No need to prompt, just return an empty String array
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (fAttemptCount == 0 && fPassword != null && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
if (fAttemptCount == 0 && fPassword != null && prompt.length == 1
|
||||||
|
&& prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
||||||
// Return the provided password the first time but always prompt on subsequent tries
|
// Return the provided password the first time but always prompt on subsequent tries
|
||||||
fAttemptCount++;
|
fAttemptCount++;
|
||||||
return new String[] { fPassword };
|
return new String[] { fPassword };
|
||||||
|
@ -341,7 +350,8 @@ public class SshConnection extends Thread {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isSessionConnected()) {
|
if (isSessionConnected()) {
|
||||||
KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null, fConnectionId, destination, name, instruction, prompt, echo);
|
KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null, fConnectionId,
|
||||||
|
destination, name, instruction, prompt, echo);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
finResult[0] = dialog.getResult();
|
finResult[0] = dialog.getResult();
|
||||||
} else {
|
} else {
|
||||||
|
@ -357,8 +367,7 @@ public class SshConnection extends Thread {
|
||||||
}
|
}
|
||||||
fAttemptCount++;
|
fAttemptCount++;
|
||||||
return result;
|
return result;
|
||||||
}
|
} catch (OperationCanceledException e) {
|
||||||
catch(OperationCanceledException e){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,22 +36,27 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
private final SshSettings fSettings;
|
private final SshSettings fSettings;
|
||||||
private int fWidth;
|
private int fWidth;
|
||||||
private int fHeight;
|
private int fHeight;
|
||||||
|
|
||||||
public SshConnector() {
|
public SshConnector() {
|
||||||
this(new SshSettings());
|
this(new SshSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SshConnector(SshSettings settings) {
|
public SshConnector(SshSettings settings) {
|
||||||
fSettings = settings;
|
fSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
fJsch = new JSch();
|
fJsch = new JSch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fConnection = new SshConnection(this, control);
|
fConnection = new SshConnection(this, control);
|
||||||
fConnection.start();
|
fConnection.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
synchronized public void doDisconnect() {
|
synchronized public void doDisconnect() {
|
||||||
fConnection.disconnect();
|
fConnection.disconnect();
|
||||||
|
@ -71,6 +76,7 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
if (fChannel != null && (newWidth != fWidth || newHeight != fHeight)) {
|
if (fChannel != null && (newWidth != fWidth || newHeight != fHeight)) {
|
||||||
|
@ -80,19 +86,24 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
fHeight = newHeight;
|
fHeight = newHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
return fInputStream;
|
return fInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getTerminalToRemoteStream() {
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
return fOutputStream;
|
return fOutputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInputStream(InputStream inputStream) {
|
void setInputStream(InputStream inputStream) {
|
||||||
fInputStream = inputStream;
|
fInputStream = inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOutputStream(OutputStream outputStream) {
|
void setOutputStream(OutputStream outputStream) {
|
||||||
fOutputStream = outputStream;
|
fOutputStream = outputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the SSH Settings.
|
* Return the SSH Settings.
|
||||||
*
|
*
|
||||||
|
@ -102,28 +113,35 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
public ISshSettings getSshSettings() {
|
public ISshSettings getSshSettings() {
|
||||||
return fSettings;
|
return fSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultSettings() {
|
public void setDefaultSettings() {
|
||||||
fSettings.load(new NullSettingsStore());
|
fSettings.load(new NullSettingsStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
return fSettings.getSummary();
|
return fSettings.getSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fSettings.load(store);
|
fSettings.load(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
fSettings.save(store);
|
fSettings.save(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JSch getJsch() {
|
protected JSch getJsch() {
|
||||||
return fJsch;
|
return fJsch;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelShell getChannel() {
|
ChannelShell getChannel() {
|
||||||
return fChannel;
|
return fChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChannel(ChannelShell channel) {
|
void setChannel(ChannelShell channel) {
|
||||||
fChannel = channel;
|
fChannel = channel;
|
||||||
fWidth = -1;
|
fWidth = -1;
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class SshSettings implements ISshSettings {
|
||||||
protected String fPort;
|
protected String fPort;
|
||||||
protected String fTimeout;
|
protected String fTimeout;
|
||||||
protected String fKeepalive;
|
protected String fKeepalive;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return fHost;
|
return fHost;
|
||||||
|
@ -68,7 +69,6 @@ public class SshSettings implements ISshSettings {
|
||||||
store.put("Keepalive", fKeepalive);//$NON-NLS-1$
|
store.put("Keepalive", fKeepalive);//$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
try {
|
try {
|
||||||
|
@ -77,6 +77,7 @@ public class SshSettings implements ISshSettings {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimeoutString() {
|
public String getTimeoutString() {
|
||||||
return fTimeout;
|
return fTimeout;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +94,7 @@ public class SshSettings implements ISshSettings {
|
||||||
return 300;
|
return 300;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeepaliveString() {
|
public String getKeepaliveString() {
|
||||||
return fKeepalive;
|
return fKeepalive;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +111,7 @@ public class SshSettings implements ISshSettings {
|
||||||
public void setUser(String user) {
|
public void setUser(String user) {
|
||||||
fUser = user;
|
fUser = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
public SshSettingsPage(SshSettings settings) {
|
public SshSettingsPage(SshSettings settings) {
|
||||||
fTerminalSettings = settings;
|
fTerminalSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveSettings() {
|
public void saveSettings() {
|
||||||
fTerminalSettings.setHost(fHostText.getText());
|
fTerminalSettings.setHost(fHostText.getText());
|
||||||
|
@ -60,11 +61,13 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
fPassword.setText(get(fTerminalSettings.getPassword(), ""));//$NON-NLS-1$
|
fPassword.setText(get(fTerminalSettings.getPassword(), ""));//$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String get(String value, String def) {
|
String get(String value, String def) {
|
||||||
if (value == null || value.length() == 0)
|
if (value == null || value.length() == 0)
|
||||||
return def;
|
return def;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validateSettings() {
|
public boolean validateSettings() {
|
||||||
String message = null;
|
String message = null;
|
||||||
|
@ -75,7 +78,10 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Please enter a host IP or name."; //$NON-NLS-1$
|
String m = "Please enter a host IP or name."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.INFORMATION;
|
int mt = IMessageProvider.INFORMATION;
|
||||||
updateControlDecoration(fHostText, m, mt);
|
updateControlDecoration(fHostText, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,7 +91,10 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Please enter a username."; //$NON-NLS-1$
|
String m = "Please enter a username."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.INFORMATION;
|
int mt = IMessageProvider.INFORMATION;
|
||||||
updateControlDecoration(fUser, m, mt);
|
updateControlDecoration(fUser, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,7 +106,10 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Invalid network port. Must be between 0 and 65535."; //$NON-NLS-1$
|
String m = "Invalid network port. Must be between 0 and 65535."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.ERROR;
|
int mt = IMessageProvider.ERROR;
|
||||||
updateControlDecoration(fPort, m, mt);
|
updateControlDecoration(fPort, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,7 +120,10 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Invalid timeout. Must be greater than 0."; //$NON-NLS-1$
|
String m = "Invalid timeout. Must be greater than 0."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.ERROR;
|
int mt = IMessageProvider.ERROR;
|
||||||
updateControlDecoration(fTimeout, m, mt);
|
updateControlDecoration(fTimeout, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,7 +134,10 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Invalid keep alive. Must be greater than 0."; //$NON-NLS-1$
|
String m = "Invalid keep alive. Must be greater than 0."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.ERROR;
|
int mt = IMessageProvider.ERROR;
|
||||||
updateControlDecoration(fKeepalive, m, mt);
|
updateControlDecoration(fKeepalive, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,6 +150,7 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
setMessage(message, messageType);
|
setMessage(message, messageType);
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Composite composite = new Composite(parent, SWT.NONE);
|
Composite composite = new Composite(parent, SWT.NONE);
|
||||||
|
@ -151,6 +170,7 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
fPort = createTextField(composite, SshMessages.PORT);
|
fPort = createTextField(composite, SshMessages.PORT);
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Text createTextField(Composite composite, String labelTxt, int textOptions) {
|
private Text createTextField(Composite composite, String labelTxt, int textOptions) {
|
||||||
GridData gridData;
|
GridData gridData;
|
||||||
// Add label
|
// Add label
|
||||||
|
@ -170,6 +190,7 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
createControlDecoration(text);
|
createControlDecoration(text);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Text createTextField(Composite composite, String labelTxt) {
|
private Text createTextField(Composite composite, String labelTxt) {
|
||||||
return createTextField(composite, labelTxt, 0);
|
return createTextField(composite, labelTxt, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
this.domain = location;
|
this.domain = location;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Window#configureShell
|
* @see Window#configureShell
|
||||||
*/
|
*/
|
||||||
|
@ -77,6 +78,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
// set F1 help
|
// set F1 help
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ISshConstants.HELP_USER_VALIDATION_DIALOG);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ISshConstants.HELP_USER_VALIDATION_DIALOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Window#create
|
* @see Window#create
|
||||||
*/
|
*/
|
||||||
|
@ -142,7 +144,8 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
if (isUsernameMutable) {
|
if (isUsernameMutable) {
|
||||||
label.setText(NLS.bind(SshMessages.UserValidationDialog_labelUser, new String[] { domain }));
|
label.setText(NLS.bind(SshMessages.UserValidationDialog_labelUser, new String[] { domain }));
|
||||||
} else {
|
} else {
|
||||||
label.setText(NLS.bind(SshMessages.UserValidationDialog_labelPassword, (new Object[]{defaultUsername, domain})));
|
label.setText(NLS.bind(SshMessages.UserValidationDialog_labelPassword,
|
||||||
|
(new Object[] { defaultUsername, domain })));
|
||||||
}
|
}
|
||||||
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
|
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
|
||||||
data.horizontalSpan = 2;
|
data.horizontalSpan = 2;
|
||||||
|
@ -175,7 +178,8 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
warningComposite.setLayoutData(data);
|
warningComposite.setLayoutData(data);
|
||||||
Label warningLabel = new Label(warningComposite, SWT.NONE);
|
Label warningLabel = new Label(warningComposite, SWT.NONE);
|
||||||
warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING));
|
warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING));
|
||||||
warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING));
|
warningLabel.setLayoutData(
|
||||||
|
new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING));
|
||||||
Label warningText = new Label(warningComposite, SWT.WRAP);
|
Label warningText = new Label(warningComposite, SWT.WRAP);
|
||||||
warningText.setText(SshMessages.UserValidationDialog_7);
|
warningText.setText(SshMessages.UserValidationDialog_7);
|
||||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
@ -202,6 +206,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
|
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
|
||||||
passwordField.setLayoutData(data);
|
passwordField.setLayoutData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the three widgets that represent the user name entry area.
|
* Creates the three widgets that represent the user name entry area.
|
||||||
*
|
*
|
||||||
|
@ -261,6 +266,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
|
|
||||||
super.okPressed();
|
super.okPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the username field should be mutable.
|
* Sets whether or not the username field should be mutable.
|
||||||
* This method must be called before create(), otherwise it
|
* This method must be called before create(), otherwise it
|
||||||
|
|
|
@ -75,7 +75,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
panel.setLayoutData(data);
|
panel.setLayoutData(data);
|
||||||
|
|
||||||
// Create the host selection combo
|
// Create the host selection combo
|
||||||
if (isWithoutSelection()) createHostsUI(panel, true);
|
if (isWithoutSelection())
|
||||||
|
createHostsUI(panel, true);
|
||||||
|
|
||||||
SshConnector conn = new SshConnector();
|
SshConnector conn = new SshConnector();
|
||||||
sshSettings = (SshSettings) conn.getSshSettings();
|
sshSettings = (SshSettings) conn.getSshSettings();
|
||||||
|
@ -92,7 +93,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
sshSettingsPage.addListener(new ISettingsPage.Listener() {
|
sshSettingsPage.addListener(new ISettingsPage.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsPageChanged(Control control) {
|
public void onSettingsPageChanged(Control control) {
|
||||||
if (getContainer() != null) getContainer().validate();
|
if (getContainer() != null)
|
||||||
|
getContainer().validate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -110,31 +112,39 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setupData(Map<String, Object> data) {
|
public void setupData(Map<String, Object> data) {
|
||||||
if (data == null || sshSettings == null || sshSettingsPage == null) return;
|
if (data == null || sshSettings == null || sshSettingsPage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
String value = (String) data.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
String value = (String) data.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
if (value != null) sshSettings.setHost(value);
|
if (value != null)
|
||||||
|
sshSettings.setHost(value);
|
||||||
|
|
||||||
Object v = data.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object v = data.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
value = v != null ? v.toString() : null;
|
value = v != null ? v.toString() : null;
|
||||||
if (value != null) sshSettings.setPort(value);
|
if (value != null)
|
||||||
|
sshSettings.setPort(value);
|
||||||
|
|
||||||
v = data.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
v = data.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
||||||
value = v != null ? v.toString() : null;
|
value = v != null ? v.toString() : null;
|
||||||
if (value != null) sshSettings.setTimeout(value);
|
if (value != null)
|
||||||
|
sshSettings.setTimeout(value);
|
||||||
|
|
||||||
v = data.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE);
|
v = data.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE);
|
||||||
value = v != null ? v.toString() : null;
|
value = v != null ? v.toString() : null;
|
||||||
if (value != null) sshSettings.setKeepalive(value);
|
if (value != null)
|
||||||
|
sshSettings.setKeepalive(value);
|
||||||
|
|
||||||
value = (String) data.get(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
value = (String) data.get(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
||||||
if (value != null) sshSettings.setPassword(value);
|
if (value != null)
|
||||||
|
sshSettings.setPassword(value);
|
||||||
|
|
||||||
value = (String) data.get(ITerminalsConnectorConstants.PROP_SSH_USER);
|
value = (String) data.get(ITerminalsConnectorConstants.PROP_SSH_USER);
|
||||||
if (value != null) sshSettings.setUser(value);
|
if (value != null)
|
||||||
|
sshSettings.setUser(value);
|
||||||
|
|
||||||
value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
||||||
if (value != null) setEncoding(value);
|
if (value != null)
|
||||||
|
setEncoding(value);
|
||||||
|
|
||||||
sshSettingsPage.loadSettings();
|
sshSettingsPage.loadSettings();
|
||||||
}
|
}
|
||||||
|
@ -151,7 +161,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
ITerminalContextPropertiesProvider provider = TerminalContextPropertiesProviderFactory.getProvider(element);
|
ITerminalContextPropertiesProvider provider = TerminalContextPropertiesProviderFactory.getProvider(element);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
Object user = provider.getProperty(element, IContextPropertiesConstants.PROP_DEFAULT_USER);
|
Object user = provider.getProperty(element, IContextPropertiesConstants.PROP_DEFAULT_USER);
|
||||||
if (user instanceof String) return ((String) user).trim();
|
if (user instanceof String)
|
||||||
|
return ((String) user).trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,10 +174,12 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void extractData(Map<String, Object> data) {
|
public void extractData(Map<String, Object> data) {
|
||||||
if (data == null) return;
|
if (data == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// set the terminal connector id for ssh
|
// set the terminal connector id for ssh
|
||||||
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.ssh.SshConnector"); //$NON-NLS-1$
|
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID,
|
||||||
|
"org.eclipse.tm.terminal.connector.ssh.SshConnector"); //$NON-NLS-1$
|
||||||
|
|
||||||
sshSettingsPage.saveSettings();
|
sshSettingsPage.saveSettings();
|
||||||
data.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
|
data.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
|
||||||
|
@ -218,7 +231,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
String encoding = hostSettings.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
String encoding = hostSettings.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
||||||
if (encoding == null || "null".equals(encoding)) { //$NON-NLS-1$
|
if (encoding == null || "null".equals(encoding)) { //$NON-NLS-1$
|
||||||
String defaultEncoding = getSelectionEncoding();
|
String defaultEncoding = getSelectionEncoding();
|
||||||
encoding = defaultEncoding != null && !"".equals(defaultEncoding.trim()) ? defaultEncoding.trim() : "ISO-8859-1"; //$NON-NLS-1$ //$NON-NLS-2$
|
encoding = defaultEncoding != null && !"".equals(defaultEncoding.trim()) ? defaultEncoding.trim() //$NON-NLS-1$
|
||||||
|
: "ISO-8859-1"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
setEncoding(encoding);
|
setEncoding(encoding);
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,15 +271,15 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE,
|
||||||
|
Integer.toString(sshSettings.getKeepalive()));
|
||||||
if (saveUser) {
|
if (saveUser) {
|
||||||
if (sshSettings.getUser() != null) {
|
if (sshSettings.getUser() != null) {
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
|
||||||
} else {
|
} else {
|
||||||
hostSettings.remove(ITerminalsConnectorConstants.PROP_SSH_USER);
|
hostSettings.remove(ITerminalsConnectorConstants.PROP_SSH_USER);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
hostSettings.remove(ITerminalsConnectorConstants.PROP_SSH_USER);
|
hostSettings.remove(ITerminalsConnectorConstants.PROP_SSH_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,13 +299,15 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe unchecked the password button - so try to remove a saved password - if any
|
// maybe unchecked the password button - so try to remove a saved password - if any
|
||||||
if (!savePassword) removeSecurePassword(host);
|
if (!savePassword)
|
||||||
|
removeSecurePassword(host);
|
||||||
} else if (add) {
|
} else if (add) {
|
||||||
Map<String, String> hostSettings = new HashMap<String, String>();
|
Map<String, String> hostSettings = new HashMap<String, String>();
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE,
|
||||||
|
Integer.toString(sshSettings.getKeepalive()));
|
||||||
if (saveUser) {
|
if (saveUser) {
|
||||||
if (sshSettings.getUser() != null) {
|
if (sshSettings.getUser() != null) {
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
|
||||||
|
@ -328,8 +344,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
try {
|
try {
|
||||||
node.put("password", password, true); //$NON-NLS-1$
|
node.put("password", password, true); //$NON-NLS-1$
|
||||||
}
|
} catch (StorageException ex) {
|
||||||
catch (StorageException ex) { /* ignored on purpose */ }
|
/* ignored on purpose */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,8 +369,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
String password = null;
|
String password = null;
|
||||||
try {
|
try {
|
||||||
password = node.get("password", null); //$NON-NLS-1$
|
password = node.get("password", null); //$NON-NLS-1$
|
||||||
}
|
} catch (StorageException ex) {
|
||||||
catch (StorageException ex) { /* ignored on purpose */ }
|
/* ignored on purpose */ }
|
||||||
|
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,8 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
private String getTerminalTitle(Map<String, Object> properties) {
|
private String getTerminalTitle(Map<String, Object> properties) {
|
||||||
// Try to see if the user set a title explicitly via the properties map.
|
// Try to see if the user set a title explicitly via the properties map.
|
||||||
String title = getDefaultTerminalTitle(properties);
|
String title = getDefaultTerminalTitle(properties);
|
||||||
if (title != null) return title;
|
if (title != null)
|
||||||
|
return title;
|
||||||
|
|
||||||
//No title,try to calculate the title
|
//No title,try to calculate the title
|
||||||
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
|
@ -107,7 +108,8 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||||
String date = format.format(new Date(System.currentTimeMillis()));
|
String date = format.format(new Date(System.currentTimeMillis()));
|
||||||
if (port != null && Integer.valueOf(port).intValue() != ISshSettings.DEFAULT_SSH_PORT) {
|
if (port != null && Integer.valueOf(port).intValue() != ISshSettings.DEFAULT_SSH_PORT) {
|
||||||
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle_port, new String[]{user, host, port, date});
|
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle_port,
|
||||||
|
new String[] { user, host, port, date });
|
||||||
}
|
}
|
||||||
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle, new String[] { user, host, date });
|
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle, new String[] { user, host, date });
|
||||||
}
|
}
|
||||||
|
@ -135,7 +137,8 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
// Check for the terminal connector id
|
// Check for the terminal connector id
|
||||||
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
||||||
if (connectorId == null) connectorId = "org.eclipse.tm.terminal.connector.ssh.SshConnector"; //$NON-NLS-1$
|
if (connectorId == null)
|
||||||
|
connectorId = "org.eclipse.tm.terminal.connector.ssh.SshConnector"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Extract the ssh properties
|
// Extract the ssh properties
|
||||||
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
|
@ -151,7 +154,8 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
int portOffset = 0;
|
int portOffset = 0;
|
||||||
if (properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) instanceof Integer) {
|
if (properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) instanceof Integer) {
|
||||||
portOffset = ((Integer) properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET)).intValue();
|
portOffset = ((Integer) properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET)).intValue();
|
||||||
if (portOffset < 0) portOffset = 0;
|
if (portOffset < 0)
|
||||||
|
portOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The real port to connect to is port + portOffset
|
// The real port to connect to is port + portOffset
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.ui.IMemento;
|
||||||
*/
|
*/
|
||||||
public class SshMementoHandler implements IMementoHandler {
|
public class SshMementoHandler implements IMementoHandler {
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler#saveState(org.eclipse.ui.IMemento, java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler#saveState(org.eclipse.ui.IMemento, java.util.Map)
|
||||||
*/
|
*/
|
||||||
|
@ -37,15 +36,21 @@ public class SshMementoHandler implements IMementoHandler {
|
||||||
|
|
||||||
// Do not write the terminal title to the memento -> needs to
|
// Do not write the terminal title to the memento -> needs to
|
||||||
// be recreated at the time of restoration.
|
// be recreated at the time of restoration.
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_IP_HOST, (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
memento.putString(ITerminalsConnectorConstants.PROP_IP_HOST,
|
||||||
|
(String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
memento.putInteger(ITerminalsConnectorConstants.PROP_IP_PORT, value instanceof Integer ? ((Integer)value).intValue() : -1);
|
memento.putInteger(ITerminalsConnectorConstants.PROP_IP_PORT,
|
||||||
|
value instanceof Integer ? ((Integer) value).intValue() : -1);
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
||||||
memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT, value instanceof Integer ? ((Integer)value).intValue() : -1);
|
memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT,
|
||||||
|
value instanceof Integer ? ((Integer) value).intValue() : -1);
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE);
|
value = properties.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE);
|
||||||
memento.putInteger(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, value instanceof Integer ? ((Integer)value).intValue() : -1);
|
memento.putInteger(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE,
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_SSH_USER, (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER));
|
value instanceof Integer ? ((Integer) value).intValue() : -1);
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING, (String)properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
|
memento.putString(ITerminalsConnectorConstants.PROP_SSH_USER,
|
||||||
|
(String) properties.get(ITerminalsConnectorConstants.PROP_SSH_USER));
|
||||||
|
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING,
|
||||||
|
(String) properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||||
|
|
||||||
// The password is stored within the Eclipse secure preferences -> no need to store it to the memento
|
// The password is stored within the Eclipse secure preferences -> no need to store it to the memento
|
||||||
//
|
//
|
||||||
|
@ -84,12 +89,18 @@ public class SshMementoHandler implements IMementoHandler {
|
||||||
Assert.isNotNull(properties);
|
Assert.isNotNull(properties);
|
||||||
|
|
||||||
// Restore the terminal properties from the memento
|
// Restore the terminal properties from the memento
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_IP_HOST, memento.getString(ITerminalsConnectorConstants.PROP_IP_HOST));
|
properties.put(ITerminalsConnectorConstants.PROP_IP_HOST,
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_IP_PORT, memento.getInteger(ITerminalsConnectorConstants.PROP_IP_PORT));
|
memento.getString(ITerminalsConnectorConstants.PROP_IP_HOST));
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_TIMEOUT, memento.getInteger(ITerminalsConnectorConstants.PROP_TIMEOUT));
|
properties.put(ITerminalsConnectorConstants.PROP_IP_PORT,
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, memento.getInteger(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE));
|
memento.getInteger(ITerminalsConnectorConstants.PROP_IP_PORT));
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_SSH_USER, memento.getString(ITerminalsConnectorConstants.PROP_SSH_USER));
|
properties.put(ITerminalsConnectorConstants.PROP_TIMEOUT,
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
memento.getInteger(ITerminalsConnectorConstants.PROP_TIMEOUT));
|
||||||
|
properties.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE,
|
||||||
|
memento.getInteger(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE));
|
||||||
|
properties.put(ITerminalsConnectorConstants.PROP_SSH_USER,
|
||||||
|
memento.getString(ITerminalsConnectorConstants.PROP_SSH_USER));
|
||||||
|
properties.put(ITerminalsConnectorConstants.PROP_ENCODING,
|
||||||
|
memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||||
|
|
||||||
// The password is stored within the Eclipse secure preferences -> restore it from there
|
// The password is stored within the Eclipse secure preferences -> restore it from there
|
||||||
// To access the secure storage, we need the preference instance
|
// To access the secure storage, we need the preference instance
|
||||||
|
@ -97,13 +108,14 @@ public class SshMementoHandler implements IMementoHandler {
|
||||||
ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
|
ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
|
||||||
if (preferences != null && (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
|
if (preferences != null && (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
|
||||||
// Construct the secure preferences node key
|
// Construct the secure preferences node key
|
||||||
String nodeKey = "/Target Explorer SSH Password/" + (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST); //$NON-NLS-1$
|
String nodeKey = "/Target Explorer SSH Password/" //$NON-NLS-1$
|
||||||
|
+ (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
ISecurePreferences node = preferences.node(nodeKey);
|
ISecurePreferences node = preferences.node(nodeKey);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
try {
|
try {
|
||||||
password = node.get("password", null); //$NON-NLS-1$
|
password = node.get("password", null); //$NON-NLS-1$
|
||||||
}
|
} catch (StorageException ex) {
|
||||||
catch (StorageException ex) { /* ignored on purpose */ }
|
/* ignored on purpose */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,19 @@ public interface ITelnetSettings {
|
||||||
static final String EOL_CRLF = "CR+LF"; //$NON-NLS-1$
|
static final String EOL_CRLF = "CR+LF"; //$NON-NLS-1$
|
||||||
|
|
||||||
String getHost();
|
String getHost();
|
||||||
|
|
||||||
int getNetworkPort();
|
int getNetworkPort();
|
||||||
|
|
||||||
int getTimeout();
|
int getTimeout();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
String getEndOfLine();
|
String getEndOfLine();
|
||||||
|
|
||||||
String getSummary();
|
String getSummary();
|
||||||
|
|
||||||
void load(ISettingsStore store);
|
void load(ISettingsStore store);
|
||||||
|
|
||||||
void save(ISettingsStore store);
|
void save(ISettingsStore store);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,7 @@ public class NetworkPortMap {
|
||||||
|
|
||||||
String[][] fPortMap = new String[][] {
|
String[][] fPortMap = new String[][] {
|
||||||
// portName, port
|
// portName, port
|
||||||
{PROP_NAMETGTCONS, PROP_VALUETGTCONS},
|
{ PROP_NAMETGTCONS, PROP_VALUETGTCONS }, { PROP_NAMETELNET, PROP_VALUETELNET } };
|
||||||
{PROP_NAMETELNET, PROP_VALUETELNET}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getDefaultNetworkPort() {
|
public String getDefaultNetworkPort() {
|
||||||
return PROP_VALUETELNET;
|
return PROP_VALUETELNET;
|
||||||
|
|
|
@ -22,8 +22,7 @@ package org.eclipse.tm.terminal.connector.telnet.connector;
|
||||||
* interface. The meanings of these constants are defined in the various TELNET RFCs
|
* interface. The meanings of these constants are defined in the various TELNET RFCs
|
||||||
* (RFC 854 to RFC 861, and others).
|
* (RFC 854 to RFC 861, and others).
|
||||||
*/
|
*/
|
||||||
interface TelnetCodes
|
interface TelnetCodes {
|
||||||
{
|
|
||||||
/** Command code: Subnegotiation End. */
|
/** Command code: Subnegotiation End. */
|
||||||
static final byte TELNET_SE = (byte) 240;
|
static final byte TELNET_SE = (byte) 240;
|
||||||
|
|
||||||
|
@ -78,7 +77,6 @@ interface TelnetCodes
|
||||||
/** Command code: SEND. */
|
/** Command code: SEND. */
|
||||||
static final byte TELNET_SEND = 1;
|
static final byte TELNET_SEND = 1;
|
||||||
|
|
||||||
|
|
||||||
/** Option code: Transmit Binary option. */
|
/** Option code: Transmit Binary option. */
|
||||||
static final byte TELNET_OPTION_TRANSMIT_BINARY = 0;
|
static final byte TELNET_OPTION_TRANSMIT_BINARY = 0;
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,13 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
class TelnetConnectWorker extends Thread {
|
class TelnetConnectWorker extends Thread {
|
||||||
private final ITerminalControl fControl;
|
private final ITerminalControl fControl;
|
||||||
private final TelnetConnector fConn;
|
private final TelnetConnector fConn;
|
||||||
|
|
||||||
protected TelnetConnectWorker(TelnetConnector conn, ITerminalControl control) {
|
protected TelnetConnectWorker(TelnetConnector conn, ITerminalControl control) {
|
||||||
fControl = control;
|
fControl = control;
|
||||||
fConn = conn;
|
fConn = conn;
|
||||||
fControl.setState(TerminalState.CONNECTING);
|
fControl.setState(TerminalState.CONNECTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Retry the connect with after a little pause in case the
|
// Retry the connect with after a little pause in case the
|
||||||
|
@ -48,7 +50,11 @@ class TelnetConnectWorker extends Thread {
|
||||||
|
|
||||||
while (remaining >= 0) {
|
while (remaining >= 0) {
|
||||||
// Pause before we re-try if the remaining tries are less than the initial value
|
// Pause before we re-try if the remaining tries are less than the initial value
|
||||||
if (remaining < 10) try { Thread.sleep(500); } catch (InterruptedException e) { /* ignored on purpose */ }
|
if (remaining < 10)
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
/* ignored on purpose */ }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int nTimeout = fConn.getTelnetSettings().getTimeout() * 1000;
|
int nTimeout = fConn.getTelnetSettings().getTimeout() * 1000;
|
||||||
|
@ -93,7 +99,8 @@ class TelnetConnectWorker extends Thread {
|
||||||
// counter is not desired.
|
// counter is not desired.
|
||||||
remaining = 0;
|
remaining = 0;
|
||||||
// Construct error message and signal failed
|
// Construct error message and signal failed
|
||||||
connectFailed(socketTimeoutException.getMessage(), "Connection Error!\n" + socketTimeoutException.getMessage()); //$NON-NLS-1$
|
connectFailed(socketTimeoutException.getMessage(),
|
||||||
|
"Connection Error!\n" + socketTimeoutException.getMessage()); //$NON-NLS-1$
|
||||||
} catch (ConnectException connectException) {
|
} catch (ConnectException connectException) {
|
||||||
// In case of a ConnectException, do a re-try. The server could have been
|
// In case of a ConnectException, do a re-try. The server could have been
|
||||||
// simply not ready yet and the worker would give up to early. If the terminal
|
// simply not ready yet and the worker would give up to early. If the terminal
|
||||||
|
|
|
@ -335,7 +335,8 @@ public class TelnetConnection extends Thread implements TelnetCodes {
|
||||||
// A "socket closed" exception is normal here. It's caused by the
|
// A "socket closed" exception is normal here. It's caused by the
|
||||||
// user clicking the disconnect button on the Terminal view toolbar.
|
// user clicking the disconnect button on the Terminal view toolbar.
|
||||||
|
|
||||||
if (message != null && !message.equalsIgnoreCase("Socket closed") && !message.equalsIgnoreCase("Connection reset")) //$NON-NLS-1$ //$NON-NLS-2$
|
if (message != null && !message.equalsIgnoreCase("Socket closed") //$NON-NLS-1$
|
||||||
|
&& !message.equalsIgnoreCase("Connection reset")) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
Logger.logException(ex);
|
Logger.logException(ex);
|
||||||
}
|
}
|
||||||
|
@ -345,8 +346,14 @@ public class TelnetConnection extends Thread implements TelnetCodes {
|
||||||
} finally {
|
} finally {
|
||||||
// Tell the ITerminalControl object that the connection is closed.
|
// Tell the ITerminalControl object that the connection is closed.
|
||||||
terminalControl.setState(TerminalState.CLOSED);
|
terminalControl.setState(TerminalState.CLOSED);
|
||||||
try { inputStream.close(); } catch(IOException ioe) { /*ignore*/ }
|
try {
|
||||||
try { outputStream.close(); } catch(IOException ioe) { /*ignore*/ }
|
inputStream.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
/*ignore*/ }
|
||||||
|
try {
|
||||||
|
outputStream.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
/*ignore*/ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,11 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
public TelnetConnector() {
|
public TelnetConnector() {
|
||||||
this(new TelnetSettings());
|
this(new TelnetSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TelnetConnector(TelnetSettings settings) {
|
public TelnetConnector(TelnetSettings settings) {
|
||||||
fSettings = settings;
|
fSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
|
@ -86,6 +88,7 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
TelnetConnectWorker worker = new TelnetConnectWorker(this, control);
|
TelnetConnectWorker worker = new TelnetConnectWorker(this, control);
|
||||||
worker.start();
|
worker.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doDisconnect() {
|
public void doDisconnect() {
|
||||||
if (getSocket() != null) {
|
if (getSocket() != null) {
|
||||||
|
@ -113,12 +116,14 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
cleanSocket();
|
cleanSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLocalEcho() {
|
public boolean isLocalEcho() {
|
||||||
if (fTelnetConnection == null)
|
if (fTelnetConnection == null)
|
||||||
return false;
|
return false;
|
||||||
return fTelnetConnection.localEcho();
|
return fTelnetConnection.localEcho();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
if (fTelnetConnection != null && (newWidth != fWidth || newHeight != fHeight)) {
|
if (fTelnetConnection != null && (newWidth != fWidth || newHeight != fHeight)) {
|
||||||
|
@ -128,16 +133,20 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
fHeight = newHeight;
|
fHeight = newHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
return fInputStream;
|
return fInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getTerminalToRemoteStream() {
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
return fOutputStream;
|
return fOutputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInputStream(InputStream inputStream) {
|
private void setInputStream(InputStream inputStream) {
|
||||||
fInputStream = inputStream;
|
fInputStream = inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOutputStream(OutputStream outputStream) {
|
private void setOutputStream(OutputStream outputStream) {
|
||||||
if (outputStream == null) {
|
if (outputStream == null) {
|
||||||
fOutputStream = null;
|
fOutputStream = null;
|
||||||
|
@ -146,6 +155,7 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
// translate CR to telnet end-of-line sequence - RFC 854
|
// translate CR to telnet end-of-line sequence - RFC 854
|
||||||
fOutputStream = new TelnetOutputStream(outputStream, fSettings.getEndOfLine());
|
fOutputStream = new TelnetOutputStream(outputStream, fSettings.getEndOfLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket getSocket() {
|
Socket getSocket() {
|
||||||
return fSocket;
|
return fSocket;
|
||||||
}
|
}
|
||||||
|
@ -169,33 +179,42 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTelnetConnection(TelnetConnection connection) {
|
public void setTelnetConnection(TelnetConnection connection) {
|
||||||
fTelnetConnection = connection;
|
fTelnetConnection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTextInTerminal(String text) {
|
public void displayTextInTerminal(String text) {
|
||||||
fControl.displayTextInTerminal(text);
|
fControl.displayTextInTerminal(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputStream getRemoteToTerminalOutputStream() {
|
public OutputStream getRemoteToTerminalOutputStream() {
|
||||||
return fControl.getRemoteToTerminalOutputStream();
|
return fControl.getRemoteToTerminalOutputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(TerminalState state) {
|
public void setState(TerminalState state) {
|
||||||
fControl.setState(state);
|
fControl.setState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITelnetSettings getTelnetSettings() {
|
public ITelnetSettings getTelnetSettings() {
|
||||||
return fSettings;
|
return fSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultSettings() {
|
public void setDefaultSettings() {
|
||||||
fSettings.load(new NullSettingsStore());
|
fSettings.load(new NullSettingsStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
return fSettings.getSummary();
|
return fSettings.getSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fSettings.load(store);
|
fSettings.load(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
fSettings.save(store);
|
fSettings.save(store);
|
||||||
|
|
|
@ -43,16 +43,13 @@ import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||||
*
|
*
|
||||||
* @author Fran Litterio (francis.litterio@windriver.com)
|
* @author Fran Litterio (francis.litterio@windriver.com)
|
||||||
*/
|
*/
|
||||||
class TelnetOption implements TelnetCodes
|
class TelnetOption implements TelnetCodes {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* This array of Strings maps an integer TELNET option code value to the symbolic
|
* This array of Strings maps an integer TELNET option code value to the symbolic
|
||||||
* name of the option. Array elements of the form "?" represent unassigned option
|
* name of the option. Array elements of the form "?" represent unassigned option
|
||||||
* values.
|
* values.
|
||||||
*/
|
*/
|
||||||
protected static final String[] optionNames =
|
protected static final String[] optionNames = { "BINARY", // 0 //$NON-NLS-1$
|
||||||
{
|
|
||||||
"BINARY", // 0 //$NON-NLS-1$
|
|
||||||
"ECHO", // 1 //$NON-NLS-1$
|
"ECHO", // 1 //$NON-NLS-1$
|
||||||
"RECONNECTION", // 2 //$NON-NLS-1$
|
"RECONNECTION", // 2 //$NON-NLS-1$
|
||||||
"SUPPRESS GO AHEAD", // 3 //$NON-NLS-1$
|
"SUPPRESS GO AHEAD", // 3 //$NON-NLS-1$
|
||||||
|
@ -251,8 +248,7 @@ class TelnetOption implements TelnetCodes
|
||||||
* @param local Whether this option is for the local or remote endpoint.
|
* @param local Whether this option is for the local or remote endpoint.
|
||||||
* @param outputStream A stream used to negotiate with the remote endpoint.
|
* @param outputStream A stream used to negotiate with the remote endpoint.
|
||||||
*/
|
*/
|
||||||
TelnetOption(byte option, boolean desired, boolean local,
|
TelnetOption(byte option, boolean desired, boolean local, OutputStream outputStream) {
|
||||||
OutputStream outputStream) {
|
|
||||||
this.option = option;
|
this.option = option;
|
||||||
this.desired = desired;
|
this.desired = desired;
|
||||||
this.local = local;
|
this.local = local;
|
||||||
|
@ -333,12 +329,10 @@ class TelnetOption implements TelnetCodes
|
||||||
public void negotiate() {
|
public void negotiate() {
|
||||||
if (negotiationState == NEGOTIATION_NOT_STARTED && desired) {
|
if (negotiationState == NEGOTIATION_NOT_STARTED && desired) {
|
||||||
if (local) {
|
if (local) {
|
||||||
Logger
|
Logger.log("Starting negotiation for local option " + optionName()); //$NON-NLS-1$
|
||||||
.log("Starting negotiation for local option " + optionName()); //$NON-NLS-1$
|
|
||||||
sendWill();
|
sendWill();
|
||||||
} else {
|
} else {
|
||||||
Logger
|
Logger.log("Starting negotiation for remote option " + optionName()); //$NON-NLS-1$
|
||||||
.log("Starting negotiation for remote option " + optionName()); //$NON-NLS-1$
|
|
||||||
sendDo();
|
sendDo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,8 +346,7 @@ class TelnetOption implements TelnetCodes
|
||||||
*/
|
*/
|
||||||
public void handleWill() {
|
public void handleWill() {
|
||||||
if (negotiationState == NEGOTIATION_DONE && ignoreNegotiation()) {
|
if (negotiationState == NEGOTIATION_DONE && ignoreNegotiation()) {
|
||||||
Logger
|
Logger.log("Ignoring superfluous WILL command from remote endpoint."); //$NON-NLS-1$
|
||||||
.log("Ignoring superfluous WILL command from remote endpoint."); //$NON-NLS-1$
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,8 +396,7 @@ class TelnetOption implements TelnetCodes
|
||||||
*/
|
*/
|
||||||
public void handleWont() {
|
public void handleWont() {
|
||||||
if (negotiationState == NEGOTIATION_DONE && ignoreNegotiation()) {
|
if (negotiationState == NEGOTIATION_DONE && ignoreNegotiation()) {
|
||||||
Logger
|
Logger.log("Ignoring superfluous WONT command from remote endpoint."); //$NON-NLS-1$
|
||||||
.log("Ignoring superfluous WONT command from remote endpoint."); //$NON-NLS-1$
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,8 +473,7 @@ class TelnetOption implements TelnetCodes
|
||||||
*/
|
*/
|
||||||
public void handleDont() {
|
public void handleDont() {
|
||||||
if (negotiationState == NEGOTIATION_DONE && ignoreNegotiation()) {
|
if (negotiationState == NEGOTIATION_DONE && ignoreNegotiation()) {
|
||||||
Logger
|
Logger.log("Ignoring superfluous DONT command from remote endpoint."); //$NON-NLS-1$
|
||||||
.log("Ignoring superfluous DONT command from remote endpoint."); //$NON-NLS-1$
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +511,7 @@ class TelnetOption implements TelnetCodes
|
||||||
case TELNET_OPTION_TERMINAL_TYPE:
|
case TELNET_OPTION_TERMINAL_TYPE:
|
||||||
if (subnegotiationData[1] != TELNET_SEND) {
|
if (subnegotiationData[1] != TELNET_SEND) {
|
||||||
// This should never happen!
|
// This should never happen!
|
||||||
Logger
|
Logger.log("Invalid TERMINAL-TYPE subnegotiation command from remote endpoint: " + //$NON-NLS-1$
|
||||||
.log("Invalid TERMINAL-TYPE subnegotiation command from remote endpoint: " + //$NON-NLS-1$
|
|
||||||
(subnegotiationData[1] & 0xff));
|
(subnegotiationData[1] & 0xff));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -531,8 +521,7 @@ class TelnetOption implements TelnetCodes
|
||||||
//
|
//
|
||||||
// IAC SB TERMINAL-TYPE IS x t e r m IAC SE
|
// IAC SB TERMINAL-TYPE IS x t e r m IAC SE
|
||||||
|
|
||||||
byte[] terminalTypeData = { TELNET_IAC, TELNET_SB,
|
byte[] terminalTypeData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_TERMINAL_TYPE, TELNET_IS, (byte) 'x',
|
||||||
TELNET_OPTION_TERMINAL_TYPE, TELNET_IS, (byte) 'x',
|
|
||||||
(byte) 't', (byte) 'e', (byte) 'r', (byte) 'm', TELNET_IAC, TELNET_SE };
|
(byte) 't', (byte) 'e', (byte) 'r', (byte) 'm', TELNET_IAC, TELNET_SE };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -545,8 +534,7 @@ class TelnetOption implements TelnetCodes
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// This should never happen!
|
// This should never happen!
|
||||||
Logger
|
Logger.log("SHOULD NOT BE REACHED: Called for option " + optionName()); //$NON-NLS-1$
|
||||||
.log("SHOULD NOT BE REACHED: Called for option " + optionName()); //$NON-NLS-1$
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,8 +555,7 @@ class TelnetOption implements TelnetCodes
|
||||||
// IAC SB NAWS <width-highbyte> <width-lowbyte> <height-highbyte>
|
// IAC SB NAWS <width-highbyte> <width-lowbyte> <height-highbyte>
|
||||||
// <height-lowbyte> IAC SE
|
// <height-lowbyte> IAC SE
|
||||||
|
|
||||||
final byte[] NAWSData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_NAWS, 0,
|
final byte[] NAWSData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_NAWS, 0, 0, 0, 0, TELNET_IAC, TELNET_SE };
|
||||||
0, 0, 0, TELNET_IAC, TELNET_SE };
|
|
||||||
int width = ((Integer) subnegotiationData[0]).intValue();
|
int width = ((Integer) subnegotiationData[0]).intValue();
|
||||||
int height = ((Integer) subnegotiationData[1]).intValue();
|
int height = ((Integer) subnegotiationData[1]).intValue();
|
||||||
|
|
||||||
|
@ -577,8 +564,7 @@ class TelnetOption implements TelnetCodes
|
||||||
NAWSData[5] = (byte) ((height >>> 8) & 0xff); // High order byte of height.
|
NAWSData[5] = (byte) ((height >>> 8) & 0xff); // High order byte of height.
|
||||||
NAWSData[6] = (byte) (height & 0xff); // Low order byte of height.
|
NAWSData[6] = (byte) (height & 0xff); // Low order byte of height.
|
||||||
|
|
||||||
Logger
|
Logger.log("sending terminal size to remote endpoint: width = " + width + //$NON-NLS-1$
|
||||||
.log("sending terminal size to remote endpoint: width = " + width + //$NON-NLS-1$
|
|
||||||
", height = " + height + "."); //$NON-NLS-1$ //$NON-NLS-2$
|
", height = " + height + "."); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
// Send the NAWS data in a new thread. The current thread is the display
|
// Send the NAWS data in a new thread. The current thread is the display
|
||||||
|
@ -602,8 +588,7 @@ class TelnetOption implements TelnetCodes
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// This should never happen!
|
// This should never happen!
|
||||||
Logger
|
Logger.log("SHOULD NOT BE REACHED: Called for option " + optionName()); //$NON-NLS-1$
|
||||||
.log("SHOULD NOT BE REACHED: Called for option " + optionName()); //$NON-NLS-1$
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class TelnetSettings implements ITelnetSettings {
|
||||||
protected String fTimeout;
|
protected String fTimeout;
|
||||||
protected String fEndOfLine = EOL_CRNUL;
|
protected String fEndOfLine = EOL_CRNUL;
|
||||||
private final TelnetProperties fProperties = new TelnetProperties();
|
private final TelnetProperties fProperties = new TelnetProperties();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return fHost;
|
return fHost;
|
||||||
|
@ -79,6 +80,7 @@ public class TelnetSettings implements ITelnetSettings {
|
||||||
public TelnetProperties getProperties() {
|
public TelnetProperties getProperties() {
|
||||||
return fProperties;
|
return fProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
try {
|
try {
|
||||||
|
@ -87,6 +89,7 @@ public class TelnetSettings implements ITelnetSettings {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimeoutString() {
|
public String getTimeoutString() {
|
||||||
return fTimeout;
|
return fTimeout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
public TelnetSettingsPage(TelnetSettings settings) {
|
public TelnetSettingsPage(TelnetSettings settings) {
|
||||||
fTerminalSettings = settings;
|
fTerminalSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveSettings() {
|
public void saveSettings() {
|
||||||
fTerminalSettings.setHost(fHostText.getText());
|
fTerminalSettings.setHost(fHostText.getText());
|
||||||
|
@ -67,18 +68,21 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
setEndOfLine(fTerminalSettings.getEndOfLine());
|
setEndOfLine(fTerminalSettings.getEndOfLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHost(String strHost) {
|
private void setHost(String strHost) {
|
||||||
if (strHost == null)
|
if (strHost == null)
|
||||||
strHost = ""; //$NON-NLS-1$
|
strHost = ""; //$NON-NLS-1$
|
||||||
fHostText.setText(strHost);
|
fHostText.setText(strHost);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTimeout(String timeout) {
|
private void setTimeout(String timeout) {
|
||||||
if (timeout == null || timeout.length() == 0)
|
if (timeout == null || timeout.length() == 0)
|
||||||
timeout = "5"; //$NON-NLS-1$
|
timeout = "5"; //$NON-NLS-1$
|
||||||
fTimeout.setText(timeout);
|
fTimeout.setText(timeout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNetworkPort(String strNetworkPort) {
|
private void setNetworkPort(String strNetworkPort) {
|
||||||
if (strNetworkPort != null) {
|
if (strNetworkPort != null) {
|
||||||
String strPortName = getNetworkPortMap().findPortName(strNetworkPort);
|
String strPortName = getNetworkPortMap().findPortName(strNetworkPort);
|
||||||
|
@ -94,21 +98,26 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNetworkPort() {
|
private String getNetworkPort() {
|
||||||
String portText = fNetworkPortCombo.getText().trim();
|
String portText = fNetworkPortCombo.getText().trim();
|
||||||
String mappedPort = getNetworkPortMap().findPort(portText);
|
String mappedPort = getNetworkPortMap().findPort(portText);
|
||||||
return mappedPort != null ? mappedPort : portText;
|
return mappedPort != null ? mappedPort : portText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkPortMap getNetworkPortMap() {
|
private NetworkPortMap getNetworkPortMap() {
|
||||||
return fTerminalSettings.getProperties().getNetworkPortMap();
|
return fTerminalSettings.getProperties().getNetworkPortMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEndOfLine(String eol) {
|
private void setEndOfLine(String eol) {
|
||||||
int idx = fEndOfLineCombo.indexOf(eol);
|
int idx = fEndOfLineCombo.indexOf(eol);
|
||||||
fEndOfLineCombo.select(idx >= 0 ? idx : 0);
|
fEndOfLineCombo.select(idx >= 0 ? idx : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEndOfLine() {
|
private String getEndOfLine() {
|
||||||
return fEndOfLineCombo.getText();
|
return fEndOfLineCombo.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validateSettings() {
|
public boolean validateSettings() {
|
||||||
String message = null;
|
String message = null;
|
||||||
|
@ -119,7 +128,10 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Please enter a host IP or name."; //$NON-NLS-1$
|
String m = "Please enter a host IP or name."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.INFORMATION;
|
int mt = IMessageProvider.INFORMATION;
|
||||||
updateControlDecoration(fHostText, m, mt);
|
updateControlDecoration(fHostText, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,7 +144,10 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Invalid network port. Must be between 0 and 65535."; //$NON-NLS-1$
|
String m = "Invalid network port. Must be between 0 and 65535."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.ERROR;
|
int mt = IMessageProvider.ERROR;
|
||||||
updateControlDecoration(fNetworkPortCombo, m, mt);
|
updateControlDecoration(fNetworkPortCombo, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +159,10 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
String m = "Invalid timeout. Must be greater than 0."; //$NON-NLS-1$
|
String m = "Invalid timeout. Must be greater than 0."; //$NON-NLS-1$
|
||||||
int mt = IMessageProvider.ERROR;
|
int mt = IMessageProvider.ERROR;
|
||||||
updateControlDecoration(fTimeout, m, mt);
|
updateControlDecoration(fTimeout, m, mt);
|
||||||
if (mt > messageType) { message = m; messageType = mt; }
|
if (mt > messageType) {
|
||||||
|
message = m;
|
||||||
|
messageType = mt;
|
||||||
|
}
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,6 +254,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCombo(Combo ctlCombo, List<String> table) {
|
private void loadCombo(Combo ctlCombo, List<String> table) {
|
||||||
for (Iterator<String> iter = table.iterator(); iter.hasNext();) {
|
for (Iterator<String> iter = table.iterator(); iter.hasNext();) {
|
||||||
String label = iter.next();
|
String label = iter.next();
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
panel.setLayoutData(data);
|
panel.setLayoutData(data);
|
||||||
|
|
||||||
// Create the host selection combo
|
// Create the host selection combo
|
||||||
if (isWithoutSelection()) createHostsUI(panel, true);
|
if (isWithoutSelection())
|
||||||
|
createHostsUI(panel, true);
|
||||||
|
|
||||||
TelnetConnector conn = new TelnetConnector();
|
TelnetConnector conn = new TelnetConnector();
|
||||||
telnetSettings = (TelnetSettings) conn.getTelnetSettings();
|
telnetSettings = (TelnetSettings) conn.getTelnetSettings();
|
||||||
|
@ -78,7 +79,8 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsPageChanged(Control control) {
|
public void onSettingsPageChanged(Control control) {
|
||||||
if (getContainer() != null) getContainer().validate();
|
if (getContainer() != null)
|
||||||
|
getContainer().validate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,25 +95,31 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setupData(Map<String, Object> data) {
|
public void setupData(Map<String, Object> data) {
|
||||||
if (data == null || telnetSettings == null || telnetSettingsPage == null) return;
|
if (data == null || telnetSettings == null || telnetSettingsPage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
String value = (String) data.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
String value = (String) data.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
if (value != null) telnetSettings.setHost(value);
|
if (value != null)
|
||||||
|
telnetSettings.setHost(value);
|
||||||
|
|
||||||
Object v = data.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object v = data.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
value = v != null ? v.toString() : null;
|
value = v != null ? v.toString() : null;
|
||||||
if (value != null) telnetSettings.setNetworkPort(value);
|
if (value != null)
|
||||||
|
telnetSettings.setNetworkPort(value);
|
||||||
|
|
||||||
v = data.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
v = data.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
||||||
value = v != null ? v.toString() : null;
|
value = v != null ? v.toString() : null;
|
||||||
if (value != null) telnetSettings.setTimeout(value);
|
if (value != null)
|
||||||
|
telnetSettings.setTimeout(value);
|
||||||
|
|
||||||
v = data.get(ITerminalsConnectorConstants.PROP_TELNET_EOL);
|
v = data.get(ITerminalsConnectorConstants.PROP_TELNET_EOL);
|
||||||
value = v != null ? v.toString() : null;
|
value = v != null ? v.toString() : null;
|
||||||
if (value != null) telnetSettings.setEndOfLine(value);
|
if (value != null)
|
||||||
|
telnetSettings.setEndOfLine(value);
|
||||||
|
|
||||||
value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
|
||||||
if (value != null) setEncoding(value);
|
if (value != null)
|
||||||
|
setEncoding(value);
|
||||||
|
|
||||||
telnetSettingsPage.loadSettings();
|
telnetSettingsPage.loadSettings();
|
||||||
}
|
}
|
||||||
|
@ -121,10 +129,12 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void extractData(Map<String, Object> data) {
|
public void extractData(Map<String, Object> data) {
|
||||||
if (data == null) return;
|
if (data == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// set the terminal connector id for ssh
|
// set the terminal connector id for ssh
|
||||||
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.telnet.TelnetConnector"); //$NON-NLS-1$
|
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID,
|
||||||
|
"org.eclipse.tm.terminal.connector.telnet.TelnetConnector"); //$NON-NLS-1$
|
||||||
|
|
||||||
telnetSettingsPage.saveSettings();
|
telnetSettingsPage.saveSettings();
|
||||||
data.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
|
data.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
|
||||||
|
@ -181,8 +191,10 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
}
|
}
|
||||||
if (hostSettings != null) {
|
if (hostSettings != null) {
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(telnetSettings.getNetworkPort()));
|
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT,
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(telnetSettings.getTimeout()));
|
Integer.toString(telnetSettings.getNetworkPort()));
|
||||||
|
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT,
|
||||||
|
Integer.toString(telnetSettings.getTimeout()));
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_TELNET_EOL, telnetSettings.getEndOfLine());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_TELNET_EOL, telnetSettings.getEndOfLine());
|
||||||
if (getEncoding() != null) {
|
if (getEncoding() != null) {
|
||||||
hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
||||||
|
|
|
@ -94,7 +94,8 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
private String getTerminalTitle(Map<String, Object> properties) {
|
private String getTerminalTitle(Map<String, Object> properties) {
|
||||||
// Try to see if the user set a title explicitly via the properties map.
|
// Try to see if the user set a title explicitly via the properties map.
|
||||||
String title = getDefaultTerminalTitle(properties);
|
String title = getDefaultTerminalTitle(properties);
|
||||||
if (title != null) return title;
|
if (title != null)
|
||||||
|
return title;
|
||||||
|
|
||||||
//No title,try to calculate the title
|
//No title,try to calculate the title
|
||||||
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
|
@ -128,7 +129,8 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
// Check for the terminal connector id
|
// Check for the terminal connector id
|
||||||
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
|
||||||
if (connectorId == null) connectorId = "org.eclipse.tm.terminal.connector.telnet.TelnetConnector"; //$NON-NLS-1$
|
if (connectorId == null)
|
||||||
|
connectorId = "org.eclipse.tm.terminal.connector.telnet.TelnetConnector"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Extract the telnet properties
|
// Extract the telnet properties
|
||||||
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||||
|
@ -141,7 +143,8 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
int portOffset = 0;
|
int portOffset = 0;
|
||||||
if (properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) instanceof Integer) {
|
if (properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) instanceof Integer) {
|
||||||
portOffset = ((Integer) properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET)).intValue();
|
portOffset = ((Integer) properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET)).intValue();
|
||||||
if (portOffset < 0) portOffset = 0;
|
if (portOffset < 0)
|
||||||
|
portOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The real port to connect to is port + portOffset
|
// The real port to connect to is port + portOffset
|
||||||
|
|
|
@ -33,12 +33,16 @@ public class TelnetMementoHandler implements IMementoHandler {
|
||||||
|
|
||||||
// Do not write the terminal title to the memento -> needs to
|
// Do not write the terminal title to the memento -> needs to
|
||||||
// be recreated at the time of restoration.
|
// be recreated at the time of restoration.
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_IP_HOST, (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
memento.putString(ITerminalsConnectorConstants.PROP_IP_HOST,
|
||||||
|
(String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
memento.putInteger(ITerminalsConnectorConstants.PROP_IP_PORT, value instanceof Integer ? ((Integer)value).intValue() : -1);
|
memento.putInteger(ITerminalsConnectorConstants.PROP_IP_PORT,
|
||||||
|
value instanceof Integer ? ((Integer) value).intValue() : -1);
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
||||||
memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT, value instanceof Integer ? ((Integer)value).intValue() : -1);
|
memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT,
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING, (String)properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
|
value instanceof Integer ? ((Integer) value).intValue() : -1);
|
||||||
|
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING,
|
||||||
|
(String) properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -50,9 +54,13 @@ public class TelnetMementoHandler implements IMementoHandler {
|
||||||
Assert.isNotNull(properties);
|
Assert.isNotNull(properties);
|
||||||
|
|
||||||
// Restore the terminal properties from the memento
|
// Restore the terminal properties from the memento
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_IP_HOST, memento.getString(ITerminalsConnectorConstants.PROP_IP_HOST));
|
properties.put(ITerminalsConnectorConstants.PROP_IP_HOST,
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_IP_PORT, memento.getInteger(ITerminalsConnectorConstants.PROP_IP_PORT));
|
memento.getString(ITerminalsConnectorConstants.PROP_IP_HOST));
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_TIMEOUT, memento.getInteger(ITerminalsConnectorConstants.PROP_TIMEOUT));
|
properties.put(ITerminalsConnectorConstants.PROP_IP_PORT,
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
memento.getInteger(ITerminalsConnectorConstants.PROP_IP_PORT));
|
||||||
|
properties.put(ITerminalsConnectorConstants.PROP_TIMEOUT,
|
||||||
|
memento.getInteger(ITerminalsConnectorConstants.PROP_TIMEOUT));
|
||||||
|
properties.put(ITerminalsConnectorConstants.PROP_ENCODING,
|
||||||
|
memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
*/
|
*/
|
||||||
TerminalConnectorImpl makeConnector() throws Exception;
|
TerminalConnectorImpl makeConnector() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The factory for creating impl instances.
|
* The factory for creating impl instances.
|
||||||
*/
|
*/
|
||||||
|
@ -95,6 +96,7 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
* This keeps the value until the connector is created.
|
* This keeps the value until the connector is created.
|
||||||
*/
|
*/
|
||||||
private ISettingsStore fStore;
|
private ISettingsStore fStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the terminal connector.
|
* Constructor for the terminal connector.
|
||||||
*
|
*
|
||||||
|
@ -104,27 +106,33 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
* this ID.
|
* this ID.
|
||||||
* @param name translatable name to display the connector in the UI.
|
* @param name translatable name to display the connector in the UI.
|
||||||
*/
|
*/
|
||||||
public TerminalConnector(TerminalConnector.Factory terminalConnectorFactory, String id, String name, boolean hidden) {
|
public TerminalConnector(TerminalConnector.Factory terminalConnectorFactory, String id, String name,
|
||||||
|
boolean hidden) {
|
||||||
fTerminalConnectorFactory = terminalConnectorFactory;
|
fTerminalConnectorFactory = terminalConnectorFactory;
|
||||||
fId = id;
|
fId = id;
|
||||||
fName = name;
|
fName = name;
|
||||||
fHidden = hidden;
|
fHidden = hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInitializationErrorMessage() {
|
public String getInitializationErrorMessage() {
|
||||||
getConnectorImpl();
|
getConnectorImpl();
|
||||||
if (fException != null)
|
if (fException != null)
|
||||||
return fException.getLocalizedMessage();
|
return fException.getLocalizedMessage();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return fId;
|
return fId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return fName;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHidden() {
|
public boolean isHidden() {
|
||||||
return fHidden;
|
return fHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TerminalConnectorImpl getConnectorImpl() {
|
private TerminalConnectorImpl getConnectorImpl() {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
try {
|
try {
|
||||||
|
@ -138,12 +146,15 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
control.setState(TerminalState.CLOSED);
|
control.setState(TerminalState.CLOSED);
|
||||||
control.setMsg(getInitializationErrorMessage());
|
control.setMsg(getInitializationErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputStream getTerminalToRemoteStream() {
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
return null;
|
return null;
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
// that's the place where we log the exception
|
// that's the place where we log the exception
|
||||||
Logger.logException(e);
|
Logger.logException(e);
|
||||||
}
|
}
|
||||||
|
@ -156,24 +167,30 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return fConnector != null || fException != null;
|
return fConnector != null || fException != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
getConnectorImpl().connect(control);
|
getConnectorImpl().connect(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
getConnectorImpl().disconnect();
|
getConnectorImpl().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputStream getTerminalToRemoteStream() {
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
return getConnectorImpl().getTerminalToRemoteStream();
|
return getConnectorImpl().getTerminalToRemoteStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
if (fConnector != null)
|
if (fConnector != null)
|
||||||
return getConnectorImpl().getSettingsSummary();
|
return getConnectorImpl().getSettingsSummary();
|
||||||
else
|
else
|
||||||
return TerminalMessages.NotInitialized;
|
return TerminalMessages.NotInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocalEcho() {
|
public boolean isLocalEcho() {
|
||||||
return getConnectorImpl().isLocalEcho();
|
return getConnectorImpl().isLocalEcho();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
if (fConnector == null) {
|
if (fConnector == null) {
|
||||||
fStore = store;
|
fStore = store;
|
||||||
|
@ -181,16 +198,19 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
getConnectorImpl().load(store);
|
getConnectorImpl().load(store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultSettings() {
|
public void setDefaultSettings() {
|
||||||
getConnectorImpl().setDefaultSettings();
|
getConnectorImpl().setDefaultSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
// no need to save the settings: it cannot have changed
|
// no need to save the settings: it cannot have changed
|
||||||
// because we are not initialized....
|
// because we are not initialized....
|
||||||
if (fConnector != null)
|
if (fConnector != null)
|
||||||
getConnectorImpl().save(store);
|
getConnectorImpl().save(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
// we assume that setTerminalSize is called also after
|
// we assume that setTerminalSize is called also after
|
||||||
// the terminal has been initialized. Else we would have to cache
|
// the terminal has been initialized. Else we would have to cache
|
||||||
|
@ -199,6 +219,7 @@ public class TerminalConnector implements ITerminalConnector {
|
||||||
fConnector.setTerminalSize(newWidth, newHeight);
|
fConnector.setTerminalSize(newWidth, newHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
TerminalConnectorImpl connector = null;
|
TerminalConnectorImpl connector = null;
|
||||||
if (isInitialized())
|
if (isInitialized())
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
*/
|
*/
|
||||||
static abstract public class Interceptor {
|
static abstract public class Interceptor {
|
||||||
protected OutputStream fOriginal;
|
protected OutputStream fOriginal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param original the injection into the original stream begins
|
* @param original the injection into the original stream begins
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
@ -36,12 +37,14 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
public void begin(OutputStream original) throws IOException {
|
public void begin(OutputStream original) throws IOException {
|
||||||
fOriginal = original;
|
fOriginal = original;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param b a byte was written to the {@link TerminalToRemoteInjectionOutputStream}.
|
* @param b a byte was written to the {@link TerminalToRemoteInjectionOutputStream}.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param b bytes written to the {@link TerminalToRemoteInjectionOutputStream}.
|
* @param b bytes written to the {@link TerminalToRemoteInjectionOutputStream}.
|
||||||
* @param off the start offset in the data.
|
* @param off the start offset in the data.
|
||||||
|
@ -50,29 +53,37 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
*/
|
*/
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The injection into the normal stream ends.
|
* The injection into the normal stream ends.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public class BufferInterceptor extends Interceptor {
|
static public class BufferInterceptor extends Interceptor {
|
||||||
private final ByteArrayOutputStream fBuffer = new ByteArrayOutputStream();
|
private final ByteArrayOutputStream fBuffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
fOriginal.write(fBuffer.toByteArray());
|
fOriginal.write(fBuffer.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
fBuffer.write(b, off, len);
|
fBuffer.write(b, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
fBuffer.write(b);
|
fBuffer.write(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TerminalFilterOutputStream extends OutputStream {
|
private class TerminalFilterOutputStream extends OutputStream {
|
||||||
final private Object fLock = TerminalToRemoteInjectionOutputStream.this;
|
final private Object fLock = TerminalToRemoteInjectionOutputStream.this;
|
||||||
|
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
if (fInjection == this) {
|
if (fInjection == this) {
|
||||||
|
@ -81,40 +92,48 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
checkStream();
|
checkStream();
|
||||||
out.write(b, off, len);
|
out.write(b, off, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] b) throws IOException {
|
public void write(byte[] b) throws IOException {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
checkStream();
|
checkStream();
|
||||||
out.write(b);
|
out.write(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() throws IOException {
|
public void flush() throws IOException {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
checkStream();
|
checkStream();
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
checkStream();
|
checkStream();
|
||||||
out.write(b);
|
out.write(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStream() throws IOException {
|
private void checkStream() throws IOException {
|
||||||
if (fInjection != this)
|
if (fInjection != this)
|
||||||
throw new IOException("Stream is closed"); //$NON-NLS-1$
|
throw new IOException("Stream is closed"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Interceptor fInterceptor;
|
private Interceptor fInterceptor;
|
||||||
private TerminalFilterOutputStream fInjection;
|
private TerminalFilterOutputStream fInjection;
|
||||||
|
|
||||||
public TerminalToRemoteInjectionOutputStream(OutputStream out) {
|
public TerminalToRemoteInjectionOutputStream(OutputStream out) {
|
||||||
super(out);
|
super(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized protected void ungrabOutput() throws IOException {
|
synchronized protected void ungrabOutput() throws IOException {
|
||||||
if (fInterceptor != null) {
|
if (fInterceptor != null) {
|
||||||
fInterceptor.close();
|
fInterceptor.close();
|
||||||
|
@ -122,6 +141,7 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
fInjection = null;
|
fInjection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There can only be one injection stream active at a time. You must call close on the
|
* There can only be one injection stream active at a time. You must call close on the
|
||||||
* returned output stream to end the injection.
|
* returned output stream to end the injection.
|
||||||
|
@ -138,6 +158,7 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
fInjection = new TerminalFilterOutputStream();
|
fInjection = new TerminalFilterOutputStream();
|
||||||
return fInjection;
|
return fInjection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** See {@link #grabOutput(TerminalToRemoteInjectionOutputStream.Interceptor)}.
|
/** See {@link #grabOutput(TerminalToRemoteInjectionOutputStream.Interceptor)}.
|
||||||
* @return injection output stream
|
* @return injection output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
@ -145,23 +166,27 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream {
|
||||||
public synchronized OutputStream grabOutput() throws IOException {
|
public synchronized OutputStream grabOutput() throws IOException {
|
||||||
return grabOutput(new BufferInterceptor());
|
return grabOutput(new BufferInterceptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void close() throws IOException {
|
synchronized public void close() throws IOException {
|
||||||
if (fInjection != null) {
|
if (fInjection != null) {
|
||||||
fInjection.close();
|
fInjection.close();
|
||||||
}
|
}
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void flush() throws IOException {
|
synchronized public void flush() throws IOException {
|
||||||
if (fInterceptor != null)
|
if (fInterceptor != null)
|
||||||
fInterceptor.flush();
|
fInterceptor.flush();
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void write(byte[] b, int off, int len) throws IOException {
|
synchronized public void write(byte[] b, int off, int len) throws IOException {
|
||||||
if (fInterceptor != null)
|
if (fInterceptor != null)
|
||||||
fInterceptor.write(b, off, len);
|
fInterceptor.write(b, off, len);
|
||||||
else
|
else
|
||||||
out.write(b, off, len);
|
out.write(b, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void write(int b) throws IOException {
|
synchronized public void write(int b) throws IOException {
|
||||||
if (fInterceptor != null)
|
if (fInterceptor != null)
|
||||||
fInterceptor.write(b);
|
fInterceptor.write(b);
|
||||||
|
|
|
@ -41,8 +41,6 @@ import org.eclipse.swt.widgets.Sash;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
|
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the Command History for the command line input
|
* Manages the Command History for the command line input
|
||||||
* of the terminal control.
|
* of the terminal control.
|
||||||
|
@ -78,14 +76,17 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Proposal implements IContentProposal {
|
private static class Proposal implements IContentProposal {
|
||||||
|
|
||||||
private final String fContent;
|
private final String fContent;
|
||||||
private final String fLabel;
|
private final String fLabel;
|
||||||
|
|
||||||
Proposal(String content, String label) {
|
Proposal(String content, String label) {
|
||||||
fContent = content;
|
fContent = content;
|
||||||
fLabel = label;
|
fLabel = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContent() {
|
public String getContent() {
|
||||||
return fContent;
|
return fContent;
|
||||||
}
|
}
|
||||||
|
@ -122,9 +123,11 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
private Text fInputField;
|
private Text fInputField;
|
||||||
private Sash fSash;
|
private Sash fSash;
|
||||||
private Composite fPanel;
|
private Composite fPanel;
|
||||||
|
|
||||||
public CommandInputFieldWithHistory(int maxHistorySize) {
|
public CommandInputFieldWithHistory(int maxHistorySize) {
|
||||||
fMaxSize = maxHistorySize;
|
fMaxSize = maxHistorySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a line to the history.
|
* Add a line to the history.
|
||||||
* @param line The line to be added to the history.
|
* @param line The line to be added to the history.
|
||||||
|
@ -142,6 +145,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
if (fHistory.size() >= fMaxSize)
|
if (fHistory.size() >= fMaxSize)
|
||||||
fHistory.remove(fHistory.size() - 1);
|
fHistory.remove(fHistory.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the history
|
* Sets the history
|
||||||
* @param history or null
|
* @param history or null
|
||||||
|
@ -159,6 +163,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
fHistory.add((String) tok.nextElement());
|
fHistory.add((String) tok.nextElement());
|
||||||
//</J2ME CDC-1.1 Foundation-1.1 variant>
|
//</J2ME CDC-1.1 Foundation-1.1 variant>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current content of the history buffer and new line separated list
|
* @return the current content of the history buffer and new line separated list
|
||||||
*/
|
*/
|
||||||
|
@ -177,6 +182,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
}
|
}
|
||||||
return buff.toString();
|
return buff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param currLine Line of text to be moved in history
|
* @param currLine Line of text to be moved in history
|
||||||
* @param count (+1 or -1) for forward and backward movement. -1 goes back
|
* @param count (+1 or -1) for forward and backward movement. -1 goes back
|
||||||
|
@ -198,6 +204,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
fEditHistoryPos += count;
|
fEditHistoryPos += count;
|
||||||
return (String) fEditedHistory.get(fEditHistoryPos);
|
return (String) fEditedHistory.get(fEditHistoryPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inHistoryMode() {
|
private boolean inHistoryMode() {
|
||||||
return fEditedHistory != null;
|
return fEditedHistory != null;
|
||||||
}
|
}
|
||||||
|
@ -213,6 +220,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
endHistoryMode();
|
endHistoryMode();
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End history editing
|
* End history editing
|
||||||
*/
|
*/
|
||||||
|
@ -220,6 +228,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
fEditedHistory = null;
|
fEditedHistory = null;
|
||||||
fEditHistoryPos = 0;
|
fEditHistoryPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createControl(final Composite parent, final ITerminalViewControl terminal) {
|
public void createControl(final Composite parent, final ITerminalViewControl terminal) {
|
||||||
// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH);
|
// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH);
|
||||||
fSash = new Sash(parent, SWT.HORIZONTAL);
|
fSash = new Sash(parent, SWT.HORIZONTAL);
|
||||||
|
@ -250,7 +259,10 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
});
|
});
|
||||||
fPanel = new Composite(parent, SWT.NONE);
|
fPanel = new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
layout.marginWidth = 0; layout.marginHeight = 0; layout.marginTop = 0; layout.marginBottom = 2;
|
layout.marginWidth = 0;
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginTop = 0;
|
||||||
|
layout.marginBottom = 2;
|
||||||
fPanel.setLayout(layout);
|
fPanel.setLayout(layout);
|
||||||
fPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
fPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
fInputField = new Text(fPanel, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
|
fInputField = new Text(fPanel, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
|
||||||
|
@ -268,12 +280,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
// Else the ENTER key is sent *first* to the input field
|
// Else the ENTER key is sent *first* to the input field
|
||||||
// and then to the field assist popup.
|
// and then to the field assist popup.
|
||||||
// (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659)
|
// (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659)
|
||||||
new ContentAssistCommandAdapter(
|
new ContentAssistCommandAdapter(fInputField, new TextContentAdapter(), new FieldAssist(), null, null,
|
||||||
fInputField,
|
|
||||||
new TextContentAdapter(),
|
|
||||||
new FieldAssist(),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
installDecoration);
|
installDecoration);
|
||||||
fInputField.addKeyListener(new KeyListener() {
|
fInputField.addKeyListener(new KeyListener() {
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
|
@ -299,20 +306,24 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
setCommand(escape());
|
setCommand(escape());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCommand(String line) {
|
private void setCommand(String line) {
|
||||||
if (line == null)
|
if (line == null)
|
||||||
return;
|
return;
|
||||||
fInputField.setText(line);
|
fInputField.setText(line);
|
||||||
fInputField.setSelection(fInputField.getCharCount());
|
fInputField.setSelection(fInputField.getCharCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFont(Font font) {
|
public void setFont(Font font) {
|
||||||
fInputField.setFont(font);
|
fInputField.setFont(font);
|
||||||
fInputField.getParent().layout(true);
|
fInputField.getParent().layout(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
fSash.dispose();
|
fSash.dispose();
|
||||||
fSash = null;
|
fSash = null;
|
||||||
|
|
|
@ -25,6 +25,7 @@ public interface ICommandInputField {
|
||||||
void createControl(Composite parent, ITerminalViewControl terminal);
|
void createControl(Composite parent, ITerminalViewControl terminal);
|
||||||
|
|
||||||
void dispose();
|
void dispose();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the font of a control created with {@link #createControl(Composite, ITerminalViewControl)}
|
* Sets the font of a control created with {@link #createControl(Composite, ITerminalViewControl)}
|
||||||
* @param control
|
* @param control
|
||||||
|
|
|
@ -26,6 +26,7 @@ public interface ITerminalMouseListener {
|
||||||
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
||||||
*/
|
*/
|
||||||
void mouseDoubleClick(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
void mouseDoubleClick(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when a mouse button is pushed down inside the terminal control.<br>
|
* Invoked when a mouse button is pushed down inside the terminal control.<br>
|
||||||
* <br>
|
* <br>
|
||||||
|
@ -34,6 +35,7 @@ public interface ITerminalMouseListener {
|
||||||
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
||||||
*/
|
*/
|
||||||
void mouseDown(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
void mouseDown(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when a mouse button is released inside the terminal control.<br>
|
* Invoked when a mouse button is released inside the terminal control.<br>
|
||||||
* <br>
|
* <br>
|
||||||
|
|
|
@ -51,12 +51,14 @@ public interface ITerminalViewControl {
|
||||||
String getEncoding();
|
String getEncoding();
|
||||||
|
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Terminal font
|
* Sets the Terminal font
|
||||||
* @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font
|
* @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font
|
||||||
* @param font
|
* @param font
|
||||||
*/
|
*/
|
||||||
void setFont(Font font);
|
void setFont(Font font);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the font for the Terminal, using a JFace symbolic font name, such
|
* Sets the font for the Terminal, using a JFace symbolic font name, such
|
||||||
* that bold and italic variants can be leveraged.
|
* that bold and italic variants can be leveraged.
|
||||||
|
@ -64,36 +66,58 @@ public interface ITerminalViewControl {
|
||||||
* @param fontName
|
* @param fontName
|
||||||
*/
|
*/
|
||||||
void setFont(String fontName);
|
void setFont(String fontName);
|
||||||
|
|
||||||
void setInvertedColors(boolean invert);
|
void setInvertedColors(boolean invert);
|
||||||
|
|
||||||
Font getFont();
|
Font getFont();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the text control
|
* @return the text control
|
||||||
*/
|
*/
|
||||||
Control getControl();
|
Control getControl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the root of all controls
|
* @return the root of all controls
|
||||||
*/
|
*/
|
||||||
Control getRootControl();
|
Control getRootControl();
|
||||||
|
|
||||||
boolean isDisposed();
|
boolean isDisposed();
|
||||||
|
|
||||||
void selectAll();
|
void selectAll();
|
||||||
|
|
||||||
void clearTerminal();
|
void clearTerminal();
|
||||||
|
|
||||||
void copy();
|
void copy();
|
||||||
|
|
||||||
void paste();
|
void paste();
|
||||||
|
|
||||||
String getSelection();
|
String getSelection();
|
||||||
|
|
||||||
TerminalState getState();
|
TerminalState getState();
|
||||||
|
|
||||||
Clipboard getClipboard();
|
Clipboard getClipboard();
|
||||||
|
|
||||||
void disconnectTerminal();
|
void disconnectTerminal();
|
||||||
|
|
||||||
void disposeTerminal();
|
void disposeTerminal();
|
||||||
|
|
||||||
String getSettingsSummary();
|
String getSettingsSummary();
|
||||||
|
|
||||||
ITerminalConnector[] getConnectors();
|
ITerminalConnector[] getConnectors();
|
||||||
|
|
||||||
void setFocus();
|
void setFocus();
|
||||||
|
|
||||||
ITerminalConnector getTerminalConnector();
|
ITerminalConnector getTerminalConnector();
|
||||||
|
|
||||||
void setConnector(ITerminalConnector connector);
|
void setConnector(ITerminalConnector connector);
|
||||||
|
|
||||||
void connectTerminal();
|
void connectTerminal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param write a single character to terminal
|
* @param write a single character to terminal
|
||||||
*/
|
*/
|
||||||
void sendKey(char arg0);
|
void sendKey(char arg0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string write string to terminal
|
* @param string write string to terminal
|
||||||
*/
|
*/
|
||||||
|
@ -105,6 +129,7 @@ public interface ITerminalViewControl {
|
||||||
* @param inputField null means no input field is shown
|
* @param inputField null means no input field is shown
|
||||||
*/
|
*/
|
||||||
void setCommandInputField(ICommandInputField inputField);
|
void setCommandInputField(ICommandInputField inputField);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null or the current input field
|
* @return null or the current input field
|
||||||
*/
|
*/
|
||||||
|
@ -121,13 +146,16 @@ public interface ITerminalViewControl {
|
||||||
* in the terminal view. -1 means unlimited.
|
* in the terminal view. -1 means unlimited.
|
||||||
*/
|
*/
|
||||||
public void setBufferLineLimit(int bufferLineLimit);
|
public void setBufferLineLimit(int bufferLineLimit);
|
||||||
|
|
||||||
boolean isScrollLock();
|
boolean isScrollLock();
|
||||||
|
|
||||||
void setScrollLock(boolean on);
|
void setScrollLock(boolean on);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
void addMouseListener(ITerminalMouseListener listener);
|
void addMouseListener(ITerminalMouseListener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,7 +23,8 @@ public class TerminalViewControlFactory {
|
||||||
* @param wndParent The Window parent to embed the Terminal in.
|
* @param wndParent The Window parent to embed the Terminal in.
|
||||||
* @param connectors Provided connectors.
|
* @param connectors Provided connectors.
|
||||||
*/
|
*/
|
||||||
public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) {
|
public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent,
|
||||||
|
ITerminalConnector[] connectors) {
|
||||||
return makeControl(target, wndParent, connectors, false);
|
return makeControl(target, wndParent, connectors, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,8 @@ public class TerminalViewControlFactory {
|
||||||
* Otherwise, clients need to maintain settings themselves.
|
* Otherwise, clients need to maintain settings themselves.
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) {
|
public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent,
|
||||||
|
ITerminalConnector[] connectors, boolean useCommonPrefs) {
|
||||||
return new VT100TerminalControl(target, wndParent, connectors, useCommonPrefs);
|
return new VT100TerminalControl(target, wndParent, connectors, useCommonPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,11 @@ public abstract class AbstractTerminalAction extends Action {
|
||||||
this(null, strId, 0);
|
this(null, strId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractTerminalAction(ITerminalViewControl target,
|
public AbstractTerminalAction(ITerminalViewControl target, String strId) {
|
||||||
String strId) {
|
|
||||||
this(target, strId, 0);
|
this(target, strId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractTerminalAction(ITerminalViewControl target,
|
public AbstractTerminalAction(ITerminalViewControl target, String strId, int style) {
|
||||||
String strId, int style) {
|
|
||||||
super("", style); //$NON-NLS-1$
|
super("", style); //$NON-NLS-1$
|
||||||
|
|
||||||
fTarget = target;
|
fTarget = target;
|
||||||
|
@ -48,27 +46,20 @@ public abstract class AbstractTerminalAction extends Action {
|
||||||
|
|
||||||
abstract public void run();
|
abstract public void run();
|
||||||
|
|
||||||
protected void setupAction(String strText, String strToolTip,
|
protected void setupAction(String strText, String strToolTip, String strImage, String strEnabledImage,
|
||||||
String strImage, String strEnabledImage, String strDisabledImage,
|
String strDisabledImage, boolean bEnabled) {
|
||||||
boolean bEnabled) {
|
setupAction(strText, strToolTip, strImage, strEnabledImage, strDisabledImage, bEnabled,
|
||||||
setupAction(strText, strToolTip, strImage, strEnabledImage,
|
TerminalPlugin.getDefault().getImageRegistry());
|
||||||
strDisabledImage, bEnabled, TerminalPlugin.getDefault()
|
|
||||||
.getImageRegistry());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupAction(String strText, String strToolTip,
|
protected void setupAction(String strText, String strToolTip, String strHoverImage, String strEnabledImage,
|
||||||
String strHoverImage, String strEnabledImage,
|
String strDisabledImage, boolean bEnabled, ImageRegistry imageRegistry) {
|
||||||
String strDisabledImage, boolean bEnabled,
|
setupAction(strText, strToolTip, imageRegistry.getDescriptor(strHoverImage),
|
||||||
ImageRegistry imageRegistry) {
|
imageRegistry.getDescriptor(strEnabledImage), imageRegistry.getDescriptor(strDisabledImage), bEnabled);
|
||||||
setupAction(strText, strToolTip, imageRegistry
|
|
||||||
.getDescriptor(strHoverImage), imageRegistry
|
|
||||||
.getDescriptor(strEnabledImage), imageRegistry
|
|
||||||
.getDescriptor(strDisabledImage), bEnabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupAction(String strText, String strToolTip,
|
protected void setupAction(String strText, String strToolTip, ImageDescriptor hoverImage,
|
||||||
ImageDescriptor hoverImage, ImageDescriptor enabledImage,
|
ImageDescriptor enabledImage, ImageDescriptor disabledImage, boolean bEnabled) {
|
||||||
ImageDescriptor disabledImage, boolean bEnabled) {
|
|
||||||
setText(strText);
|
setText(strText);
|
||||||
setToolTipText(strToolTip);
|
setToolTipText(strToolTip);
|
||||||
setEnabled(bEnabled);
|
setEnabled(bEnabled);
|
||||||
|
|
|
@ -23,8 +23,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class ActionMessages extends NLS {
|
public class ActionMessages extends NLS {
|
||||||
static {
|
static {
|
||||||
NLS.initializeMessages(ActionMessages.class.getName(),
|
NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class);
|
||||||
ActionMessages.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String COPY;
|
public static String COPY;
|
||||||
|
|
|
@ -26,19 +26,15 @@ public class TerminalActionClearAll extends AbstractTerminalAction {
|
||||||
public TerminalActionClearAll() {
|
public TerminalActionClearAll() {
|
||||||
super(TerminalActionClearAll.class.getName());
|
super(TerminalActionClearAll.class.getName());
|
||||||
|
|
||||||
setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL,
|
setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, ImageConsts.IMAGE_CLCL_CLEAR_ALL,
|
||||||
ImageConsts.IMAGE_CLCL_CLEAR_ALL,
|
ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DLCL_CLEAR_ALL, false);
|
||||||
ImageConsts.IMAGE_ELCL_CLEAR_ALL,
|
|
||||||
ImageConsts.IMAGE_DLCL_CLEAR_ALL, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalActionClearAll(ITerminalViewControl target) {
|
public TerminalActionClearAll(ITerminalViewControl target) {
|
||||||
super(target, TerminalActionClearAll.class.getName());
|
super(target, TerminalActionClearAll.class.getName());
|
||||||
|
|
||||||
setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL,
|
setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, ImageConsts.IMAGE_CLCL_CLEAR_ALL,
|
||||||
ImageConsts.IMAGE_CLCL_CLEAR_ALL,
|
ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DLCL_CLEAR_ALL, false);
|
||||||
ImageConsts.IMAGE_ELCL_CLEAR_ALL,
|
|
||||||
ImageConsts.IMAGE_DLCL_CLEAR_ALL, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -29,20 +29,18 @@ public class TerminalActionCopy extends AbstractTerminalAction {
|
||||||
super(TerminalActionCopy.class.getName());
|
super(TerminalActionCopy.class.getName());
|
||||||
setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$
|
setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$
|
||||||
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setupAction(ActionMessages.COPY, ActionMessages.COPY, si
|
setupAction(ActionMessages.COPY, ActionMessages.COPY, si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true);
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalActionCopy(ITerminalViewControl target) {
|
public TerminalActionCopy(ITerminalViewControl target) {
|
||||||
super(target, TerminalActionCopy.class.getName());
|
super(target, TerminalActionCopy.class.getName());
|
||||||
setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$
|
setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$
|
||||||
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setupAction(ActionMessages.COPY, ActionMessages.COPY, si
|
setupAction(ActionMessages.COPY, ActionMessages.COPY, si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true);
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -27,19 +27,17 @@ public class TerminalActionCut extends AbstractTerminalAction {
|
||||||
public TerminalActionCut() {
|
public TerminalActionCut() {
|
||||||
super(TerminalActionCut.class.getName());
|
super(TerminalActionCut.class.getName());
|
||||||
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setupAction(ActionMessages.CUT, ActionMessages.CUT, si
|
setupAction(ActionMessages.CUT, ActionMessages.CUT, si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true);
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalActionCut(ITerminalViewControl target) {
|
public TerminalActionCut(ITerminalViewControl target) {
|
||||||
super(target, TerminalActionCut.class.getName());
|
super(target, TerminalActionCut.class.getName());
|
||||||
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setupAction(ActionMessages.CUT, ActionMessages.CUT, si
|
setupAction(ActionMessages.CUT, ActionMessages.CUT, si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT),
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true);
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -33,22 +33,18 @@ public class TerminalActionPaste extends AbstractTerminalAction {
|
||||||
super(TerminalActionPaste.class.getName());
|
super(TerminalActionPaste.class.getName());
|
||||||
setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$
|
setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$
|
||||||
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setupAction(ActionMessages.PASTE, ActionMessages.PASTE,
|
setupAction(ActionMessages.PASTE, ActionMessages.PASTE, si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
||||||
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
||||||
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), false);
|
||||||
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED),
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalActionPaste(ITerminalViewControl target) {
|
public TerminalActionPaste(ITerminalViewControl target) {
|
||||||
super(target, TerminalActionPaste.class.getName());
|
super(target, TerminalActionPaste.class.getName());
|
||||||
setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$
|
setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$
|
||||||
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages si = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setupAction(ActionMessages.PASTE, ActionMessages.PASTE,
|
setupAction(ActionMessages.PASTE, ActionMessages.PASTE, si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
||||||
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
||||||
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE),
|
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), false);
|
||||||
si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED),
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -62,8 +58,7 @@ public class TerminalActionPaste extends AbstractTerminalAction {
|
||||||
ITerminalViewControl target = getTarget();
|
ITerminalViewControl target = getTarget();
|
||||||
boolean bEnabled = target != null && target.getClipboard() != null && !target.getClipboard().isDisposed();
|
boolean bEnabled = target != null && target.getClipboard() != null && !target.getClipboard().isDisposed();
|
||||||
if (bEnabled) {
|
if (bEnabled) {
|
||||||
String strText = (String) target.getClipboard().getContents(
|
String strText = (String) target.getClipboard().getContents(TextTransfer.getInstance());
|
||||||
TextTransfer.getInstance());
|
|
||||||
bEnabled = ((strText != null) && (!strText.equals("")) && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$
|
bEnabled = ((strText != null) && (!strText.equals("")) && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$
|
||||||
}
|
}
|
||||||
setEnabled(bEnabled);
|
setEnabled(bEnabled);
|
||||||
|
|
|
@ -27,15 +27,13 @@ public class TerminalActionSelectAll extends AbstractTerminalAction {
|
||||||
public TerminalActionSelectAll() {
|
public TerminalActionSelectAll() {
|
||||||
super(TerminalActionSelectAll.class.getName());
|
super(TerminalActionSelectAll.class.getName());
|
||||||
|
|
||||||
setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL,
|
setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, (ImageDescriptor) null, null, null, false);
|
||||||
(ImageDescriptor) null, null, null, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalActionSelectAll(ITerminalViewControl target) {
|
public TerminalActionSelectAll(ITerminalViewControl target) {
|
||||||
super(target, TerminalActionSelectAll.class.getName());
|
super(target, TerminalActionSelectAll.class.getName());
|
||||||
|
|
||||||
setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL,
|
setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, (ImageDescriptor) null, null, null, false);
|
||||||
(ImageDescriptor) null, null, null, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -25,7 +25,9 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
public interface ITerminalControlForText {
|
public interface ITerminalControlForText {
|
||||||
|
|
||||||
TerminalState getState();
|
TerminalState getState();
|
||||||
|
|
||||||
void setState(TerminalState state);
|
void setState(TerminalState state);
|
||||||
|
|
||||||
void setTerminalTitle(String title);
|
void setTerminalTitle(String title);
|
||||||
|
|
||||||
ITerminalConnector getTerminalConnector();
|
ITerminalConnector getTerminalConnector();
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class TerminalPlugin extends AbstractUIPlugin {
|
||||||
*/
|
*/
|
||||||
public TerminalPlugin() {
|
public TerminalPlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the shared instance.
|
* Returns the shared instance.
|
||||||
*/
|
*/
|
||||||
|
@ -76,17 +77,21 @@ public class TerminalPlugin extends AbstractUIPlugin {
|
||||||
protected void initializeImageRegistry(ImageRegistry imageRegistry) {
|
protected void initializeImageRegistry(ImageRegistry imageRegistry) {
|
||||||
try {
|
try {
|
||||||
// Local toolbars
|
// Local toolbars
|
||||||
putImageInRegistry(imageRegistry, ImageConsts.IMAGE_CLCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_LOCALTOOL + "clear_co.gif"); //$NON-NLS-1$
|
putImageInRegistry(imageRegistry, ImageConsts.IMAGE_CLCL_CLEAR_ALL,
|
||||||
|
ImageConsts.IMAGE_DIR_LOCALTOOL + "clear_co.gif"); //$NON-NLS-1$
|
||||||
// Enabled local toolbars
|
// Enabled local toolbars
|
||||||
putImageInRegistry(imageRegistry, ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_ELCL + "clear_co.gif"); //$NON-NLS-1$
|
putImageInRegistry(imageRegistry, ImageConsts.IMAGE_ELCL_CLEAR_ALL,
|
||||||
|
ImageConsts.IMAGE_DIR_ELCL + "clear_co.gif"); //$NON-NLS-1$
|
||||||
// Disabled local toolbars
|
// Disabled local toolbars
|
||||||
putImageInRegistry(imageRegistry, ImageConsts.IMAGE_DLCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_DLCL + "clear_co.gif"); //$NON-NLS-1$
|
putImageInRegistry(imageRegistry, ImageConsts.IMAGE_DLCL_CLEAR_ALL,
|
||||||
|
ImageConsts.IMAGE_DIR_DLCL + "clear_co.gif"); //$NON-NLS-1$
|
||||||
} catch (MalformedURLException malformedURLException) {
|
} catch (MalformedURLException malformedURLException) {
|
||||||
malformedURLException.printStackTrace();
|
malformedURLException.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putImageInRegistry(ImageRegistry imageRegistry, String strKey, String relativePath) throws MalformedURLException {
|
protected void putImageInRegistry(ImageRegistry imageRegistry, String strKey, String relativePath)
|
||||||
|
throws MalformedURLException {
|
||||||
URL url = TerminalPlugin.getDefault().getBundle().getEntry(relativePath);
|
URL url = TerminalPlugin.getDefault().getBundle().getEntry(relativePath);
|
||||||
ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
|
ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
|
||||||
imageRegistry.put(strKey, imageDescriptor);
|
imageRegistry.put(strKey, imageDescriptor);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.tm.terminal.model.Style;
|
||||||
public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
||||||
final IVT100EmulatorBackend fBackend;
|
final IVT100EmulatorBackend fBackend;
|
||||||
final PrintStream fWriter;
|
final PrintStream fWriter;
|
||||||
|
|
||||||
public VT100BackendTraceDecorator(IVT100EmulatorBackend backend, PrintStream out) {
|
public VT100BackendTraceDecorator(IVT100EmulatorBackend backend, PrintStream out) {
|
||||||
fBackend = backend;
|
fBackend = backend;
|
||||||
fWriter = out;
|
fWriter = out;
|
||||||
|
|
|
@ -85,7 +85,6 @@ public class VT100Emulator implements ControlListener {
|
||||||
*/
|
*/
|
||||||
private static final int ANSISTATE_EXPECTING_CHARSET_DESIGNATION = 5;
|
private static final int ANSISTATE_EXPECTING_CHARSET_DESIGNATION = 5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field holds the current state of the Finite TerminalState Automaton (FSA)
|
* This field holds the current state of the Finite TerminalState Automaton (FSA)
|
||||||
* that recognizes ANSI escape sequences.
|
* that recognizes ANSI escape sequences.
|
||||||
|
@ -140,6 +139,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
Reader fReader;
|
Reader fReader;
|
||||||
|
|
||||||
boolean fCrAfterNewLine;
|
boolean fCrAfterNewLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -236,6 +236,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
if (text != null)
|
if (text != null)
|
||||||
adjustTerminalDimensions();
|
adjustTerminalDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * This method executes in the Display thread to process data received from
|
// * This method executes in the Display thread to process data received from
|
||||||
// * the remote host by class {@link org.eclipse.tm.internal.terminal.telnet.TelnetConnection} and
|
// * the remote host by class {@link org.eclipse.tm.internal.terminal.telnet.TelnetConnection} and
|
||||||
|
@ -275,6 +276,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
Logger.logException(ex);
|
Logger.logException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method scans the newly received text, processing ANSI control
|
* This method scans the newly received text, processing ANSI control
|
||||||
* characters and escape sequences and displaying normal text.
|
* characters and escape sequences and displaying normal text.
|
||||||
|
@ -283,7 +285,6 @@ public class VT100Emulator implements ControlListener {
|
||||||
private void processNewText() throws IOException {
|
private void processNewText() throws IOException {
|
||||||
Logger.log("entered"); //$NON-NLS-1$
|
Logger.log("entered"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
// Scan the newly received text.
|
// Scan the newly received text.
|
||||||
|
|
||||||
while (hasNextChar()) {
|
while (hasNextChar()) {
|
||||||
|
@ -382,8 +383,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Logger
|
Logger.log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
.log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
ansiState = ANSISTATE_INITIAL;
|
ansiState = ANSISTATE_INITIAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -448,6 +448,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetTerminal() {
|
private void resetTerminal() {
|
||||||
text.eraseAll();
|
text.eraseAll();
|
||||||
text.setCursor(0, 0);
|
text.setCursor(0, 0);
|
||||||
|
@ -456,6 +457,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
text.setInsertMode(false);
|
text.setInsertMode(false);
|
||||||
terminal.enableApplicationCursorKeys(false);
|
terminal.enableApplicationCursorKeys(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when we have parsed an OS Command escape sequence.
|
* This method is called when we have parsed an OS Command escape sequence.
|
||||||
* The only one we support is "\e]0;...\u0007", which sets the terminal
|
* The only one we support is "\e]0;...\u0007", which sets the terminal
|
||||||
|
@ -463,8 +465,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
*/
|
*/
|
||||||
private void processAnsiOsCommand() {
|
private void processAnsiOsCommand() {
|
||||||
if (ansiOsCommand.charAt(0) != '0' || ansiOsCommand.charAt(1) != ';') {
|
if (ansiOsCommand.charAt(0) != '0' || ansiOsCommand.charAt(1) != ';') {
|
||||||
Logger
|
Logger.log("Ignoring unsupported ANSI OSC sequence: '" + ansiOsCommand + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
.log("Ignoring unsupported ANSI OSC sequence: '" + ansiOsCommand + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
terminal.setTerminalTitle(ansiOsCommand.substring(2));
|
terminal.setTerminalTitle(ansiOsCommand.substring(2));
|
||||||
|
@ -845,8 +846,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
int totalParameters = ansiParameters.length;
|
int totalParameters = ansiParameters.length;
|
||||||
int parameterIndex = 0;
|
int parameterIndex = 0;
|
||||||
|
|
||||||
while (parameterIndex < totalParameters
|
while (parameterIndex < totalParameters && ansiParameters[parameterIndex].length() > 0) {
|
||||||
&& ansiParameters[parameterIndex].length() > 0) {
|
|
||||||
int ansiParameter = getAnsiParameter(parameterIndex);
|
int ansiParameter = getAnsiParameter(parameterIndex);
|
||||||
|
|
||||||
switch (ansiParameter) {
|
switch (ansiParameter) {
|
||||||
|
@ -964,8 +964,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Logger
|
Logger.log("Unsupported graphics rendition parameter: " + ansiParameter); //$NON-NLS-1$
|
||||||
.log("Unsupported graphics rendition parameter: " + ansiParameter); //$NON-NLS-1$
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,6 +1127,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
ansiParameters[nextAnsiParameter].append(ch);
|
ansiParameters[nextAnsiParameter].append(ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method processes a contiguous sequence of non-control characters.
|
* This method processes a contiguous sequence of non-control characters.
|
||||||
* This is a performance optimization, so that we don't have to insert or
|
* This is a performance optimization, so that we don't have to insert or
|
||||||
|
@ -1143,9 +1143,8 @@ public class VT100Emulator implements ControlListener {
|
||||||
// firstNonControlCharacterIndex in newText.
|
// firstNonControlCharacterIndex in newText.
|
||||||
while (hasNextChar()) {
|
while (hasNextChar()) {
|
||||||
character = getNextChar();
|
character = getNextChar();
|
||||||
if(character == '\u0000' || character == '\b' || character == '\t'
|
if (character == '\u0000' || character == '\b' || character == '\t' || character == '\u0007'
|
||||||
|| character == '\u0007' || character == '\n'
|
|| character == '\n' || character == '\r' || character == '\u001b') {
|
||||||
|| character == '\r' || character == '\u001b') {
|
|
||||||
pushBackChar(character);
|
pushBackChar(character);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1172,6 @@ public class VT100Emulator implements ControlListener {
|
||||||
text.appendString(buffer);
|
text.appendString(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a BEL (Control-G) character.
|
* Process a BEL (Control-G) character.
|
||||||
*/
|
*/
|
||||||
|
@ -1330,6 +1328,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
private void moveCursorBackward(int columnsToMove) {
|
private void moveCursorBackward(int columnsToMove) {
|
||||||
moveCursor(relativeCursorLine(), getCursorColumn() - columnsToMove);
|
moveCursor(relativeCursorLine(), getCursorColumn() - columnsToMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the state of the terminal text (foreground color, background color,
|
* Resets the state of the terminal text (foreground color, background color,
|
||||||
* font style and other internal state). It essentially makes it ready for new input.
|
* font style and other internal state). It essentially makes it ready for new input.
|
||||||
|
@ -1380,18 +1379,23 @@ public class VT100Emulator implements ControlListener {
|
||||||
//assert fNextChar!=-1: "Already a character waiting:"+fNextChar; //$NON-NLS-1$
|
//assert fNextChar!=-1: "Already a character waiting:"+fNextChar; //$NON-NLS-1$
|
||||||
fNextChar = c;
|
fNextChar = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCursorColumn() {
|
private int getCursorColumn() {
|
||||||
return text.getCursorColumn();
|
return text.getCursorColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCrAfterNewLine() {
|
public boolean isCrAfterNewLine() {
|
||||||
return fCrAfterNewLine;
|
return fCrAfterNewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCrAfterNewLine(boolean crAfterNewLine) {
|
public void setCrAfterNewLine(boolean crAfterNewLine) {
|
||||||
fCrAfterNewLine = crAfterNewLine;
|
fCrAfterNewLine = crAfterNewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVT100LineWrapping(boolean enable) {
|
void setVT100LineWrapping(boolean enable) {
|
||||||
text.setVT100LineWrapping(enable);
|
text.setVT100LineWrapping(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isVT100LineWrapping() {
|
boolean isVT100LineWrapping() {
|
||||||
return text.isVT100LineWrapping();
|
return text.isVT100LineWrapping();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,19 +29,24 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
static final ScrollRegion FULL_WINDOW = new ScrollRegion(0, Integer.MAX_VALUE - 1);
|
static final ScrollRegion FULL_WINDOW = new ScrollRegion(0, Integer.MAX_VALUE - 1);
|
||||||
private final int fTop;
|
private final int fTop;
|
||||||
private final int fBottom;
|
private final int fBottom;
|
||||||
|
|
||||||
ScrollRegion(int top, int bottom) {
|
ScrollRegion(int top, int bottom) {
|
||||||
fTop = top;
|
fTop = top;
|
||||||
fBottom = bottom;
|
fBottom = bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean contains(int line) {
|
boolean contains(int line) {
|
||||||
return line >= fTop && line <= fBottom;
|
return line >= fTop && line <= fBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getTopLine() {
|
int getTopLine() {
|
||||||
return fTop;
|
return fTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBottomLine() {
|
int getBottomLine() {
|
||||||
return fBottom;
|
return fBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getHeight() {
|
int getHeight() {
|
||||||
return fBottom - fTop + 1;
|
return fBottom - fTop + 1;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +114,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
setCursor(0, 0);
|
setCursor(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDimensions(int, int)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDimensions(int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -151,6 +157,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
return fTerminal.getHeight() - fLines + line;
|
return fTerminal.getHeight() - fLines + line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#insertCharacters(int)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#insertCharacters(int)
|
||||||
*/
|
*/
|
||||||
|
@ -182,6 +189,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseToCursor()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseToCursor()
|
||||||
*/
|
*/
|
||||||
|
@ -193,6 +201,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
eraseLineToCursor();
|
eraseLineToCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseAll()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseAll()
|
||||||
*/
|
*/
|
||||||
|
@ -203,6 +212,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLine()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLine()
|
||||||
*/
|
*/
|
||||||
|
@ -211,6 +221,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
fTerminal.cleanLine(toAbsoluteLine(fCursorLine));
|
fTerminal.cleanLine(toAbsoluteLine(fCursorLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToEnd()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToEnd()
|
||||||
*/
|
*/
|
||||||
|
@ -222,6 +233,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToCursor()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToCursor()
|
||||||
*/
|
*/
|
||||||
|
@ -247,6 +259,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
fTerminal.scroll(line, nLines, n);
|
fTerminal.scroll(line, nLines, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteCharacters(int)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteCharacters(int)
|
||||||
*/
|
*/
|
||||||
|
@ -264,6 +277,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteLines(int)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteLines(int)
|
||||||
*/
|
*/
|
||||||
|
@ -277,6 +291,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
fTerminal.scroll(line, nLines, -n);
|
fTerminal.scroll(line, nLines, -n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCusorInScrollingRegion() {
|
private boolean isCusorInScrollingRegion() {
|
||||||
return fScrollRegion.contains(fCursorLine);
|
return fScrollRegion.contains(fCursorLine);
|
||||||
}
|
}
|
||||||
|
@ -309,6 +324,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
return fStyle;
|
return fStyle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setStyle(org.eclipse.tm.terminal.model.Style)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setStyle(org.eclipse.tm.terminal.model.Style)
|
||||||
*/
|
*/
|
||||||
|
@ -317,6 +333,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
fStyle = style;
|
fStyle = style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#appendString(java.lang.String)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#appendString(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -376,6 +393,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
setCursorLine(fCursorLine + 1);
|
setCursorLine(fCursorLine + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#processNewline()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#processNewline()
|
||||||
*/
|
*/
|
||||||
|
@ -384,6 +402,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
doNewline();
|
doNewline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorLine()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorLine()
|
||||||
*/
|
*/
|
||||||
|
@ -392,6 +411,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
return fCursorLine;
|
return fCursorLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorColumn()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorColumn()
|
||||||
*/
|
*/
|
||||||
|
@ -400,6 +420,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
return fCursorColumn;
|
return fCursorColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursor(int, int)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursor(int, int)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -125,8 +125,7 @@ import org.eclipse.ui.keys.IBindingService;
|
||||||
*
|
*
|
||||||
* @author Chris Thew <chris.thew@windriver.com>
|
* @author Chris Thew <chris.thew@windriver.com>
|
||||||
*/
|
*/
|
||||||
public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl
|
public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl {
|
||||||
{
|
|
||||||
protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$
|
protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,7 +204,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* Otherwise, clients need to maintain settings themselves.
|
* Otherwise, clients need to maintain settings themselves.
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) {
|
public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors,
|
||||||
|
boolean useCommonPrefs) {
|
||||||
fConnectors = connectors;
|
fConnectors = connectors;
|
||||||
fUseCommonPrefs = useCommonPrefs;
|
fUseCommonPrefs = useCommonPrefs;
|
||||||
fTerminalListener = target;
|
fTerminalListener = target;
|
||||||
|
@ -429,9 +429,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
fTerminalText.resetState();
|
fTerminalText.resetState();
|
||||||
fApplicationCursorKeys = false;
|
fApplicationCursorKeys = false;
|
||||||
if (fConnector.getInitializationErrorMessage() != null) {
|
if (fConnector.getInitializationErrorMessage() != null) {
|
||||||
showErrorMessage(NLS.bind(
|
showErrorMessage(NLS.bind(TerminalMessages.CannotConnectTo, fConnector.getName(),
|
||||||
TerminalMessages.CannotConnectTo,
|
|
||||||
fConnector.getName(),
|
|
||||||
fConnector.getInitializationErrorMessage()));
|
fConnector.getInitializationErrorMessage()));
|
||||||
// we cannot connect because the connector was not initialized
|
// we cannot connect because the connector was not initialized
|
||||||
return;
|
return;
|
||||||
|
@ -446,6 +444,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
public ITerminalConnector getTerminalConnector() {
|
public ITerminalConnector getTerminalConnector() {
|
||||||
return fConnector;
|
return fConnector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disconnectTerminal()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disconnectTerminal()
|
||||||
*/
|
*/
|
||||||
|
@ -471,10 +470,12 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
// Join job to avoid leaving job running after workbench shutdown (333613).
|
// Join job to avoid leaving job running after workbench shutdown (333613).
|
||||||
// Interrupt to be fast enough; cannot close fInputStream since it is re-used (bug 348700).
|
// Interrupt to be fast enough; cannot close fInputStream since it is re-used (bug 348700).
|
||||||
Thread t = job.getThread();
|
Thread t = job.getThread();
|
||||||
if(t!=null) t.interrupt();
|
if (t != null)
|
||||||
|
t.interrupt();
|
||||||
try {
|
try {
|
||||||
job.join();
|
job.join();
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fPollingTextCanvasModel.stopPolling();
|
fPollingTextCanvasModel.stopPolling();
|
||||||
}
|
}
|
||||||
|
@ -530,7 +531,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
fTerminalText.processText();
|
fTerminalText.processText();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
status=new Status(IStatus.ERROR,TerminalPlugin.PLUGIN_ID,e.getLocalizedMessage(),e);
|
status = new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, e.getLocalizedMessage(),
|
||||||
|
e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,8 +578,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
} catch (SocketException socketException) {
|
} catch (SocketException socketException) {
|
||||||
displayTextInTerminal(socketException.getMessage());
|
displayTextInTerminal(socketException.getMessage());
|
||||||
|
|
||||||
String strMsg = TerminalMessages.SocketError
|
String strMsg = TerminalMessages.SocketError + "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
||||||
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
|
||||||
showErrorMessage(strMsg);
|
showErrorMessage(strMsg);
|
||||||
|
|
||||||
Logger.logException(socketException);
|
Logger.logException(socketException);
|
||||||
|
@ -619,7 +620,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding);
|
byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding);
|
||||||
StringBuilder b = new StringBuilder("sending ESC"); //$NON-NLS-1$
|
StringBuilder b = new StringBuilder("sending ESC"); //$NON-NLS-1$
|
||||||
for (int i = 0; i < bytesToSend.length; i++) {
|
for (int i = 0; i < bytesToSend.length; i++) {
|
||||||
if (i != 0) b.append(" +"); //$NON-NLS-1$
|
if (i != 0)
|
||||||
|
b.append(" +"); //$NON-NLS-1$
|
||||||
b.append(" '" + bytesToSend[i] + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
b.append(" '" + bytesToSend[i] + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
Logger.log(b.toString());
|
Logger.log(b.toString());
|
||||||
|
@ -629,7 +631,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding);
|
byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding);
|
||||||
StringBuilder b = new StringBuilder("sending"); //$NON-NLS-1$
|
StringBuilder b = new StringBuilder("sending"); //$NON-NLS-1$
|
||||||
for (int i = 0; i < bytesToSend.length; i++) {
|
for (int i = 0; i < bytesToSend.length; i++) {
|
||||||
if (i != 0) b.append(" +"); //$NON-NLS-1$
|
if (i != 0)
|
||||||
|
b.append(" +"); //$NON-NLS-1$
|
||||||
b.append(" '" + bytesToSend[i] + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
b.append(" '" + bytesToSend[i] + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
Logger.log(b.toString());
|
Logger.log(b.toString());
|
||||||
|
@ -642,8 +645,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
|
|
||||||
displayTextInTerminal(socketException.getMessage());
|
displayTextInTerminal(socketException.getMessage());
|
||||||
|
|
||||||
String strMsg = TerminalMessages.SocketError
|
String strMsg = TerminalMessages.SocketError + "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
||||||
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
|
||||||
|
|
||||||
showErrorMessage(strMsg);
|
showErrorMessage(strMsg);
|
||||||
Logger.logException(socketException);
|
Logger.logException(socketException);
|
||||||
|
@ -703,8 +705,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#updatePreferences()
|
* @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#updatePreferences()
|
||||||
*/
|
*/
|
||||||
private void updatePreferences() {
|
private void updatePreferences() {
|
||||||
int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_BUFFERLINES, 0, null);
|
int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID,
|
||||||
boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_INVERT_COLORS, false, null);
|
ITerminalConstants.PREF_BUFFERLINES, 0, null);
|
||||||
|
boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID,
|
||||||
|
ITerminalConstants.PREF_INVERT_COLORS, false, null);
|
||||||
setBufferLineLimit(bufferLineLimit);
|
setBufferLineLimit(bufferLineLimit);
|
||||||
setInvertedColors(invert);
|
setInvertedColors(invert);
|
||||||
}
|
}
|
||||||
|
@ -745,29 +749,36 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
fCtlText.onFontChange();
|
fCtlText.onFontChange();
|
||||||
getTerminalText().fontChanged();
|
getTerminalText().fontChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
return getCtlText().getFont();
|
return getCtlText().getFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Control getControl() {
|
public Control getControl() {
|
||||||
return fCtlText;
|
return fCtlText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Control getRootControl() {
|
public Control getRootControl() {
|
||||||
return fWndParent;
|
return fWndParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupControls(Composite parent) {
|
protected void setupControls(Composite parent) {
|
||||||
fWndParent = new Composite(parent, SWT.NONE);
|
fWndParent = new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
layout.marginWidth=0; layout.marginHeight=0; layout.verticalSpacing=0;
|
layout.marginWidth = 0;
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.verticalSpacing = 0;
|
||||||
fWndParent.setLayout(layout);
|
fWndParent.setLayout(layout);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = fTerminalModel.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = fTerminalModel.makeSnapshot();
|
||||||
// TODO how to get the initial size correctly!
|
// TODO how to get the initial size correctly!
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
fPollingTextCanvasModel = new PollingTextCanvasModel(snapshot);
|
fPollingTextCanvasModel = new PollingTextCanvasModel(snapshot);
|
||||||
fCtlText=new TextCanvas(fWndParent,fPollingTextCanvasModel,SWT.NONE,new TextLineRenderer(fCtlText,fPollingTextCanvasModel));
|
fCtlText = new TextCanvas(fWndParent, fPollingTextCanvasModel, SWT.NONE,
|
||||||
|
new TextLineRenderer(fCtlText, fPollingTextCanvasModel));
|
||||||
|
|
||||||
fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
fCtlText.addResizeHandler(new TextCanvas.ResizeListener() {
|
fCtlText.addResizeHandler(new TextCanvas.ResizeListener() {
|
||||||
|
@ -821,6 +832,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
public void displayTextInTerminal(String text) {
|
public void displayTextInTerminal(String text) {
|
||||||
writeToTerminal("\r\n" + text + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
writeToTerminal("\r\n" + text + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeToTerminal(String text) {
|
private void writeToTerminal(String text) {
|
||||||
try {
|
try {
|
||||||
getRemoteToTerminalOutputStream().write(text.getBytes(fEncoding));
|
getRemoteToTerminalOutputStream().write(text.getBytes(fEncoding));
|
||||||
|
@ -841,6 +853,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
return fInputStream.getOutputStream();
|
return fInputStream.getOutputStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isLogCharEnabled() {
|
protected boolean isLogCharEnabled() {
|
||||||
return TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_CHAR);
|
return TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_CHAR);
|
||||||
}
|
}
|
||||||
|
@ -877,6 +890,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
public VT100Emulator getTerminalText() {
|
public VT100Emulator getTerminalText() {
|
||||||
return fTerminalText;
|
return fTerminalText;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class TerminalMouseTrackListener implements MouseTrackListener {
|
protected class TerminalMouseTrackListener implements MouseTrackListener {
|
||||||
private IContextActivation terminalContextActivation = null;
|
private IContextActivation terminalContextActivation = null;
|
||||||
private IContextActivation editContextActivation = null;
|
private IContextActivation editContextActivation = null;
|
||||||
|
@ -898,7 +912,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
if (getState() == TerminalState.CONNECTED)
|
if (getState() == TerminalState.CONNECTED)
|
||||||
captureKeyEvents(true);
|
captureKeyEvents(true);
|
||||||
|
|
||||||
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
|
IContextService contextService = (IContextService) PlatformUI.getWorkbench()
|
||||||
|
.getAdapter(IContextService.class);
|
||||||
editContextActivation = contextService.activateContext("org.eclipse.tm.terminal.EditContext"); //$NON-NLS-1$
|
editContextActivation = contextService.activateContext("org.eclipse.tm.terminal.EditContext"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,14 +925,17 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
|
|
||||||
// Restore the command context to its previous value.
|
// Restore the command context to its previous value.
|
||||||
|
|
||||||
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
|
IContextService contextService = (IContextService) PlatformUI.getWorkbench()
|
||||||
|
.getAdapter(IContextService.class);
|
||||||
contextService.deactivateContext(editContextActivation);
|
contextService.deactivateContext(editContextActivation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("cast")
|
@SuppressWarnings("cast")
|
||||||
protected void captureKeyEvents(boolean capture) {
|
protected void captureKeyEvents(boolean capture) {
|
||||||
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
|
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench()
|
||||||
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
|
.getAdapter(IBindingService.class);
|
||||||
|
IContextService contextService = (IContextService) PlatformUI.getWorkbench()
|
||||||
|
.getAdapter(IContextService.class);
|
||||||
|
|
||||||
boolean enableKeyFilter = !capture;
|
boolean enableKeyFilter = !capture;
|
||||||
if (bindingService.isKeyFilterEnabled() != enableKeyFilter)
|
if (bindingService.isKeyFilterEnabled() != enableKeyFilter)
|
||||||
|
@ -1203,12 +1221,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
//
|
//
|
||||||
// o The character is the DELETE character.
|
// o The character is the DELETE character.
|
||||||
|
|
||||||
if (getTerminalConnector() == null
|
if (getTerminalConnector() == null || getTerminalConnector().isLocalEcho() == false || altKeyPressed
|
||||||
|| getTerminalConnector().isLocalEcho() == false || altKeyPressed
|
|| (character >= '\u0001' && character < '\t') || (character > '\t' && character < '\r')
|
||||||
|| (character >= '\u0001' && character < '\t')
|
|| (character > '\r' && character <= '\u001f') || character == '\u007f') {
|
||||||
|| (character > '\t' && character < '\r')
|
|
||||||
|| (character > '\r' && character <= '\u001f')
|
|
||||||
|| character == '\u007f') {
|
|
||||||
// No local echoing.
|
// No local echoing.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1232,13 +1247,15 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("cast")
|
@SuppressWarnings("cast")
|
||||||
private void processKeyBinding(KeyEvent event, int accelerator) {
|
private void processKeyBinding(KeyEvent event, int accelerator) {
|
||||||
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
|
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench()
|
||||||
|
.getAdapter(IBindingService.class);
|
||||||
KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator);
|
KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator);
|
||||||
Binding binding = bindingService.getPerfectMatch(KeySequence.getInstance(keyStroke));
|
Binding binding = bindingService.getPerfectMatch(KeySequence.getInstance(keyStroke));
|
||||||
if (binding != null) {
|
if (binding != null) {
|
||||||
ParameterizedCommand cmd = binding.getParameterizedCommand();
|
ParameterizedCommand cmd = binding.getParameterizedCommand();
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
|
IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
|
||||||
|
.getAdapter(IHandlerService.class);
|
||||||
Event cmdEvent = new Event();
|
Event cmdEvent = new Event();
|
||||||
cmdEvent.type = SWT.KeyDown;
|
cmdEvent.type = SWT.KeyDown;
|
||||||
cmdEvent.display = event.display;
|
cmdEvent.display = event.display;
|
||||||
|
@ -1262,8 +1279,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
try {
|
try {
|
||||||
handlerService.executeCommand(cmd, cmdEvent);
|
handlerService.executeCommand(cmd, cmdEvent);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
TerminalPlugin.getDefault().getLog().log(
|
TerminalPlugin.getDefault().getLog()
|
||||||
new Status(IStatus.ERROR,TerminalPlugin.PLUGIN_ID,e.getLocalizedMessage(),e));
|
.log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore other exceptions from cmd execution
|
// ignore other exceptions from cmd execution
|
||||||
}
|
}
|
||||||
|
@ -1278,13 +1295,11 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
fTerminalListener.setTerminalTitle(title);
|
fTerminalListener.setTerminalTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TerminalState getState() {
|
public TerminalState getState() {
|
||||||
return fState;
|
return fState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setState(TerminalState state) {
|
public void setState(TerminalState state) {
|
||||||
fState = state;
|
fState = state;
|
||||||
|
@ -1305,13 +1320,15 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param runnable run in display thread
|
* @param runnable run in display thread
|
||||||
*/
|
*/
|
||||||
private void runAsyncInDisplayThread(Runnable runnable) {
|
private void runAsyncInDisplayThread(Runnable runnable) {
|
||||||
if (Display.findDisplay(Thread.currentThread()) != null)
|
if (Display.findDisplay(Thread.currentThread()) != null)
|
||||||
runnable.run();
|
runnable.run();
|
||||||
else if(PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getDisplay() != null && !PlatformUI.getWorkbench().getDisplay().isDisposed())
|
else if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getDisplay() != null
|
||||||
|
&& !PlatformUI.getWorkbench().getDisplay().isDisposed())
|
||||||
PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
|
PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
|
||||||
// else should not happen and we ignore it...
|
// else should not happen and we ignore it...
|
||||||
}
|
}
|
||||||
|
@ -1328,6 +1345,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
fConnector = connector;
|
fConnector = connector;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICommandInputField getCommandInputField() {
|
public ICommandInputField getCommandInputField() {
|
||||||
return fCommandInputField;
|
return fCommandInputField;
|
||||||
|
|
|
@ -66,19 +66,21 @@ public interface ISnapshotChanges {
|
||||||
boolean hasLineChanged(int line);
|
boolean hasLineChanged(int line);
|
||||||
|
|
||||||
void markDimensionsChanged();
|
void markDimensionsChanged();
|
||||||
|
|
||||||
boolean hasDimensionsChanged();
|
boolean hasDimensionsChanged();
|
||||||
|
|
||||||
void markCursorChanged();
|
void markCursorChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the terminal data has changed
|
* @return true if the terminal data has changed
|
||||||
*/
|
*/
|
||||||
boolean hasTerminalChanged();
|
boolean hasTerminalChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mark the terminal as changed
|
* mark the terminal as changed
|
||||||
*/
|
*/
|
||||||
void setTerminalChanged();
|
void setTerminalChanged();
|
||||||
|
|
||||||
|
|
||||||
void copyChangedLines(ITerminalTextData dest, ITerminalTextData source);
|
void copyChangedLines(ITerminalTextData dest, ITerminalTextData source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +88,9 @@ public interface ISnapshotChanges {
|
||||||
* @param size number of lines to follow
|
* @param size number of lines to follow
|
||||||
*/
|
*/
|
||||||
void setInterestWindow(int startLine, int size);
|
void setInterestWindow(int startLine, int size);
|
||||||
|
|
||||||
int getInterestWindowStartLine();
|
int getInterestWindowStartLine();
|
||||||
|
|
||||||
int getInterestWindowSize();
|
int getInterestWindowSize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.tm.internal.terminal.model;
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects the changes of the {@link ITerminalTextData}
|
* Collects the changes of the {@link ITerminalTextData}
|
||||||
*
|
*
|
||||||
|
@ -57,6 +56,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
fFirstChangedLine = Integer.MAX_VALUE;
|
fFirstChangedLine = Integer.MAX_VALUE;
|
||||||
fLastChangedLine = -1;
|
fLastChangedLine = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SnapshotChanges(int windowStart, int windowSize) {
|
public SnapshotChanges(int windowStart, int windowSize) {
|
||||||
setChangedLinesLength(windowStart + windowSize);
|
setChangedLinesLength(windowStart + windowSize);
|
||||||
fFirstChangedLine = Integer.MAX_VALUE;
|
fFirstChangedLine = Integer.MAX_VALUE;
|
||||||
|
@ -65,6 +65,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
fInterestWindowSize = windowSize;
|
fInterestWindowSize = windowSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used in asserts to throw an {@link RuntimeException}.
|
* This is used in asserts to throw an {@link RuntimeException}.
|
||||||
* This is useful for tests.
|
* This is useful for tests.
|
||||||
|
@ -73,6 +74,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
private boolean throwRuntimeException() {
|
private boolean throwRuntimeException() {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line
|
* @param line
|
||||||
* @param size
|
* @param size
|
||||||
|
@ -88,6 +90,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line
|
* @param line
|
||||||
* @return true if the line is within the interest window
|
* @return true if the line is within the interest window
|
||||||
|
@ -102,6 +105,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line
|
* @param line
|
||||||
* @return the line within the window
|
* @return the line within the window
|
||||||
|
@ -116,6 +120,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
return fInterestWindowStartLine;
|
return fInterestWindowStartLine;
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result is only defined if {@link #isInInterestWindow(int, int)} returns true!
|
* The result is only defined if {@link #isInInterestWindow(int, int)} returns true!
|
||||||
* @param line the line <b>before</b> {@link #fitLineToWindow(int)} has been called!
|
* @param line the line <b>before</b> {@link #fitLineToWindow(int)} has been called!
|
||||||
|
@ -139,6 +144,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
size = fInterestWindowStartLine + fInterestWindowSize - line;
|
size = fInterestWindowStartLine + fInterestWindowSize - line;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLineChanged(int)
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLineChanged(int)
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +163,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
setChangedLine(line, true);
|
setChangedLine(line, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLinesChanged(int, int)
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLinesChanged(int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -178,9 +185,11 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
// this sets fLastChangedLine as well
|
// this sets fLastChangedLine as well
|
||||||
markLineChanged(line + n - 1);
|
markLineChanged(line + n - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markCursorChanged() {
|
public void markCursorChanged() {
|
||||||
fCursorHasChanged = true;
|
fCursorHasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#convertScrollingIntoChanges()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#convertScrollingIntoChanges()
|
||||||
*/
|
*/
|
||||||
|
@ -190,26 +199,33 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
fScrollWindowSize = 0;
|
fScrollWindowSize = 0;
|
||||||
fScrollWindowShift = 0;
|
fScrollWindowShift = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#hasChanged()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#hasChanged()
|
||||||
*/
|
*/
|
||||||
public boolean hasChanged() {
|
public boolean hasChanged() {
|
||||||
if(fFirstChangedLine!=Integer.MAX_VALUE || fLastChangedLine>0 || fScrollWindowShift!=0 ||fDimensionsChanged || fCursorHasChanged)
|
if (fFirstChangedLine != Integer.MAX_VALUE || fLastChangedLine > 0 || fScrollWindowShift != 0
|
||||||
|
|| fDimensionsChanged || fCursorHasChanged)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markDimensionsChanged() {
|
public void markDimensionsChanged() {
|
||||||
fDimensionsChanged = true;
|
fDimensionsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDimensionsChanged() {
|
public boolean hasDimensionsChanged() {
|
||||||
return fDimensionsChanged;
|
return fDimensionsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTerminalChanged() {
|
public boolean hasTerminalChanged() {
|
||||||
return fTerminalHasChanged;
|
return fTerminalHasChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerminalChanged() {
|
public void setTerminalChanged() {
|
||||||
fTerminalHasChanged = true;
|
fTerminalHasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#scroll(int, int, int)
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#scroll(int, int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -250,6 +266,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some incompatible scrolling occurred. We cannot do the
|
* Some incompatible scrolling occurred. We cannot do the
|
||||||
* scroll optimization anymore...
|
* scroll optimization anymore...
|
||||||
|
@ -265,6 +282,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
// don't be clever on scrolling anymore
|
// don't be clever on scrolling anymore
|
||||||
fScrollDontTrack = true;
|
fScrollDontTrack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls the changed lines data
|
* Scrolls the changed lines data
|
||||||
*
|
*
|
||||||
|
@ -292,6 +310,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
markLineChanged(i);
|
markLineChanged(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#setAllChanged(int)
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#setAllChanged(int)
|
||||||
*/
|
*/
|
||||||
|
@ -304,36 +323,42 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
// no need to keep an array of changes anymore
|
// no need to keep an array of changes anymore
|
||||||
setChangedLinesLength(0);
|
setChangedLinesLength(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getFirstChangedLine()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getFirstChangedLine()
|
||||||
*/
|
*/
|
||||||
public int getFirstChangedLine() {
|
public int getFirstChangedLine() {
|
||||||
return fFirstChangedLine;
|
return fFirstChangedLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getLastChangedLine()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getLastChangedLine()
|
||||||
*/
|
*/
|
||||||
public int getLastChangedLine() {
|
public int getLastChangedLine() {
|
||||||
return fLastChangedLine;
|
return fLastChangedLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowStartLine()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowStartLine()
|
||||||
*/
|
*/
|
||||||
public int getScrollWindowStartLine() {
|
public int getScrollWindowStartLine() {
|
||||||
return fScrollWindowStartLine;
|
return fScrollWindowStartLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowSize()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowSize()
|
||||||
*/
|
*/
|
||||||
public int getScrollWindowSize() {
|
public int getScrollWindowSize() {
|
||||||
return fScrollWindowSize;
|
return fScrollWindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowShift()
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowShift()
|
||||||
*/
|
*/
|
||||||
public int getScrollWindowShift() {
|
public int getScrollWindowShift() {
|
||||||
return fScrollWindowShift;
|
return fScrollWindowShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#copyChangedLines(org.eclipse.tm.terminal.model.ITerminalTextData, org.eclipse.tm.terminal.model.ITerminalTextData)
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#copyChangedLines(org.eclipse.tm.terminal.model.ITerminalTextData, org.eclipse.tm.terminal.model.ITerminalTextData)
|
||||||
*/
|
*/
|
||||||
|
@ -386,6 +411,7 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#hasLineChanged(int)
|
* @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#hasLineChanged(int)
|
||||||
*/
|
*/
|
||||||
|
@ -398,12 +424,15 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
// the the range of the previous height has changed
|
// the the range of the previous height has changed
|
||||||
return isInInterestWindow(line);
|
return isInInterestWindow(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getChangedLineLength() {
|
int getChangedLineLength() {
|
||||||
return fChangedLines.length;
|
return fChangedLines.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChangedLine(int line, boolean changed) {
|
void setChangedLine(int line, boolean changed) {
|
||||||
fChangedLines[line] = changed;
|
fChangedLines[line] = changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChangedLinesLength(int length) {
|
void setChangedLinesLength(int length) {
|
||||||
fChangedLines = new boolean[length];
|
fChangedLines = new boolean[length];
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,84 +23,111 @@ import org.eclipse.tm.terminal.model.Style;
|
||||||
*/
|
*/
|
||||||
public class SynchronizedTerminalTextData implements ITerminalTextData {
|
public class SynchronizedTerminalTextData implements ITerminalTextData {
|
||||||
final ITerminalTextData fData;
|
final ITerminalTextData fData;
|
||||||
|
|
||||||
public SynchronizedTerminalTextData(ITerminalTextData data) {
|
public SynchronizedTerminalTextData(ITerminalTextData data) {
|
||||||
fData = data;
|
fData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void addLine() {
|
synchronized public void addLine() {
|
||||||
fData.addLine();
|
fData.addLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void cleanLine(int line) {
|
synchronized public void cleanLine(int line) {
|
||||||
fData.cleanLine(line);
|
fData.cleanLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void copy(ITerminalTextData source) {
|
synchronized public void copy(ITerminalTextData source) {
|
||||||
fData.copy(source);
|
fData.copy(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
synchronized public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
||||||
fData.copyLine(source, sourceLine, destLine);
|
fData.copyLine(source, sourceLine, destLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
synchronized public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
||||||
fData.copyRange(source, sourceStartLine, destStartLine, length);
|
fData.copyRange(source, sourceStartLine, destStartLine, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public char getChar(int line, int column) {
|
synchronized public char getChar(int line, int column) {
|
||||||
return fData.getChar(line, column);
|
return fData.getChar(line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public char[] getChars(int line) {
|
synchronized public char[] getChars(int line) {
|
||||||
return fData.getChars(line);
|
return fData.getChars(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public int getCursorColumn() {
|
synchronized public int getCursorColumn() {
|
||||||
return fData.getCursorColumn();
|
return fData.getCursorColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public int getCursorLine() {
|
synchronized public int getCursorLine() {
|
||||||
return fData.getCursorLine();
|
return fData.getCursorLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public int getHeight() {
|
synchronized public int getHeight() {
|
||||||
return fData.getHeight();
|
return fData.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) {
|
synchronized public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) {
|
||||||
return fData.getLineSegments(line, startCol, numberOfCols);
|
return fData.getLineSegments(line, startCol, numberOfCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public int getMaxHeight() {
|
synchronized public int getMaxHeight() {
|
||||||
return fData.getMaxHeight();
|
return fData.getMaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public Style getStyle(int line, int column) {
|
synchronized public Style getStyle(int line, int column) {
|
||||||
return fData.getStyle(line, column);
|
return fData.getStyle(line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public Style[] getStyles(int line) {
|
synchronized public Style[] getStyles(int line) {
|
||||||
return fData.getStyles(line);
|
return fData.getStyles(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public int getWidth() {
|
synchronized public int getWidth() {
|
||||||
return fData.getWidth();
|
return fData.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public ITerminalTextDataSnapshot makeSnapshot() {
|
synchronized public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
return fData.makeSnapshot();
|
return fData.makeSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void scroll(int startLine, int size, int shift) {
|
synchronized public void scroll(int startLine, int size, int shift) {
|
||||||
fData.scroll(startLine, size, shift);
|
fData.scroll(startLine, size, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setChar(int line, int column, char c, Style style) {
|
synchronized public void setChar(int line, int column, char c, Style style) {
|
||||||
fData.setChar(line, column, c, style);
|
fData.setChar(line, column, c, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setChars(int line, int column, char[] chars, int start, int len, Style style) {
|
synchronized public void setChars(int line, int column, char[] chars, int start, int len, Style style) {
|
||||||
fData.setChars(line, column, chars, start, len, style);
|
fData.setChars(line, column, chars, start, len, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setChars(int line, int column, char[] chars, Style style) {
|
synchronized public void setChars(int line, int column, char[] chars, Style style) {
|
||||||
fData.setChars(line, column, chars, style);
|
fData.setChars(line, column, chars, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setCursorColumn(int column) {
|
synchronized public void setCursorColumn(int column) {
|
||||||
fData.setCursorColumn(column);
|
fData.setCursorColumn(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setCursorLine(int line) {
|
synchronized public void setCursorLine(int line) {
|
||||||
fData.setCursorLine(line);
|
fData.setCursorLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setDimensions(int height, int width) {
|
synchronized public void setDimensions(int height, int width) {
|
||||||
fData.setDimensions(height, width);
|
fData.setDimensions(height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setMaxHeight(int height) {
|
synchronized public void setMaxHeight(int height) {
|
||||||
fData.setMaxHeight(height);
|
fData.setMaxHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public boolean isWrappedLine(int line) {
|
synchronized public boolean isWrappedLine(int line) {
|
||||||
return fData.isWrappedLine(line);
|
return fData.isWrappedLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void setWrappedLine(int line) {
|
synchronized public void setWrappedLine(int line) {
|
||||||
fData.setWrappedLine(line);
|
fData.setWrappedLine(line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
public TerminalTextDataSnapshot[] fSnapshots = new TerminalTextDataSnapshot[0];
|
public TerminalTextDataSnapshot[] fSnapshots = new TerminalTextDataSnapshot[0];
|
||||||
private int fCursorColumn;
|
private int fCursorColumn;
|
||||||
private int fCursorLine;
|
private int fCursorLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug helper method -- use as "New Detail Formatter.." in the
|
* Debug helper method -- use as "New Detail Formatter.." in the
|
||||||
* debugger variables view:
|
* debugger variables view:
|
||||||
|
@ -85,16 +86,20 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
|
|
||||||
// this(new TerminalTextDataStore());
|
// this(new TerminalTextDataStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalTextData(ITerminalTextData data) {
|
public TerminalTextData(ITerminalTextData data) {
|
||||||
fData = data;
|
fData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return fData.getWidth();
|
return fData.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
// no need for an extra variable
|
// no need for an extra variable
|
||||||
return fData.getHeight();
|
return fData.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimensions(int height, int width) {
|
public void setDimensions(int height, int width) {
|
||||||
int h = getHeight();
|
int h = getHeight();
|
||||||
int w = getWidth();
|
int w = getWidth();
|
||||||
|
@ -103,6 +108,7 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
fData.setDimensions(height, width);
|
fData.setDimensions(height, width);
|
||||||
sendDimensionsChanged(h, w, height, width);
|
sendDimensionsChanged(h, w, height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDimensionsChanged(int oldHeight, int oldWidth, int newHeight, int newWidth) {
|
private void sendDimensionsChanged(int oldHeight, int oldWidth, int newHeight, int newWidth) {
|
||||||
// determine what has changed
|
// determine what has changed
|
||||||
if (oldWidth == newWidth) {
|
if (oldWidth == newWidth) {
|
||||||
|
@ -115,39 +121,49 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
sendDimensionsChanged();
|
sendDimensionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LineSegment[] getLineSegments(int line, int column, int len) {
|
public LineSegment[] getLineSegments(int line, int column, int len) {
|
||||||
return fData.getLineSegments(line, column, len);
|
return fData.getLineSegments(line, column, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char getChar(int line, int column) {
|
public char getChar(int line, int column) {
|
||||||
return fData.getChar(line, column);
|
return fData.getChar(line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle(int line, int column) {
|
public Style getStyle(int line, int column) {
|
||||||
return fData.getStyle(line, column);
|
return fData.getStyle(line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChar(int line, int column, char c, Style style) {
|
public void setChar(int line, int column, char c, Style style) {
|
||||||
fData.setChar(line, column, c, style);
|
fData.setChar(line, column, c, style);
|
||||||
sendLineChangedToSnapshots(line);
|
sendLineChangedToSnapshots(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChars(int line, int column, char[] chars, Style style) {
|
public void setChars(int line, int column, char[] chars, Style style) {
|
||||||
fData.setChars(line, column, chars, style);
|
fData.setChars(line, column, chars, style);
|
||||||
sendLineChangedToSnapshots(line);
|
sendLineChangedToSnapshots(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChars(int line, int column, char[] chars, int start, int len, Style style) {
|
public void setChars(int line, int column, char[] chars, int start, int len, Style style) {
|
||||||
fData.setChars(line, column, chars, start, len, style);
|
fData.setChars(line, column, chars, start, len, style);
|
||||||
sendLineChangedToSnapshots(line);
|
sendLineChangedToSnapshots(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scroll(int startLine, int size, int shift) {
|
public void scroll(int startLine, int size, int shift) {
|
||||||
fData.scroll(startLine, size, shift);
|
fData.scroll(startLine, size, shift);
|
||||||
sendScrolledToSnapshots(startLine, size, shift);
|
sendScrolledToSnapshots(startLine, size, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fData.toString();
|
return fData.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDimensionsChanged() {
|
private void sendDimensionsChanged() {
|
||||||
for (int i = 0; i < fSnapshots.length; i++) {
|
for (int i = 0; i < fSnapshots.length; i++) {
|
||||||
fSnapshots[i].markDimensionsChanged();
|
fSnapshots[i].markDimensionsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line notifies snapshots that line line has changed
|
* @param line notifies snapshots that line line has changed
|
||||||
*/
|
*/
|
||||||
|
@ -156,6 +172,7 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
fSnapshots[i].markLineChanged(line);
|
fSnapshots[i].markLineChanged(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify snapshots that multiple lines have changed
|
* Notify snapshots that multiple lines have changed
|
||||||
* @param line changed line
|
* @param line changed line
|
||||||
|
@ -178,11 +195,13 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
fSnapshots[i].scroll(startLine, size, shift);
|
fSnapshots[i].scroll(startLine, size, shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendCursorChanged() {
|
protected void sendCursorChanged() {
|
||||||
for (int i = 0; i < fSnapshots.length; i++) {
|
for (int i = 0; i < fSnapshots.length; i++) {
|
||||||
fSnapshots[i].markCursorChanged();
|
fSnapshots[i].markCursorChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the snapshot from the @observer@ list
|
* Removes the snapshot from the @observer@ list
|
||||||
* @param snapshot A snapshot of a terminal model
|
* @param snapshot A snapshot of a terminal model
|
||||||
|
@ -205,6 +224,7 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]);
|
fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]);
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLine() {
|
public void addLine() {
|
||||||
int oldHeight = getHeight();
|
int oldHeight = getHeight();
|
||||||
fData.addLine();
|
fData.addLine();
|
||||||
|
@ -232,35 +252,45 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
||||||
fData.copyLine(source, sourceLine, destLine);
|
fData.copyLine(source, sourceLine, destLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
||||||
fData.copyRange(source, sourceStartLine, destStartLine, length);
|
fData.copyRange(source, sourceStartLine, destStartLine, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getChars(int line) {
|
public char[] getChars(int line) {
|
||||||
return fData.getChars(line);
|
return fData.getChars(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style[] getStyles(int line) {
|
public Style[] getStyles(int line) {
|
||||||
return fData.getStyles(line);
|
return fData.getStyles(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return fData.getMaxHeight();
|
return fData.getMaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHeight(int height) {
|
public void setMaxHeight(int height) {
|
||||||
fData.setMaxHeight(height);
|
fData.setMaxHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanLine(int line) {
|
public void cleanLine(int line) {
|
||||||
fData.cleanLine(line);
|
fData.cleanLine(line);
|
||||||
sendLineChangedToSnapshots(line);
|
sendLineChangedToSnapshots(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorColumn() {
|
public int getCursorColumn() {
|
||||||
return fCursorColumn;
|
return fCursorColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorLine() {
|
public int getCursorLine() {
|
||||||
return fCursorLine;
|
return fCursorLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorColumn(int column) {
|
public void setCursorColumn(int column) {
|
||||||
fCursorColumn = column;
|
fCursorColumn = column;
|
||||||
sendCursorChanged();
|
sendCursorChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorLine(int line) {
|
public void setCursorLine(int line) {
|
||||||
fCursorLine = line;
|
fCursorLine = line;
|
||||||
sendCursorChanged();
|
sendCursorChanged();
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
* The offset into the array.
|
* The offset into the array.
|
||||||
*/
|
*/
|
||||||
int fOffset;
|
int fOffset;
|
||||||
|
|
||||||
public TerminalTextDataFastScroll(ITerminalTextData data, int maxHeight) {
|
public TerminalTextDataFastScroll(ITerminalTextData data, int maxHeight) {
|
||||||
fMaxHeight = maxHeight;
|
fMaxHeight = maxHeight;
|
||||||
fData = data;
|
fData = data;
|
||||||
|
@ -38,12 +39,15 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
if (maxHeight > 2)
|
if (maxHeight > 2)
|
||||||
assert shiftOffset(-2) || throwRuntimeException();
|
assert shiftOffset(-2) || throwRuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalTextDataFastScroll(int maxHeight) {
|
public TerminalTextDataFastScroll(int maxHeight) {
|
||||||
this(new TerminalTextDataStore(), maxHeight);
|
this(new TerminalTextDataStore(), maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalTextDataFastScroll() {
|
public TerminalTextDataFastScroll() {
|
||||||
this(new TerminalTextDataStore(), 1);
|
this(new TerminalTextDataStore(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used in asserts to throw an {@link RuntimeException}.
|
* This is used in asserts to throw an {@link RuntimeException}.
|
||||||
* This is useful for tests.
|
* This is useful for tests.
|
||||||
|
@ -52,6 +56,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
private boolean throwRuntimeException() {
|
private boolean throwRuntimeException() {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param line
|
* @param line
|
||||||
|
@ -60,6 +65,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
int getPositionOfLine(int line) {
|
int getPositionOfLine(int line) {
|
||||||
return (line + fOffset) % fMaxHeight;
|
return (line + fOffset) % fMaxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves offset by delta. This does <b>not</b> move the data!
|
* Moves offset by delta. This does <b>not</b> move the data!
|
||||||
* @param delta
|
* @param delta
|
||||||
|
@ -69,6 +75,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
fOffset = (fMaxHeight + fOffset + delta) % fMaxHeight;
|
fOffset = (fMaxHeight + fOffset + delta) % fMaxHeight;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method to shift the offset for testing (if assert ==true)
|
* Test method to shift the offset for testing (if assert ==true)
|
||||||
* @param shift TODO
|
* @param shift TODO
|
||||||
|
@ -78,6 +85,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
moveOffset(shift);
|
moveOffset(shift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLine() {
|
public void addLine() {
|
||||||
if (getHeight() < fMaxHeight) {
|
if (getHeight() < fMaxHeight) {
|
||||||
setDimensions(getHeight() + 1, getWidth());
|
setDimensions(getHeight() + 1, getWidth());
|
||||||
|
@ -85,6 +93,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
scroll(0, getHeight(), -1);
|
scroll(0, getHeight(), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanLine(int line) {
|
public void cleanLine(int line) {
|
||||||
fData.cleanLine(getPositionOfLine(line));
|
fData.cleanLine(getPositionOfLine(line));
|
||||||
}
|
}
|
||||||
|
@ -148,11 +157,13 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
public ITerminalTextDataSnapshot makeSnapshot() {
|
public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
return fData.makeSnapshot();
|
return fData.makeSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanLines(int line, int len) {
|
private void cleanLines(int line, int len) {
|
||||||
for (int i = line; i < line + len; i++) {
|
for (int i = line; i < line + len; i++) {
|
||||||
fData.cleanLine(getPositionOfLine(i));
|
fData.cleanLine(getPositionOfLine(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scroll(int startLine, int size, int shift) {
|
public void scroll(int startLine, int size, int shift) {
|
||||||
assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException();
|
assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException();
|
||||||
if (shift >= fMaxHeight || -shift >= fMaxHeight) {
|
if (shift >= fMaxHeight || -shift >= fMaxHeight) {
|
||||||
|
@ -235,22 +246,28 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
fMaxHeight = maxHeight;
|
fMaxHeight = maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorColumn() {
|
public int getCursorColumn() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorLine() {
|
public int getCursorLine() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorColumn(int column) {
|
public void setCursorColumn(int column) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorLine(int line) {
|
public void setCursorLine(int line) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWrappedLine(int line) {
|
public boolean isWrappedLine(int line) {
|
||||||
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
return fData.isWrappedLine(getPositionOfLine(line));
|
return fData.isWrappedLine(getPositionOfLine(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWrappedLine(int line) {
|
public void setWrappedLine(int line) {
|
||||||
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
fData.setWrappedLine(getPositionOfLine(line));
|
fData.setWrappedLine(getPositionOfLine(line));
|
||||||
|
|
|
@ -63,6 +63,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
fListenersNeedNotify = true;
|
fListenersNeedNotify = true;
|
||||||
fInterestWindowSize = -1;
|
fInterestWindowSize = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used in asserts to throw an {@link RuntimeException}.
|
* This is used in asserts to throw an {@link RuntimeException}.
|
||||||
* This is useful for tests.
|
* This is useful for tests.
|
||||||
|
@ -82,6 +83,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
return fFutureChanges.hasChanged();
|
return fFutureChanges.hasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#snapshot()
|
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#snapshot()
|
||||||
*/
|
*/
|
||||||
|
@ -138,12 +140,14 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return fSnapshot.getWidth();
|
return fSnapshot.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getFirstChangedLine()
|
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getFirstChangedLine()
|
||||||
*/
|
*/
|
||||||
public int getFirstChangedLine() {
|
public int getFirstChangedLine() {
|
||||||
return fCurrentChanges.getFirstChangedLine();
|
return fCurrentChanges.getFirstChangedLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getLastChangedLine()
|
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getLastChangedLine()
|
||||||
*/
|
*/
|
||||||
|
@ -154,9 +158,11 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
public boolean hasLineChanged(int line) {
|
public boolean hasLineChanged(int line) {
|
||||||
return fCurrentChanges.hasLineChanged(line);
|
return fCurrentChanges.hasLineChanged(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDimensionsChanged() {
|
public boolean hasDimensionsChanged() {
|
||||||
return fCurrentChanges.hasDimensionsChanged();
|
return fCurrentChanges.hasDimensionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTerminalChanged() {
|
public boolean hasTerminalChanged() {
|
||||||
return fCurrentChanges.hasTerminalChanged();
|
return fCurrentChanges.hasTerminalChanged();
|
||||||
}
|
}
|
||||||
|
@ -167,12 +173,14 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
public int getScrollWindowStartLine() {
|
public int getScrollWindowStartLine() {
|
||||||
return fCurrentChanges.getScrollWindowStartLine();
|
return fCurrentChanges.getScrollWindowStartLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeN()
|
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeN()
|
||||||
*/
|
*/
|
||||||
public int getScrollWindowSize() {
|
public int getScrollWindowSize() {
|
||||||
return fCurrentChanges.getScrollWindowSize();
|
return fCurrentChanges.getScrollWindowSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeShift()
|
* @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeShift()
|
||||||
*/
|
*/
|
||||||
|
@ -190,6 +198,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
fFutureChanges.setTerminalChanged();
|
fFutureChanges.setTerminalChanged();
|
||||||
notifyListers();
|
notifyListers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Announces a change of n lines beginning with line line
|
* Announces a change of n lines beginning with line line
|
||||||
* @param line
|
* @param line
|
||||||
|
@ -206,6 +215,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
fFutureChanges.setTerminalChanged();
|
fFutureChanges.setTerminalChanged();
|
||||||
notifyListers();
|
notifyListers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void markCursorChanged() {
|
void markCursorChanged() {
|
||||||
fFutureChanges.markCursorChanged();
|
fFutureChanges.markCursorChanged();
|
||||||
fFutureChanges.setTerminalChanged();
|
fFutureChanges.setTerminalChanged();
|
||||||
|
@ -222,6 +232,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
fFutureChanges.setTerminalChanged();
|
fFutureChanges.setTerminalChanged();
|
||||||
notifyListers();
|
notifyListers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies listeners about the change
|
* Notifies listeners about the change
|
||||||
*/
|
*/
|
||||||
|
@ -236,6 +247,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITerminalTextDataSnapshot makeSnapshot() {
|
public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
return fSnapshot.makeSnapshot();
|
return fSnapshot.makeSnapshot();
|
||||||
}
|
}
|
||||||
|
@ -253,16 +265,15 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
list.remove(listener);
|
list.remove(listener);
|
||||||
fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]);
|
fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fSnapshot.toString();
|
return fSnapshot.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getInterestWindowSize() {
|
public int getInterestWindowSize() {
|
||||||
return fInterestWindowSize;
|
return fInterestWindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getInterestWindowStartLine() {
|
public int getInterestWindowStartLine() {
|
||||||
return fInterestWindowStartLine;
|
return fInterestWindowStartLine;
|
||||||
}
|
}
|
||||||
|
@ -277,27 +288,27 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
notifyListers();
|
notifyListers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public char[] getChars(int line) {
|
public char[] getChars(int line) {
|
||||||
return fSnapshot.getChars(line);
|
return fSnapshot.getChars(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Style[] getStyles(int line) {
|
public Style[] getStyles(int line) {
|
||||||
return fSnapshot.getStyles(line);
|
return fSnapshot.getStyles(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorColumn() {
|
public int getCursorColumn() {
|
||||||
return fSnapshot.getCursorColumn();
|
return fSnapshot.getCursorColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorLine() {
|
public int getCursorLine() {
|
||||||
return fSnapshot.getCursorLine();
|
return fSnapshot.getCursorLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITerminalTextData getTerminalTextData() {
|
public ITerminalTextData getTerminalTextData() {
|
||||||
return fTerminal;
|
return fTerminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWrappedLine(int line) {
|
public boolean isWrappedLine(int line) {
|
||||||
return fSnapshot.isWrappedLine(line);
|
return fSnapshot.isWrappedLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
fStyle = new Style[0][];
|
fStyle = new Style[0][];
|
||||||
fWidth = 0;
|
fWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used in asserts to throw an {@link RuntimeException}.
|
* This is used in asserts to throw an {@link RuntimeException}.
|
||||||
* This is useful for tests.
|
* This is useful for tests.
|
||||||
|
@ -49,19 +50,20 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getWidth()
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getWidth()
|
||||||
*/
|
*/
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return fWidth;
|
return fWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getHeight()
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getHeight()
|
||||||
*/
|
*/
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return fHeight;
|
return fHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setDimensions(int, int)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setDimensions(int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -86,6 +88,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
fWidth = width;
|
fWidth = width;
|
||||||
fHeight = height;
|
fHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reallocates an array with a new size, and copies the contents of the old
|
* Reallocates an array with a new size, and copies the contents of the old
|
||||||
* array to the new array.
|
* array to the new array.
|
||||||
|
@ -106,7 +109,6 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getLineSegments(int, int, int)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getLineSegments(int, int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -143,6 +145,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
return segments.toArray(new LineSegment[segments.size()]);
|
return segments.toArray(new LineSegment[segments.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getChar(int, int)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getChar(int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -152,6 +155,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
return 0;
|
return 0;
|
||||||
return fChars[line][column];
|
return fChars[line][column];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getStyle(int, int)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getStyle(int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -185,12 +189,14 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
fChars[line][column] = c;
|
fChars[line][column] = c;
|
||||||
fStyle[line][column] = style;
|
fStyle[line][column] = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChars(int, int, char[], org.eclipse.tm.internal.terminal.text.Style)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChars(int, int, char[], org.eclipse.tm.internal.terminal.text.Style)
|
||||||
*/
|
*/
|
||||||
public void setChars(int line, int column, char[] chars, Style style) {
|
public void setChars(int line, int column, char[] chars, Style style) {
|
||||||
setChars(line, column, chars, 0, chars.length, style);
|
setChars(line, column, chars, 0, chars.length, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChars(int, int, char[], int, int, org.eclipse.tm.internal.terminal.text.Style)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChars(int, int, char[], int, int, org.eclipse.tm.internal.terminal.text.Style)
|
||||||
*/
|
*/
|
||||||
|
@ -201,6 +207,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
fStyle[line][column + i] = style;
|
fStyle[line][column + i] = style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#scroll(int, int, int)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#scroll(int, int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -226,6 +233,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
cleanLines(startLine, Math.min(shift, getHeight() - startLine));
|
cleanLines(startLine, Math.min(shift, getHeight() - startLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the lines with new empty data
|
* Replaces the lines with new empty data
|
||||||
* @param line
|
* @param line
|
||||||
|
@ -253,7 +261,6 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
return buff.toString();
|
return buff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ITerminalTextDataSnapshot makeSnapshot() {
|
public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
@ -280,6 +287,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
fCursorLine = source.getCursorLine();
|
fCursorLine = source.getCursorLine();
|
||||||
fCursorColumn = source.getCursorColumn();
|
fCursorColumn = source.getCursorColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
copyLine(source, i + sourceStartLine, i + destStartLine);
|
copyLine(source, i + sourceStartLine, i + destStartLine);
|
||||||
|
@ -323,21 +331,27 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
fStyle[line] = null;
|
fStyle[line] = null;
|
||||||
fWrappedLines.clear(line);
|
fWrappedLines.clear(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorColumn() {
|
public int getCursorColumn() {
|
||||||
return fCursorColumn;
|
return fCursorColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorLine() {
|
public int getCursorLine() {
|
||||||
return fCursorLine;
|
return fCursorLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorColumn(int column) {
|
public void setCursorColumn(int column) {
|
||||||
fCursorColumn = column;
|
fCursorColumn = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorLine(int line) {
|
public void setCursorLine(int line) {
|
||||||
fCursorLine = line;
|
fCursorLine = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWrappedLine(int line) {
|
public boolean isWrappedLine(int line) {
|
||||||
return fWrappedLines.get(line);
|
return fWrappedLines.get(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWrappedLine(int line) {
|
public void setWrappedLine(int line) {
|
||||||
fWrappedLines.set(line);
|
fWrappedLines.set(line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,15 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
int fWindowSize;
|
int fWindowSize;
|
||||||
int fHeight;
|
int fHeight;
|
||||||
int fMaxHeight;
|
int fMaxHeight;
|
||||||
|
|
||||||
public TerminalTextDataWindow(ITerminalTextData data) {
|
public TerminalTextDataWindow(ITerminalTextData data) {
|
||||||
fData = data;
|
fData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalTextDataWindow() {
|
public TerminalTextDataWindow() {
|
||||||
this(new TerminalTextDataStore());
|
this(new TerminalTextDataStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used in asserts to throw an {@link RuntimeException}.
|
* This is used in asserts to throw an {@link RuntimeException}.
|
||||||
* This is useful for tests.
|
* This is useful for tests.
|
||||||
|
@ -42,6 +45,7 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
private boolean throwRuntimeException() {
|
private boolean throwRuntimeException() {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line
|
* @param line
|
||||||
* @return true if the line is within the window
|
* @return true if the line is within the window
|
||||||
|
@ -49,6 +53,7 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
boolean isInWindow(int line) {
|
boolean isInWindow(int line) {
|
||||||
return line >= fWindowStartLine && line < fWindowStartLine + fWindowSize;
|
return line >= fWindowStartLine && line < fWindowStartLine + fWindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public char getChar(int line, int column) {
|
public char getChar(int line, int column) {
|
||||||
if (!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -94,6 +99,7 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
public ITerminalTextDataSnapshot makeSnapshot() {
|
public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLine() {
|
public void addLine() {
|
||||||
if (fMaxHeight > 0 && getHeight() < fMaxHeight) {
|
if (fMaxHeight > 0 && getHeight() < fMaxHeight) {
|
||||||
setDimensions(getHeight() + 1, getWidth());
|
setDimensions(getHeight() + 1, getWidth());
|
||||||
|
@ -101,6 +107,7 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
scroll(0, getHeight(), -1);
|
scroll(0, getHeight(), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copy(ITerminalTextData source) {
|
public void copy(ITerminalTextData source) {
|
||||||
// we inherit the dimensions of the source
|
// we inherit the dimensions of the source
|
||||||
setDimensions(source.getHeight(), source.getWidth());
|
setDimensions(source.getHeight(), source.getWidth());
|
||||||
|
@ -108,6 +115,7 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
fData.copyRange(source, fWindowStartLine, 0, n);
|
fData.copyRange(source, fWindowStartLine, 0, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
||||||
int n = length;
|
int n = length;
|
||||||
int dStart = destStartLine - fWindowStartLine;
|
int dStart = destStartLine - fWindowStartLine;
|
||||||
|
@ -124,10 +132,12 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
fData.copyRange(source, sStart, dStart, n);
|
fData.copyRange(source, sStart, dStart, n);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
||||||
if (isInWindow(destLine))
|
if (isInWindow(destLine))
|
||||||
fData.copyLine(source, sourceLine, destLine - fWindowStartLine);
|
fData.copyLine(source, sourceLine, destLine - fWindowStartLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scroll(int startLine, int size, int shift) {
|
public void scroll(int startLine, int size, int shift) {
|
||||||
assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException();
|
assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException();
|
||||||
int n = size;
|
int n = size;
|
||||||
|
@ -142,64 +152,80 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
fData.scroll(start, n, shift);
|
fData.scroll(start, n, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChar(int line, int column, char c, Style style) {
|
public void setChar(int line, int column, char c, Style style) {
|
||||||
if (!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return;
|
return;
|
||||||
fData.setChar(line - fWindowStartLine, column, c, style);
|
fData.setChar(line - fWindowStartLine, column, c, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChars(int line, int column, char[] chars, int start, int len, Style style) {
|
public void setChars(int line, int column, char[] chars, int start, int len, Style style) {
|
||||||
if (!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return;
|
return;
|
||||||
fData.setChars(line - fWindowStartLine, column, chars, start, len, style);
|
fData.setChars(line - fWindowStartLine, column, chars, start, len, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChars(int line, int column, char[] chars, Style style) {
|
public void setChars(int line, int column, char[] chars, Style style) {
|
||||||
if (!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return;
|
return;
|
||||||
fData.setChars(line - fWindowStartLine, column, chars, style);
|
fData.setChars(line - fWindowStartLine, column, chars, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimensions(int height, int width) {
|
public void setDimensions(int height, int width) {
|
||||||
assert height >= 0 || throwRuntimeException();
|
assert height >= 0 || throwRuntimeException();
|
||||||
fData.setDimensions(fWindowSize, width);
|
fData.setDimensions(fWindowSize, width);
|
||||||
fHeight = height;
|
fHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHeight(int height) {
|
public void setMaxHeight(int height) {
|
||||||
fMaxHeight = height;
|
fMaxHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWindow(int startLine, int size) {
|
public void setWindow(int startLine, int size) {
|
||||||
fWindowStartLine = startLine;
|
fWindowStartLine = startLine;
|
||||||
fWindowSize = size;
|
fWindowSize = size;
|
||||||
fData.setDimensions(fWindowSize, getWidth());
|
fData.setDimensions(fWindowSize, getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWindowStartLine() {
|
public int getWindowStartLine() {
|
||||||
return fWindowStartLine;
|
return fWindowStartLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWindowSize() {
|
public int getWindowSize() {
|
||||||
return fWindowSize;
|
return fWindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeight(int height) {
|
public void setHeight(int height) {
|
||||||
fHeight = height;
|
fHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanLine(int line) {
|
public void cleanLine(int line) {
|
||||||
if (isInWindow(line))
|
if (isInWindow(line))
|
||||||
fData.cleanLine(line - fWindowStartLine);
|
fData.cleanLine(line - fWindowStartLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorColumn() {
|
public int getCursorColumn() {
|
||||||
return fData.getCursorColumn();
|
return fData.getCursorColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCursorLine() {
|
public int getCursorLine() {
|
||||||
return fData.getCursorLine();
|
return fData.getCursorLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorColumn(int column) {
|
public void setCursorColumn(int column) {
|
||||||
fData.setCursorColumn(column);
|
fData.setCursorColumn(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorLine(int line) {
|
public void setCursorLine(int line) {
|
||||||
fData.setCursorLine(line);
|
fData.setCursorLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWrappedLine(int line) {
|
public boolean isWrappedLine(int line) {
|
||||||
if (isInWindow(line))
|
if (isInWindow(line))
|
||||||
return fData.isWrappedLine(line - fWindowStartLine);
|
return fData.isWrappedLine(line - fWindowStartLine);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWrappedLine(int line) {
|
public void setWrappedLine(int line) {
|
||||||
if (isInWindow(line))
|
if (isInWindow(line))
|
||||||
fData.setWrappedLine(line - fWindowStartLine);
|
fData.setWrappedLine(line - fWindowStartLine);
|
||||||
|
|
|
@ -35,8 +35,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
* @noreference This class is not intended to be referenced by clients.
|
* @noreference This class is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
public class TerminalPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||||
IWorkbenchPreferencePage {
|
|
||||||
protected BooleanFieldEditor fInvertColors;
|
protected BooleanFieldEditor fInvertColors;
|
||||||
|
|
||||||
protected IntegerFieldEditor fEditorBufferSize;
|
protected IntegerFieldEditor fEditorBufferSize;
|
||||||
|
@ -44,16 +43,20 @@ public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
||||||
public TerminalPreferencePage() {
|
public TerminalPreferencePage() {
|
||||||
super(GRID);
|
super(GRID);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createFieldEditors() {
|
protected void createFieldEditors() {
|
||||||
setupPage();
|
setupPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(IWorkbench workbench) {
|
public void init(IWorkbench workbench) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupPage() {
|
protected void setupPage() {
|
||||||
setupData();
|
setupData();
|
||||||
setupEditors();
|
setupEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupData() {
|
protected void setupData() {
|
||||||
TerminalPlugin plugin;
|
TerminalPlugin plugin;
|
||||||
IPreferenceStore preferenceStore;
|
IPreferenceStore preferenceStore;
|
||||||
|
@ -62,12 +65,12 @@ public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
||||||
preferenceStore = plugin.getPreferenceStore();
|
preferenceStore = plugin.getPreferenceStore();
|
||||||
setPreferenceStore(preferenceStore);
|
setPreferenceStore(preferenceStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupEditors() {
|
protected void setupEditors() {
|
||||||
fInvertColors = new BooleanFieldEditor(
|
fInvertColors = new BooleanFieldEditor(ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS,
|
||||||
ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS,
|
getFieldEditorParent());
|
||||||
|
fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, TerminalMessages.BUFFERLINES,
|
||||||
getFieldEditorParent());
|
getFieldEditorParent());
|
||||||
fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES,
|
|
||||||
TerminalMessages.BUFFERLINES, getFieldEditorParent());
|
|
||||||
|
|
||||||
fEditorBufferSize.setValidRange(0, Integer.MAX_VALUE);
|
fEditorBufferSize.setValidRange(0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro
|
||||||
Object[] list = listeners.getListeners();
|
Object[] list = listeners.getListeners();
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
Object l = list[i];
|
Object l = list[i];
|
||||||
if (!(l instanceof Listener)) continue;
|
if (!(l instanceof Listener))
|
||||||
|
continue;
|
||||||
((Listener) l).onSettingsPageChanged(control);
|
((Listener) l).onSettingsPageChanged(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +121,8 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro
|
||||||
*/
|
*/
|
||||||
protected final ControlDecoration createControlDecoration(Control control) {
|
protected final ControlDecoration createControlDecoration(Control control) {
|
||||||
Assert.isNotNull(control);
|
Assert.isNotNull(control);
|
||||||
if (!hasDecoration) return null;
|
if (!hasDecoration)
|
||||||
|
return null;
|
||||||
ControlDecoration controlDecoration = new ControlDecoration(control, getControlDecorationPosition());
|
ControlDecoration controlDecoration = new ControlDecoration(control, getControlDecorationPosition());
|
||||||
controlDecoration.setShowOnlyOnFocus(false);
|
controlDecoration.setShowOnlyOnFocus(false);
|
||||||
control.setData("controlDecoration", controlDecoration); //$NON-NLS-1$
|
control.setData("controlDecoration", controlDecoration); //$NON-NLS-1$
|
||||||
|
@ -173,8 +175,7 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro
|
||||||
|
|
||||||
if (message == null || messageType == IMessageProvider.NONE) {
|
if (message == null || messageType == IMessageProvider.NONE) {
|
||||||
controlDecoration.hide();
|
controlDecoration.hide();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
controlDecoration.show();
|
controlDecoration.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,36 +86,52 @@ public final class Logger {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\\':
|
case '\\':
|
||||||
case '\'':
|
case '\'':
|
||||||
buf.append('\\'); buf.append(c); encoded=true;
|
buf.append('\\');
|
||||||
|
buf.append(c);
|
||||||
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
case '\r':
|
case '\r':
|
||||||
buf.append('\\'); buf.append('r'); encoded=true;
|
buf.append('\\');
|
||||||
|
buf.append('r');
|
||||||
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
buf.append('\\'); buf.append('n'); encoded=true;
|
buf.append('\\');
|
||||||
|
buf.append('n');
|
||||||
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
buf.append('\\'); buf.append('t'); encoded=true;
|
buf.append('\\');
|
||||||
|
buf.append('t');
|
||||||
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
case '\f':
|
case '\f':
|
||||||
buf.append('\\'); buf.append('f'); encoded=true;
|
buf.append('\\');
|
||||||
|
buf.append('f');
|
||||||
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
case '\b':
|
case '\b':
|
||||||
buf.append('\\'); buf.append('b'); encoded=true;
|
buf.append('\\');
|
||||||
|
buf.append('b');
|
||||||
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (c <= '\u000f') {
|
if (c <= '\u000f') {
|
||||||
buf.append('\\'); buf.append('x'); buf.append('0');
|
buf.append('\\');
|
||||||
|
buf.append('x');
|
||||||
|
buf.append('0');
|
||||||
buf.append(Integer.toHexString(c));
|
buf.append(Integer.toHexString(c));
|
||||||
encoded = true;
|
encoded = true;
|
||||||
} else if (c >= ' ' && c < '\u007f') {
|
} else if (c >= ' ' && c < '\u007f') {
|
||||||
buf.append(c);
|
buf.append(c);
|
||||||
} else if (c <= '\u00ff') {
|
} else if (c <= '\u00ff') {
|
||||||
buf.append('\\'); buf.append('x');
|
buf.append('\\');
|
||||||
|
buf.append('x');
|
||||||
buf.append(Integer.toHexString(c));
|
buf.append(Integer.toHexString(c));
|
||||||
encoded = true;
|
encoded = true;
|
||||||
} else {
|
} else {
|
||||||
buf.append('\\'); buf.append('u');
|
buf.append('\\');
|
||||||
|
buf.append('u');
|
||||||
if (c <= '\u0fff') {
|
if (c <= '\u0fff') {
|
||||||
buf.append('0');
|
buf.append('0');
|
||||||
}
|
}
|
||||||
|
@ -168,7 +184,8 @@ public final class Logger {
|
||||||
public static final void logException(Exception ex) {
|
public static final void logException(Exception ex) {
|
||||||
// log in eclipse error log
|
// log in eclipse error log
|
||||||
if (TerminalPlugin.getDefault() != null) {
|
if (TerminalPlugin.getDefault() != null) {
|
||||||
TerminalPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex));
|
TerminalPlugin.getDefault().getLog()
|
||||||
|
.log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex));
|
||||||
} else {
|
} else {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -188,8 +205,7 @@ public final class Logger {
|
||||||
tmpStream = logStream;
|
tmpStream = logStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStream.println(className
|
tmpStream.println(className + "." + methodName + ":" + lineNumber + ": " + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
+ "." + methodName + ":" + lineNumber + ": " + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
"Caught exception: " + ex); //$NON-NLS-1$
|
"Caught exception: " + ex); //$NON-NLS-1$
|
||||||
ex.printStackTrace(tmpStream);
|
ex.printStackTrace(tmpStream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,8 @@ public class TerminalConnectorExtension {
|
||||||
TerminalConnector.Factory factory = new TerminalConnector.Factory() {
|
TerminalConnector.Factory factory = new TerminalConnector.Factory() {
|
||||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
public TerminalConnectorImpl makeConnector() throws Exception {
|
||||||
return (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$
|
return (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
return new TerminalConnector(factory, id, name, isHidden);
|
return new TerminalConnector(factory, id, name, isHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@ public class TerminalConnectorExtension {
|
||||||
* @since org.eclipse.tm.terminal 2.0
|
* @since org.eclipse.tm.terminal 2.0
|
||||||
*/
|
*/
|
||||||
public static ITerminalConnector makeTerminalConnector(String id) {
|
public static ITerminalConnector makeTerminalConnector(String id) {
|
||||||
IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$
|
IConfigurationElement[] config = RegistryFactory.getRegistry()
|
||||||
|
.getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$
|
||||||
for (int i = 0; i < config.length; i++) {
|
for (int i = 0; i < config.length; i++) {
|
||||||
if (id.equals(config[i].getAttribute("id"))) { //$NON-NLS-1$
|
if (id.equals(config[i].getAttribute("id"))) { //$NON-NLS-1$
|
||||||
return makeConnector(config[i]);
|
return makeConnector(config[i]);
|
||||||
|
@ -76,6 +78,7 @@ public class TerminalConnectorExtension {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of available terminal connectors (connection types).
|
* Return a list of available terminal connectors (connection types).
|
||||||
*
|
*
|
||||||
|
@ -89,7 +92,8 @@ public class TerminalConnectorExtension {
|
||||||
* @since org.eclipse.tm.terminal 2.0 return value is ITerminalConnector[]
|
* @since org.eclipse.tm.terminal 2.0 return value is ITerminalConnector[]
|
||||||
*/
|
*/
|
||||||
public static ITerminalConnector[] makeTerminalConnectors() {
|
public static ITerminalConnector[] makeTerminalConnectors() {
|
||||||
IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$
|
IConfigurationElement[] config = RegistryFactory.getRegistry()
|
||||||
|
.getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$
|
||||||
List<ITerminalConnector> result = new ArrayList<ITerminalConnector>();
|
List<ITerminalConnector> result = new ArrayList<ITerminalConnector>();
|
||||||
for (int i = 0; i < config.length; i++) {
|
for (int i = 0; i < config.length; i++) {
|
||||||
result.add(makeConnector(config[i]));
|
result.add(makeConnector(config[i]));
|
||||||
|
|
|
@ -49,6 +49,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
fSnapshot = snapshot;
|
fSnapshot = snapshot;
|
||||||
fLines = fSnapshot.getHeight();
|
fLines = fSnapshot.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCellCanvasModelListener(ITextCanvasModelListener listener) {
|
public void addCellCanvasModelListener(ITextCanvasModelListener listener) {
|
||||||
fListeners.add(listener);
|
fListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +64,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
listener.rangeChanged(x, y, width, height);
|
listener.rangeChanged(x, y, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireDimensionsChanged(int width, int height) {
|
protected void fireDimensionsChanged(int width, int height) {
|
||||||
for (Iterator<ITextCanvasModelListener> iter = fListeners.iterator(); iter.hasNext();) {
|
for (Iterator<ITextCanvasModelListener> iter = fListeners.iterator(); iter.hasNext();) {
|
||||||
ITextCanvasModelListener listener = iter.next();
|
ITextCanvasModelListener listener = iter.next();
|
||||||
|
@ -70,6 +72,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireTerminalDataChanged() {
|
protected void fireTerminalDataChanged() {
|
||||||
for (Iterator<ITextCanvasModelListener> iter = fListeners.iterator(); iter.hasNext();) {
|
for (Iterator<ITextCanvasModelListener> iter = fListeners.iterator(); iter.hasNext();) {
|
||||||
ITextCanvasModelListener listener = iter.next();
|
ITextCanvasModelListener listener = iter.next();
|
||||||
|
@ -81,9 +84,11 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
public ITerminalTextDataReadOnly getTerminalText() {
|
public ITerminalTextDataReadOnly getTerminalText() {
|
||||||
return fSnapshot;
|
return fSnapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ITerminalTextDataSnapshot getSnapshot() {
|
protected ITerminalTextDataSnapshot getSnapshot() {
|
||||||
return fSnapshot;
|
return fSnapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSnapshot() {
|
protected void updateSnapshot() {
|
||||||
if (!fInUpdate && fSnapshot.isOutOfDate()) {
|
if (!fInUpdate && fSnapshot.isOutOfDate()) {
|
||||||
fInUpdate = true;
|
fInUpdate = true;
|
||||||
|
@ -111,6 +116,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* must be called from the UI thread
|
* must be called from the UI thread
|
||||||
*/
|
*/
|
||||||
|
@ -121,7 +127,6 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
updateCursor();
|
updateCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getCursorColumn() {
|
public int getCursorColumn() {
|
||||||
return fCursorColumn;
|
return fCursorColumn;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +138,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
public boolean isCursorOn() {
|
public boolean isCursorOn() {
|
||||||
return fShowCursor && fCursorIsEnabled;
|
return fShowCursor && fCursorIsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* should be called regularly to draw an update of the
|
* should be called regularly to draw an update of the
|
||||||
* blinking cursor
|
* blinking cursor
|
||||||
|
@ -187,19 +193,23 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibleRectangle(int startLine, int startCol, int height, int width) {
|
public void setVisibleRectangle(int startLine, int startCol, int height, int width) {
|
||||||
fSnapshot.setInterestWindow(Math.max(0, startLine), Math.max(1, height));
|
fSnapshot.setInterestWindow(Math.max(0, startLine), Math.max(1, height));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showCursor(boolean show) {
|
protected void showCursor(boolean show) {
|
||||||
fShowCursor = true;
|
fShowCursor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorEnabled(boolean visible) {
|
public void setCursorEnabled(boolean visible) {
|
||||||
fCursorTime = System.currentTimeMillis();
|
fCursorTime = System.currentTimeMillis();
|
||||||
fShowCursor = visible;
|
fShowCursor = visible;
|
||||||
fCursorIsEnabled = visible;
|
fCursorIsEnabled = visible;
|
||||||
fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1);
|
fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCursorEnabled() {
|
public boolean isCursorEnabled() {
|
||||||
return fCursorIsEnabled;
|
return fCursorIsEnabled;
|
||||||
}
|
}
|
||||||
|
@ -217,11 +227,13 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
else
|
else
|
||||||
return new Point(fSelectionStartCoumn, fSelectionStartLine);
|
return new Point(fSelectionStartCoumn, fSelectionStartLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getSelectionAnchor() {
|
public Point getSelectionAnchor() {
|
||||||
if (fSelectionStartLine < 0)
|
if (fSelectionStartLine < 0)
|
||||||
return null;
|
return null;
|
||||||
return new Point(fSelectionAnchor.x, fSelectionAnchor.y);
|
return new Point(fSelectionAnchor.x, fSelectionAnchor.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectionAnchor(Point anchor) {
|
public void setSelectionAnchor(Point anchor) {
|
||||||
fSelectionAnchor.x = anchor.x;
|
fSelectionAnchor.x = anchor.x;
|
||||||
fSelectionAnchor.y = anchor.y;
|
fSelectionAnchor.y = anchor.y;
|
||||||
|
@ -232,6 +244,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
doSetSelection(startLine, endLine, startColumn, endColumn);
|
doSetSelection(startLine, endLine, startColumn, endColumn);
|
||||||
fCurrentSelection = extractSelectedText();
|
fCurrentSelection = extractSelectedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSetSelection(int startLine, int endLine, int startColumn, int endColumn) {
|
private void doSetSelection(int startLine, int endLine, int startColumn, int endColumn) {
|
||||||
assert (startLine < 0 || startLine <= endLine);
|
assert (startLine < 0 || startLine <= endLine);
|
||||||
if (startLine >= 0) {
|
if (startLine >= 0) {
|
||||||
|
@ -322,11 +335,13 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSelection() {
|
private void updateSelection() {
|
||||||
if (fSelectionSnapshot != null && fSelectionSnapshot.isOutOfDate()) {
|
if (fSelectionSnapshot != null && fSelectionSnapshot.isOutOfDate()) {
|
||||||
fSelectionSnapshot.updateSnapshot(true);
|
fSelectionSnapshot.updateSnapshot(true);
|
||||||
// has the selection moved?
|
// has the selection moved?
|
||||||
if (fSelectionSnapshot != null && fSelectionStartLine >= 0 && fSelectionSnapshot.getScrollWindowSize() > 0) {
|
if (fSelectionSnapshot != null && fSelectionStartLine >= 0
|
||||||
|
&& fSelectionSnapshot.getScrollWindowSize() > 0) {
|
||||||
int start = fSelectionStartLine + fSelectionSnapshot.getScrollWindowShift();
|
int start = fSelectionStartLine + fSelectionSnapshot.getScrollWindowShift();
|
||||||
int end = fSeletionEndLine + fSelectionSnapshot.getScrollWindowShift();
|
int end = fSeletionEndLine + fSelectionSnapshot.getScrollWindowShift();
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.textcanvas;
|
package org.eclipse.tm.internal.terminal.textcanvas;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
@ -81,6 +80,7 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
}
|
}
|
||||||
paintUnoccupiedSpace(gc, clipping);
|
paintUnoccupiedSpace(gc, clipping);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param gc
|
* @param gc
|
||||||
* @param row the line to draw
|
* @param row the line to draw
|
||||||
|
@ -92,6 +92,7 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
abstract void drawLine(GC gc, int row, int x, int y, int colFirst, int colLast);
|
abstract void drawLine(GC gc, int row, int x, int y, int colFirst, int colLast);
|
||||||
|
|
||||||
abstract protected int getRows();
|
abstract protected int getRows();
|
||||||
|
|
||||||
abstract protected int getCols();
|
abstract protected int getCols();
|
||||||
|
|
||||||
protected void setCellWidth(int cellWidth) {
|
protected void setCellWidth(int cellWidth) {
|
||||||
|
@ -159,6 +160,7 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
y = fCellHeight * y;
|
y = fCellHeight * y;
|
||||||
return new Rectangle(x, y, fCellWidth, fCellHeight);
|
return new Rectangle(x, y, fCellWidth, fCellHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void viewRectangleChanged(int x, int y, int width, int height) {
|
protected void viewRectangleChanged(int x, int y, int width, int height) {
|
||||||
int cellX = virtualXToCell(x);
|
int cellX = virtualXToCell(x);
|
||||||
int cellY = virtualYToCell(y);
|
int cellY = virtualYToCell(y);
|
||||||
|
|
|
@ -22,18 +22,24 @@ import org.eclipse.swt.graphics.GC;
|
||||||
*/
|
*/
|
||||||
public interface ILinelRenderer {
|
public interface ILinelRenderer {
|
||||||
int getCellWidth();
|
int getCellWidth();
|
||||||
|
|
||||||
int getCellHeight();
|
int getCellHeight();
|
||||||
|
|
||||||
void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast);
|
void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update for a font change from the global JFace Registry.
|
* Update for a font change from the global JFace Registry.
|
||||||
*/
|
*/
|
||||||
void onFontChange();
|
void onFontChange();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a new font
|
* Set a new font
|
||||||
* @param fontName Jface name of the new font
|
* @param fontName Jface name of the new font
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void updateFont(String fontName);
|
void updateFont(String fontName);
|
||||||
|
|
||||||
void setInvertedColors(boolean invert);
|
void setInvertedColors(boolean invert);
|
||||||
|
|
||||||
Color getDefaultBackgroundColor();
|
Color getDefaultBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,11 @@ import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
||||||
|
|
||||||
public interface ITextCanvasModel {
|
public interface ITextCanvasModel {
|
||||||
void addCellCanvasModelListener(ITextCanvasModelListener listener);
|
void addCellCanvasModelListener(ITextCanvasModelListener listener);
|
||||||
|
|
||||||
void removeCellCanvasModelListener(ITextCanvasModelListener listener);
|
void removeCellCanvasModelListener(ITextCanvasModelListener listener);
|
||||||
|
|
||||||
ITerminalTextDataReadOnly getTerminalText();
|
ITerminalTextDataReadOnly getTerminalText();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is is
|
* This is is
|
||||||
* @param startLine
|
* @param startLine
|
||||||
|
@ -33,6 +35,7 @@ public interface ITextCanvasModel {
|
||||||
* @return true when the cursor is shown (used for blinking cursors)
|
* @return true when the cursor is shown (used for blinking cursors)
|
||||||
*/
|
*/
|
||||||
boolean isCursorOn();
|
boolean isCursorOn();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show/Hide the cursor.
|
* Show/Hide the cursor.
|
||||||
* @param visible
|
* @param visible
|
||||||
|
@ -48,6 +51,7 @@ public interface ITextCanvasModel {
|
||||||
* @return the line of the cursor
|
* @return the line of the cursor
|
||||||
*/
|
*/
|
||||||
int getCursorLine();
|
int getCursorLine();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the column of the cursor
|
* @return the column of the cursor
|
||||||
*/
|
*/
|
||||||
|
@ -58,6 +62,7 @@ public interface ITextCanvasModel {
|
||||||
* {@link Point#x} is the column and {@link Point#y} is the line.
|
* {@link Point#x} is the column and {@link Point#y} is the line.
|
||||||
*/
|
*/
|
||||||
Point getSelectionStart();
|
Point getSelectionStart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the end of the selection or null if nothing is selected
|
* @return the end of the selection or null if nothing is selected
|
||||||
* {@link Point#x} is the column and {@link Point#y} is the line.
|
* {@link Point#x} is the column and {@link Point#y} is the line.
|
||||||
|
@ -67,6 +72,7 @@ public interface ITextCanvasModel {
|
||||||
Point getSelectionAnchor();
|
Point getSelectionAnchor();
|
||||||
|
|
||||||
void setSelectionAnchor(Point anchor);
|
void setSelectionAnchor(Point anchor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the selection. A negative startLine clears the selection.
|
* Sets the selection. A negative startLine clears the selection.
|
||||||
* @param startLine
|
* @param startLine
|
||||||
|
|
|
@ -16,7 +16,9 @@ package org.eclipse.tm.internal.terminal.textcanvas;
|
||||||
*/
|
*/
|
||||||
public interface ITextCanvasModelListener {
|
public interface ITextCanvasModelListener {
|
||||||
void rangeChanged(int col, int line, int width, int height);
|
void rangeChanged(int col, int line, int width, int height);
|
||||||
|
|
||||||
void dimensionsChanged(int cols, int rows);
|
void dimensionsChanged(int cols, int rows);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when any text change happened. Used to scroll to the
|
* Called when any text change happened. Used to scroll to the
|
||||||
* end of text in auto scroll mode. This does not get fired
|
* end of text in auto scroll mode. This does not get fired
|
||||||
|
|
|
@ -62,12 +62,14 @@ public class PipedInputStream extends InputStream {
|
||||||
protected int fTakePos = 0;
|
protected int fTakePos = 0;
|
||||||
protected int fUsedSlots = 0; // the count
|
protected int fUsedSlots = 0; // the count
|
||||||
private boolean fClosed;
|
private boolean fClosed;
|
||||||
|
|
||||||
public BoundedByteBuffer(int capacity) throws IllegalArgumentException {
|
public BoundedByteBuffer(int capacity) throws IllegalArgumentException {
|
||||||
// make sure we don't deadlock on too small capacity
|
// make sure we don't deadlock on too small capacity
|
||||||
if (capacity <= 0)
|
if (capacity <= 0)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
fBuffer = new byte[capacity];
|
fBuffer = new byte[capacity];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the bytes available for {@link #read()}
|
* @return the bytes available for {@link #read()}
|
||||||
* Must be called with a lock on this!
|
* Must be called with a lock on this!
|
||||||
|
@ -75,6 +77,7 @@ public class PipedInputStream extends InputStream {
|
||||||
public int available() {
|
public int available() {
|
||||||
return fUsedSlots;
|
return fUsedSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a single byte to the buffer. Blocks if the buffer is full.
|
* Writes a single byte to the buffer. Blocks if the buffer is full.
|
||||||
* @param b byte to write to the buffer
|
* @param b byte to write to the buffer
|
||||||
|
@ -93,9 +96,11 @@ public class PipedInputStream extends InputStream {
|
||||||
if (fUsedSlots++ == 0) // signal if was empty
|
if (fUsedSlots++ == 0) // signal if was empty
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFreeSlots() {
|
public int getFreeSlots() {
|
||||||
return fBuffer.length - fUsedSlots;
|
return fBuffer.length - fUsedSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] b, int off, int len) throws InterruptedException {
|
public void write(byte[] b, int off, int len) throws InterruptedException {
|
||||||
assert len <= getFreeSlots();
|
assert len <= getFreeSlots();
|
||||||
while (fUsedSlots == fBuffer.length)
|
while (fUsedSlots == fBuffer.length)
|
||||||
|
@ -111,6 +116,7 @@ public class PipedInputStream extends InputStream {
|
||||||
if (wasEmpty) // signal if was empty
|
if (wasEmpty) // signal if was empty
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a single byte. Blocks until a byte is available.
|
* Read a single byte. Blocks until a byte is available.
|
||||||
* @return a byte from the buffer
|
* @return a byte from the buffer
|
||||||
|
@ -132,6 +138,7 @@ public class PipedInputStream extends InputStream {
|
||||||
notifyAll();
|
notifyAll();
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(byte[] cbuf, int off, int len) throws InterruptedException {
|
public int read(byte[] cbuf, int off, int len) throws InterruptedException {
|
||||||
assert len <= available();
|
assert len <= available();
|
||||||
while (fUsedSlots == 0) {
|
while (fUsedSlots == 0) {
|
||||||
|
@ -152,10 +159,12 @@ public class PipedInputStream extends InputStream {
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
fClosed = true;
|
fClosed = true;
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClosed() {
|
public boolean isClosed() {
|
||||||
return fClosed;
|
return fClosed;
|
||||||
}
|
}
|
||||||
|
@ -205,12 +214,14 @@ public class PipedInputStream extends InputStream {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
synchronized (fQueue) {
|
synchronized (fQueue) {
|
||||||
fQueue.close();
|
fQueue.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bufferSize the size of the buffer of the output stream
|
* @param bufferSize the size of the buffer of the output stream
|
||||||
*/
|
*/
|
||||||
|
@ -218,12 +229,14 @@ public class PipedInputStream extends InputStream {
|
||||||
fOutputStream = new PipedOutputStream();
|
fOutputStream = new PipedOutputStream();
|
||||||
fQueue = new BoundedByteBuffer(bufferSize);
|
fQueue = new BoundedByteBuffer(bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the output stream used by the backend to write to the terminal.
|
* @return the output stream used by the backend to write to the terminal.
|
||||||
*/
|
*/
|
||||||
public OutputStream getOutputStream() {
|
public OutputStream getOutputStream() {
|
||||||
return fOutputStream;
|
return fOutputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits until data is available for reading.
|
* Waits until data is available for reading.
|
||||||
* @param millis see {@link Object#wait(long)}
|
* @param millis see {@link Object#wait(long)}
|
||||||
|
@ -236,6 +249,7 @@ public class PipedInputStream extends InputStream {
|
||||||
fQueue.wait(millis);
|
fQueue.wait(millis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must be called in the Display Thread!
|
* Must be called in the Display Thread!
|
||||||
* @return number of characters available for reading.
|
* @return number of characters available for reading.
|
||||||
|
@ -245,6 +259,7 @@ public class PipedInputStream extends InputStream {
|
||||||
return fQueue.available();
|
return fQueue.available();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the next available byte. Check with {@link #available}
|
* @return the next available byte. Check with {@link #available}
|
||||||
* if characters are available.
|
* if characters are available.
|
||||||
|
@ -259,6 +274,7 @@ public class PipedInputStream extends InputStream {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closing a <tt>PipedInputStream</tt> is the same as closing the output stream.
|
* Closing a <tt>PipedInputStream</tt> is the same as closing the output stream.
|
||||||
* The stream will allow reading data that's still in the pipe after which it will
|
* The stream will allow reading data that's still in the pipe after which it will
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* Anton Leherbauer (Wind River) - [420928] Terminal widget leaks memory
|
* Anton Leherbauer (Wind River) - [420928] Terminal widget leaks memory
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.textcanvas;
|
package org.eclipse.tm.internal.terminal.textcanvas;
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
|
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
|
||||||
|
|
||||||
|
@ -28,13 +29,16 @@ public class PollingTextCanvasModel extends AbstractTextCanvasModel {
|
||||||
super(snapshot);
|
super(snapshot);
|
||||||
startPolling();
|
startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdateInterval(int t) {
|
public void setUpdateInterval(int t) {
|
||||||
fPollInterval = t;
|
fPollInterval = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopPolling() {
|
public void stopPolling() {
|
||||||
// timerExec only dispatches if the delay is >=0
|
// timerExec only dispatches if the delay is >=0
|
||||||
fPollInterval = -1;
|
fPollInterval = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPolling() {
|
public void startPolling() {
|
||||||
if (fPollInterval < 0) {
|
if (fPollInterval < 0) {
|
||||||
fPollInterval = DEFAULT_POLL_INTERVAL;
|
fPollInterval = DEFAULT_POLL_INTERVAL;
|
||||||
|
|
|
@ -56,16 +56,19 @@ public class StyleMap {
|
||||||
private boolean fInvertColors;
|
private boolean fInvertColors;
|
||||||
private boolean fProportional;
|
private boolean fProportional;
|
||||||
private final int[] fOffsets = new int[256];
|
private final int[] fOffsets = new int[256];
|
||||||
|
|
||||||
StyleMap() {
|
StyleMap() {
|
||||||
initColors();
|
initColors();
|
||||||
fDefaultStyle = Style.getStyle(StyleColor.getStyleColor(BLACK), StyleColor.getStyleColor(WHITE));
|
fDefaultStyle = Style.getStyle(StyleColor.getStyleColor(BLACK), StyleColor.getStyleColor(WHITE));
|
||||||
updateFont();
|
updateFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initColors() {
|
private void initColors() {
|
||||||
initForegroundColors();
|
initForegroundColors();
|
||||||
initBackgroundColors();
|
initBackgroundColors();
|
||||||
initIntenseColors();
|
initIntenseColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initForegroundColors() {
|
private void initForegroundColors() {
|
||||||
if (fInvertColors) {
|
if (fInvertColors) {
|
||||||
setColor(fColorMapForeground, WHITE, 0, 0, 0);
|
setColor(fColorMapForeground, WHITE, 0, 0, 0);
|
||||||
|
@ -143,6 +146,7 @@ public class StyleMap {
|
||||||
else
|
else
|
||||||
return getColor(map, style.getForground());
|
return getColor(map, style.getForground());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getBackgroundColor(Style style) {
|
public Color getBackgroundColor(Style style) {
|
||||||
style = defaultIfNull(style);
|
style = defaultIfNull(style);
|
||||||
if (style.isReverse())
|
if (style.isReverse())
|
||||||
|
@ -150,6 +154,7 @@ public class StyleMap {
|
||||||
else
|
else
|
||||||
return getColor(fColorMapBackground, style.getBackground());
|
return getColor(fColorMapBackground, style.getBackground());
|
||||||
}
|
}
|
||||||
|
|
||||||
Color getColor(Map<StyleColor, Color> map, StyleColor color) {
|
Color getColor(Map<StyleColor, Color> map, StyleColor color) {
|
||||||
Color c = map.get(color);
|
Color c = map.get(color);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
@ -157,11 +162,13 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Style defaultIfNull(Style style) {
|
private Style defaultIfNull(Style style) {
|
||||||
if (style == null)
|
if (style == null)
|
||||||
style = fDefaultStyle;
|
style = fDefaultStyle;
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInvertedColors(boolean invert) {
|
public void setInvertedColors(boolean invert) {
|
||||||
if (invert == fInvertColors)
|
if (invert == fInvertColors)
|
||||||
return;
|
return;
|
||||||
|
@ -189,15 +196,19 @@ public class StyleMap {
|
||||||
return JFaceResources.getFontRegistry().get(fFontName);
|
return JFaceResources.getFontRegistry().get(fFontName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFontWidth() {
|
public int getFontWidth() {
|
||||||
return fCharSize.x;
|
return fCharSize.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFontHeight() {
|
public int getFontHeight() {
|
||||||
return fCharSize.y;
|
return fCharSize.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateFont() {
|
public void updateFont() {
|
||||||
updateFont(ITerminalConstants.FONT_DEFINITION);
|
updateFont(ITerminalConstants.FONT_DEFINITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the StyleMap for a new font name.
|
* Update the StyleMap for a new font name.
|
||||||
* The font name must be a valid name in the Jface font registry.
|
* The font name must be a valid name in the Jface font registry.
|
||||||
|
@ -263,6 +274,7 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
gc.dispose();
|
gc.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param gc
|
* @param gc
|
||||||
* @param c
|
* @param c
|
||||||
|
@ -282,9 +294,11 @@ public class StyleMap {
|
||||||
fOffsets[c] = ext.x;
|
fOffsets[c] = ext.x;
|
||||||
return proportional;
|
return proportional;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFontProportional() {
|
public boolean isFontProportional() {
|
||||||
return fProportional;
|
return fProportional;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the offset in pixels required to center a given character
|
* Return the offset in pixels required to center a given character
|
||||||
* @param c the character to measure
|
* @param c the character to measure
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.textcanvas;
|
package org.eclipse.tm.internal.terminal.textcanvas;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -99,15 +98,20 @@ public class TextCanvas extends GridCanvas {
|
||||||
fCellCanvasModel = model;
|
fCellCanvasModel = model;
|
||||||
fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener() {
|
fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener() {
|
||||||
public void rangeChanged(int col, int line, int width, int height) {
|
public void rangeChanged(int col, int line, int width, int height) {
|
||||||
if(isDisposed()) return;
|
if (isDisposed())
|
||||||
|
return;
|
||||||
repaintRange(col, line, width, height);
|
repaintRange(col, line, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dimensionsChanged(int cols, int rows) {
|
public void dimensionsChanged(int cols, int rows) {
|
||||||
if(isDisposed()) return;
|
if (isDisposed())
|
||||||
|
return;
|
||||||
calculateGrid();
|
calculateGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terminalDataChanged() {
|
public void terminalDataChanged() {
|
||||||
if(isDisposed()) return;
|
if (isDisposed())
|
||||||
|
return;
|
||||||
|
|
||||||
// scroll to end (unless scroll lock is active)
|
// scroll to end (unless scroll lock is active)
|
||||||
if (!fResizing) {
|
if (!fResizing) {
|
||||||
|
@ -121,9 +125,11 @@ public class TextCanvas extends GridCanvas {
|
||||||
public void focusGained(FocusEvent e) {
|
public void focusGained(FocusEvent e) {
|
||||||
fCellCanvasModel.setCursorEnabled(fCursorEnabled);
|
fCellCanvasModel.setCursorEnabled(fCursorEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void focusLost(FocusEvent e) {
|
public void focusLost(FocusEvent e) {
|
||||||
fCellCanvasModel.setCursorEnabled(false);
|
fCellCanvasModel.setCursorEnabled(false);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
fMouseListeners = new ArrayList<ITerminalMouseListener>();
|
fMouseListeners = new ArrayList<ITerminalMouseListener>();
|
||||||
addMouseListener(new MouseListener() {
|
addMouseListener(new MouseListener() {
|
||||||
public void mouseDoubleClick(MouseEvent e) {
|
public void mouseDoubleClick(MouseEvent e) {
|
||||||
|
@ -136,6 +142,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseDown(MouseEvent e) {
|
public void mouseDown(MouseEvent e) {
|
||||||
if (e.button == 1) { // left button
|
if (e.button == 1) { // left button
|
||||||
fDraggingStart = screenPointToCell(e.x, e.y);
|
fDraggingStart = screenPointToCell(e.x, e.y);
|
||||||
|
@ -158,6 +165,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseUp(MouseEvent e) {
|
public void mouseUp(MouseEvent e) {
|
||||||
if (e.button == 1) { // left button
|
if (e.button == 1) { // left button
|
||||||
updateHasSelection(e);
|
updateHasSelection(e);
|
||||||
|
@ -234,6 +242,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILinelRenderer getCellRenderer() {
|
public ILinelRenderer getCellRenderer() {
|
||||||
return fCellRenderer;
|
return fCellRenderer;
|
||||||
}
|
}
|
||||||
|
@ -311,6 +320,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
setRedraw(true);
|
setRedraw(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollToEnd() {
|
void scrollToEnd() {
|
||||||
if (!fScrollLock) {
|
if (!fScrollLock) {
|
||||||
int y = -(getRows() * getCellHeight() - getClientArea().height);
|
int y = -(getRows() * getCellHeight() - getClientArea().height);
|
||||||
|
@ -326,6 +336,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
scrollX(getHorizontalBar());
|
scrollX(getHorizontalBar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return true if the cursor should be shown on output....
|
* @return true if the cursor should be shown on output....
|
||||||
|
@ -333,37 +344,46 @@ public class TextCanvas extends GridCanvas {
|
||||||
public boolean isScrollLock() {
|
public boolean isScrollLock() {
|
||||||
return fScrollLock;
|
return fScrollLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set then if the size changes
|
* If set then if the size changes
|
||||||
*/
|
*/
|
||||||
public void setScrollLock(boolean scrollLock) {
|
public void setScrollLock(boolean scrollLock) {
|
||||||
fScrollLock = scrollLock;
|
fScrollLock = scrollLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void repaintRange(int col, int line, int width, int height) {
|
protected void repaintRange(int col, int line, int width, int height) {
|
||||||
Point origin = cellToOriginOnScreen(col, line);
|
Point origin = cellToOriginOnScreen(col, line);
|
||||||
Rectangle r = new Rectangle(origin.x, origin.y, width * getCellWidth(), height * getCellHeight());
|
Rectangle r = new Rectangle(origin.x, origin.y, width * getCellWidth(), height * getCellHeight());
|
||||||
repaint(r);
|
repaint(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawLine(GC gc, int line, int x, int y, int colFirst, int colLast) {
|
protected void drawLine(GC gc, int line, int x, int y, int colFirst, int colLast) {
|
||||||
fCellRenderer.drawLine(fCellCanvasModel, gc, line, x, y, colFirst, colLast);
|
fCellRenderer.drawLine(fCellCanvasModel, gc, line, x, y, colFirst, colLast);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Color getTerminalBackgroundColor() {
|
protected Color getTerminalBackgroundColor() {
|
||||||
return fCellRenderer.getDefaultBackgroundColor();
|
return fCellRenderer.getDefaultBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void visibleCellRectangleChanged(int x, int y, int width, int height) {
|
protected void visibleCellRectangleChanged(int x, int y, int width, int height) {
|
||||||
fCellCanvasModel.setVisibleRectangle(y, x, height, width);
|
fCellCanvasModel.setVisibleRectangle(y, x, height, width);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getCols() {
|
protected int getCols() {
|
||||||
return fCellCanvasModel.getTerminalText().getWidth();
|
return fCellCanvasModel.getTerminalText().getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getRows() {
|
protected int getRows() {
|
||||||
return fCellCanvasModel.getTerminalText().getHeight();
|
return fCellCanvasModel.getTerminalText().getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSelectionText() {
|
public String getSelectionText() {
|
||||||
// TODO -- create a hasSelectionMethod!
|
// TODO -- create a hasSelectionMethod!
|
||||||
return fCellCanvasModel.getSelectedText();
|
return fCellCanvasModel.getSelectedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copy() {
|
public void copy() {
|
||||||
String selectionText = getSelectionText();
|
String selectionText = getSelectionText();
|
||||||
if (selectionText != null && selectionText.length() > 0) {
|
if (selectionText != null && selectionText.length() > 0) {
|
||||||
|
@ -372,8 +392,10 @@ public class TextCanvas extends GridCanvas {
|
||||||
clipboard.dispose();
|
clipboard.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectAll() {
|
public void selectAll() {
|
||||||
fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth());
|
fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0,
|
||||||
|
fCellCanvasModel.getTerminalText().getWidth());
|
||||||
fCellCanvasModel.setSelectionAnchor(new Point(0, 0));
|
fCellCanvasModel.setSelectionAnchor(new Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +425,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets notified when the visible size of the terminal changes.
|
* Gets notified when the visible size of the terminal changes.
|
||||||
* This should update the model!
|
* This should update the model!
|
||||||
|
@ -411,6 +434,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
public interface ResizeListener {
|
public interface ResizeListener {
|
||||||
void sizeChanged(int lines, int columns);
|
void sizeChanged(int lines, int columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param listener this listener gets notified, when the size of
|
* @param listener this listener gets notified, when the size of
|
||||||
* the widget changed. It should change the dimensions of the underlying
|
* the widget changed. It should change the dimensions of the underlying
|
||||||
|
@ -485,4 +509,3 @@ public class TextCanvas extends GridCanvas {
|
||||||
fMouseListeners.remove(listener);
|
fMouseListeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,23 +32,28 @@ import org.eclipse.tm.terminal.model.Style;
|
||||||
public class TextLineRenderer implements ILinelRenderer {
|
public class TextLineRenderer implements ILinelRenderer {
|
||||||
private final ITextCanvasModel fModel;
|
private final ITextCanvasModel fModel;
|
||||||
StyleMap fStyleMap = new StyleMap();
|
StyleMap fStyleMap = new StyleMap();
|
||||||
|
|
||||||
public TextLineRenderer(TextCanvas c, ITextCanvasModel model) {
|
public TextLineRenderer(TextCanvas c, ITextCanvasModel model) {
|
||||||
fModel = model;
|
fModel = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.imagicus.thumbs.view.ICellRenderer#getCellWidth()
|
* @see com.imagicus.thumbs.view.ICellRenderer#getCellWidth()
|
||||||
*/
|
*/
|
||||||
public int getCellWidth() {
|
public int getCellWidth() {
|
||||||
return fStyleMap.getFontWidth();
|
return fStyleMap.getFontWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.imagicus.thumbs.view.ICellRenderer#getCellHeight()
|
* @see com.imagicus.thumbs.view.ICellRenderer#getCellHeight()
|
||||||
*/
|
*/
|
||||||
public int getCellHeight() {
|
public int getCellHeight() {
|
||||||
return fStyleMap.getFontHeight();
|
return fStyleMap.getFontHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast) {
|
public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast) {
|
||||||
if(line<0 || line>=getTerminalText().getHeight() || colFirst>=getTerminalText().getWidth() || colFirst-colLast==0) {
|
if (line < 0 || line >= getTerminalText().getHeight() || colFirst >= getTerminalText().getWidth()
|
||||||
|
|| colFirst - colLast == 0) {
|
||||||
fillBackground(gc, x, y, getCellWidth() * (colLast - colFirst), getCellHeight());
|
fillBackground(gc, x, y, getCellWidth() * (colLast - colFirst), getCellHeight());
|
||||||
} else {
|
} else {
|
||||||
colLast = Math.min(colLast, getTerminalText().getWidth());
|
colLast = Math.min(colLast, getTerminalText().getWidth());
|
||||||
|
@ -120,6 +125,7 @@ public class TextLineRenderer implements ILinelRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawText(GC gc, int x, int y, int colFirst, int col, String text) {
|
private void drawText(GC gc, int x, int y, int colFirst, int col, String text) {
|
||||||
int offset = (col - colFirst) * getCellWidth();
|
int offset = (col - colFirst) * getCellWidth();
|
||||||
if (fStyleMap.isFontProportional()) {
|
if (fStyleMap.isFontProportional()) {
|
||||||
|
@ -140,6 +146,7 @@ public class TextLineRenderer implements ILinelRenderer {
|
||||||
gc.drawString(text, x + offset, y, false);
|
gc.drawString(text, x + offset, y, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupGC(GC gc, Style style) {
|
private void setupGC(GC gc, Style style) {
|
||||||
Color c = fStyleMap.getForegrondColor(style);
|
Color c = fStyleMap.getForegrondColor(style);
|
||||||
if (c != gc.getForeground()) {
|
if (c != gc.getForeground()) {
|
||||||
|
@ -154,15 +161,19 @@ public class TextLineRenderer implements ILinelRenderer {
|
||||||
gc.setFont(f);
|
gc.setFont(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ITerminalTextDataReadOnly getTerminalText() {
|
ITerminalTextDataReadOnly getTerminalText() {
|
||||||
return fModel.getTerminalText();
|
return fModel.getTerminalText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFontChange() {
|
public void onFontChange() {
|
||||||
fStyleMap.updateFont();
|
fStyleMap.updateFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateFont(String fontName) {
|
public void updateFont(String fontName) {
|
||||||
fStyleMap.updateFont(fontName);
|
fStyleMap.updateFont(fontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInvertedColors(boolean invert) {
|
public void setInvertedColors(boolean invert) {
|
||||||
fStyleMap.setInvertedColors(invert);
|
fStyleMap.setInvertedColors(invert);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.textcanvas;
|
package org.eclipse.tm.internal.terminal.textcanvas;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
@ -68,9 +67,11 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onResize() {
|
protected void onResize() {
|
||||||
updateViewRectangle();
|
updateViewRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void scrollX(ScrollBar hBar) {
|
protected void scrollX(ScrollBar hBar) {
|
||||||
int hSelection = hBar.getSelection();
|
int hSelection = hBar.getSelection();
|
||||||
int destX = -hSelection - fVirtualBounds.x;
|
int destX = -hSelection - fVirtualBounds.x;
|
||||||
|
@ -78,6 +79,7 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
scrollSmart(destX, 0);
|
scrollSmart(destX, 0);
|
||||||
updateViewRectangle();
|
updateViewRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void scrollXDelta(int delta) {
|
protected void scrollXDelta(int delta) {
|
||||||
getHorizontalBar().setSelection(-fVirtualBounds.x + delta);
|
getHorizontalBar().setSelection(-fVirtualBounds.x + delta);
|
||||||
scrollX(getHorizontalBar());
|
scrollX(getHorizontalBar());
|
||||||
|
@ -93,12 +95,12 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void scrollYDelta(int delta) {
|
protected void scrollYDelta(int delta) {
|
||||||
getVerticalBar().setSelection(-fVirtualBounds.y + delta);
|
getVerticalBar().setSelection(-fVirtualBounds.y + delta);
|
||||||
scrollY(getVerticalBar());
|
scrollY(getVerticalBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void scrollSmart(int deltaX, int deltaY) {
|
protected void scrollSmart(int deltaX, int deltaY) {
|
||||||
if (deltaX != 0 || deltaY != 0) {
|
if (deltaX != 0 || deltaY != 0) {
|
||||||
Rectangle rect = getBounds();
|
Rectangle rect = getBounds();
|
||||||
|
@ -152,10 +154,12 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
* @param gc graphics context to paint in
|
* @param gc graphics context to paint in
|
||||||
*/
|
*/
|
||||||
abstract protected void paint(GC gc);
|
abstract protected void paint(GC gc);
|
||||||
|
|
||||||
protected Color getTerminalBackgroundColor() {
|
protected Color getTerminalBackgroundColor() {
|
||||||
// return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
|
// return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
|
||||||
return getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
return getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintUnoccupiedSpace(GC gc, Rectangle clipping) {
|
protected void paintUnoccupiedSpace(GC gc, Rectangle clipping) {
|
||||||
int width = fVirtualBounds.width + fVirtualBounds.x;
|
int width = fVirtualBounds.width + fVirtualBounds.x;
|
||||||
int height = fVirtualBounds.height + fVirtualBounds.y;
|
int height = fVirtualBounds.height + fVirtualBounds.y;
|
||||||
|
@ -173,6 +177,7 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
gc.setBackground(bg);
|
gc.setBackground(bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -190,14 +195,17 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the screen rect in virtual space (starting with (0,0))
|
* @return the screen rect in virtual space (starting with (0,0))
|
||||||
* of the visible screen. (x,y>=0)
|
* of the visible screen. (x,y>=0)
|
||||||
*/
|
*/
|
||||||
protected Rectangle getScreenRectInVirtualSpace() {
|
protected Rectangle getScreenRectInVirtualSpace() {
|
||||||
Rectangle r= new Rectangle(fClientArea.x-fVirtualBounds.x,fClientArea.y-fVirtualBounds.y,fClientArea.width,fClientArea.height);
|
Rectangle r = new Rectangle(fClientArea.x - fVirtualBounds.x, fClientArea.y - fVirtualBounds.y,
|
||||||
|
fClientArea.width, fClientArea.height);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rect in virtual space (starting with (0,0))
|
* @return the rect in virtual space (starting with (0,0))
|
||||||
* of the visible screen. (x,y>=0)
|
* of the visible screen. (x,y>=0)
|
||||||
|
@ -217,6 +225,7 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
updateScrollbars();
|
updateScrollbars();
|
||||||
updateViewRectangle();
|
updateViewRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the scrolling origin. Also sets the scrollbars.
|
* sets the scrolling origin. Also sets the scrollbars.
|
||||||
* Does NOT redraw!
|
* Does NOT redraw!
|
||||||
|
@ -234,9 +243,11 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
updateViewRectangle();
|
updateViewRectangle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rectangle getVirtualBounds() {
|
protected Rectangle getVirtualBounds() {
|
||||||
return cloneRectangle(fVirtualBounds);
|
return cloneRectangle(fVirtualBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param x
|
* @param x
|
||||||
* @return the virtual coordinate in screen space
|
* @return the virtual coordinate in screen space
|
||||||
|
@ -244,24 +255,25 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
protected int virtualXtoScreen(int x) {
|
protected int virtualXtoScreen(int x) {
|
||||||
return x + fVirtualBounds.x;
|
return x + fVirtualBounds.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int virtualYtoScreen(int y) {
|
protected int virtualYtoScreen(int y) {
|
||||||
return y + fVirtualBounds.y;
|
return y + fVirtualBounds.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int screenXtoVirtual(int x) {
|
protected int screenXtoVirtual(int x) {
|
||||||
return x - fVirtualBounds.x;
|
return x - fVirtualBounds.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int screenYtoVirtual(int y) {
|
protected int screenYtoVirtual(int y) {
|
||||||
return y - fVirtualBounds.y;
|
return y - fVirtualBounds.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** called when the viewed part is changing */
|
/** called when the viewed part is changing */
|
||||||
private final Rectangle fViewRectangle = new Rectangle(0, 0, 0, 0);
|
private final Rectangle fViewRectangle = new Rectangle(0, 0, 0, 0);
|
||||||
|
|
||||||
protected void updateViewRectangle() {
|
protected void updateViewRectangle() {
|
||||||
if(
|
if (fViewRectangle.x == -fVirtualBounds.x && fViewRectangle.y == -fVirtualBounds.y
|
||||||
fViewRectangle.x==-fVirtualBounds.x
|
&& fViewRectangle.width == fClientArea.width && fViewRectangle.height == fClientArea.height)
|
||||||
&& fViewRectangle.y==-fVirtualBounds.y
|
|
||||||
&& fViewRectangle.width==fClientArea.width
|
|
||||||
&& fViewRectangle.height==fClientArea.height
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
fViewRectangle.x = -fVirtualBounds.x;
|
fViewRectangle.x = -fVirtualBounds.x;
|
||||||
fViewRectangle.y = -fVirtualBounds.y;
|
fViewRectangle.y = -fVirtualBounds.y;
|
||||||
|
@ -269,12 +281,15 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
fViewRectangle.height = fClientArea.height;
|
fViewRectangle.height = fClientArea.height;
|
||||||
viewRectangleChanged(fViewRectangle.x, fViewRectangle.y, fViewRectangle.width, fViewRectangle.height);
|
viewRectangleChanged(fViewRectangle.x, fViewRectangle.y, fViewRectangle.width, fViewRectangle.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rectangle getViewRectangle() {
|
protected Rectangle getViewRectangle() {
|
||||||
return cloneRectangle(fViewRectangle);
|
return cloneRectangle(fViewRectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rectangle cloneRectangle(Rectangle r) {
|
private Rectangle cloneRectangle(Rectangle r) {
|
||||||
return new Rectangle(r.x, r.y, r.width, r.height);
|
return new Rectangle(r.x, r.y, r.width, r.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the viewed part has changed.
|
* Called when the viewed part has changed.
|
||||||
* Override when you need this information....
|
* Override when you need this information....
|
||||||
|
@ -286,6 +301,7 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
*/
|
*/
|
||||||
protected void viewRectangleChanged(int x, int y, int width, int height) {
|
protected void viewRectangleChanged(int x, int y, int width, int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -301,12 +317,14 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
} else {
|
} else {
|
||||||
if (!fInUpdateScrollbarsLogged) {
|
if (!fInUpdateScrollbarsLogged) {
|
||||||
fInUpdateScrollbarsLogged = true;
|
fInUpdateScrollbarsLogged = true;
|
||||||
TerminalPlugin.getDefault().getLog().log(new Status(IStatus.WARNING,
|
TerminalPlugin.getDefault().getLog()
|
||||||
TerminalPlugin.PLUGIN_ID, IStatus.OK, "Unexpected Recursion in terminal", //$NON-NLS-1$
|
.log(new Status(IStatus.WARNING, TerminalPlugin.PLUGIN_ID, IStatus.OK,
|
||||||
|
"Unexpected Recursion in terminal", //$NON-NLS-1$
|
||||||
new RuntimeException()));
|
new RuntimeException()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doUpdateScrollbar() {
|
private void doUpdateScrollbar() {
|
||||||
Rectangle clientArea = getClientArea();
|
Rectangle clientArea = getClientArea();
|
||||||
ScrollBar horizontal = getHorizontalBar();
|
ScrollBar horizontal = getHorizontalBar();
|
||||||
|
@ -328,21 +346,24 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
vertical.setThumb(clientArea.height);
|
vertical.setThumb(clientArea.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isVertialBarVisible() {
|
protected boolean isVertialBarVisible() {
|
||||||
return getVerticalBar().isVisible();
|
return getVerticalBar().isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void serVerticalBarVisible(boolean showVScrollBar) {
|
protected void serVerticalBarVisible(boolean showVScrollBar) {
|
||||||
ScrollBar vertical = getVerticalBar();
|
ScrollBar vertical = getVerticalBar();
|
||||||
vertical.setVisible(showVScrollBar);
|
vertical.setVisible(showVScrollBar);
|
||||||
vertical.setSelection(0);
|
vertical.setSelection(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isHorizontalBarVisble() {
|
protected boolean isHorizontalBarVisble() {
|
||||||
return getHorizontalBar().isVisible();
|
return getHorizontalBar().isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setHorizontalBarVisible(boolean showHScrollBar) {
|
protected void setHorizontalBarVisible(boolean showHScrollBar) {
|
||||||
ScrollBar horizontal = getHorizontalBar();
|
ScrollBar horizontal = getHorizontalBar();
|
||||||
horizontal.setVisible(showHScrollBar);
|
horizontal.setVisible(showHScrollBar);
|
||||||
horizontal.setSelection(0);
|
horizontal.setSelection(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
|
||||||
void setDimensions(int height, int width);
|
void setDimensions(int height, int width);
|
||||||
|
|
||||||
void setMaxHeight(int height);
|
void setMaxHeight(int height);
|
||||||
|
|
||||||
int getMaxHeight();
|
int getMaxHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +69,6 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
|
||||||
*/
|
*/
|
||||||
void setChars(int line, int column, char[] chars, int start, int len, Style style);
|
void setChars(int line, int column, char[] chars, int start, int len, Style style);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans the entire line.
|
* Cleans the entire line.
|
||||||
* @param line
|
* @param line
|
||||||
|
@ -116,11 +116,13 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
|
||||||
* will be scrolled. Else a line will be added.
|
* will be scrolled. Else a line will be added.
|
||||||
*/
|
*/
|
||||||
void addLine();
|
void addLine();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the entire source into this and changes the size accordingly
|
* Copies the entire source into this and changes the size accordingly
|
||||||
* @param source
|
* @param source
|
||||||
*/
|
*/
|
||||||
void copy(ITerminalTextData source);
|
void copy(ITerminalTextData source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a sourceLine from source to this at destLine.
|
* Copy a sourceLine from source to this at destLine.
|
||||||
* @param source
|
* @param source
|
||||||
|
@ -128,6 +130,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
|
||||||
* @param destLine
|
* @param destLine
|
||||||
*/
|
*/
|
||||||
void copyLine(ITerminalTextData source, int sourceLine, int destLine);
|
void copyLine(ITerminalTextData source, int sourceLine, int destLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy <code>length</code> lines from source starting at sourceLine into this starting at
|
* Copy <code>length</code> lines from source starting at sourceLine into this starting at
|
||||||
* destLine.
|
* destLine.
|
||||||
|
@ -139,6 +142,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
|
||||||
void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length);
|
void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length);
|
||||||
|
|
||||||
void setCursorLine(int line);
|
void setCursorLine(int line);
|
||||||
|
|
||||||
void setCursorColumn(int column);
|
void setCursorColumn(int column);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,12 +66,14 @@ public interface ITerminalTextDataReadOnly {
|
||||||
public ITerminalTextDataSnapshot makeSnapshot();
|
public ITerminalTextDataSnapshot makeSnapshot();
|
||||||
|
|
||||||
char[] getChars(int line);
|
char[] getChars(int line);
|
||||||
|
|
||||||
Style[] getStyles(int line);
|
Style[] getStyles(int line);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the line in which the cursor is at the moment
|
* @return the line in which the cursor is at the moment
|
||||||
*/
|
*/
|
||||||
int getCursorLine();
|
int getCursorLine();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the column at which the cursor is at the moment
|
* @return the column at which the cursor is at the moment
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -108,7 +108,9 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly {
|
||||||
*/
|
*/
|
||||||
void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot);
|
void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addListener(SnapshotOutOfDateListener listener);
|
void addListener(SnapshotOutOfDateListener listener);
|
||||||
|
|
||||||
void removeListener(SnapshotOutOfDateListener listener);
|
void removeListener(SnapshotOutOfDateListener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +118,7 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly {
|
||||||
* has been called no new snapshot data is collected.
|
* has been called no new snapshot data is collected.
|
||||||
*/
|
*/
|
||||||
void detach();
|
void detach();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the data has changed since the previous snapshot.
|
* @return true if the data has changed since the previous snapshot.
|
||||||
*/
|
*/
|
||||||
|
@ -129,7 +132,9 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly {
|
||||||
* @param size number of lines to track. A size of -1 means track all.
|
* @param size number of lines to track. A size of -1 means track all.
|
||||||
*/
|
*/
|
||||||
void setInterestWindow(int startLine, int size);
|
void setInterestWindow(int startLine, int size);
|
||||||
|
|
||||||
int getInterestWindowStartLine();
|
int getInterestWindowStartLine();
|
||||||
|
|
||||||
int getInterestWindowSize();
|
int getInterestWindowSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,6 +200,7 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly {
|
||||||
* window of interest)
|
* window of interest)
|
||||||
*/
|
*/
|
||||||
boolean hasTerminalChanged();
|
boolean hasTerminalChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If {@link #updateSnapshot(boolean)} was called with <code>true</code>, then this method
|
* If {@link #updateSnapshot(boolean)} was called with <code>true</code>, then this method
|
||||||
* returns the top of the scroll region.
|
* returns the top of the scroll region.
|
||||||
|
|
|
@ -10,25 +10,29 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.terminal.model;
|
package org.eclipse.tm.terminal.model;
|
||||||
|
|
||||||
|
|
||||||
public class LineSegment {
|
public class LineSegment {
|
||||||
private final String fText;
|
private final String fText;
|
||||||
private final int fCol;
|
private final int fCol;
|
||||||
private final Style fStyle;
|
private final Style fStyle;
|
||||||
|
|
||||||
public LineSegment(int col, String text, Style style) {
|
public LineSegment(int col, String text, Style style) {
|
||||||
fCol = col;
|
fCol = col;
|
||||||
fText = text;
|
fText = text;
|
||||||
fStyle = style;
|
fStyle = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
return fStyle;
|
return fStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return fText;
|
return fText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColumn() {
|
public int getColumn() {
|
||||||
return fCol;
|
return fCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "LineSegment(" + fCol + ", \"" + fText + "\"," + fStyle + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
return "LineSegment(" + fCol + ", \"" + fText + "\"," + fStyle + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@ public class Style {
|
||||||
private final boolean fUnderline;
|
private final boolean fUnderline;
|
||||||
private final boolean fReverse;
|
private final boolean fReverse;
|
||||||
private final static Map<Style, Style> fgStyles = new HashMap<Style, Style>();
|
private final static Map<Style, Style> fgStyles = new HashMap<Style, Style>();
|
||||||
private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, boolean reverse) {
|
|
||||||
|
private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline,
|
||||||
|
boolean reverse) {
|
||||||
fForground = forground;
|
fForground = forground;
|
||||||
fBackground = background;
|
fBackground = background;
|
||||||
fBold = bold;
|
fBold = bold;
|
||||||
|
@ -37,7 +39,9 @@ public class Style {
|
||||||
fUnderline = underline;
|
fUnderline = underline;
|
||||||
fReverse = reverse;
|
fReverse = reverse;
|
||||||
}
|
}
|
||||||
public static Style getStyle(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, boolean reverse) {
|
|
||||||
|
public static Style getStyle(StyleColor forground, StyleColor background, boolean bold, boolean blink,
|
||||||
|
boolean underline, boolean reverse) {
|
||||||
Style style = new Style(forground, background, bold, blink, underline, reverse);
|
Style style = new Style(forground, background, bold, blink, underline, reverse);
|
||||||
Style cached;
|
Style cached;
|
||||||
synchronized (fgStyles) {
|
synchronized (fgStyles) {
|
||||||
|
@ -49,54 +53,72 @@ public class Style {
|
||||||
}
|
}
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Style getStyle(String forground, String background) {
|
public static Style getStyle(String forground, String background) {
|
||||||
return getStyle(StyleColor.getStyleColor(forground), StyleColor.getStyleColor(background),false,false,false,false);
|
return getStyle(StyleColor.getStyleColor(forground), StyleColor.getStyleColor(background), false, false, false,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Style getStyle(StyleColor forground, StyleColor background) {
|
public static Style getStyle(StyleColor forground, StyleColor background) {
|
||||||
return getStyle(forground, background, false, false, false, false);
|
return getStyle(forground, background, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setForground(StyleColor forground) {
|
public Style setForground(StyleColor forground) {
|
||||||
return getStyle(forground, fBackground, fBold, fBlink, fUnderline, fReverse);
|
return getStyle(forground, fBackground, fBold, fBlink, fUnderline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setBackground(StyleColor background) {
|
public Style setBackground(StyleColor background) {
|
||||||
return getStyle(fForground, background, fBold, fBlink, fUnderline, fReverse);
|
return getStyle(fForground, background, fBold, fBlink, fUnderline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setForground(String colorName) {
|
public Style setForground(String colorName) {
|
||||||
return getStyle(StyleColor.getStyleColor(colorName), fBackground, fBold, fBlink, fUnderline, fReverse);
|
return getStyle(StyleColor.getStyleColor(colorName), fBackground, fBold, fBlink, fUnderline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setBackground(String colorName) {
|
public Style setBackground(String colorName) {
|
||||||
return getStyle(fForground, StyleColor.getStyleColor(colorName), fBold, fBlink, fUnderline, fReverse);
|
return getStyle(fForground, StyleColor.getStyleColor(colorName), fBold, fBlink, fUnderline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setBold(boolean bold) {
|
public Style setBold(boolean bold) {
|
||||||
return getStyle(fForground, fBackground, bold, fBlink, fUnderline, fReverse);
|
return getStyle(fForground, fBackground, bold, fBlink, fUnderline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setBlink(boolean blink) {
|
public Style setBlink(boolean blink) {
|
||||||
return getStyle(fForground, fBackground, fBold, blink, fUnderline, fReverse);
|
return getStyle(fForground, fBackground, fBold, blink, fUnderline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setUnderline(boolean underline) {
|
public Style setUnderline(boolean underline) {
|
||||||
return getStyle(fForground, fBackground, fBold, fBlink, underline, fReverse);
|
return getStyle(fForground, fBackground, fBold, fBlink, underline, fReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style setReverse(boolean reverse) {
|
public Style setReverse(boolean reverse) {
|
||||||
return getStyle(fForground, fBackground, fBold, fBlink, fUnderline, reverse);
|
return getStyle(fForground, fBackground, fBold, fBlink, fUnderline, reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StyleColor getBackground() {
|
public StyleColor getBackground() {
|
||||||
return fBackground;
|
return fBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlink() {
|
public boolean isBlink() {
|
||||||
return fBlink;
|
return fBlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBold() {
|
public boolean isBold() {
|
||||||
return fBold;
|
return fBold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StyleColor getForground() {
|
public StyleColor getForground() {
|
||||||
return fForground;
|
return fForground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReverse() {
|
public boolean isReverse() {
|
||||||
return fReverse;
|
return fReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnderline() {
|
public boolean isUnderline() {
|
||||||
return fUnderline;
|
return fUnderline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
@ -108,6 +130,7 @@ public class Style {
|
||||||
result = prime * result + (fUnderline ? 1231 : 1237);
|
result = prime * result + (fUnderline ? 1231 : 1237);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
|
@ -131,6 +154,7 @@ public class Style {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
result.append("Style(foreground="); //$NON-NLS-1$
|
result.append("Style(foreground="); //$NON-NLS-1$
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class StyleColor {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nobody except the factory method is allowed to instantiate this class!
|
// nobody except the factory method is allowed to instantiate this class!
|
||||||
private StyleColor(String name) {
|
private StyleColor(String name) {
|
||||||
fName = name;
|
fName = name;
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TerminalControlMock implements ITerminalControl {
|
public static class TerminalControlMock implements ITerminalControl {
|
||||||
|
|
||||||
public void setEncoding(String encoding) {
|
public void setEncoding(String encoding) {
|
||||||
|
@ -93,6 +94,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ConnectorMock extends TerminalConnectorImpl {
|
static class ConnectorMock extends TerminalConnectorImpl {
|
||||||
|
|
||||||
public boolean fEcho;
|
public boolean fEcho;
|
||||||
|
@ -106,14 +108,17 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
public boolean isLocalEcho() {
|
public boolean isLocalEcho() {
|
||||||
return fEcho;
|
return fEcho;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
fWidth = newWidth;
|
fWidth = newWidth;
|
||||||
fHeight = newHeight;
|
fHeight = newHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fTerminalControl = control;
|
fTerminalControl = control;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDisconnect() {
|
public void doDisconnect() {
|
||||||
fDisconnect = true;
|
fDisconnect = true;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +139,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
fSaveStore = store;
|
fSaveStore = store;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TerminalConnector makeTerminalConnector() {
|
protected TerminalConnector makeTerminalConnector() {
|
||||||
return makeTerminalConnector(new ConnectorMock());
|
return makeTerminalConnector(new ConnectorMock());
|
||||||
}
|
}
|
||||||
|
@ -155,7 +161,8 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
c = makeTerminalConnector(new ConnectorMock() {
|
c = makeTerminalConnector(new ConnectorMock() {
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
throw new Exception("FAILED");
|
throw new Exception("FAILED");
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
c.connect(new TerminalControlMock());
|
c.connect(new TerminalControlMock());
|
||||||
assertEquals("FAILED", c.getInitializationErrorMessage());
|
assertEquals("FAILED", c.getInitializationErrorMessage());
|
||||||
|
|
||||||
|
@ -182,7 +189,8 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
assertFalse(c.isInitialized());
|
assertFalse(c.isInitialized());
|
||||||
c.save(null);
|
c.save(null);
|
||||||
assertFalse(c.isInitialized());
|
assertFalse(c.isInitialized());
|
||||||
if (!Platform.isRunning()) return;
|
if (!Platform.isRunning())
|
||||||
|
return;
|
||||||
c.getAdapter(ConnectorMock.class);
|
c.getAdapter(ConnectorMock.class);
|
||||||
assertFalse(c.isInitialized());
|
assertFalse(c.isInitialized());
|
||||||
}
|
}
|
||||||
|
@ -211,6 +219,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
c.connect(control);
|
c.connect(control);
|
||||||
assertSame(mock.fTerminalControl, control);
|
assertSame(mock.fTerminalControl, control);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetSettingsSummary() {
|
public void testGetSettingsSummary() {
|
||||||
TerminalConnector c = makeTerminalConnector();
|
TerminalConnector c = makeTerminalConnector();
|
||||||
assertEquals("Not Initialized", c.getSettingsSummary());
|
assertEquals("Not Initialized", c.getSettingsSummary());
|
||||||
|
@ -262,7 +271,8 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetAdapter() {
|
public void testGetAdapter() {
|
||||||
if (!Platform.isRunning()) return;
|
if (!Platform.isRunning())
|
||||||
|
return;
|
||||||
ConnectorMock mock = new ConnectorMock();
|
ConnectorMock mock = new ConnectorMock();
|
||||||
TerminalConnector c = makeTerminalConnector(mock);
|
TerminalConnector c = makeTerminalConnector(mock);
|
||||||
assertNull(c.getAdapter(ConnectorMock.class));
|
assertNull(c.getAdapter(ConnectorMock.class));
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TerminalControlMock implements ITerminalControl {
|
public static class TerminalControlMock implements ITerminalControl {
|
||||||
|
|
||||||
public void setEncoding(String encoding) {
|
public void setEncoding(String encoding) {
|
||||||
|
@ -93,6 +94,7 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ConnectorMock extends TerminalConnectorImpl {
|
static class ConnectorMock extends TerminalConnectorImpl {
|
||||||
|
|
||||||
public boolean fEcho;
|
public boolean fEcho;
|
||||||
|
@ -106,14 +108,17 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
public boolean isLocalEcho() {
|
public boolean isLocalEcho() {
|
||||||
return fEcho;
|
return fEcho;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
fWidth = newWidth;
|
fWidth = newWidth;
|
||||||
fHeight = newHeight;
|
fHeight = newHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fTerminalControl = control;
|
fTerminalControl = control;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDisconnect() {
|
public void doDisconnect() {
|
||||||
fDisconnect = true;
|
fDisconnect = true;
|
||||||
}
|
}
|
||||||
|
@ -134,16 +139,20 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
fSaveStore = store;
|
fSaveStore = store;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SimpleFactory implements Factory {
|
static class SimpleFactory implements Factory {
|
||||||
final TerminalConnectorImpl fConnector;
|
final TerminalConnectorImpl fConnector;
|
||||||
|
|
||||||
public SimpleFactory(TerminalConnectorImpl connector) {
|
public SimpleFactory(TerminalConnectorImpl connector) {
|
||||||
fConnector = connector;
|
fConnector = connector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
public TerminalConnectorImpl makeConnector() throws Exception {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return fConnector;
|
return fConnector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetInitializationErrorMessage() {
|
public void testGetInitializationErrorMessage() {
|
||||||
TerminalConnector c = new TerminalConnector(new SimpleFactory(new ConnectorMock()), "xID", "xName", false);
|
TerminalConnector c = new TerminalConnector(new SimpleFactory(new ConnectorMock()), "xID", "xName", false);
|
||||||
c.connect(new TerminalControlMock());
|
c.connect(new TerminalControlMock());
|
||||||
|
@ -152,7 +161,8 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
c = new TerminalConnector(new SimpleFactory(new ConnectorMock() {
|
c = new TerminalConnector(new SimpleFactory(new ConnectorMock() {
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
throw new Exception("FAILED");
|
throw new Exception("FAILED");
|
||||||
}}),"xID","xName", false);
|
}
|
||||||
|
}), "xID", "xName", false);
|
||||||
c.connect(new TerminalControlMock());
|
c.connect(new TerminalControlMock());
|
||||||
assertEquals("FAILED", c.getInitializationErrorMessage());
|
assertEquals("FAILED", c.getInitializationErrorMessage());
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
final static String ENCODING = "UTF-8";
|
final static String ENCODING = "UTF-8";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class escapes strings coming on the original
|
* This class escapes strings coming on the original
|
||||||
* terminal..
|
* terminal..
|
||||||
|
@ -30,11 +31,13 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
|
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
fOriginal.write('[');
|
fOriginal.write('[');
|
||||||
fOriginal.write(b);
|
fOriginal.write(b);
|
||||||
fOriginal.write(']');
|
fOriginal.write(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
fOriginal.write('[');
|
fOriginal.write('[');
|
||||||
fOriginal.write(b, off, len);
|
fOriginal.write(b, off, len);
|
||||||
|
@ -42,8 +45,10 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class NullInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
|
class NullInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClose() throws UnsupportedEncodingException, IOException {
|
public void testClose() throws UnsupportedEncodingException, IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
||||||
|
@ -101,6 +106,7 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
|
|
||||||
public void testWriteByteArrayIntInt() {
|
public void testWriteByteArrayIntInt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGrabOutput() throws UnsupportedEncodingException, IOException {
|
public void testGrabOutput() throws UnsupportedEncodingException, IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
||||||
|
@ -128,6 +134,7 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
assertEquals("begin:Test the west!", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test the west!", new String(bs.toByteArray(), ENCODING));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGrabOutputWithCleverInterceptor() throws UnsupportedEncodingException, IOException {
|
public void testGrabOutputWithCleverInterceptor() throws UnsupportedEncodingException, IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
||||||
|
@ -150,6 +157,7 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
assertEquals("begin:Test[ west] the[x]!", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test[ west] the[x]!", new String(bs.toByteArray(), ENCODING));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGrabOutputWithNullInterceptor() throws UnsupportedEncodingException, IOException {
|
public void testGrabOutputWithNullInterceptor() throws UnsupportedEncodingException, IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,6 +10,7 @@
|
||||||
* Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break
|
* Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.model;
|
package org.eclipse.tm.internal.terminal.model;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
@ -30,9 +31,11 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
}
|
}
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String toSimple(ITerminalTextData term) {
|
protected String toSimple(ITerminalTextData term) {
|
||||||
return TerminalTextTestHelper.toSimple(term);
|
return TerminalTextTestHelper.toSimple(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String toMultiLineText(ITerminalTextDataReadOnly term) {
|
protected String toMultiLineText(ITerminalTextDataReadOnly term) {
|
||||||
return TerminalTextTestHelper.toMultiLineText(term);
|
return TerminalTextTestHelper.toMultiLineText(term);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +52,6 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
TerminalTextTestHelper.fillSimple(term, s);
|
TerminalTextTestHelper.fillSimple(term, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for multi line text
|
* Used for multi line text
|
||||||
* @param expected
|
* @param expected
|
||||||
|
@ -58,6 +60,7 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
protected void assertEqualsTerm(String expected, String actual) {
|
protected void assertEqualsTerm(String expected, String actual) {
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for simple text
|
* Used for simple text
|
||||||
* @param expected
|
* @param expected
|
||||||
|
@ -67,6 +70,7 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEquals(-1, actual.indexOf('\n'));
|
assertEquals(-1, actual.indexOf('\n'));
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetWidth() {
|
public void testGetWidth() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
assertEquals(0, term.getWidth());
|
assertEquals(0, term.getWidth());
|
||||||
|
@ -77,57 +81,28 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddLine() {
|
public void testAddLine() {
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setMaxHeight(5);
|
term.setMaxHeight(5);
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCleanLine() {
|
public void testCleanLine() {
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.cleanLine(0);
|
term.cleanLine(0);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("\000\000\000\n" + "222\n" + "333\n" + "444\n" + "555", toMultiLineText(term));
|
||||||
"\000\000\000\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.cleanLine(4);
|
term.cleanLine(4);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("111\n" + "222\n" + "333\n" + "444\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMaxSize() {
|
public void testMaxSize() {
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setMaxHeight(8);
|
term.setMaxHeight(8);
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
|
@ -135,57 +110,26 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEquals(8, term.getMaxHeight());
|
assertEquals(8, term.getMaxHeight());
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(6, term.getHeight());
|
assertEquals(6, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("111\n" + "222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(7, term.getHeight());
|
assertEquals(7, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("111\n" + "222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000\n" + "\000\000\000",
|
||||||
"111\n" +
|
toMultiLineText(term));
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(8, term.getHeight());
|
assertEquals(8, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm(
|
||||||
"111\n" +
|
"111\n" + "222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000\n" + "\000\000\000\n" + "\000\000\000",
|
||||||
"222\n" +
|
toMultiLineText(term));
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(8, term.getHeight());
|
assertEquals(8, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000\n" + "\000\000\000\n" + "\000\000\000\n"
|
||||||
"222\n" +
|
+ "\000\000\000", toMultiLineText(term));
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(8, term.getHeight());
|
assertEquals(8, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("333\n" + "444\n" + "555\n" + "\000\000\000\n" + "\000\000\000\n" + "\000\000\000\n"
|
||||||
"333\n" +
|
+ "\000\000\000\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetHeight() {
|
public void testGetHeight() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
assertEquals(0, term.getHeight());
|
assertEquals(0, term.getHeight());
|
||||||
|
@ -214,49 +158,32 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEquals(0, term.getWidth());
|
assertEquals(0, term.getWidth());
|
||||||
assertEquals(0, term.getHeight());
|
assertEquals(0, term.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResize() {
|
public void testResize() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(3, 5);
|
term.setDimensions(3, 5);
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE";
|
|
||||||
fill(term, 0, 0, s);
|
fill(term, 0, 0, s);
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
term.setDimensions(3, 4);
|
term.setDimensions(3, 4);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("1234\n" + "abcd\n" + "ABCD", toMultiLineText(term));
|
||||||
"1234\n" +
|
|
||||||
"abcd\n" +
|
|
||||||
"ABCD", toMultiLineText(term));
|
|
||||||
// the columns should be restored
|
// the columns should be restored
|
||||||
term.setDimensions(3, 5);
|
term.setDimensions(3, 5);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("12345\n" + "abcde\n" + "ABCDE", toMultiLineText(term));
|
||||||
"12345\n" +
|
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE", toMultiLineText(term));
|
|
||||||
term.setDimensions(3, 6);
|
term.setDimensions(3, 6);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("12345\000\n" + "abcde\000\n" + "ABCDE\000", toMultiLineText(term));
|
||||||
"12345\000\n" +
|
|
||||||
"abcde\000\n" +
|
|
||||||
"ABCDE\000", toMultiLineText(term));
|
|
||||||
term.setChar(0, 5, 'x', null);
|
term.setChar(0, 5, 'x', null);
|
||||||
term.setChar(1, 5, 'y', null);
|
term.setChar(1, 5, 'y', null);
|
||||||
term.setChar(2, 5, 'z', null);
|
term.setChar(2, 5, 'z', null);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("12345x\n" + "abcdey\n" + "ABCDEz", toMultiLineText(term));
|
||||||
"12345x\n" +
|
|
||||||
"abcdey\n" +
|
|
||||||
"ABCDEz", toMultiLineText(term));
|
|
||||||
term.setDimensions(2, 4);
|
term.setDimensions(2, 4);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("1234\n" + "abcd", toMultiLineText(term));
|
||||||
"1234\n" +
|
|
||||||
"abcd", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResizeFailure() {
|
public void testResizeFailure() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(3, 5);
|
term.setDimensions(3, 5);
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE";
|
|
||||||
fill(term, 0, 0, s);
|
fill(term, 0, 0, s);
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
try {
|
try {
|
||||||
|
@ -285,7 +212,6 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertSegment(0, "0123", s1, segments[0]);
|
assertSegment(0, "0123", s1, segments[0]);
|
||||||
assertSegment(4, "abcd", null, segments[1]);
|
assertSegment(4, "abcd", null, segments[1]);
|
||||||
|
|
||||||
|
|
||||||
segments = term.getLineSegments(0, 4, term.getWidth() - 4);
|
segments = term.getLineSegments(0, 4, term.getWidth() - 4);
|
||||||
assertEquals(1, segments.length);
|
assertEquals(1, segments.length);
|
||||||
assertSegment(4, "abcd", null, segments[0]);
|
assertSegment(4, "abcd", null, segments[0]);
|
||||||
|
@ -329,12 +255,14 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
|
assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLineSegmentsNull() {
|
public void testGetLineSegmentsNull() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(8, 8);
|
term.setDimensions(8, 8);
|
||||||
LineSegment[] segments = term.getLineSegments(0, 0, term.getWidth());
|
LineSegment[] segments = term.getLineSegments(0, 0, term.getWidth());
|
||||||
assertEquals(1, segments.length);
|
assertEquals(1, segments.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLineSegmentsOutOfBounds() {
|
public void testGetLineSegmentsOutOfBounds() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(1, 8);
|
term.setDimensions(1, 8);
|
||||||
|
@ -342,18 +270,17 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
LineSegment[] segments = term.getLineSegments(0, 5, 2);
|
LineSegment[] segments = term.getLineSegments(0, 5, 2);
|
||||||
assertEquals(1, segments.length);
|
assertEquals(1, segments.length);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertSegment(int col, String text, Style style, LineSegment segment) {
|
void assertSegment(int col, String text, Style style, LineSegment segment) {
|
||||||
assertEquals(col, segment.getColumn());
|
assertEquals(col, segment.getColumn());
|
||||||
assertEqualsTerm(text, segment.getText());
|
assertEqualsTerm(text, segment.getText());
|
||||||
assertEquals(style, segment.getStyle());
|
assertEquals(style, segment.getStyle());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetChar() {
|
public void testGetChar() {
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
assertEquals('1', term.getChar(0, 0));
|
assertEquals('1', term.getChar(0, 0));
|
||||||
|
@ -423,7 +350,8 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Style getDefaultStyle() {
|
protected Style getDefaultStyle() {
|
||||||
return Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
return Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChar() {
|
public void testSetChar() {
|
||||||
|
@ -440,14 +368,9 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEquals(c, term.getChar(line, column));
|
assertEquals(c, term.getChar(line, column));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "def\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "def\n"
|
|
||||||
+ "efg\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChars() {
|
public void testSetChars() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(6, 3);
|
term.setDimensions(6, 3);
|
||||||
|
@ -464,98 +387,77 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEquals(c, term.getChar(line, column));
|
assertEquals(c, term.getChar(line, column));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "def\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "def\n"
|
|
||||||
+ "efg\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
|
|
||||||
term.setChars(3, 1, new char[] { '1', '2' }, null);
|
term.setChars(3, 1, new char[] { '1', '2' }, null);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "d12\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "d12\n"
|
|
||||||
+ "efg\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
try {
|
try {
|
||||||
// check if we cannot exceed the range
|
// check if we cannot exceed the range
|
||||||
term.setChars(4, 1, new char[] { '1', '2', '3', '4', '5' }, null);
|
term.setChars(4, 1, new char[] { '1', '2', '3', '4', '5' }, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetCharsLen() {
|
public void testSetCharsLen() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s= "ZYXWVU\n"
|
String s = "ZYXWVU\n" + "abcdef\n" + "ABCDEF";
|
||||||
+ "abcdef\n"
|
|
||||||
+ "ABCDEF";
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
char[] chars = new char[] { '1', '2', '3', '4', '5', '6', '7', '8' };
|
char[] chars = new char[] { '1', '2', '3', '4', '5', '6', '7', '8' };
|
||||||
term.setChars(1, 0, chars, 0, 6, null);
|
term.setChars(1, 0, chars, 0, 6, null);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("ZYXWVU\n" + "123456\n" + "ABCDEF", toMultiLineText(term));
|
||||||
"ZYXWVU\n"
|
|
||||||
+ "123456\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 0, chars, 0, 5, null);
|
term.setChars(1, 0, chars, 0, 5, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "12345f\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "12345f\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 0, chars, 1, 5, null);
|
term.setChars(1, 0, chars, 1, 5, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "23456f\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "23456f\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 1, chars, 1, 4, null);
|
term.setChars(1, 1, chars, 1, 4, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "a2345f\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "a2345f\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 2, chars, 3, 4, null);
|
term.setChars(1, 2, chars, 3, 4, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "ab4567\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "ab4567\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
try {
|
try {
|
||||||
term.setChars(1, 0, chars, 7, 10, null);
|
term.setChars(1, 0, chars, 7, 10, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
try {
|
try {
|
||||||
term.setChars(1, -1, chars, 0, 2, null);
|
term.setChars(1, -1, chars, 0, 2, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
term.setChars(-1, 1, chars, 0, 2, null);
|
term.setChars(-1, 1, chars, 0, 2, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
term.setChars(1, 10, chars, 0, 2, null);
|
term.setChars(1, 10, chars, 0, 2, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
term.setChars(10, 1, chars, 0, 2, null);
|
term.setChars(10, 1, chars, 0, 2, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
// assertEquals(s, toSimpleText(term));
|
// assertEquals(s, toSimpleText(term));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetCopyInto() {
|
public void testSetCopyInto() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(3, 5);
|
term.setDimensions(3, 5);
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE";
|
|
||||||
fill(term, 0, 0, s);
|
fill(term, 0, 0, s);
|
||||||
ITerminalTextData termCopy = makeITerminalTextData();
|
ITerminalTextData termCopy = makeITerminalTextData();
|
||||||
termCopy.copy(term);
|
termCopy.copy(term);
|
||||||
|
@ -568,13 +470,12 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEquals(5, termCopy.getWidth());
|
assertEquals(5, termCopy.getWidth());
|
||||||
assertEquals(3, termCopy.getHeight());
|
assertEquals(3, termCopy.getHeight());
|
||||||
|
|
||||||
assertEqualsTerm("12345\n" +
|
assertEqualsTerm("12345\n" + "aXcde\n" + "ABCDE", toMultiLineText(termCopy));
|
||||||
"aXcde\n" +
|
|
||||||
"ABCDE", toMultiLineText(termCopy));
|
|
||||||
|
|
||||||
assertEquals(4, term.getWidth());
|
assertEquals(4, term.getWidth());
|
||||||
assertEquals(2, term.getHeight());
|
assertEquals(2, term.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetCopyLines() {
|
public void testSetCopyLines() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s = "012345";
|
String s = "012345";
|
||||||
|
@ -620,48 +521,38 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
fillSimple(termCopy, sCopy);
|
fillSimple(termCopy, sCopy);
|
||||||
termCopy.copyRange(term, 1, 1, 5);
|
termCopy.copyRange(term, 1, 1, 5);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
fillSimple(termCopy, sCopy);
|
fillSimple(termCopy, sCopy);
|
||||||
termCopy.copyRange(term, 0, 0, 6);
|
termCopy.copyRange(term, 0, 0, 6);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
fillSimple(termCopy, sCopy);
|
fillSimple(termCopy, sCopy);
|
||||||
termCopy.copyRange(term, 7, 0, 1);
|
termCopy.copyRange(term, 7, 0, 1);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
fillSimple(termCopy, sCopy);
|
fillSimple(termCopy, sCopy);
|
||||||
termCopy.copyRange(term, 0, 7, 1);
|
termCopy.copyRange(term, 0, 7, 1);
|
||||||
fail();
|
fail();
|
||||||
} catch (RuntimeException e) {}
|
} catch (RuntimeException e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testCopyLine() {
|
public void testCopyLine() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
ITerminalTextData dest = makeITerminalTextData();
|
ITerminalTextData dest = makeITerminalTextData();
|
||||||
String sCopy=
|
String sCopy = "aaa\n" + "bbb\n" + "ccc\n" + "ddd\n" + "eee";
|
||||||
"aaa\n" +
|
|
||||||
"bbb\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"ddd\n" +
|
|
||||||
"eee";
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 0, 0, new boolean[] { true, true, false, false, true });
|
copySelective(dest, term, 0, 0, new boolean[] { true, true, false, false, true });
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("111\n" + "222\n" + "ccc\n" + "ddd\n" + "555", toMultiLineText(dest));
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"ddd\n" +
|
|
||||||
"555", toMultiLineText(dest));
|
|
||||||
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 0, 0, new boolean[] { true, true, true, true, true });
|
copySelective(dest, term, 0, 0, new boolean[] { true, true, true, true, true });
|
||||||
|
@ -673,7 +564,9 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(sCopy, toMultiLineText(dest));
|
assertEqualsTerm(sCopy, toMultiLineText(dest));
|
||||||
}
|
}
|
||||||
protected void copySelective(ITerminalTextData dest, ITerminalTextData source, int sourceStartLine, int destStartLine, boolean[] linesToCopy) {
|
|
||||||
|
protected void copySelective(ITerminalTextData dest, ITerminalTextData source, int sourceStartLine,
|
||||||
|
int destStartLine, boolean[] linesToCopy) {
|
||||||
for (int i = 0; i < linesToCopy.length; i++) {
|
for (int i = 0; i < linesToCopy.length; i++) {
|
||||||
if (linesToCopy[i]) {
|
if (linesToCopy[i]) {
|
||||||
dest.copyLine(source, i + sourceStartLine, i + destStartLine);
|
dest.copyLine(source, i + sourceStartLine, i + destStartLine);
|
||||||
|
@ -683,39 +576,19 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
|
|
||||||
public void testCopyLineWithOffset() {
|
public void testCopyLineWithOffset() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
ITerminalTextData dest = makeITerminalTextData();
|
ITerminalTextData dest = makeITerminalTextData();
|
||||||
String sCopy=
|
String sCopy = "aaa\n" + "bbb\n" + "ccc\n" + "ddd\n" + "eee";
|
||||||
"aaa\n" +
|
|
||||||
"bbb\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"ddd\n" +
|
|
||||||
"eee";
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 1, 0, new boolean[] { true, false, false, true });
|
copySelective(dest, term, 1, 0, new boolean[] { true, false, false, true });
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("222\n" + "bbb\n" + "ccc\n" + "555\n" + "eee", toMultiLineText(dest));
|
||||||
"222\n" +
|
|
||||||
"bbb\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"555\n" +
|
|
||||||
"eee", toMultiLineText(dest));
|
|
||||||
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 2, 0, new boolean[] { true, true });
|
copySelective(dest, term, 2, 0, new boolean[] { true, true });
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("333\n" + "444\n" + "ccc\n" + "ddd\n" + "eee", toMultiLineText(dest));
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"ddd\n" +
|
|
||||||
"eee", toMultiLineText(dest));
|
|
||||||
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 0, 0, new boolean[] { true, true, true, true, true });
|
copySelective(dest, term, 0, 0, new boolean[] { true, true, true, true, true });
|
||||||
|
@ -727,17 +600,20 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(sCopy, toMultiLineText(dest));
|
assertEqualsTerm(sCopy, toMultiLineText(dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNoop() {
|
public void testScrollNoop() {
|
||||||
scrollTest(0, 0, 0, "012345", "012345");
|
scrollTest(0, 0, 0, "012345", "012345");
|
||||||
scrollTest(0, 1, 0, "012345", "012345");
|
scrollTest(0, 1, 0, "012345", "012345");
|
||||||
scrollTest(0, 6, 0, "012345", "012345");
|
scrollTest(0, 6, 0, "012345", "012345");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollAll() {
|
public void testScrollAll() {
|
||||||
scrollTest(0, 6, 1, "012345", " 01234");
|
scrollTest(0, 6, 1, "012345", " 01234");
|
||||||
scrollTest(0, 6, -1, "012345", "12345 ");
|
scrollTest(0, 6, -1, "012345", "12345 ");
|
||||||
scrollTest(0, 6, 2, "012345", " 0123");
|
scrollTest(0, 6, 2, "012345", " 0123");
|
||||||
scrollTest(0, 6, -2, "012345", "2345 ");
|
scrollTest(0, 6, -2, "012345", "2345 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNegative() {
|
public void testScrollNegative() {
|
||||||
scrollTest(0, 2, -1, "012345", "1 2345");
|
scrollTest(0, 2, -1, "012345", "1 2345");
|
||||||
scrollTest(0, 1, -1, "012345", " 12345");
|
scrollTest(0, 1, -1, "012345", " 12345");
|
||||||
|
@ -752,6 +628,7 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
scrollTest(5, 1, -1, "012345", "01234 ");
|
scrollTest(5, 1, -1, "012345", "01234 ");
|
||||||
scrollTest(5, 1, -1, "012345", "01234 ");
|
scrollTest(5, 1, -1, "012345", "01234 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNegative2() {
|
public void testScrollNegative2() {
|
||||||
scrollTest(0, 2, -1, " 23 ", " 23 ");
|
scrollTest(0, 2, -1, " 23 ", " 23 ");
|
||||||
scrollTest(0, 1, -1, " 23 ", " 23 ");
|
scrollTest(0, 1, -1, " 23 ", " 23 ");
|
||||||
|
@ -765,12 +642,15 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
||||||
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNegative3() {
|
public void testScrollNegative3() {
|
||||||
scrollTest(1, 5, -7, "012345", "0 ");
|
scrollTest(1, 5, -7, "012345", "0 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollPositive2() {
|
public void testScrollPositive2() {
|
||||||
scrollTest(2, 8, 20, "0123456789", "01 ");
|
scrollTest(2, 8, 20, "0123456789", "01 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollPositive() {
|
public void testScrollPositive() {
|
||||||
scrollTest(0, 2, 1, "012345", " 02345");
|
scrollTest(0, 2, 1, "012345", " 02345");
|
||||||
scrollTest(0, 2, 2, "012345", " 2345");
|
scrollTest(0, 2, 2, "012345", " 2345");
|
||||||
|
@ -788,6 +668,7 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
scrollTest(0, 10, 9, "0123456789", " 0");
|
scrollTest(0, 10, 9, "0123456789", " 0");
|
||||||
scrollTest(0, 6, 6, "012345", " ");
|
scrollTest(0, 6, 6, "012345", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollFail() {
|
public void testScrollFail() {
|
||||||
try {
|
try {
|
||||||
scrollTest(5, 2, -1, "012345", "012345");
|
scrollTest(5, 2, -1, "012345", "012345");
|
||||||
|
@ -800,6 +681,7 @@ abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a simple shift test
|
* Makes a simple shift test
|
||||||
* @param line scroll start
|
* @param line scroll start
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertEquals(0, changes.getInterestWindowStartLine());
|
assertEquals(0, changes.getInterestWindowStartLine());
|
||||||
assertEquals(0, changes.getInterestWindowSize());
|
assertEquals(0, changes.getInterestWindowSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSnapshotChangesWithWindow() {
|
public void testSnapshotChangesWithWindow() {
|
||||||
SnapshotChanges changes = new SnapshotChanges(2, 5);
|
SnapshotChanges changes = new SnapshotChanges(2, 5);
|
||||||
assertEquals(2, changes.getInterestWindowStartLine());
|
assertEquals(2, changes.getInterestWindowStartLine());
|
||||||
|
@ -60,6 +61,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertFalse(changes.isInInterestWindow(7, 1));
|
assertFalse(changes.isInInterestWindow(7, 1));
|
||||||
assertFalse(changes.isInInterestWindow(8, 10));
|
assertFalse(changes.isInInterestWindow(8, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsInInterestWindowIntIntNoWindow() {
|
public void testIsInInterestWindowIntIntNoWindow() {
|
||||||
SnapshotChanges changes = new SnapshotChanges(3);
|
SnapshotChanges changes = new SnapshotChanges(3);
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
@ -122,6 +124,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertEquals(6, changes.fitLineToWindow(6));
|
assertEquals(6, changes.fitLineToWindow(6));
|
||||||
assertEquals(7, changes.fitLineToWindow(7));
|
assertEquals(7, changes.fitLineToWindow(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFitSizeToWindow() {
|
public void testFitSizeToWindow() {
|
||||||
SnapshotChanges changes = new SnapshotChanges(2, 3);
|
SnapshotChanges changes = new SnapshotChanges(2, 3);
|
||||||
assertFalse(changes.isInInterestWindow(0, 1));
|
assertFalse(changes.isInInterestWindow(0, 1));
|
||||||
|
@ -149,6 +152,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertFalse(changes.isInInterestWindow(5, 1));
|
assertFalse(changes.isInInterestWindow(5, 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFitSizeToWindowNoWindow() {
|
public void testFitSizeToWindowNoWindow() {
|
||||||
SnapshotChanges changes = new SnapshotChanges(3);
|
SnapshotChanges changes = new SnapshotChanges(3);
|
||||||
assertEquals(1, changes.fitSizeToWindow(0, 1));
|
assertEquals(1, changes.fitSizeToWindow(0, 1));
|
||||||
|
@ -188,6 +192,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
|
|
||||||
assertLineChange(true, 2, 4, 5);
|
assertLineChange(true, 2, 4, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertLineChange(boolean expected, int windowStart, int windowSize, int changedLine) {
|
void assertLineChange(boolean expected, int windowStart, int windowSize, int changedLine) {
|
||||||
SnapshotChanges changes = new SnapshotChanges(windowStart, windowSize);
|
SnapshotChanges changes = new SnapshotChanges(windowStart, windowSize);
|
||||||
assertFalse(changes.hasChanged());
|
assertFalse(changes.hasChanged());
|
||||||
|
@ -207,6 +212,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMarkLinesChanged() {
|
public void testMarkLinesChanged() {
|
||||||
SnapshotChanges changes = new SnapshotChanges(2, 3);
|
SnapshotChanges changes = new SnapshotChanges(2, 3);
|
||||||
assertFalse(changes.hasChanged());
|
assertFalse(changes.hasChanged());
|
||||||
|
@ -256,7 +262,6 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertTrue(changes.hasChanged());
|
assertTrue(changes.hasChanged());
|
||||||
assertChangedLines(changes, "00111000000");
|
assertChangedLines(changes, "00111000000");
|
||||||
|
|
||||||
|
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
changes.markLinesChanged(3, 4);
|
changes.markLinesChanged(3, 4);
|
||||||
assertEquals(3, changes.getFirstChangedLine());
|
assertEquals(3, changes.getFirstChangedLine());
|
||||||
|
@ -285,6 +290,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertFalse(changes.hasChanged());
|
assertFalse(changes.hasChanged());
|
||||||
assertChangedLines(changes, "00000000000");
|
assertChangedLines(changes, "00000000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMarkLinesChangedNoWindow() {
|
public void testMarkLinesChangedNoWindow() {
|
||||||
SnapshotChanges changes = new SnapshotChanges(10);
|
SnapshotChanges changes = new SnapshotChanges(10);
|
||||||
assertFalse(changes.hasChanged());
|
assertFalse(changes.hasChanged());
|
||||||
|
@ -311,7 +317,6 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertEquals(6, changes.getLastChangedLine());
|
assertEquals(6, changes.getLastChangedLine());
|
||||||
assertChangedLines(changes, "011");
|
assertChangedLines(changes, "011");
|
||||||
|
|
||||||
|
|
||||||
changes = new SnapshotChanges(10);
|
changes = new SnapshotChanges(10);
|
||||||
changes.markLinesChanged(5, 6);
|
changes.markLinesChanged(5, 6);
|
||||||
assertTrue(changes.hasChanged());
|
assertTrue(changes.hasChanged());
|
||||||
|
@ -367,6 +372,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertTrue(changes.hasChanged());
|
assertTrue(changes.hasChanged());
|
||||||
assertChangedLines(changes, "00111000000");
|
assertChangedLines(changes, "00111000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetAllChangedNoWindow() {
|
public void testSetAllChangedNoWindow() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(5);
|
changes = new SnapshotChanges(5);
|
||||||
|
@ -414,6 +420,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertEquals(0, changes.getScrollWindowShift());
|
assertEquals(0, changes.getScrollWindowShift());
|
||||||
assertChangedLines(changes, "111100");
|
assertChangedLines(changes, "111100");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNoWindow() {
|
public void testScrollNoWindow() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(7);
|
changes = new SnapshotChanges(7);
|
||||||
|
@ -461,6 +468,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertChangedLines(changes, "1111111");
|
assertChangedLines(changes, "1111111");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScroll() {
|
public void testScroll() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
|
@ -483,6 +491,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertTrue(changes.hasChanged());
|
assertTrue(changes.hasChanged());
|
||||||
assertChangedLines(changes, "0001100000");
|
assertChangedLines(changes, "0001100000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNergative() {
|
public void testScrollNergative() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
|
@ -497,6 +506,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
assertChangedLines(changes, "0001100000");
|
assertChangedLines(changes, "0001100000");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollPositive() {
|
public void testScrollPositive() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
|
@ -588,6 +598,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
changes.copyChangedLines(dest, source);
|
changes.copyChangedLines(dest, source);
|
||||||
assertEquals("abcd4fghijk", TerminalTextTestHelper.toSimple(dest));
|
assertEquals("abcd4fghijk", TerminalTextTestHelper.toSimple(dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyChangedLinesWithSmallSource() {
|
public void testCopyChangedLinesWithSmallSource() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
|
@ -598,6 +609,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
dest.setWindow(2, 2);
|
dest.setWindow(2, 2);
|
||||||
changes.copyChangedLines(dest, source);
|
changes.copyChangedLines(dest, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyChangedLinesWithSmallSource1() {
|
public void testCopyChangedLinesWithSmallSource1() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
|
@ -634,7 +646,6 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
changes.convertScrollingIntoChanges();
|
changes.convertScrollingIntoChanges();
|
||||||
assertChangedLines(changes, "0001111");
|
assertChangedLines(changes, "0001111");
|
||||||
|
|
||||||
|
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
// move the window
|
// move the window
|
||||||
changes.setInterestWindow(6, 3);
|
changes.setInterestWindow(6, 3);
|
||||||
|
@ -654,6 +665,7 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
|
|
||||||
assertChangedLines(changes, "0000011000");
|
assertChangedLines(changes, "0000011000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetInterestWindowSize2() {
|
public void testSetInterestWindowSize2() {
|
||||||
SnapshotChanges changes;
|
SnapshotChanges changes;
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
|
@ -666,7 +678,6 @@ public class SnapshotChangesTest extends TestCase {
|
||||||
changes.setInterestWindow(1, 4);
|
changes.setInterestWindow(1, 4);
|
||||||
assertChangedLines(changes, "01111000");
|
assertChangedLines(changes, "01111000");
|
||||||
|
|
||||||
|
|
||||||
changes = new SnapshotChanges(2, 3);
|
changes = new SnapshotChanges(2, 3);
|
||||||
// expand the window
|
// expand the window
|
||||||
changes.setInterestWindow(6, 3);
|
changes.setInterestWindow(6, 3);
|
||||||
|
|
|
@ -19,19 +19,23 @@ import org.eclipse.tm.terminal.model.StyleColor;
|
||||||
|
|
||||||
public class TerminalTextDataPerformanceTest extends TestCase {
|
public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
long TIME = 100;
|
long TIME = 100;
|
||||||
|
|
||||||
private void initPerformance(ITerminalTextData term) {
|
private void initPerformance(ITerminalTextData term) {
|
||||||
term.setDimensions(300, 200);
|
term.setDimensions(300, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance0() {
|
public void testPerformance0() {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
method0(term, "0 ");
|
method0(term, "0 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance0a() {
|
public void testPerformance0a() {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
method0(term, "0a");
|
method0(term, "0a");
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance0b() {
|
public void testPerformance0b() {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -39,12 +43,15 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
||||||
N++;
|
N++;
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
method0(term, "0b");
|
method0(term, "0b");
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void method0(ITerminalTextData term, String label) {
|
private void method0(ITerminalTextData term, String label) {
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
String s = "This is a test string";
|
String s = "This is a test string";
|
||||||
long n = 0;
|
long n = 0;
|
||||||
|
@ -58,21 +65,25 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - t0 > TIME) {
|
if (System.currentTimeMillis() - t0 > TIME) {
|
||||||
System.out.println(label+" "+(n*1000)/(System.currentTimeMillis()-t0)+" setChar()/sec "+ N);
|
System.out
|
||||||
|
.println(label + " " + (n * 1000) / (System.currentTimeMillis() - t0) + " setChar()/sec " + N);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance1() {
|
public void testPerformance1() {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
method1(term, "1 ");
|
method1(term, "1 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance1a() {
|
public void testPerformance1a() {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
method1(term, "1a");
|
method1(term, "1a");
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance1b() {
|
public void testPerformance1b() {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -80,12 +91,15 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
||||||
N++;
|
N++;
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
method1(term, "1b");
|
method1(term, "1b");
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void method1(ITerminalTextData term, String label) {
|
private void method1(ITerminalTextData term, String label) {
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
String s = "This is a test string";
|
String s = "This is a test string";
|
||||||
long n = 0;
|
long n = 0;
|
||||||
|
@ -100,14 +114,17 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
n += chars.length;
|
n += chars.length;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - t0 > TIME) {
|
if (System.currentTimeMillis() - t0 > TIME) {
|
||||||
System.out.println(label+" "+(n*1000)/(System.currentTimeMillis()-t0)+" setChars()/sec "+ N);
|
System.out
|
||||||
|
.println(label + " " + (n * 1000) / (System.currentTimeMillis() - t0) + " setChars()/sec " + N);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance2() {
|
public void testPerformance2() {
|
||||||
TerminalTextData term = new TerminalTextData();
|
TerminalTextData term = new TerminalTextData();
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
TerminalTextData copy = new TerminalTextData();
|
TerminalTextData copy = new TerminalTextData();
|
||||||
copy.copy(term);
|
copy.copy(term);
|
||||||
|
@ -131,10 +148,12 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance2a() {
|
public void testPerformance2a() {
|
||||||
TerminalTextData term = new TerminalTextData();
|
TerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
TerminalTextData copy = new TerminalTextData();
|
TerminalTextData copy = new TerminalTextData();
|
||||||
copy.copy(term);
|
copy.copy(term);
|
||||||
|
@ -159,7 +178,9 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
}
|
}
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int N = 0;
|
int N = 0;
|
||||||
|
|
||||||
public void testPerformance2b() {
|
public void testPerformance2b() {
|
||||||
TerminalTextData term = new TerminalTextData();
|
TerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -167,8 +188,10 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
||||||
N++;
|
N++;
|
||||||
}});
|
}
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
});
|
||||||
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
TerminalTextData copy = new TerminalTextData();
|
TerminalTextData copy = new TerminalTextData();
|
||||||
copy.copy(term);
|
copy.copy(term);
|
||||||
|
@ -193,9 +216,11 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
}
|
}
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformance3() {
|
public void testPerformance3() {
|
||||||
TerminalTextData term = new TerminalTextData();
|
TerminalTextData term = new TerminalTextData();
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
TerminalTextData copy = new TerminalTextData();
|
TerminalTextData copy = new TerminalTextData();
|
||||||
copy.copy(term);
|
copy.copy(term);
|
||||||
|
|
|
@ -27,14 +27,9 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
return new TerminalTextData();
|
return new TerminalTextData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testTerminalTextDataSnapshot() {
|
public void testTerminalTextDataSnapshot() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -54,11 +49,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testDetach() {
|
public void testDetach() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -72,13 +63,10 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
term.setDimensions(2, 2);
|
term.setDimensions(2, 2);
|
||||||
assertEquals(s, toMultiLineText(snapshot));
|
assertEquals(s, toMultiLineText(snapshot));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsOutOfDate() {
|
public void testIsOutOfDate() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -144,6 +132,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertFalse(snapshot.isOutOfDate());
|
assertFalse(snapshot.isOutOfDate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot(String text, ITerminalTextData term) {
|
ITerminalTextDataSnapshot snapshot(String text, ITerminalTextData term) {
|
||||||
TerminalTextTestHelper.fill(term, text);
|
TerminalTextTestHelper.fill(term, text);
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -152,13 +141,10 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
return snapshot;
|
return snapshot;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateSnapshot() {
|
public void testUpdateSnapshot() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
String termString = toMultiLineText(term);
|
String termString = toMultiLineText(term);
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -236,12 +222,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMaxSize() {
|
public void testMaxSize() {
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setMaxHeight(8);
|
term.setMaxHeight(8);
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
@ -275,14 +256,9 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testGetChar() {
|
public void testGetChar() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
ITerminalTextData termUnchanged = makeITerminalTextData();
|
ITerminalTextData termUnchanged = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fill(termUnchanged, s);
|
TerminalTextTestHelper.fill(termUnchanged, s);
|
||||||
|
@ -315,11 +291,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testGetHeight() {
|
public void testGetHeight() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -337,6 +309,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
term.setDimensions(term.getHeight() - 1, term.getWidth());
|
term.setDimensions(term.getHeight() - 1, term.getWidth());
|
||||||
assertEquals(expectedHeight, snapshot.getHeight());
|
assertEquals(expectedHeight, snapshot.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// public void testGetLineSegments() {
|
// public void testGetLineSegments() {
|
||||||
// fail("Not yet implemented");
|
// fail("Not yet implemented");
|
||||||
|
@ -344,7 +317,8 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
//
|
//
|
||||||
public void testGetStyle() {
|
public void testGetStyle() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
term.setDimensions(6, 3);
|
term.setDimensions(6, 3);
|
||||||
for (int line = 0; line < term.getHeight(); line++) {
|
for (int line = 0; line < term.getHeight(); line++) {
|
||||||
for (int column = 0; column < term.getWidth(); column++) {
|
for (int column = 0; column < term.getWidth(); column++) {
|
||||||
|
@ -355,7 +329,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
|
|
||||||
|
|
||||||
for (int line = 0; line < term.getHeight(); line++) {
|
for (int line = 0; line < term.getHeight(); line++) {
|
||||||
for (int column = 0; column < term.getWidth(); column++) {
|
for (int column = 0; column < term.getWidth(); column++) {
|
||||||
char c = (char) ('a' + column + line);
|
char c = (char) ('a' + column + line);
|
||||||
|
@ -367,11 +340,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testGetWidth() {
|
public void testGetWidth() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -392,14 +361,9 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testGetFirstChangedLine() {
|
public void testGetFirstChangedLine() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
||||||
|
|
||||||
|
|
||||||
assertEquals(0, snapshot.getFirstChangedLine());
|
assertEquals(0, snapshot.getFirstChangedLine());
|
||||||
|
|
||||||
// if nothing has changed the first changed line i height
|
// if nothing has changed the first changed line i height
|
||||||
|
@ -441,16 +405,12 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(1, snapshot.getFirstChangedLine());
|
assertEquals(1, snapshot.getFirstChangedLine());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLastChangedLine() {
|
public void testGetLastChangedLine() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
||||||
|
|
||||||
|
|
||||||
assertEquals(4, snapshot.getLastChangedLine());
|
assertEquals(4, snapshot.getLastChangedLine());
|
||||||
|
|
||||||
// if nothing has changed the first changed line i height
|
// if nothing has changed the first changed line i height
|
||||||
|
@ -497,6 +457,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(3, snapshot.getLastChangedLine());
|
assertEquals(3, snapshot.getLastChangedLine());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param snapshot
|
* @param snapshot
|
||||||
* @param expected a string of 0 and 1 (1 means changed)
|
* @param expected a string of 0 and 1 (1 means changed)
|
||||||
|
@ -512,18 +473,10 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
}
|
}
|
||||||
assertEquals(expected, buffer.toString());
|
assertEquals(expected, buffer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHasLineChangedScroll() {
|
public void testHasLineChangedScroll() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="00\n" +
|
String s = "00\n" + "11\n" + "22\n" + "33\n" + "44\n" + "55\n" + "66\n" + "77\n" + "88\n" + "99";
|
||||||
"11\n" +
|
|
||||||
"22\n" +
|
|
||||||
"33\n" +
|
|
||||||
"44\n" +
|
|
||||||
"55\n" +
|
|
||||||
"66\n" +
|
|
||||||
"77\n" +
|
|
||||||
"88\n" +
|
|
||||||
"99";
|
|
||||||
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
||||||
|
|
||||||
term.scroll(2, 3, -1);
|
term.scroll(2, 3, -1);
|
||||||
|
@ -556,7 +509,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
assertChangedLines(snapshot, "0011110000");
|
assertChangedLines(snapshot, "0011110000");
|
||||||
|
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
term.scroll(2, 3, -1);
|
term.scroll(2, 3, -1);
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
|
@ -573,18 +525,10 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertChangedLines(snapshot, "0011110000");
|
assertChangedLines(snapshot, "0011110000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultiScrollWithDifferentSizes() {
|
public void testMultiScrollWithDifferentSizes() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="00\n" +
|
String s = "00\n" + "11\n" + "22\n" + "33\n" + "44\n" + "55\n" + "66\n" + "77\n" + "88\n" + "99";
|
||||||
"11\n" +
|
|
||||||
"22\n" +
|
|
||||||
"33\n" +
|
|
||||||
"44\n" +
|
|
||||||
"55\n" +
|
|
||||||
"66\n" +
|
|
||||||
"77\n" +
|
|
||||||
"88\n" +
|
|
||||||
"99";
|
|
||||||
ITerminalTextDataSnapshot snapshot;
|
ITerminalTextDataSnapshot snapshot;
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
|
@ -611,18 +555,11 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(0, snapshot.getScrollWindowSize());
|
assertEquals(0, snapshot.getScrollWindowSize());
|
||||||
assertEquals(0, snapshot.getScrollWindowStartLine());
|
assertEquals(0, snapshot.getScrollWindowStartLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHasLineChanged() {
|
public void testHasLineChanged() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="000000\n" +
|
String s = "000000\n" + "111111\n" + "222222\n" + "333333\n" + "444444\n" + "555555\n" + "666666\n" + "777777\n"
|
||||||
"111111\n" +
|
+ "888888\n" + "999999";
|
||||||
"222222\n" +
|
|
||||||
"333333\n" +
|
|
||||||
"444444\n" +
|
|
||||||
"555555\n" +
|
|
||||||
"666666\n" +
|
|
||||||
"777777\n" +
|
|
||||||
"888888\n" +
|
|
||||||
"999999";
|
|
||||||
ITerminalTextDataSnapshot snapshot;
|
ITerminalTextDataSnapshot snapshot;
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
|
@ -652,7 +589,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
assertChangedLines(snapshot, "0001001110");
|
assertChangedLines(snapshot, "0001001110");
|
||||||
|
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
term.scroll(2, 7, -1);
|
term.scroll(2, 7, -1);
|
||||||
term.setChar(5, 2, '.', null);
|
term.setChar(5, 2, '.', null);
|
||||||
|
@ -664,16 +600,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testScroll() {
|
public void testScroll() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="00\n" +
|
String s = "00\n" + "11\n" + "22\n" + "33\n" + "44\n" + "55\n" + "66\n" + "77\n" + "88\n" + "99";
|
||||||
"11\n" +
|
|
||||||
"22\n" +
|
|
||||||
"33\n" +
|
|
||||||
"44\n" +
|
|
||||||
"55\n" +
|
|
||||||
"66\n" +
|
|
||||||
"77\n" +
|
|
||||||
"88\n" +
|
|
||||||
"99";
|
|
||||||
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
ITerminalTextDataSnapshot snapshot = snapshot(s, term);
|
||||||
|
|
||||||
term.scroll(2, 3, -1);
|
term.scroll(2, 3, -1);
|
||||||
|
@ -701,7 +628,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(4, snapshot.getFirstChangedLine());
|
assertEquals(4, snapshot.getFirstChangedLine());
|
||||||
assertEquals(5, snapshot.getLastChangedLine());
|
assertEquals(5, snapshot.getLastChangedLine());
|
||||||
|
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
term.scroll(2, 3, -1);
|
term.scroll(2, 3, -1);
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
|
@ -712,18 +638,11 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(4, snapshot.getLastChangedLine());
|
assertEquals(4, snapshot.getLastChangedLine());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisjointScroll() {
|
public void testDisjointScroll() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="000000\n" +
|
String s = "000000\n" + "111111\n" + "222222\n" + "333333\n" + "444444\n" + "555555\n" + "666666\n" + "777777\n"
|
||||||
"111111\n" +
|
+ "888888\n" + "999999";
|
||||||
"222222\n" +
|
|
||||||
"333333\n" +
|
|
||||||
"444444\n" +
|
|
||||||
"555555\n" +
|
|
||||||
"666666\n" +
|
|
||||||
"777777\n" +
|
|
||||||
"888888\n" +
|
|
||||||
"999999";
|
|
||||||
ITerminalTextDataSnapshot snapshot;
|
ITerminalTextDataSnapshot snapshot;
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
|
@ -773,12 +692,10 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(0, snapshot.getScrollWindowSize());
|
assertEquals(0, snapshot.getScrollWindowSize());
|
||||||
assertEquals(0, snapshot.getScrollWindowShift());
|
assertEquals(0, snapshot.getScrollWindowShift());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResize() {
|
public void testResize() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="000000\n" +
|
String s = "000000\n" + "111111\n" + "222222\n" + "333333";
|
||||||
"111111\n" +
|
|
||||||
"222222\n" +
|
|
||||||
"333333";
|
|
||||||
ITerminalTextDataSnapshot snapshot;
|
ITerminalTextDataSnapshot snapshot;
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
|
@ -822,18 +739,11 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(0, snapshot.getScrollWindowShift());
|
assertEquals(0, snapshot.getScrollWindowShift());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResizeAfterScroll() {
|
public void testResizeAfterScroll() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="000000\n" +
|
String s = "000000\n" + "111111\n" + "222222\n" + "333333\n" + "444444\n" + "555555\n" + "666666\n" + "777777\n"
|
||||||
"111111\n" +
|
+ "888888\n" + "999999";
|
||||||
"222222\n" +
|
|
||||||
"333333\n" +
|
|
||||||
"444444\n" +
|
|
||||||
"555555\n" +
|
|
||||||
"666666\n" +
|
|
||||||
"777777\n" +
|
|
||||||
"888888\n" +
|
|
||||||
"999999";
|
|
||||||
ITerminalTextDataSnapshot snapshot;
|
ITerminalTextDataSnapshot snapshot;
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
|
@ -864,18 +774,11 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(0, snapshot.getScrollWindowSize());
|
assertEquals(0, snapshot.getScrollWindowSize());
|
||||||
assertEquals(0, snapshot.getScrollWindowShift());
|
assertEquals(0, snapshot.getScrollWindowShift());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollAfterResize() {
|
public void testScrollAfterResize() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="000000\n" +
|
String s = "000000\n" + "111111\n" + "222222\n" + "333333\n" + "444444\n" + "555555\n" + "666666\n" + "777777\n"
|
||||||
"111111\n" +
|
+ "888888\n" + "999999";
|
||||||
"222222\n" +
|
|
||||||
"333333\n" +
|
|
||||||
"444444\n" +
|
|
||||||
"555555\n" +
|
|
||||||
"666666\n" +
|
|
||||||
"777777\n" +
|
|
||||||
"888888\n" +
|
|
||||||
"999999";
|
|
||||||
ITerminalTextDataSnapshot snapshot;
|
ITerminalTextDataSnapshot snapshot;
|
||||||
|
|
||||||
snapshot = snapshot(s, term);
|
snapshot = snapshot(s, term);
|
||||||
|
@ -887,11 +790,14 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(0, snapshot.getScrollWindowSize());
|
assertEquals(0, snapshot.getScrollWindowSize());
|
||||||
assertEquals(0, snapshot.getScrollWindowShift());
|
assertEquals(0, snapshot.getScrollWindowShift());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class SnapshotListener implements ITerminalTextDataSnapshot.SnapshotOutOfDateListener {
|
private final class SnapshotListener implements ITerminalTextDataSnapshot.SnapshotOutOfDateListener {
|
||||||
int N;
|
int N;
|
||||||
|
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
||||||
N++;
|
N++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
N = 0;
|
N = 0;
|
||||||
}
|
}
|
||||||
|
@ -899,11 +805,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testAddListener() {
|
public void testAddListener() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -989,11 +891,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
public void testRemoveListener() {
|
public void testRemoveListener() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -1035,7 +933,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
assertEquals(1, listener3.N);
|
assertEquals(1, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
|
@ -1058,7 +955,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(0, listener2.N);
|
assertEquals(0, listener2.N);
|
||||||
assertEquals(1, listener3.N);
|
assertEquals(1, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(0, listener2.N);
|
assertEquals(0, listener2.N);
|
||||||
|
@ -1069,7 +965,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
listener2.reset();
|
listener2.reset();
|
||||||
listener3.reset();
|
listener3.reset();
|
||||||
|
|
||||||
|
|
||||||
snapshot.removeListener(listener3);
|
snapshot.removeListener(listener3);
|
||||||
// scroll
|
// scroll
|
||||||
term.scroll(1, 2, 1);
|
term.scroll(1, 2, 1);
|
||||||
|
@ -1082,7 +977,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
assertEquals(0, listener3.N);
|
assertEquals(0, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
|
@ -1107,7 +1001,6 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
assertEquals(2, listener3.N);
|
assertEquals(2, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
|
@ -1119,14 +1012,12 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
// remove the duplicate listener
|
// remove the duplicate listener
|
||||||
snapshot.removeListener(listener3);
|
snapshot.removeListener(listener3);
|
||||||
|
|
||||||
|
|
||||||
// scroll
|
// scroll
|
||||||
term.scroll(1, 2, 1);
|
term.scroll(1, 2, 1);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
assertEquals(1, listener3.N);
|
assertEquals(1, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
|
@ -1136,14 +1027,12 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
listener2.reset();
|
listener2.reset();
|
||||||
listener3.reset();
|
listener3.reset();
|
||||||
|
|
||||||
|
|
||||||
// setDimensions
|
// setDimensions
|
||||||
term.setDimensions(2, 2);
|
term.setDimensions(2, 2);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
assertEquals(1, listener3.N);
|
assertEquals(1, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
|
@ -1153,17 +1042,16 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
listener2.reset();
|
listener2.reset();
|
||||||
listener3.reset();
|
listener3.reset();
|
||||||
|
|
||||||
|
|
||||||
// setDimensions
|
// setDimensions
|
||||||
term.setDimensions(20, 20);
|
term.setDimensions(20, 20);
|
||||||
assertEquals(1, listener1.N);
|
assertEquals(1, listener1.N);
|
||||||
assertEquals(1, listener2.N);
|
assertEquals(1, listener2.N);
|
||||||
assertEquals(1, listener3.N);
|
assertEquals(1, listener3.N);
|
||||||
|
|
||||||
|
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertFalse(snapshot.isOutOfDate());
|
assertFalse(snapshot.isOutOfDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWindowOfInterest() {
|
public void testWindowOfInterest() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
||||||
|
@ -1173,6 +1061,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
snapshot.setInterestWindow(9, 4);
|
snapshot.setInterestWindow(9, 4);
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWindowOfInterest2() {
|
public void testWindowOfInterest2() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
||||||
|
@ -1182,6 +1071,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
snapshot.setInterestWindow(9, 4);
|
snapshot.setInterestWindow(9, 4);
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddLine() {
|
public void testAddLine() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
||||||
|
@ -1210,6 +1100,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(13, term.getHeight());
|
assertEquals(13, term.getHeight());
|
||||||
assertEquals(20, term.getMaxHeight());
|
assertEquals(20, term.getMaxHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHasDimensionsChanged() {
|
public void testHasDimensionsChanged() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
||||||
|
@ -1241,6 +1132,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(13, term.getHeight());
|
assertEquals(13, term.getHeight());
|
||||||
assertEquals(20, term.getMaxHeight());
|
assertEquals(20, term.getMaxHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCursor() {
|
public void testCursor() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
||||||
|
@ -1259,6 +1151,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
assertEquals(3, snapshot.getCursorLine());
|
assertEquals(3, snapshot.getCursorLine());
|
||||||
assertEquals(2, snapshot.getCursorColumn());
|
assertEquals(2, snapshot.getCursorColumn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCursor2() {
|
public void testCursor2() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
TerminalTextTestHelper.fillSimple(term, "0123456789");
|
||||||
|
@ -1272,13 +1165,10 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
term.setCursorColumn(1);
|
term.setCursorColumn(1);
|
||||||
assertTrue(snapshot.isOutOfDate());
|
assertTrue(snapshot.isOutOfDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHasTerminalChanged() {
|
public void testHasTerminalChanged() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE\n" + "vwxzy\n" + "VWXYZ";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE\n" +
|
|
||||||
"vwxzy\n" +
|
|
||||||
"VWXYZ";
|
|
||||||
TerminalTextTestHelper.fill(term, s);
|
TerminalTextTestHelper.fill(term, s);
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
@ -1336,6 +1226,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
|
|
||||||
assertFalse(snapshot.hasTerminalChanged());
|
assertFalse(snapshot.hasTerminalChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetTerminalTextData() {
|
public void testGetTerminalTextData() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class TerminalTextDataSnapshotWindowTest extends TestCase {
|
||||||
String toMultiLineText(ITerminalTextDataReadOnly term) {
|
String toMultiLineText(ITerminalTextDataReadOnly term) {
|
||||||
return TerminalTextTestHelper.toMultiLineText(term);
|
return TerminalTextTestHelper.toMultiLineText(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
String toSimpleText(ITerminalTextDataReadOnly term) {
|
String toSimpleText(ITerminalTextDataReadOnly term) {
|
||||||
return TerminalTextTestHelper.toSimple(term);
|
return TerminalTextTestHelper.toSimple(term);
|
||||||
}
|
}
|
||||||
|
@ -27,12 +28,14 @@ public class TerminalTextDataSnapshotWindowTest extends TestCase {
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
return new TerminalTextData();
|
return new TerminalTextData();
|
||||||
}
|
}
|
||||||
|
|
||||||
ITerminalTextDataSnapshot snapshotSimple(String text, ITerminalTextData term) {
|
ITerminalTextDataSnapshot snapshotSimple(String text, ITerminalTextData term) {
|
||||||
TerminalTextTestHelper.fillSimple(term, text);
|
TerminalTextTestHelper.fillSimple(term, text);
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
return snapshot;
|
return snapshot;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param snapshot
|
* @param snapshot
|
||||||
* @param expected a string of 0 and 1 (1 means changed)
|
* @param expected a string of 0 and 1 (1 means changed)
|
||||||
|
@ -60,6 +63,7 @@ public class TerminalTextDataSnapshotWindowTest extends TestCase {
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertChangedLines(snapshot, "0011100000");
|
assertChangedLines(snapshot, "0011100000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChar() {
|
public void testSetChar() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = snapshotSimple("0123456789", term);
|
ITerminalTextDataSnapshot snapshot = snapshotSimple("0123456789", term);
|
||||||
|
@ -146,6 +150,7 @@ public class TerminalTextDataSnapshotWindowTest extends TestCase {
|
||||||
snapshot.updateSnapshot(false);
|
snapshot.updateSnapshot(false);
|
||||||
assertChangedLines(snapshot, "0011100000");
|
assertChangedLines(snapshot, "0011100000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChars2() {
|
public void testSetChars2() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = snapshotSimple("0123456789", term);
|
ITerminalTextDataSnapshot snapshot = snapshotSimple("0123456789", term);
|
||||||
|
|
|
@ -23,15 +23,18 @@ import org.eclipse.tm.terminal.model.StyleColor;
|
||||||
public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
int fOffset;
|
int fOffset;
|
||||||
int fSize;
|
int fSize;
|
||||||
|
|
||||||
public TerminalTextDataWindowTest() {
|
public TerminalTextDataWindowTest() {
|
||||||
fOffset = 2;
|
fOffset = 2;
|
||||||
fSize = 2;
|
fSize = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
TerminalTextDataWindow term = new TerminalTextDataWindow();
|
TerminalTextDataWindow term = new TerminalTextDataWindow();
|
||||||
term.setWindow(fOffset, fSize);
|
term.setWindow(fOffset, fSize);
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for multi line text
|
* Used for multi line text
|
||||||
* @param expected
|
* @param expected
|
||||||
|
@ -40,6 +43,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
protected void assertEqualsTerm(String expected, String actual) {
|
protected void assertEqualsTerm(String expected, String actual) {
|
||||||
assertEquals(stripMultiLine(expected), stripMultiLine(actual));
|
assertEquals(stripMultiLine(expected), stripMultiLine(actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String stripMultiLine(String s) {
|
private String stripMultiLine(String s) {
|
||||||
StringBuffer b = new StringBuffer();
|
StringBuffer b = new StringBuffer();
|
||||||
// String[] lines=s.split("\n");
|
// String[] lines=s.split("\n");
|
||||||
|
@ -72,6 +76,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
}
|
}
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for simple text
|
* Used for simple text
|
||||||
* @param expected
|
* @param expected
|
||||||
|
@ -80,6 +85,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
protected void assertEqualsSimple(String expected, String actual) {
|
protected void assertEqualsSimple(String expected, String actual) {
|
||||||
assertEquals(stripSimple(expected), stripSimple(actual));
|
assertEquals(stripSimple(expected), stripSimple(actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
String stripSimple(String s) {
|
String stripSimple(String s) {
|
||||||
StringBuffer b = new StringBuffer();
|
StringBuffer b = new StringBuffer();
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
@ -90,31 +96,17 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
}
|
}
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddLine() {
|
public void testAddLine() {
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("222\n" + "333\n" + "444\n" + "\0\0\0\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"\0\0\0\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMaxSize() {
|
public void testMaxSize() {
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setMaxHeight(8);
|
term.setMaxHeight(8);
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
|
@ -122,45 +114,20 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEquals(8, term.getMaxHeight());
|
assertEquals(8, term.getMaxHeight());
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(6, term.getHeight());
|
assertEquals(6, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("111\n" + "222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(7, term.getHeight());
|
assertEquals(7, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("111\n" + "222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000\n" + "\000\000\000",
|
||||||
"111\n" +
|
toMultiLineText(term));
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(8, term.getHeight());
|
assertEquals(8, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm(
|
||||||
"111\n" +
|
"111\n" + "222\n" + "333\n" + "444\n" + "555\n" + "\000\000\000\n" + "\000\000\000\n" + "\000\000\000",
|
||||||
"222\n" +
|
toMultiLineText(term));
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
term.addLine();
|
term.addLine();
|
||||||
assertEquals(8, term.getHeight());
|
assertEquals(8, term.getHeight());
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("222\n" + "333\n" + "444\n" + "\000\000\000\n" + "\000\000\000\n" + "\000\000\000\n"
|
||||||
"222\n" +
|
+ "\000\000\000\n" + "\000\000\000", toMultiLineText(term));
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000\n" +
|
|
||||||
"\000\000\000", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLineSegments() {
|
public void testGetLineSegments() {
|
||||||
|
@ -178,7 +145,6 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertSegment(0, "0123", s1, segments[0]);
|
assertSegment(0, "0123", s1, segments[0]);
|
||||||
assertSegment(4, "abcd", null, segments[1]);
|
assertSegment(4, "abcd", null, segments[1]);
|
||||||
|
|
||||||
|
|
||||||
segments = term.getLineSegments(2, 4, term.getWidth() - 4);
|
segments = term.getLineSegments(2, 4, term.getWidth() - 4);
|
||||||
assertEquals(1, segments.length);
|
assertEquals(1, segments.length);
|
||||||
assertSegment(4, "abcd", null, segments[0]);
|
assertSegment(4, "abcd", null, segments[0]);
|
||||||
|
@ -211,10 +177,9 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
|
assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetChar() {
|
public void testGetChar() {
|
||||||
String s="12345\n" +
|
String s = "12345\n" + "abcde\n" + "ABCDE";
|
||||||
"abcde\n" +
|
|
||||||
"ABCDE";
|
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
assertEquals('\000', term.getChar(0, 0));
|
assertEquals('\000', term.getChar(0, 0));
|
||||||
|
@ -233,6 +198,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEquals('D', term.getChar(2, 3));
|
assertEquals('D', term.getChar(2, 3));
|
||||||
assertEquals('E', term.getChar(2, 4));
|
assertEquals('E', term.getChar(2, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetStyle() {
|
public void testGetStyle() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
Style style = getDefaultStyle();
|
Style style = getDefaultStyle();
|
||||||
|
@ -254,6 +220,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChar() {
|
public void testSetChar() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(6, 3);
|
term.setDimensions(6, 3);
|
||||||
|
@ -270,13 +237,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEquals(c, term.getChar(line, column));
|
assertEquals(c, term.getChar(line, column));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "def\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "def\n"
|
|
||||||
+ "efg\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChars() {
|
public void testSetChars() {
|
||||||
|
@ -297,74 +258,43 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEquals(c, term.getChar(line, column));
|
assertEquals(c, term.getChar(line, column));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "def\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "def\n"
|
|
||||||
+ "efg\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
|
|
||||||
term.setChars(3, 1, new char[] { '1', '2' }, null);
|
term.setChars(3, 1, new char[] { '1', '2' }, null);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "d12\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "d12\n"
|
|
||||||
+ "efg\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
// check if chars are correctly chopped
|
// check if chars are correctly chopped
|
||||||
term.setChars(4, 1, new char[] { '1', '2', '3', '4', '5' }, null);
|
term.setChars(4, 1, new char[] { '1', '2', '3', '4', '5' }, null);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "d12\n" + "e12\n" + "fgh", toMultiLineText(term));
|
||||||
"abc\n"
|
|
||||||
+ "bcd\n"
|
|
||||||
+ "cde\n"
|
|
||||||
+ "d12\n"
|
|
||||||
+ "e12\n"
|
|
||||||
+ "fgh", toMultiLineText(term));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetCharsLen() {
|
public void testSetCharsLen() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s= "ZYXWVU\n"
|
String s = "ZYXWVU\n" + "abcdef\n" + "ABCDEF";
|
||||||
+ "abcdef\n"
|
|
||||||
+ "ABCDEF";
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
char[] chars = new char[] { '1', '2', '3', '4', '5', '6', '7', '8' };
|
char[] chars = new char[] { '1', '2', '3', '4', '5', '6', '7', '8' };
|
||||||
term.setChars(1, 0, chars, 0, 6, null);
|
term.setChars(1, 0, chars, 0, 6, null);
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("ZYXWVU\n" + "123456\n" + "ABCDEF", toMultiLineText(term));
|
||||||
"ZYXWVU\n"
|
|
||||||
+ "123456\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 0, chars, 0, 5, null);
|
term.setChars(1, 0, chars, 0, 5, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "12345f\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "12345f\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 0, chars, 1, 5, null);
|
term.setChars(1, 0, chars, 1, 5, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "23456f\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "23456f\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 1, chars, 1, 4, null);
|
term.setChars(1, 1, chars, 1, 4, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "a2345f\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "a2345f\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
term.setChars(1, 2, chars, 3, 4, null);
|
term.setChars(1, 2, chars, 3, 4, null);
|
||||||
assertEqualsTerm("ZYXWVU\n"
|
assertEqualsTerm("ZYXWVU\n" + "ab4567\n" + "ABCDEF", toMultiLineText(term));
|
||||||
+ "ab4567\n"
|
|
||||||
+ "ABCDEF", toMultiLineText(term));
|
|
||||||
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetCopyLines() {
|
public void testSetCopyLines() {
|
||||||
ITerminalTextData term = new TerminalTextDataStore();
|
ITerminalTextData term = new TerminalTextDataStore();
|
||||||
String s = "012345";
|
String s = "012345";
|
||||||
|
@ -406,6 +336,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEqualsSimple(s, toSimple(term));
|
assertEqualsSimple(s, toSimple(term));
|
||||||
assertEqualsSimple("a2345", toSimple(termCopy));
|
assertEqualsSimple("a2345", toSimple(termCopy));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollNegative() {
|
public void testScrollNegative() {
|
||||||
scrollTest(0, 2, -1, " 23 ", " 23 ");
|
scrollTest(0, 2, -1, " 23 ", " 23 ");
|
||||||
scrollTest(0, 1, -1, " 23 ", " 23 ");
|
scrollTest(0, 1, -1, " 23 ", " 23 ");
|
||||||
|
@ -419,47 +350,29 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
||||||
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScrollAll() {
|
public void testScrollAll() {
|
||||||
scrollTest(0, 6, 1, " 2345", " 2 ");
|
scrollTest(0, 6, 1, " 2345", " 2 ");
|
||||||
scrollTest(0, 6, -1, " 2345", " 3 ");
|
scrollTest(0, 6, -1, " 2345", " 3 ");
|
||||||
scrollTest(0, 6, 2, " 2345", " ");
|
scrollTest(0, 6, 2, " 2345", " ");
|
||||||
scrollTest(0, 6, -2, " 2345", " ");
|
scrollTest(0, 6, -2, " 2345", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyLineWithOffset() {
|
public void testCopyLineWithOffset() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s=
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
"111\n" +
|
|
||||||
"222\n" +
|
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"555";
|
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
ITerminalTextData dest = makeITerminalTextData();
|
ITerminalTextData dest = makeITerminalTextData();
|
||||||
String sCopy=
|
String sCopy = "aaa\n" + "bbb\n" + "ccc\n" + "ddd\n" + "eee";
|
||||||
"aaa\n" +
|
|
||||||
"bbb\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"ddd\n" +
|
|
||||||
"eee";
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 1, 0, new boolean[] { true, false, false, true });
|
copySelective(dest, term, 1, 0, new boolean[] { true, false, false, true });
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("222\n" + "bbb\n" + "ccc\n" + "\00\00\00\n" + "eee", toMultiLineText(dest));
|
||||||
"222\n" +
|
|
||||||
"bbb\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"\00\00\00\n" +
|
|
||||||
"eee", toMultiLineText(dest));
|
|
||||||
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 2, 0, new boolean[] { true, true });
|
copySelective(dest, term, 2, 0, new boolean[] { true, true });
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(
|
assertEqualsTerm("333\n" + "444\n" + "ccc\n" + "ddd\n" + "eee", toMultiLineText(dest));
|
||||||
"333\n" +
|
|
||||||
"444\n" +
|
|
||||||
"ccc\n" +
|
|
||||||
"ddd\n" +
|
|
||||||
"eee", toMultiLineText(dest));
|
|
||||||
|
|
||||||
fill(dest, sCopy);
|
fill(dest, sCopy);
|
||||||
copySelective(dest, term, 0, 0, new boolean[] { true, true, true, true, true });
|
copySelective(dest, term, 0, 0, new boolean[] { true, true, true, true, true });
|
||||||
|
@ -471,6 +384,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEqualsTerm(s, toMultiLineText(term));
|
assertEqualsTerm(s, toMultiLineText(term));
|
||||||
assertEqualsTerm(sCopy, toMultiLineText(dest));
|
assertEqualsTerm(sCopy, toMultiLineText(dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopy() {
|
public void testCopy() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(3, 1);
|
term.setDimensions(3, 1);
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class TerminalTextTestHelper {
|
||||||
static public String toSimple(ITerminalTextDataReadOnly term) {
|
static public String toSimple(ITerminalTextDataReadOnly term) {
|
||||||
return toSimple(toMultiLineText(term));
|
return toSimple(toMultiLineText(term));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String toMultiLineText(ITerminalTextDataReadOnly term) {
|
static public String toMultiLineText(ITerminalTextDataReadOnly term) {
|
||||||
StringBuffer buff = new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
int width = term.getWidth();
|
int width = term.getWidth();
|
||||||
|
@ -34,6 +35,7 @@ public class TerminalTextTestHelper {
|
||||||
}
|
}
|
||||||
return buff.toString();
|
return buff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String toSimple(String str) {
|
static public String toSimple(String str) {
|
||||||
//return str.replaceAll("\000", " ").replaceAll("\n", "");
|
//return str.replaceAll("\000", " ").replaceAll("\n", "");
|
||||||
// <J2ME CDC-1.1 Foundation-1.1 variant>
|
// <J2ME CDC-1.1 Foundation-1.1 variant>
|
||||||
|
@ -54,18 +56,21 @@ public class TerminalTextTestHelper {
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
// </J2ME CDC-1.1 Foundation-1.1 variant>
|
// </J2ME CDC-1.1 Foundation-1.1 variant>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param term
|
* @param term
|
||||||
* @param s each character is one line
|
* @param s each character is one line
|
||||||
*/
|
*/
|
||||||
static public void fillSimple(ITerminalTextData term, String s) {
|
static public void fillSimple(ITerminalTextData term, String s) {
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
term.setDimensions(s.length(), 1);
|
term.setDimensions(s.length(), 1);
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
char c = s.charAt(i);
|
char c = s.charAt(i);
|
||||||
term.setChar(i, 0, c, style.setForground(StyleColor.getStyleColor("" + c)));
|
term.setChar(i, 0, c, style.setForground(StyleColor.getStyleColor("" + c)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param term
|
* @param term
|
||||||
* @param s lines separated by \n. The terminal will automatically
|
* @param s lines separated by \n. The terminal will automatically
|
||||||
|
@ -94,7 +99,8 @@ public class TerminalTextTestHelper {
|
||||||
static public void fill(ITerminalTextData term, int column, int line, String s) {
|
static public void fill(ITerminalTextData term, int column, int line, String s) {
|
||||||
int xx = column;
|
int xx = column;
|
||||||
int yy = line;
|
int yy = line;
|
||||||
Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
|
false, false);
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
char c = s.charAt(i);
|
char c = s.charAt(i);
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
|
|
|
@ -26,12 +26,14 @@ public class SpeedTestConnection extends Thread {
|
||||||
private final ITerminalControl fControl;
|
private final ITerminalControl fControl;
|
||||||
private final InputStream fInputStream;
|
private final InputStream fInputStream;
|
||||||
private final SpeedTestSettings fSettings;
|
private final SpeedTestSettings fSettings;
|
||||||
|
|
||||||
protected SpeedTestConnection(InputStream inputStream, SpeedTestSettings settings, ITerminalControl control) {
|
protected SpeedTestConnection(InputStream inputStream, SpeedTestSettings settings, ITerminalControl control) {
|
||||||
super("SpeedTestConnection-" + fgNo++);
|
super("SpeedTestConnection-" + fgNo++);
|
||||||
fControl = control;
|
fControl = control;
|
||||||
fInputStream = inputStream;
|
fInputStream = inputStream;
|
||||||
fSettings = settings;
|
fSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
fControl.setState(TerminalState.CONNECTED);
|
fControl.setState(TerminalState.CONNECTED);
|
||||||
|
|
||||||
|
@ -43,12 +45,14 @@ public class SpeedTestConnection extends Thread {
|
||||||
// when reading is done, we set the state to closed
|
// when reading is done, we set the state to closed
|
||||||
fControl.setState(TerminalState.CLOSED);
|
fControl.setState(TerminalState.CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectFailed(String terminalText, String msg) {
|
private void connectFailed(String terminalText, String msg) {
|
||||||
Logger.log(terminalText);
|
Logger.log(terminalText);
|
||||||
fControl.displayTextInTerminal(terminalText);
|
fControl.displayTextInTerminal(terminalText);
|
||||||
fControl.setState(TerminalState.CLOSED);
|
fControl.setState(TerminalState.CLOSED);
|
||||||
fControl.setMsg(msg);
|
fControl.setMsg(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the data from the input file and display it in the terminal.
|
* Read the data from the input file and display it in the terminal.
|
||||||
* @param in
|
* @param in
|
||||||
|
@ -99,6 +103,7 @@ public class SpeedTestConnection extends Thread {
|
||||||
}
|
}
|
||||||
} while (line != null);
|
} while (line != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sleep(int ms) {
|
private void sleep(int ms) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(ms);
|
Thread.sleep(ms);
|
||||||
|
@ -106,11 +111,13 @@ public class SpeedTestConnection extends Thread {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTitle(final String title) {
|
private void setTitle(final String title) {
|
||||||
Display.getDefault().asyncExec(new Runnable() {
|
Display.getDefault().asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
fControl.setTerminalTitle(title);
|
fControl.setTerminalTitle(title);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,10 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||||
InputStream fInputStream;
|
InputStream fInputStream;
|
||||||
OutputStream fOutputStream;
|
OutputStream fOutputStream;
|
||||||
SpeedTestConnection fConnection;
|
SpeedTestConnection fConnection;
|
||||||
|
|
||||||
public SpeedTestConnector() {
|
public SpeedTestConnector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void connect(ITerminalControl control) {
|
synchronized public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fControl.setState(TerminalState.CONNECTING);
|
fControl.setState(TerminalState.CONNECTING);
|
||||||
|
@ -72,6 +74,7 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
fOutputStream = null;
|
fOutputStream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public InputStream getInputStream() {
|
synchronized public InputStream getInputStream() {
|
||||||
return fInputStream;
|
return fInputStream;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue