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
|
@ -69,13 +69,13 @@ public class Activator extends AbstractUIPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
plugin = null;
|
plugin = null;
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
plugin = null;
|
plugin = null;
|
||||||
scopedPreferences = null;
|
scopedPreferences = null;
|
||||||
traceHandler = null;
|
traceHandler = null;
|
||||||
|
|
|
@ -44,18 +44,18 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
*
|
*
|
||||||
* @param container The configuration panel container or <code>null</code>.
|
* @param container The configuration panel container or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public LocalWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
public LocalWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
||||||
super(container);
|
super(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setupPanel(Composite parent) {
|
public void setupPanel(Composite parent) {
|
||||||
Composite panel = new Composite(parent, SWT.NONE);
|
Composite panel = new Composite(parent, SWT.NONE);
|
||||||
panel.setLayout(new GridLayout());
|
panel.setLayout(new GridLayout());
|
||||||
panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
|
|
||||||
// Create the encoding selection combo
|
// Create the encoding selection combo
|
||||||
createEncodingUI(panel, false);
|
createEncodingUI(panel, false);
|
||||||
|
@ -66,13 +66,14 @@ 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
|
||||||
// set a height and width hint for the dialog
|
// set a height and width hint for the dialog
|
||||||
Label label = new Label(panel, SWT.HORIZONTAL);
|
Label label = new Label(panel, SWT.HORIZONTAL);
|
||||||
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
layoutData.widthHint = 300;
|
layoutData.widthHint = 300;
|
||||||
layoutData.heightHint = 80;
|
layoutData.heightHint = 80;
|
||||||
label.setLayoutData(layoutData);
|
label.setLayoutData(layoutData);
|
||||||
|
@ -82,36 +83,39 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
resource = getSelectionResource();
|
resource = getSelectionResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
setControl(panel);
|
setControl(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#setupData(java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#setupData(java.util.Map)
|
||||||
*/
|
*/
|
||||||
@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)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#extractData(java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#extractData(java.util.Map)
|
||||||
*/
|
*/
|
||||||
@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());
|
||||||
|
|
||||||
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 we have a IResource selection use the location for working directory
|
// if we have a IResource selection use the location for working directory
|
||||||
if (resource instanceof org.eclipse.core.resources.IResource){
|
if (resource instanceof org.eclipse.core.resources.IResource) {
|
||||||
String dir = ((org.eclipse.core.resources.IResource)resource).getProject().getLocation().toString();
|
String dir = ((org.eclipse.core.resources.IResource) resource).getProject().getLocation().toString();
|
||||||
data.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, dir);
|
data.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,21 +125,21 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void fillSettingsForHost(String host){
|
protected void fillSettingsForHost(String host) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void saveSettingsForHost(boolean add){
|
protected void saveSettingsForHost(boolean add) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(){
|
public boolean isValid() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,16 +147,16 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
||||||
// Save the encodings widget values
|
// Save the encodings widget values
|
||||||
doSaveEncodingsWidgetValues(settings, idPrefix);
|
doSaveEncodingsWidgetValues(settings, idPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
|
public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
|
||||||
// Restore the encodings widget values
|
// Restore the encodings widget values
|
||||||
doRestoreEncodingsWidgetValues(settings, idPrefix);
|
doRestoreEncodingsWidgetValues(settings, idPrefix);
|
||||||
}
|
}
|
||||||
|
@ -161,17 +165,17 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected String getHostFromSettings() {
|
protected String getHostFromSettings() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isWithHostList()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isWithHostList()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithHostList() {
|
public boolean isWithHostList() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the IResource from the current selection
|
* Returns the IResource from the current selection
|
||||||
|
@ -184,11 +188,12 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
|
|
||||||
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
||||||
Object element = ((IStructuredSelection) selection).getFirstElement();
|
Object element = ((IStructuredSelection) selection).getFirstElement();
|
||||||
if (element instanceof org.eclipse.core.resources.IResource){
|
if (element instanceof org.eclipse.core.resources.IResource) {
|
||||||
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,16 +129,18 @@ 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$
|
||||||
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
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 {
|
||||||
try {
|
try {
|
||||||
|
@ -161,28 +166,39 @@ 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)
|
||||||
ISelection selection = (ISelection)properties.get(ITerminalsConnectorConstants.PROP_SELECTION);
|
|| properties.containsKey(ITerminalsConnectorConstants.PROP_SELECTION)) {
|
||||||
if (selection == null) selection = service.getSelection();
|
ISelection selection = (ISelection) properties.get(ITerminalsConnectorConstants.PROP_SELECTION);
|
||||||
|
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();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
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
|
||||||
IPath location = ((org.eclipse.core.resources.IResource)element).getLocation();
|
&& ((org.eclipse.core.resources.IResource) element).exists()) {
|
||||||
if (location == null) continue;
|
IPath location = ((org.eclipse.core.resources.IResource) element).getLocation();
|
||||||
if (location.toFile().isFile()) location = location.removeLastSegments(1);
|
if (location == null)
|
||||||
|
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;
|
||||||
|
@ -190,7 +206,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof IPath || element instanceof File) {
|
if (element instanceof IPath || element instanceof File) {
|
||||||
File f = element instanceof IPath ? ((IPath)element).toFile() : (File)element;
|
File f = element instanceof IPath ? ((IPath) element).toFile() : (File) element;
|
||||||
if (f.isDirectory() && f.canRead()) {
|
if (f.isDirectory() && f.canRead()) {
|
||||||
dir = f.getAbsolutePath();
|
dir = f.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$
|
||||||
}
|
}
|
||||||
|
@ -245,7 +263,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
if (IMementoHandler.class.equals(adapter)) {
|
if (IMementoHandler.class.equals(adapter)) {
|
||||||
return mementoHandler;
|
return mementoHandler;
|
||||||
}
|
}
|
||||||
return super.getAdapter(adapter);
|
return super.getAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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$
|
||||||
|
@ -280,13 +299,14 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
||||||
Assert.isNotNull(properties);
|
Assert.isNotNull(properties);
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -295,17 +315,19 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
File defaultShell = defaultShell();
|
File defaultShell = defaultShell();
|
||||||
image = defaultShell.isAbsolute() ? defaultShell.getAbsolutePath() : defaultShell.getPath();
|
image = defaultShell.isAbsolute() ? defaultShell.getAbsolutePath() : defaultShell.getPath();
|
||||||
} else {
|
} else {
|
||||||
image = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
|
image = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|| properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ) instanceof PTY;
|
&& PTY.isSupported(PTY.Mode.TERMINAL))
|
||||||
|
|| properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ) instanceof PTY;
|
||||||
|
|
||||||
boolean localEcho = false;
|
boolean localEcho = false;
|
||||||
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_LOCAL_ECHO)
|
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_LOCAL_ECHO)
|
||||||
|
@ -315,7 +337,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
localEcho = !isUsingPTY;
|
localEcho = !isUsingPTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localEcho = ((Boolean)properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO)).booleanValue();
|
localEcho = ((Boolean) properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
String lineSeparator = null;
|
String lineSeparator = null;
|
||||||
|
@ -323,28 +345,32 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
String workingDir = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
|
ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
|
||||||
|
.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS);
|
||||||
|
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,21 +379,23 @@ 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
|
||||||
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 (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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert back into a string array
|
// Convert back into a string array
|
||||||
envp = envpList.toArray(new String[envpList.size()]);
|
envp = envpList.toArray(new String[envpList.size()]);
|
||||||
|
|
||||||
Assert.isTrue(image != null || process != null);
|
Assert.isTrue(image != null || process != null);
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
|
@ -46,10 +46,12 @@ public class LocalLauncherHandler extends AbstractHandler {
|
||||||
if (!(selection instanceof IStructuredSelection)) {
|
if (!(selection instanceof IStructuredSelection)) {
|
||||||
IEditorInput input = HandlerUtil.getActiveEditorInput(event);
|
IEditorInput input = HandlerUtil.getActiveEditorInput(event);
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
pty = new PTY(PTY.Mode.TERMINAL);
|
pty = new PTY(PTY.Mode.TERMINAL);
|
||||||
|
|
||||||
// Initialize the terminal size
|
// Initialize the terminal size
|
||||||
VT100Emulator text = ((VT100TerminalControl)control).getTerminalText();
|
VT100Emulator text = ((VT100TerminalControl) control).getTerminalText();
|
||||||
text.fontChanged();
|
text.fontChanged();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// PTY not supported
|
// PTY not supported
|
||||||
|
@ -129,13 +129,13 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
command.append(arguments.trim());
|
command.append(arguments.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
File workingDir =null;
|
File workingDir = null;
|
||||||
if (settings.getWorkingDir()!=null){
|
if (settings.getWorkingDir() != null) {
|
||||||
workingDir = new File(settings.getWorkingDir());
|
workingDir = new File(settings.getWorkingDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] envp = null;
|
String[] envp = null;
|
||||||
if (settings.getEnvironment()!=null){
|
if (settings.getEnvironment() != null) {
|
||||||
envp = settings.getEnvironment();
|
envp = settings.getEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -225,10 +226,10 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
private static String getTermVariable(String[] envp) {
|
private static String getTermVariable(String[] envp) {
|
||||||
if (envp != null && !Platform.OS_WIN32.equals(Platform.getOS()))
|
if (envp != null && !Platform.OS_WIN32.equals(Platform.getOS()))
|
||||||
for (String var : envp)
|
for (String var : envp)
|
||||||
if (var.startsWith("TERM=")) //$NON-NLS-1$
|
if (var.startsWith("TERM=")) //$NON-NLS-1$
|
||||||
return var.substring(5);
|
return var.substring(5);
|
||||||
return "xterm"; //$NON-NLS-1$
|
return "xterm"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#isLocalEcho()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#isLocalEcho()
|
||||||
|
@ -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.
|
||||||
|
@ -274,7 +281,7 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultSettings() {
|
public void setDefaultSettings() {
|
||||||
settings.load(new NullSettingsStore());
|
settings.load(new NullSettingsStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -72,26 +72,29 @@ public class ProcessLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
Assert.isNotNull(properties);
|
Assert.isNotNull(properties);
|
||||||
|
|
||||||
// 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);
|
||||||
String arguments = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS);
|
String arguments = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS);
|
||||||
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);
|
||||||
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);
|
||||||
String workingDir = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
|
ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
|
||||||
|
.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.isTrue(image != null || process != null);
|
Assert.isTrue(image != null || process != null);
|
||||||
|
@ -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,82 +26,84 @@ public class ProcessMonitor {
|
||||||
// Flag to mark the monitor disposed
|
// Flag to mark the monitor disposed
|
||||||
private boolean disposed;
|
private boolean disposed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param processConnector The parent process connector. Must not be <code>null</code>.
|
||||||
|
*/
|
||||||
|
public ProcessMonitor(ProcessConnector processConnector) {
|
||||||
|
super();
|
||||||
|
|
||||||
/**
|
Assert.isNotNull(processConnector);
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param processConnector The parent process connector. Must not be <code>null</code>.
|
|
||||||
*/
|
|
||||||
public ProcessMonitor(ProcessConnector processConnector) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
Assert.isNotNull(processConnector);
|
|
||||||
this.processConnector = processConnector;
|
this.processConnector = processConnector;
|
||||||
|
|
||||||
// Query the monitored process for easier access
|
// Query the monitored process for easier access
|
||||||
this.process = processConnector.getProcess();
|
this.process = processConnector.getProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose the process monitor.
|
* Dispose the process monitor.
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
// 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;
|
||||||
// Unlink the monitor from the thread
|
// Unlink the monitor from the thread
|
||||||
thread = null;
|
thread = null;
|
||||||
// And interrupt the writer thread
|
// And interrupt the writer thread
|
||||||
oldThread.interrupt();
|
oldThread.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the terminal output stream monitor.
|
* Starts the terminal output stream monitor.
|
||||||
*/
|
*/
|
||||||
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() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
monitorProcess();
|
monitorProcess();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the monitor thread
|
// Create the monitor thread
|
||||||
thread = new Thread(runnable, "Terminal Process Monitor Thread"); //$NON-NLS-1$
|
thread = new Thread(runnable, "Terminal Process Monitor Thread"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Configure the monitor thread
|
// Configure the monitor thread
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
|
|
||||||
// Start the processing
|
// Start the processing
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors the associated system process, waiting for it to terminate,
|
* Monitors the associated system process, waiting for it to terminate,
|
||||||
* and notifies the associated process monitor's.
|
* and notifies the associated process monitor's.
|
||||||
*/
|
*/
|
||||||
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
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
// clear interrupted state
|
// clear interrupted state
|
||||||
Thread.interrupted();
|
Thread.interrupted();
|
||||||
} finally {
|
} finally {
|
||||||
// Dispose the parent process connector
|
// Dispose the parent process connector
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
processConnector.disconnect();
|
processConnector.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,15 +266,18 @@ 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$
|
||||||
environment = (String[])((SettingsStore)store).getSettings().get("Environment"); //$NON-NLS-1$
|
stderrListeners = (ITerminalServiceOutputStreamMonitorListener[]) ((SettingsStore) store).getSettings()
|
||||||
|
.get("StdErrListeners"); //$NON-NLS-1$
|
||||||
|
environment = (String[]) ((SettingsStore) store).getSettings().get("Environment"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,11 +295,11 @@ public class ProcessSettings {
|
||||||
store.put("LineSeparator", lineSeparator); //$NON-NLS-1$
|
store.put("LineSeparator", lineSeparator); //$NON-NLS-1$
|
||||||
store.put("WorkingDir", workingDir); //$NON-NLS-1$
|
store.put("WorkingDir", workingDir); //$NON-NLS-1$
|
||||||
if (store instanceof SettingsStore) {
|
if (store instanceof SettingsStore) {
|
||||||
((SettingsStore)store).getSettings().put("Process", process); //$NON-NLS-1$
|
((SettingsStore) store).getSettings().put("Process", process); //$NON-NLS-1$
|
||||||
((SettingsStore)store).getSettings().put("PTY", pty); //$NON-NLS-1$
|
((SettingsStore) store).getSettings().put("PTY", pty); //$NON-NLS-1$
|
||||||
((SettingsStore)store).getSettings().put("StdOutListeners", stdoutListeners); //$NON-NLS-1$
|
((SettingsStore) store).getSettings().put("StdOutListeners", stdoutListeners); //$NON-NLS-1$
|
||||||
((SettingsStore)store).getSettings().put("StdErrListeners", stderrListeners); //$NON-NLS-1$
|
((SettingsStore) store).getSettings().put("StdErrListeners", stderrListeners); //$NON-NLS-1$
|
||||||
((SettingsStore)store).getSettings().put("Environment", environment); //$NON-NLS-1$
|
((SettingsStore) store).getSettings().put("Environment", 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
plugin = null;
|
plugin = null;
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,28 +70,28 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
return traceHandler;
|
return traceHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//<copied code from org.eclipse.team.cvs.ssh2/CVSSSH2Plugin (Copyright IBM)>
|
//<copied code from org.eclipse.team.cvs.ssh2/CVSSSH2Plugin (Copyright IBM)>
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
tracker = new ServiceTracker(getBundle().getBundleContext(), IJSchService.class.getName(), null);
|
tracker = new ServiceTracker(getBundle().getBundleContext(), IJSchService.class.getName(), null);
|
||||||
tracker.open();
|
tracker.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
try {
|
try {
|
||||||
SshConnection.shutdown();
|
SshConnection.shutdown();
|
||||||
tracker.close();
|
tracker.close();
|
||||||
|
@ -106,13 +106,13 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @return An instance of IJSchService, or <code>null</code> if no
|
* @return An instance of IJSchService, or <code>null</code> if no
|
||||||
* IJschService service is available.
|
* IJschService service is available.
|
||||||
*/
|
*/
|
||||||
public IJSchService getJSchService() {
|
public IJSchService getJSchService() {
|
||||||
return (IJSchService)tracker.getService();
|
return (IJSchService) tracker.getService();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//<copied code from org.eclipse.team.cvs.ssh2/CVSSSH2Plugin (Copyright IBM)>
|
//<copied code from org.eclipse.team.cvs.ssh2/CVSSSH2Plugin (Copyright IBM)>
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
|
||||||
|
|
|
@ -14,13 +14,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public interface ISshConstants {
|
public interface ISshConstants {
|
||||||
|
|
||||||
// These are from cvs.ui.IHelpContextIds
|
// These are from cvs.ui.IHelpContextIds
|
||||||
public static final String CVSUIPREFIX = "org.eclipse.team.cvs.ui."; //$NON-NLS-1$
|
public static final String CVSUIPREFIX = "org.eclipse.team.cvs.ui."; //$NON-NLS-1$
|
||||||
public static final String HELP_USER_VALIDATION_DIALOG = CVSUIPREFIX + "user_validation_dialog_context"; //$NON-NLS-1$
|
public static final String HELP_USER_VALIDATION_DIALOG = CVSUIPREFIX + "user_validation_dialog_context"; //$NON-NLS-1$
|
||||||
public static final String HELP_KEYBOARD_INTERACTIVE_DIALOG = CVSUIPREFIX + "keyboard_interactive_dialog_context"; //$NON-NLS-1$
|
public static final String HELP_KEYBOARD_INTERACTIVE_DIALOG = CVSUIPREFIX + "keyboard_interactive_dialog_context"; //$NON-NLS-1$
|
||||||
|
|
|
@ -33,161 +33,164 @@ import org.eclipse.ui.PlatformUI;
|
||||||
* A dialog for keyboad-interactive authentication for the ssh2 connection.
|
* A dialog for keyboad-interactive authentication for the ssh2 connection.
|
||||||
*/
|
*/
|
||||||
public class KeyboardInteractiveDialog extends TrayDialog {
|
public class KeyboardInteractiveDialog extends TrayDialog {
|
||||||
// widgets
|
// widgets
|
||||||
private Text[] texts;
|
private Text[] texts;
|
||||||
|
|
||||||
protected String domain;
|
protected String domain;
|
||||||
protected String destination;
|
protected String destination;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String instruction;
|
protected String instruction;
|
||||||
protected String lang;
|
protected String lang;
|
||||||
protected String[] prompt;
|
protected String[] prompt;
|
||||||
protected boolean[] echo;
|
protected boolean[] echo;
|
||||||
private String message;
|
private String message;
|
||||||
private String[] result;
|
private String[] result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a nwe KeyboardInteractiveDialog.
|
* Creates a nwe KeyboardInteractiveDialog.
|
||||||
*
|
*
|
||||||
* @param parentShell the parent shell
|
* @param parentShell the parent shell
|
||||||
* @param connectionId an id for the connection
|
* @param connectionId an id for the connection
|
||||||
* @param destination the location
|
* @param destination the location
|
||||||
* @param name the name
|
* @param name the name
|
||||||
* @param instruction the instruction
|
* @param instruction the instruction
|
||||||
* @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,
|
super(parentShell);
|
||||||
String name,
|
this.domain = connectionId;
|
||||||
String instruction,
|
this.destination = destination;
|
||||||
String[] prompt,
|
this.name = name;
|
||||||
boolean[] echo){
|
this.instruction = instruction;
|
||||||
super(parentShell);
|
this.prompt = prompt;
|
||||||
this.domain=connectionId;
|
this.echo = echo;
|
||||||
this.destination=destination;
|
this.message = NLS.bind(SshMessages.KeyboardInteractiveDialog_message,
|
||||||
this.name=name;
|
new String[] { destination + (name != null && name.length() > 0 ? ": " + name : "") }); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
this.instruction=instruction;
|
}
|
||||||
this.prompt=prompt;
|
|
||||||
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$
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see Window#configureShell
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void configureShell(Shell newShell) {
|
|
||||||
super.configureShell(newShell);
|
|
||||||
newShell.setText(message);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see Window#create
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void create() {
|
|
||||||
super.create();
|
|
||||||
if(texts.length>0){
|
|
||||||
texts[0].setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see Dialog#createDialogArea
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected Control createDialogArea(Composite parent) {
|
|
||||||
Composite main=new Composite(parent, SWT.NONE);
|
|
||||||
GridLayout layout=new GridLayout();
|
|
||||||
layout.numColumns=3;
|
|
||||||
main.setLayout(layout);
|
|
||||||
main.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
||||||
|
|
||||||
// set F1 help
|
/**
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(main, ISshConstants.HELP_KEYBOARD_INTERACTIVE_DIALOG);
|
* @see Window#configureShell
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
newShell.setText(message);
|
||||||
|
}
|
||||||
|
|
||||||
if (message!=null) {
|
/**
|
||||||
Label messageLabel=new Label(main, SWT.WRAP);
|
* @see Window#create
|
||||||
messageLabel.setText(message);
|
*/
|
||||||
GridData data=new GridData(GridData.FILL_HORIZONTAL);
|
@Override
|
||||||
data.horizontalSpan=3;
|
public void create() {
|
||||||
messageLabel.setLayoutData(data);
|
super.create();
|
||||||
}
|
if (texts.length > 0) {
|
||||||
if(domain!=null){
|
texts[0].setFocus();
|
||||||
Label label = new Label(main, SWT.WRAP);
|
}
|
||||||
label.setText(NLS.bind(SshMessages.KeyboardInteractiveDialog_labelConnection, new String[] { domain }));
|
}
|
||||||
GridData data=new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
data.horizontalSpan=3;
|
|
||||||
label.setLayoutData(data);
|
|
||||||
}
|
|
||||||
if (instruction!=null && instruction.length()>0) {
|
|
||||||
Label messageLabel=new Label(main, SWT.WRAP);
|
|
||||||
messageLabel.setText(instruction);
|
|
||||||
GridData data=new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
data.horizontalSpan=3;
|
|
||||||
messageLabel.setLayoutData(data);
|
|
||||||
}
|
|
||||||
createPasswordFields(main);
|
|
||||||
return main;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates the widgets that represent the entry area.
|
|
||||||
*
|
|
||||||
* @param parent the parent of the widgets
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
protected void createPasswordFields(Composite parent) {
|
|
||||||
texts=new Text[prompt.length];
|
|
||||||
|
|
||||||
for(int i=0; i<prompt.length; i++){
|
/**
|
||||||
new Label(parent, SWT.NONE).setText(prompt[i]);
|
* @see Dialog#createDialogArea
|
||||||
texts[i]=new Text(parent, SWT.BORDER);
|
*/
|
||||||
GridData data=new GridData(GridData.FILL_HORIZONTAL);
|
@Override
|
||||||
data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
|
protected Control createDialogArea(Composite parent) {
|
||||||
texts[i].setLayoutData(data);
|
Composite main = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = 3;
|
||||||
|
main.setLayout(layout);
|
||||||
|
main.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
if(!echo[i]){
|
// set F1 help
|
||||||
texts[i].setEchoChar('*');
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(main, ISshConstants.HELP_KEYBOARD_INTERACTIVE_DIALOG);
|
||||||
}
|
|
||||||
new Label(parent, SWT.NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (message != null) {
|
||||||
/**
|
Label messageLabel = new Label(main, SWT.WRAP);
|
||||||
* Returns the entered values, or null
|
messageLabel.setText(message);
|
||||||
* if the user cancelled.
|
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
*
|
data.horizontalSpan = 3;
|
||||||
* @return the entered values
|
messageLabel.setLayoutData(data);
|
||||||
*/
|
}
|
||||||
public String[] getResult() {
|
if (domain != null) {
|
||||||
return result;
|
Label label = new Label(main, SWT.WRAP);
|
||||||
}
|
label.setText(NLS.bind(SshMessages.KeyboardInteractiveDialog_labelConnection, new String[] { domain }));
|
||||||
/**
|
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
* Notifies that the ok button of this dialog has been pressed.
|
data.horizontalSpan = 3;
|
||||||
* <p>
|
label.setLayoutData(data);
|
||||||
* The default implementation of this framework method sets
|
}
|
||||||
* this dialog's return code to <code>Window.OK</code>
|
if (instruction != null && instruction.length() > 0) {
|
||||||
* and closes the dialog. Subclasses may override.
|
Label messageLabel = new Label(main, SWT.WRAP);
|
||||||
* </p>
|
messageLabel.setText(instruction);
|
||||||
*/
|
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
@Override
|
data.horizontalSpan = 3;
|
||||||
protected void okPressed() {
|
messageLabel.setLayoutData(data);
|
||||||
result=new String[prompt.length];
|
}
|
||||||
for(int i=0; i<texts.length; i++){
|
createPasswordFields(main);
|
||||||
result[i]=texts[i].getText();
|
return main;
|
||||||
}
|
}
|
||||||
super.okPressed();
|
|
||||||
}
|
/**
|
||||||
/**
|
* Creates the widgets that represent the entry area.
|
||||||
* Notifies that the cancel button of this dialog has been pressed.
|
*
|
||||||
* <p>
|
* @param parent the parent of the widgets
|
||||||
* The default implementation of this framework method sets
|
*/
|
||||||
* this dialog's return code to <code>Window.CANCEL</code>
|
@SuppressWarnings("unused")
|
||||||
* and closes the dialog. Subclasses may override.
|
protected void createPasswordFields(Composite parent) {
|
||||||
* </p>
|
texts = new Text[prompt.length];
|
||||||
*/
|
|
||||||
@Override
|
for (int i = 0; i < prompt.length; i++) {
|
||||||
protected void cancelPressed() {
|
new Label(parent, SWT.NONE).setText(prompt[i]);
|
||||||
result=null;
|
texts[i] = new Text(parent, SWT.BORDER);
|
||||||
super.cancelPressed();
|
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
}
|
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
|
||||||
|
texts[i].setLayoutData(data);
|
||||||
|
|
||||||
|
if (!echo[i]) {
|
||||||
|
texts[i].setEchoChar('*');
|
||||||
|
}
|
||||||
|
new Label(parent, SWT.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the entered values, or null
|
||||||
|
* if the user cancelled.
|
||||||
|
*
|
||||||
|
* @return the entered values
|
||||||
|
*/
|
||||||
|
public String[] getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies that the ok button of this dialog has been pressed.
|
||||||
|
* <p>
|
||||||
|
* The default implementation of this framework method sets
|
||||||
|
* this dialog's return code to <code>Window.OK</code>
|
||||||
|
* and closes the dialog. Subclasses may override.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void okPressed() {
|
||||||
|
result = new String[prompt.length];
|
||||||
|
for (int i = 0; i < texts.length; i++) {
|
||||||
|
result[i] = texts[i].getText();
|
||||||
|
}
|
||||||
|
super.okPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies that the cancel button of this dialog has been pressed.
|
||||||
|
* <p>
|
||||||
|
* The default implementation of this framework method sets
|
||||||
|
* this dialog's return code to <code>Window.CANCEL</code>
|
||||||
|
* and closes the dialog. Subclasses may override.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void cancelPressed() {
|
||||||
|
result = null;
|
||||||
|
super.cancelPressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,9 @@ 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) {
|
|
||||||
super("SshConnection-"+fgNo++); //$NON-NLS-1$
|
protected SshConnection(SshConnector conn, ITerminalControl control) {
|
||||||
|
super("SshConnection-" + fgNo++); //$NON-NLS-1$
|
||||||
fControl = control;
|
fControl = control;
|
||||||
fConn = conn;
|
fConn = conn;
|
||||||
fControl.setState(TerminalState.CONNECTING);
|
fControl.setState(TerminalState.CONNECTING);
|
||||||
|
@ -72,19 +73,20 @@ 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,
|
||||||
IJSchService service = UIPlugin.getDefault().getJSchService();
|
IProgressMonitor monitor) throws JSchException {
|
||||||
if (service == null)
|
IJSchService service = UIPlugin.getDefault().getJSchService();
|
||||||
return null;
|
if (service == null)
|
||||||
Session session = service.createSession(hostname, port, username);
|
return null;
|
||||||
//session.setTimeout(getSshTimeoutInMillis());
|
Session session = service.createSession(hostname, port, username);
|
||||||
session.setTimeout(0); //never time out on the session
|
//session.setTimeout(getSshTimeoutInMillis());
|
||||||
session.setServerAliveCountMax(6); //give up after 6 tries (remote will be dead after 30 min)
|
session.setTimeout(0); //never time out on the session
|
||||||
if (password != null)
|
session.setServerAliveCountMax(6); //give up after 6 tries (remote will be dead after 30 min)
|
||||||
|
if (password != null)
|
||||||
session.setPassword(password);
|
session.setPassword(password);
|
||||||
session.setUserInfo(wrapperUI);
|
session.setUserInfo(wrapperUI);
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
//TODO: Store all Jsch sessions in a pool and disconnect them on shutdown
|
//TODO: Store all Jsch sessions in a pool and disconnect them on shutdown
|
||||||
|
@ -95,7 +97,7 @@ public class SshConnection extends Thread {
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean connectSucceeded = false;
|
boolean connectSucceeded = false;
|
||||||
String host = ""; //$NON-NLS-1$
|
String host = ""; //$NON-NLS-1$
|
||||||
int port = ISshSettings.DEFAULT_SSH_PORT;
|
int port = ISshSettings.DEFAULT_SSH_PORT;
|
||||||
|
@ -107,32 +109,31 @@ public class SshConnection extends Thread {
|
||||||
String password = fConn.getSshSettings().getPassword();
|
String password = fConn.getSshSettings().getPassword();
|
||||||
port = fConn.getSshSettings().getPort();
|
port = fConn.getSshSettings().getPort();
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//java.util.Hashtable config=new java.util.Hashtable();
|
//java.util.Hashtable config=new java.util.Hashtable();
|
||||||
//config.put("StrictHostKeyChecking", "no");
|
//config.put("StrictHostKeyChecking", "no");
|
||||||
//session.setConfig(config);
|
//session.setConfig(config);
|
||||||
//ui.aboutToConnect();
|
//ui.aboutToConnect();
|
||||||
if (nKeepalive > 0) {
|
if (nKeepalive > 0) {
|
||||||
session.setServerAliveInterval(nKeepalive); //default is 5 minutes
|
session.setServerAliveInterval(nKeepalive); //default is 5 minutes
|
||||||
}
|
}
|
||||||
// dont try to connect if disconnect has been requested already
|
// dont try to connect if disconnect has been requested already
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (fDisconnectHasBeenCalled)
|
if (fDisconnectHasBeenCalled)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.connect(nTimeout); // making connection with timeout.
|
session.connect(nTimeout); // making connection with timeout.
|
||||||
// if we got disconnected, do not continue
|
// if we got disconnected, do not continue
|
||||||
if(!isSessionConnected())
|
if (!isSessionConnected())
|
||||||
return;
|
return;
|
||||||
ChannelShell channel=(ChannelShell) session.openChannel("shell"); //$NON-NLS-1$
|
ChannelShell channel = (ChannelShell) session.openChannel("shell"); //$NON-NLS-1$
|
||||||
channel.setPtyType("xterm"); //$NON-NLS-1$
|
channel.setPtyType("xterm"); //$NON-NLS-1$
|
||||||
// TERM=xterm implies VT100 line wrapping mode
|
// TERM=xterm implies VT100 line wrapping mode
|
||||||
fControl.setVT100LineWrapping(true);
|
fControl.setVT100LineWrapping(true);
|
||||||
|
@ -195,18 +196,19 @@ public class SshConnection extends Thread {
|
||||||
void disconnect() {
|
void disconnect() {
|
||||||
interrupt();
|
interrupt();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
fDisconnectHasBeenCalled=true;
|
fDisconnectHasBeenCalled = true;
|
||||||
if(fSession!=null) {
|
if (fSession != null) {
|
||||||
try {
|
try {
|
||||||
fSession.disconnect();
|
fSession.disconnect();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Ignore NPE due to bug in JSch if disconnecting
|
// Ignore NPE due to bug in JSch if disconnecting
|
||||||
// while not yet authenticated
|
// while not yet authenticated
|
||||||
}
|
}
|
||||||
fSession=null;
|
fSession = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -214,45 +216,47 @@ public class SshConnection extends Thread {
|
||||||
*/
|
*/
|
||||||
private void readDataForever(InputStream in) throws IOException {
|
private void readDataForever(InputStream in) throws IOException {
|
||||||
// read the data
|
// read the data
|
||||||
byte bytes[]=new byte[32*1024];
|
byte bytes[] = new byte[32 * 1024];
|
||||||
int n;
|
int n;
|
||||||
// read until the thread gets interrupted....
|
// read until the thread gets interrupted....
|
||||||
while( (n=in.read(bytes))!=-1) {
|
while ((n = in.read(bytes)) != -1) {
|
||||||
fControl.getRemoteToTerminalOutputStream().write(bytes,0,n);
|
fControl.getRemoteToTerminalOutputStream().write(bytes, 0, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Display getStandardDisplay() {
|
protected static Display getStandardDisplay() {
|
||||||
Display display = Display.getCurrent();
|
Display display = Display.getCurrent();
|
||||||
if( display==null ) {
|
if (display == null) {
|
||||||
display = Display.getDefault();
|
display = Display.getDefault();
|
||||||
}
|
}
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyUserInfo implements UserInfo, UIKeyboardInteractive {
|
private class MyUserInfo implements UserInfo, UIKeyboardInteractive {
|
||||||
/* default */ final String fConnectionId;
|
/* default */ final String fConnectionId;
|
||||||
/* default */ final String fUser;
|
/* default */ final String fUser;
|
||||||
private String fPassword;
|
private String fPassword;
|
||||||
private String fPassphrase;
|
private String fPassphrase;
|
||||||
private int fAttemptCount;
|
private int fAttemptCount;
|
||||||
|
|
||||||
public MyUserInfo(String connectionId, String user, String password) {
|
public MyUserInfo(String connectionId, String user, String password) {
|
||||||
fConnectionId = connectionId;
|
fConnectionId = connectionId;
|
||||||
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
|
||||||
final boolean[] retval = new boolean[1];
|
final boolean[] retval = new boolean[1];
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// [168197] Replace JFace MessagDialog by SWT MessageBox
|
// [168197] Replace JFace MessagDialog by SWT MessageBox
|
||||||
//retval[0] = MessageDialog.openQuestion(null, SshMessages.WARNING, str);
|
//retval[0] = MessageDialog.openQuestion(null, SshMessages.WARNING, str);
|
||||||
if (isSessionConnected()) {
|
if (isSessionConnected()) {
|
||||||
|
@ -267,11 +271,12 @@ 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() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isSessionConnected()) {
|
if (isSessionConnected()) {
|
||||||
UserValidationDialog uvd = new UserValidationDialog(null, fConnectionId, fUser, message);
|
UserValidationDialog uvd = new UserValidationDialog(null, fConnectionId, fUser, message);
|
||||||
uvd.setUsernameMutable(false);
|
uvd.setUsernameMutable(false);
|
||||||
|
@ -287,29 +292,33 @@ 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);
|
||||||
if (_password!=null) {
|
if (_password != null) {
|
||||||
fPassword=_password;
|
fPassword = _password;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
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() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// [168197] Replace JFace MessagDialog by SWT MessageBox
|
// [168197] Replace JFace MessagDialog by SWT MessageBox
|
||||||
// MessageDialog.openInformation(null, SshMessages.INFO, message);
|
// MessageDialog.openInformation(null, SshMessages.INFO, message);
|
||||||
if (isSessionConnected()) {
|
if (isSessionConnected()) {
|
||||||
|
@ -321,50 +330,50 @@ 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) {
|
||||||
{
|
// No need to prompt, just return an empty String array
|
||||||
if (prompt.length == 0) {
|
return new String[0];
|
||||||
// No need to prompt, just return an empty String array
|
}
|
||||||
return new String[0];
|
try {
|
||||||
}
|
if (fAttemptCount == 0 && fPassword != null && prompt.length == 1
|
||||||
try{
|
&& 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 };
|
}
|
||||||
}
|
final String[][] finResult = new String[1][];
|
||||||
final String[][] finResult = new String[1][];
|
getStandardDisplay().syncExec(new Runnable() {
|
||||||
getStandardDisplay().syncExec(new Runnable() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
if (isSessionConnected()) {
|
||||||
if (isSessionConnected()) {
|
KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null, fConnectionId,
|
||||||
KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null, fConnectionId, destination, name, instruction, prompt, echo);
|
destination, name, instruction, prompt, echo);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
finResult[0] = dialog.getResult();
|
finResult[0] = dialog.getResult();
|
||||||
} else {
|
} else {
|
||||||
finResult[0] = null; // indicate cancel to JSch
|
finResult[0] = null; // indicate cancel to JSch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
String[] result=finResult[0];
|
String[] result = finResult[0];
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return null; // cancelled
|
return null; // cancelled
|
||||||
if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
||||||
fPassword = result[0];
|
fPassword = result[0];
|
||||||
}
|
}
|
||||||
fAttemptCount++;
|
fAttemptCount++;
|
||||||
return result;
|
return result;
|
||||||
}
|
} catch (OperationCanceledException e) {
|
||||||
catch(OperationCanceledException e){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.setMsg(msg);
|
// fControl.setMsg(msg);
|
||||||
|
|
|
@ -36,24 +36,29 @@ 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();
|
||||||
if (getInputStream() != null) {
|
if (getInputStream() != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -71,28 +76,34 @@ 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)) {
|
||||||
//avoid excessive communications due to change size requests by caching previous size
|
//avoid excessive communications due to change size requests by caching previous size
|
||||||
fChannel.setPtySize(newWidth, newHeight, 8*newWidth, 8*newHeight);
|
fChannel.setPtySize(newWidth, newHeight, 8 * newWidth, 8 * newHeight);
|
||||||
fWidth=newWidth;
|
fWidth = newWidth;
|
||||||
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,31 +113,38 @@ 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;
|
||||||
fHeight=-1;
|
fHeight = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class SshMessages extends NLS {
|
||||||
public static String java_net_SocketException;
|
public static String java_net_SocketException;
|
||||||
public static String java_net_NoRouteToHostException;
|
public static String java_net_NoRouteToHostException;
|
||||||
|
|
||||||
// <Copied from org.eclipse.team.cvs.core / CVSCommunicationException (c) IBM 2000, 2007>
|
// <Copied from org.eclipse.team.cvs.core / CVSCommunicationException (c) IBM 2000, 2007>
|
||||||
|
|
||||||
public static String getMessageFor(Throwable throwable) {
|
public static String getMessageFor(Throwable throwable) {
|
||||||
String message = getMessage(getMessageKey(throwable));
|
String message = getMessage(getMessageKey(throwable));
|
||||||
|
@ -96,4 +96,4 @@ public class SshMessages extends NLS {
|
||||||
|
|
||||||
// </Copied from org.eclipse.team.cvs.core / Policy>
|
// </Copied from org.eclipse.team.cvs.core / Policy>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,15 @@ package org.eclipse.tm.terminal.connector.ssh.connector;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||||
|
|
||||||
public class SshSettings implements ISshSettings {
|
public class SshSettings implements ISshSettings {
|
||||||
protected String fHost;
|
protected String fHost;
|
||||||
protected String fUser;
|
protected String fUser;
|
||||||
protected String fPassword;
|
protected String fPassword;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,16 +36,16 @@ public class SshSettings implements ISshSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
String settings = getUser()+'@'+getHost();
|
String settings = getUser() + '@' + getHost();
|
||||||
if(getPort()!=ISshSettings.DEFAULT_SSH_PORT) {
|
if (getPort() != ISshSettings.DEFAULT_SSH_PORT) {
|
||||||
settings += ":" + getPort(); //$NON-NLS-1$
|
settings += ":" + getPort(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fHost = store.get("Host", "");//$NON-NLS-1$ //$NON-NLS-2$
|
fHost = store.get("Host", "");//$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fUser = store.get("User", "");//$NON-NLS-1$ //$NON-NLS-2$
|
fUser = store.get("User", "");//$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// ISettingsStore providers have to make sure that
|
// ISettingsStore providers have to make sure that
|
||||||
|
@ -57,7 +58,7 @@ public class SshSettings implements ISshSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
store.put("Host", fHost);//$NON-NLS-1$
|
store.put("Host", fHost);//$NON-NLS-1$
|
||||||
store.put("User", fUser);//$NON-NLS-1$
|
store.put("User", fUser);//$NON-NLS-1$
|
||||||
store.put("Port", fPort);//$NON-NLS-1$
|
store.put("Port", fPort);//$NON-NLS-1$
|
||||||
|
@ -68,15 +69,15 @@ 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 {
|
||||||
return Integer.parseInt(fTimeout);
|
return Integer.parseInt(fTimeout);
|
||||||
} catch (NumberFormatException numberFormatException) {
|
} catch (NumberFormatException numberFormatException) {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimeoutString() {
|
public String getTimeoutString() {
|
||||||
return fTimeout;
|
return fTimeout;
|
||||||
}
|
}
|
||||||
|
@ -86,13 +87,14 @@ public class SshSettings implements ISshSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getKeepalive() {
|
public int getKeepalive() {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(fKeepalive);
|
return Integer.parseInt(fKeepalive);
|
||||||
} catch (NumberFormatException numberFormatException) {
|
} catch (NumberFormatException numberFormatException) {
|
||||||
return 300;
|
return 300;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeepaliveString() {
|
public String getKeepaliveString() {
|
||||||
return fKeepalive;
|
return fKeepalive;
|
||||||
}
|
}
|
||||||
|
@ -102,15 +104,16 @@ public class SshSettings implements ISshSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUser() {
|
public String getUser() {
|
||||||
return fUser;
|
return fUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUser(String user) {
|
public void setUser(String user) {
|
||||||
fUser = user;
|
fUser = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(fPort);
|
return Integer.parseInt(fPort);
|
||||||
} catch (NumberFormatException numberFormatException) {
|
} catch (NumberFormatException numberFormatException) {
|
||||||
|
@ -127,7 +130,7 @@ public class SshSettings implements ISshSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return fPassword;
|
return fPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,11 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
private Text fPassword;
|
private Text fPassword;
|
||||||
|
|
||||||
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());
|
||||||
fTerminalSettings.setUser(fUser.getText());
|
fTerminalSettings.setUser(fUser.getText());
|
||||||
fTerminalSettings.setPassword(fPassword.getText());
|
fTerminalSettings.setPassword(fPassword.getText());
|
||||||
|
@ -50,23 +51,25 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings() {
|
public void loadSettings() {
|
||||||
if(fTerminalSettings!=null) {
|
if (fTerminalSettings != null) {
|
||||||
fHostText.setText(get(fTerminalSettings.getHost(),""));//$NON-NLS-1$
|
fHostText.setText(get(fTerminalSettings.getHost(), ""));//$NON-NLS-1$
|
||||||
fTimeout.setText(get(fTerminalSettings.getTimeoutString(),"0"));//$NON-NLS-1$
|
fTimeout.setText(get(fTerminalSettings.getTimeoutString(), "0"));//$NON-NLS-1$
|
||||||
fKeepalive.setText(get(fTerminalSettings.getKeepaliveString(),"300"));//$NON-NLS-1$
|
fKeepalive.setText(get(fTerminalSettings.getKeepaliveString(), "300"));//$NON-NLS-1$
|
||||||
fUser.setText(get(fTerminalSettings.getUser(),""));//$NON-NLS-1$
|
fUser.setText(get(fTerminalSettings.getUser(), ""));//$NON-NLS-1$
|
||||||
fPort.setText(get(fTerminalSettings.getPortString(), String.valueOf(ISshSettings.DEFAULT_SSH_PORT)));
|
fPort.setText(get(fTerminalSettings.getPortString(), String.valueOf(ISshSettings.DEFAULT_SSH_PORT)));
|
||||||
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;
|
||||||
int messageType = IMessageProvider.NONE;
|
int messageType = IMessageProvider.NONE;
|
||||||
boolean valid = true;
|
boolean valid = true;
|
||||||
|
@ -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,8 +150,9 @@ 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);
|
||||||
GridLayout gridLayout = new GridLayout(2, false);
|
GridLayout gridLayout = new GridLayout(2, false);
|
||||||
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
@ -144,13 +163,14 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
|
|
||||||
fHostText = createTextField(composite, SshMessages.HOST);
|
fHostText = createTextField(composite, SshMessages.HOST);
|
||||||
fUser = createTextField(composite, SshMessages.USER);
|
fUser = createTextField(composite, SshMessages.USER);
|
||||||
fPassword = createTextField(composite, SshMessages.PASSWORD,SWT.PASSWORD);
|
fPassword = createTextField(composite, SshMessages.PASSWORD, SWT.PASSWORD);
|
||||||
fTimeout = createTextField(composite, SshMessages.TIMEOUT);
|
fTimeout = createTextField(composite, SshMessages.TIMEOUT);
|
||||||
fKeepalive = createTextField(composite, SshMessages.KEEPALIVE);
|
fKeepalive = createTextField(composite, SshMessages.KEEPALIVE);
|
||||||
fKeepalive.setToolTipText(SshMessages.KEEPALIVE_Tooltip);
|
fKeepalive.setToolTipText(SshMessages.KEEPALIVE_Tooltip);
|
||||||
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
|
||||||
|
@ -159,17 +179,18 @@ public class SshSettingsPage extends AbstractSettingsPage {
|
||||||
|
|
||||||
// Add control
|
// Add control
|
||||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
final Text text= new Text(composite, SWT.BORDER | textOptions);
|
final Text text = new Text(composite, SWT.BORDER | textOptions);
|
||||||
text.setLayoutData(gridData);
|
text.setLayoutData(gridData);
|
||||||
text.addModifyListener(new ModifyListener() {
|
text.addModifyListener(new ModifyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
fireListeners(text);
|
fireListeners(text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,26 +62,28 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
*/
|
*/
|
||||||
public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) {
|
public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) {
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
setShellStyle(getShellStyle() | SWT.RESIZE);
|
setShellStyle(getShellStyle() | SWT.RESIZE);
|
||||||
this.defaultUsername = defaultName;
|
this.defaultUsername = defaultName;
|
||||||
this.domain = location;
|
this.domain = location;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Window#configureShell
|
* @see Window#configureShell
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void configureShell(Shell newShell) {
|
protected void configureShell(Shell newShell) {
|
||||||
super.configureShell(newShell);
|
super.configureShell(newShell);
|
||||||
newShell.setText(SshMessages.UserValidationDialog_required);
|
newShell.setText(SshMessages.UserValidationDialog_required);
|
||||||
// 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
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
super.create();
|
super.create();
|
||||||
// add some default values
|
// add some default values
|
||||||
usernameField.setText(defaultUsername);
|
usernameField.setText(defaultUsername);
|
||||||
|
@ -100,7 +102,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
* @see Dialog#createDialogArea
|
* @see Dialog#createDialogArea
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Control createDialogArea(Composite parent) {
|
protected Control createDialogArea(Composite parent) {
|
||||||
Composite top = new Composite(parent, SWT.NONE);
|
Composite top = new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
layout.numColumns = 2;
|
layout.numColumns = 2;
|
||||||
|
@ -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;
|
||||||
|
@ -152,7 +155,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
createUsernameFields(main);
|
createUsernameFields(main);
|
||||||
createPasswordFields(main);
|
createPasswordFields(main);
|
||||||
|
|
||||||
if(domain != null) {
|
if (domain != null) {
|
||||||
allowCachingButton = new Button(main, SWT.CHECK);
|
allowCachingButton = new Button(main, SWT.CHECK);
|
||||||
allowCachingButton.setText(SshMessages.UserValidationDialog_6);
|
allowCachingButton.setText(SshMessages.UserValidationDialog_6);
|
||||||
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
|
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
|
||||||
|
@ -160,7 +163,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
allowCachingButton.setLayoutData(data);
|
allowCachingButton.setLayoutData(data);
|
||||||
allowCachingButton.addSelectionListener(new SelectionAdapter() {
|
allowCachingButton.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
allowCaching = allowCachingButton.getSelection();
|
allowCaching = allowCachingButton.getSelection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
|
@ -183,7 +187,7 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
warningText.setLayoutData(data);
|
warningText.setLayoutData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog.applyDialogFont(parent);
|
Dialog.applyDialogFont(parent);
|
||||||
|
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
*
|
*
|
||||||
|
@ -255,12 +260,13 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void okPressed() {
|
protected void okPressed() {
|
||||||
password = passwordField.getText();
|
password = passwordField.getText();
|
||||||
username = usernameField.getText();
|
username = usernameField.getText();
|
||||||
|
|
||||||
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
|
||||||
|
@ -276,8 +282,8 @@ public class UserValidationDialog extends TrayDialog {
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#close()
|
* @see org.eclipse.jface.dialogs.Dialog#close()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean close() {
|
public boolean close() {
|
||||||
if(keyLockImage != null) {
|
if (keyLockImage != null) {
|
||||||
keyLockImage.dispose();
|
keyLockImage.dispose();
|
||||||
}
|
}
|
||||||
return super.close();
|
return super.close();
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
private static final String SAVE_USER = "saveUser"; //$NON-NLS-1$
|
private static final String SAVE_USER = "saveUser"; //$NON-NLS-1$
|
||||||
private static final String SAVE_PASSWORD = "savePassword"; //$NON-NLS-1$
|
private static final String SAVE_PASSWORD = "savePassword"; //$NON-NLS-1$
|
||||||
|
|
||||||
private SshSettings sshSettings;
|
private SshSettings sshSettings;
|
||||||
private ISettingsPage sshSettingsPage;
|
private ISettingsPage sshSettingsPage;
|
||||||
private Button userButton;
|
private Button userButton;
|
||||||
private Button passwordButton;
|
private Button passwordButton;
|
||||||
|
@ -61,8 +61,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
* @param container The configuration panel container or <code>null</code>.
|
* @param container The configuration panel container or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public SshWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
public SshWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
||||||
super(container);
|
super(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
||||||
|
@ -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();
|
||||||
|
@ -84,7 +85,7 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
|
|
||||||
sshSettingsPage = new SshSettingsPage(sshSettings);
|
sshSettingsPage = new SshSettingsPage(sshSettings);
|
||||||
if (sshSettingsPage instanceof AbstractSettingsPage) {
|
if (sshSettingsPage instanceof AbstractSettingsPage) {
|
||||||
((AbstractSettingsPage)sshSettingsPage).setHasControlDecoration(true);
|
((AbstractSettingsPage) sshSettingsPage).setHasControlDecoration(true);
|
||||||
}
|
}
|
||||||
sshSettingsPage.createControl(panel);
|
sshSettingsPage.createControl(panel);
|
||||||
|
|
||||||
|
@ -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,34 +112,42 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default user name.
|
* Returns the default user name.
|
||||||
|
@ -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,20 +174,22 @@ 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());
|
||||||
data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(sshSettings.getPort()));
|
data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(sshSettings.getPort()));
|
||||||
data.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.valueOf(sshSettings.getTimeout()));
|
data.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.valueOf(sshSettings.getTimeout()));
|
||||||
data.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.valueOf(sshSettings.getKeepalive()));
|
data.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.valueOf(sshSettings.getKeepalive()));
|
||||||
data.put(ITerminalsConnectorConstants.PROP_SSH_PASSWORD, sshSettings.getPassword());
|
data.put(ITerminalsConnectorConstants.PROP_SSH_PASSWORD, sshSettings.getPassword());
|
||||||
data.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
|
data.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
|
||||||
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
||||||
|
@ -185,8 +198,8 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
protected void fillSettingsForHost(String host) {
|
protected void fillSettingsForHost(String host) {
|
||||||
boolean saveUser = true;
|
boolean saveUser = true;
|
||||||
boolean savePassword = false;
|
boolean savePassword = false;
|
||||||
if (host != null && host.length() != 0){
|
if (host != null && host.length() != 0) {
|
||||||
if (hostSettingsMap.containsKey(host)){
|
if (hostSettingsMap.containsKey(host)) {
|
||||||
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
||||||
if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
|
if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
|
||||||
sshSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
sshSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
||||||
|
@ -206,7 +219,7 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
if (hostSettings.get(SAVE_PASSWORD) != null) {
|
if (hostSettings.get(SAVE_PASSWORD) != null) {
|
||||||
savePassword = new Boolean(hostSettings.get(SAVE_PASSWORD)).booleanValue();
|
savePassword = new Boolean(hostSettings.get(SAVE_PASSWORD)).booleanValue();
|
||||||
}
|
}
|
||||||
if (!savePassword){
|
if (!savePassword) {
|
||||||
sshSettings.setPassword(""); //$NON-NLS-1$
|
sshSettings.setPassword(""); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
String password = accessSecurePassword(sshSettings.getHost());
|
String password = accessSecurePassword(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 {
|
||||||
|
@ -238,10 +252,10 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
||||||
saveSettingsForHost(true);
|
saveSettingsForHost(true);
|
||||||
super.doSaveWidgetValues(settings, idPrefix);
|
super.doSaveWidgetValues(settings, idPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
||||||
|
@ -252,20 +266,20 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
boolean savePassword = passwordButton.getSelection();
|
boolean savePassword = passwordButton.getSelection();
|
||||||
String host = getHostFromSettings();
|
String host = getHostFromSettings();
|
||||||
if (host != null && host.length() != 0) {
|
if (host != null && host.length() != 0) {
|
||||||
if (hostSettingsMap.containsKey(host)){
|
if (hostSettingsMap.containsKey(host)) {
|
||||||
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,18 +294,20 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
hostSettings.put(SAVE_USER, Boolean.toString(saveUser));
|
hostSettings.put(SAVE_USER, Boolean.toString(saveUser));
|
||||||
hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
|
hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
|
||||||
|
|
||||||
if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
|
if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0) {
|
||||||
saveSecurePassword(host, sshSettings.getPassword());
|
saveSecurePassword(host, sshSettings.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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());
|
||||||
|
@ -302,7 +318,7 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
|
hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
|
||||||
hostSettingsMap.put(host, hostSettings);
|
hostSettingsMap.put(host, hostSettings);
|
||||||
|
|
||||||
if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
|
if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0) {
|
||||||
saveSecurePassword(host, sshSettings.getPassword());
|
saveSecurePassword(host, sshSettings.getPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +401,7 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(){
|
public boolean isValid() {
|
||||||
return isEncodingValid() && sshSettingsPage.validateSettings();
|
return isEncodingValid() && sshSettingsPage.validateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,10 +409,10 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected String getHostFromSettings() {
|
protected String getHostFromSettings() {
|
||||||
sshSettingsPage.saveSettings();
|
sshSettingsPage.saveSettings();
|
||||||
return sshSettings.getHost();
|
return sshSettings.getHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSaveButtonsUI(final Composite parent, boolean separator) {
|
private void createSaveButtonsUI(final Composite parent, boolean separator) {
|
||||||
Assert.isNotNull(parent);
|
Assert.isNotNull(parent);
|
||||||
|
|
|
@ -92,24 +92,26 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
*
|
*
|
||||||
* @return The terminal title string or <code>null</code>.
|
* @return The terminal title string or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
String user = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER);
|
String user = (String) properties.get(ITerminalsConnectorConstants.PROP_SSH_USER);
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
String port = value != null ? value.toString() : null;
|
String port = value != null ? value.toString() : null;
|
||||||
|
|
||||||
if (host != null && user!= null) {
|
if (host != null && user != null) {
|
||||||
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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
return Messages.SshLauncherDelegate_terminalTitle_default;
|
return Messages.SshLauncherDelegate_terminalTitle_default;
|
||||||
|
@ -118,40 +120,42 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
if (IMementoHandler.class.equals(adapter)) {
|
if (IMementoHandler.class.equals(adapter)) {
|
||||||
return mementoHandler;
|
return mementoHandler;
|
||||||
}
|
}
|
||||||
return super.getAdapter(adapter);
|
return super.getAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
||||||
Assert.isNotNull(properties);
|
Assert.isNotNull(properties);
|
||||||
|
|
||||||
// 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);
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
String port = value != null ? value.toString() : null;
|
String port = value != null ? value.toString() : null;
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
||||||
String timeout = value != null ? value.toString() : null;
|
String timeout = value != null ? value.toString() : null;
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE);
|
value = properties.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE);
|
||||||
String keepAlive = value != null ? value.toString() : null;
|
String keepAlive = value != null ? value.toString() : null;
|
||||||
String password = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
String password = (String) properties.get(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
||||||
String user = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER);
|
String user = (String) properties.get(ITerminalsConnectorConstants.PROP_SSH_USER);
|
||||||
|
|
||||||
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
|
||||||
//
|
//
|
||||||
|
@ -55,22 +60,22 @@ public class SshMementoHandler implements IMementoHandler {
|
||||||
String password = properties.getStringProperty(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
String password = properties.getStringProperty(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
||||||
if (password != null) {
|
if (password != null) {
|
||||||
try {
|
try {
|
||||||
// Generate a temporary key. In practice, you would save this key.
|
// Generate a temporary key. In practice, you would save this key.
|
||||||
// See also Encrypting with DES Using a Pass Phrase.
|
// See also Encrypting with DES Using a Pass Phrase.
|
||||||
// SecretKey key = KeyGenerator.getInstance("DESede").generateKey();
|
// SecretKey key = KeyGenerator.getInstance("DESede").generateKey();
|
||||||
|
|
||||||
SecretKeyFactory factory = SecretKeyFactory.getInstance("DESede"); //$NON-NLS-1$
|
SecretKeyFactory factory = SecretKeyFactory.getInstance("DESede"); //$NON-NLS-1$
|
||||||
SecretKey key = factory.generateSecret(new DESKeySpec((ITerminalsConnectorConstants.PROP_SSH_PASSWORD + ".SshMementoHandler").getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$
|
SecretKey key = factory.generateSecret(new DESKeySpec((ITerminalsConnectorConstants.PROP_SSH_PASSWORD + ".SshMementoHandler").getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); //$NON-NLS-1$
|
Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); //$NON-NLS-1$
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
|
|
||||||
String encrypedPwd = new String(Base64.encode(cipher.doFinal(password.getBytes("UTF-8")))); //$NON-NLS-1$
|
String encrypedPwd = new String(Base64.encode(cipher.doFinal(password.getBytes("UTF-8")))); //$NON-NLS-1$
|
||||||
memento.putString(ITerminalsConnectorConstants.PROP_SSH_PASSWORD, encrypedPwd);
|
memento.putString(ITerminalsConnectorConstants.PROP_SSH_PASSWORD, encrypedPwd);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
if (Platform.inDebugMode()) e.printStackTrace();
|
if (Platform.inDebugMode()) e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -84,50 +89,57 @@ 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
|
||||||
String password = null;
|
String password = null;
|
||||||
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 */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of restoring the password from an 3DES encrypted string. Do not remove!
|
// Example of restoring the password from an 3DES encrypted string. Do not remove!
|
||||||
/*
|
/*
|
||||||
String encrypedPwd = memento.getString(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
String encrypedPwd = memento.getString(ITerminalsConnectorConstants.PROP_SSH_PASSWORD);
|
||||||
if (encrypedPwd != null) {
|
if (encrypedPwd != null) {
|
||||||
try {
|
try {
|
||||||
SecretKeyFactory factory = SecretKeyFactory.getInstance("DESede"); //$NON-NLS-1$
|
SecretKeyFactory factory = SecretKeyFactory.getInstance("DESede"); //$NON-NLS-1$
|
||||||
SecretKey key = factory.generateSecret(new DESKeySpec((ITerminalsConnectorConstants.PROP_SSH_PASSWORD + ".SshMementoHandler").getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$
|
SecretKey key = factory.generateSecret(new DESKeySpec((ITerminalsConnectorConstants.PROP_SSH_PASSWORD + ".SshMementoHandler").getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); //$NON-NLS-1$
|
Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); //$NON-NLS-1$
|
||||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||||
|
|
||||||
byte[] encBytes = Base64.decode(encrypedPwd.getBytes("UTF-8")); //$NON-NLS-1$
|
byte[] encBytes = Base64.decode(encrypedPwd.getBytes("UTF-8")); //$NON-NLS-1$
|
||||||
byte[] decBytes = cipher.doFinal(encBytes);
|
byte[] decBytes = cipher.doFinal(encBytes);
|
||||||
|
|
||||||
password = new String(decBytes);
|
password = new String(decBytes);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
if (Platform.inDebugMode()) e.printStackTrace();
|
if (Platform.inDebugMode()) e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_SSH_PASSWORD, password);
|
properties.put(ITerminalsConnectorConstants.PROP_SSH_PASSWORD, password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
plugin = null;
|
plugin = null;
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,15 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NetworkPortMap {
|
public class NetworkPortMap {
|
||||||
public static final String PROP_NAMETGTCONS = "tgtcons"; //$NON-NLS-1$
|
public static final String PROP_NAMETGTCONS = "tgtcons"; //$NON-NLS-1$
|
||||||
public static final String PROP_NAMETELNET = "telnet"; //$NON-NLS-1$
|
public static final String PROP_NAMETELNET = "telnet"; //$NON-NLS-1$
|
||||||
public static final String PROP_VALUENET = "1233"; //$NON-NLS-1$
|
public static final String PROP_VALUENET = "1233"; //$NON-NLS-1$
|
||||||
public static final String PROP_VALUETGTCONS = "1232"; //$NON-NLS-1$
|
public static final String PROP_VALUETGTCONS = "1232"; //$NON-NLS-1$
|
||||||
public static final String PROP_VALUETELNET = "23"; //$NON-NLS-1$
|
public static final String PROP_VALUETELNET = "23"; //$NON-NLS-1$
|
||||||
|
|
||||||
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;
|
||||||
|
@ -40,7 +38,7 @@ public class NetworkPortMap {
|
||||||
|
|
||||||
public String findPortName(String strPort) {
|
public String findPortName(String strPort) {
|
||||||
for (int i = 0; i < fPortMap.length; i++) {
|
for (int i = 0; i < fPortMap.length; i++) {
|
||||||
if(fPortMap[i][1].equals(strPort))
|
if (fPortMap[i][1].equals(strPort))
|
||||||
return fPortMap[i][0];
|
return fPortMap[i][0];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -48,14 +46,14 @@ public class NetworkPortMap {
|
||||||
|
|
||||||
public String findPort(String strPortName) {
|
public String findPort(String strPortName) {
|
||||||
for (int i = 0; i < fPortMap.length; i++) {
|
for (int i = 0; i < fPortMap.length; i++) {
|
||||||
if(fPortMap[i][0].equals(strPortName))
|
if (fPortMap[i][0].equals(strPortName))
|
||||||
return fPortMap[i][1];
|
return fPortMap[i][1];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getNameTable() {
|
public List<String> getNameTable() {
|
||||||
List<String> names=new ArrayList<String>();
|
List<String> names = new ArrayList<String>();
|
||||||
for (int i = 0; i < fPortMap.length; i++) {
|
for (int i = 0; i < fPortMap.length; i++) {
|
||||||
names.add(fPortMap[i][0]);
|
names.add(fPortMap[i][0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,75 +22,73 @@ 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;
|
|
||||||
|
|
||||||
/** Command code: No-op. */
|
/** Command code: No-op. */
|
||||||
static final byte TELNET_NOP = (byte)241;
|
static final byte TELNET_NOP = (byte) 241;
|
||||||
|
|
||||||
/** Command code: Data Mark. */
|
/** Command code: Data Mark. */
|
||||||
static final byte TELNET_DM = (byte)242;
|
static final byte TELNET_DM = (byte) 242;
|
||||||
|
|
||||||
/** Command code: Break. */
|
/** Command code: Break. */
|
||||||
static final byte TELNET_BREAK = (byte)243;
|
static final byte TELNET_BREAK = (byte) 243;
|
||||||
|
|
||||||
/** Command code: Interrupt Process. */
|
/** Command code: Interrupt Process. */
|
||||||
static final byte TELNET_IP = (byte)244;
|
static final byte TELNET_IP = (byte) 244;
|
||||||
|
|
||||||
/** Command code: Abort Output. */
|
/** Command code: Abort Output. */
|
||||||
static final byte TELNET_AO = (byte)245;
|
static final byte TELNET_AO = (byte) 245;
|
||||||
|
|
||||||
/** Command code: Are You There. */
|
/** Command code: Are You There. */
|
||||||
static final byte TELNET_AYT = (byte)246;
|
static final byte TELNET_AYT = (byte) 246;
|
||||||
|
|
||||||
/** Command code: Erase Character. */
|
/** Command code: Erase Character. */
|
||||||
static final byte TELNET_EC = (byte)247;
|
static final byte TELNET_EC = (byte) 247;
|
||||||
|
|
||||||
/** Command code: Erase Line. */
|
/** Command code: Erase Line. */
|
||||||
static final byte TELNET_EL = (byte)248;
|
static final byte TELNET_EL = (byte) 248;
|
||||||
|
|
||||||
/** Command code: Go Ahead. */
|
/** Command code: Go Ahead. */
|
||||||
static final byte TELNET_GA = (byte)249;
|
static final byte TELNET_GA = (byte) 249;
|
||||||
|
|
||||||
/** Command code: Subnegotiation Begin. */
|
/** Command code: Subnegotiation Begin. */
|
||||||
static final byte TELNET_SB = (byte)250;
|
static final byte TELNET_SB = (byte) 250;
|
||||||
|
|
||||||
/** Command code: Will. */
|
/** Command code: Will. */
|
||||||
static final byte TELNET_WILL = (byte)251;
|
static final byte TELNET_WILL = (byte) 251;
|
||||||
|
|
||||||
/** Command code: Won't. */
|
/** Command code: Won't. */
|
||||||
static final byte TELNET_WONT = (byte)252;
|
static final byte TELNET_WONT = (byte) 252;
|
||||||
|
|
||||||
/** Command code: Do. */
|
/** Command code: Do. */
|
||||||
static final byte TELNET_DO = (byte)253;
|
static final byte TELNET_DO = (byte) 253;
|
||||||
|
|
||||||
/** Command code: Don't. */
|
/** Command code: Don't. */
|
||||||
static final byte TELNET_DONT = (byte)254;
|
static final byte TELNET_DONT = (byte) 254;
|
||||||
|
|
||||||
/** Command code: Interpret As Command. */
|
/** Command code: Interpret As Command. */
|
||||||
static final byte TELNET_IAC = (byte)255;
|
static final byte TELNET_IAC = (byte) 255;
|
||||||
|
|
||||||
/** Command code: IS. */
|
/** Command code: IS. */
|
||||||
static final byte TELNET_IS = 0;
|
static final byte TELNET_IS = 0;
|
||||||
|
|
||||||
/** Command code: SEND. */
|
/** Command code: SEND. */
|
||||||
static final byte TELNET_SEND = 1;
|
static final byte TELNET_SEND = 1;
|
||||||
|
|
||||||
|
/** Option code: Transmit Binary option. */
|
||||||
|
static final byte TELNET_OPTION_TRANSMIT_BINARY = 0;
|
||||||
|
|
||||||
/** Option code: Transmit Binary option. */
|
/** Option code: Echo option. */
|
||||||
static final byte TELNET_OPTION_TRANSMIT_BINARY = 0;
|
static final byte TELNET_OPTION_ECHO = 1;
|
||||||
|
|
||||||
/** Option code: Echo option. */
|
/** Option code: Suppress Go Ahead option. */
|
||||||
static final byte TELNET_OPTION_ECHO = 1;
|
static final byte TELNET_OPTION_SUPPRESS_GA = 3;
|
||||||
|
|
||||||
/** Option code: Suppress Go Ahead option. */
|
/** Option code: Terminal Type */
|
||||||
static final byte TELNET_OPTION_SUPPRESS_GA = 3;
|
static final byte TELNET_OPTION_TERMINAL_TYPE = 24;
|
||||||
|
|
||||||
/** Option code: Terminal Type */
|
/** Option code: Negotitate About Window Size (NAWS) */
|
||||||
static final byte TELNET_OPTION_TERMINAL_TYPE = 24;
|
static final byte TELNET_OPTION_NAWS = 31;
|
||||||
|
|
||||||
/** Option code: Negotitate About Window Size (NAWS) */
|
|
||||||
static final byte TELNET_OPTION_NAWS = 31;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,15 @@ 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
|
||||||
// remote telnet server isn't ready. ConnectExceptions might
|
// remote telnet server isn't ready. ConnectExceptions might
|
||||||
// happen if the telnet server process did not initialized itself.
|
// happen if the telnet server process did not initialized itself.
|
||||||
|
@ -48,14 +50,18 @@ 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;
|
||||||
String strHost = fConn.getTelnetSettings().getHost();
|
String strHost = fConn.getTelnetSettings().getHost();
|
||||||
int nPort = fConn.getTelnetSettings().getNetworkPort();
|
int nPort = fConn.getTelnetSettings().getNetworkPort();
|
||||||
InetSocketAddress address = new InetSocketAddress(strHost, nPort);
|
InetSocketAddress address = new InetSocketAddress(strHost, nPort);
|
||||||
Socket socket=new Socket();
|
Socket socket = new Socket();
|
||||||
|
|
||||||
socket.connect(address, nTimeout);
|
socket.connect(address, nTimeout);
|
||||||
|
|
||||||
|
@ -74,7 +80,7 @@ class TelnetConnectWorker extends Thread {
|
||||||
|
|
||||||
fConn.setSocket(socket);
|
fConn.setSocket(socket);
|
||||||
|
|
||||||
TelnetConnection connection=new TelnetConnection(fConn, socket);
|
TelnetConnection connection = new TelnetConnection(fConn, socket);
|
||||||
socket.setKeepAlive(true);
|
socket.setKeepAlive(true);
|
||||||
fConn.setTelnetConnection(connection);
|
fConn.setTelnetConnection(connection);
|
||||||
connection.start();
|
connection.start();
|
||||||
|
@ -85,21 +91,22 @@ class TelnetConnectWorker extends Thread {
|
||||||
// the DNS will fix itself
|
// the DNS will fix itself
|
||||||
remaining = 0;
|
remaining = 0;
|
||||||
//Construct error message and signal failed
|
//Construct error message and signal failed
|
||||||
String txt="Unknown host: " + ex.getMessage(); //$NON-NLS-1$
|
String txt = "Unknown host: " + ex.getMessage(); //$NON-NLS-1$
|
||||||
connectFailed(txt,"Unknown host: " + ex.getMessage() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
connectFailed(txt, "Unknown host: " + ex.getMessage() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
} catch (SocketTimeoutException socketTimeoutException) {
|
} catch (SocketTimeoutException socketTimeoutException) {
|
||||||
// Time out occurred. No re-try in this case either. Time out can
|
// Time out occurred. No re-try in this case either. Time out can
|
||||||
// be increased by the user. Multiplying the timeout with the remaining
|
// be increased by the user. Multiplying the timeout with the remaining
|
||||||
// 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
|
||||||
// control is already closed (disconnected), don't print "Connection refused" errors
|
// control is already closed (disconnected), don't print "Connection refused" errors
|
||||||
if (remaining == 0 && TerminalState.CLOSED != fControl.getState()) {
|
if (remaining == 0 && TerminalState.CLOSED != fControl.getState()) {
|
||||||
connectFailed(connectException.getMessage(),"Connection refused!"); //$NON-NLS-1$
|
connectFailed(connectException.getMessage(), "Connection refused!"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
// Any other exception on connect. No re-try in this case either
|
// Any other exception on connect. No re-try in this case either
|
||||||
|
@ -107,7 +114,7 @@ class TelnetConnectWorker extends Thread {
|
||||||
// Log the exception
|
// Log the exception
|
||||||
Logger.logException(exception);
|
Logger.logException(exception);
|
||||||
// And signal failed
|
// And signal failed
|
||||||
connectFailed(exception.getMessage(),""); //$NON-NLS-1$
|
connectFailed(exception.getMessage(), ""); //$NON-NLS-1$
|
||||||
} finally {
|
} finally {
|
||||||
remaining--;
|
remaining--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
|
||||||
* display.
|
* display.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Logger.log("Entered"); //$NON-NLS-1$
|
Logger.log("Entered"); //$NON-NLS-1$
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -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,21 +73,24 @@ 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);
|
||||||
fWidth=-1;
|
fWidth = -1;
|
||||||
fHeight=-1;
|
fHeight = -1;
|
||||||
// TERM=xterm implies VT100 line wrapping mode
|
// TERM=xterm implies VT100 line wrapping mode
|
||||||
control.setVT100LineWrapping(true);
|
control.setVT100LineWrapping(true);
|
||||||
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) {
|
||||||
try {
|
try {
|
||||||
getSocket().close();
|
getSocket().close();
|
||||||
|
@ -113,31 +116,37 @@ 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)) {
|
||||||
//avoid excessive communications due to change size requests by caching previous size
|
//avoid excessive communications due to change size requests by caching previous size
|
||||||
fTelnetConnection.setTerminalSize(newWidth, newHeight);
|
fTelnetConnection.setTerminalSize(newWidth, newHeight);
|
||||||
fWidth=newWidth;
|
fWidth = newWidth;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -154,13 +164,13 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
||||||
* sets the socket to null
|
* sets the socket to null
|
||||||
*/
|
*/
|
||||||
void cleanSocket() {
|
void cleanSocket() {
|
||||||
fSocket=null;
|
fSocket = null;
|
||||||
setInputStream(null);
|
setInputStream(null);
|
||||||
setOutputStream(null);
|
setOutputStream(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSocket(Socket socket) throws IOException {
|
void setSocket(Socket socket) throws IOException {
|
||||||
if(socket==null) {
|
if (socket == null) {
|
||||||
cleanSocket();
|
cleanSocket();
|
||||||
} else {
|
} else {
|
||||||
fSocket = socket;
|
fSocket = socket;
|
||||||
|
@ -169,35 +179,44 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,4 @@ public class TelnetMessages extends NLS {
|
||||||
*/
|
*/
|
||||||
public static String END_OF_LINE;
|
public static String END_OF_LINE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,207 +43,204 @@ 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 = { "BINARY", // 0 //$NON-NLS-1$
|
||||||
protected static final String[] optionNames =
|
"ECHO", // 1 //$NON-NLS-1$
|
||||||
{
|
"RECONNECTION", // 2 //$NON-NLS-1$
|
||||||
"BINARY", // 0 //$NON-NLS-1$
|
"SUPPRESS GO AHEAD", // 3 //$NON-NLS-1$
|
||||||
"ECHO", // 1 //$NON-NLS-1$
|
"MSG SIZE NEGOTIATION", // 4 //$NON-NLS-1$
|
||||||
"RECONNECTION", // 2 //$NON-NLS-1$
|
"STATUS", // 5 //$NON-NLS-1$
|
||||||
"SUPPRESS GO AHEAD", // 3 //$NON-NLS-1$
|
"TIMING MARK", // 6 //$NON-NLS-1$
|
||||||
"MSG SIZE NEGOTIATION", // 4 //$NON-NLS-1$
|
"REMOTE CTRL TRANS+ECHO", // 7 //$NON-NLS-1$
|
||||||
"STATUS", // 5 //$NON-NLS-1$
|
"OUTPUT LINE WIDTH", // 8 //$NON-NLS-1$
|
||||||
"TIMING MARK", // 6 //$NON-NLS-1$
|
"OUTPUT PAGE SIZE", // 9 //$NON-NLS-1$
|
||||||
"REMOTE CTRL TRANS+ECHO", // 7 //$NON-NLS-1$
|
"OUTPUT CR DISPOSITION", // 10 //$NON-NLS-1$
|
||||||
"OUTPUT LINE WIDTH", // 8 //$NON-NLS-1$
|
"OUTPUT HORIZ TABSTOPS", // 11 //$NON-NLS-1$
|
||||||
"OUTPUT PAGE SIZE", // 9 //$NON-NLS-1$
|
"OUTPUT HORIZ TAB DISPOSITION", // 12 //$NON-NLS-1$
|
||||||
"OUTPUT CR DISPOSITION", // 10 //$NON-NLS-1$
|
"OUTPUT FORMFEED DISPOSITION", // 13 //$NON-NLS-1$
|
||||||
"OUTPUT HORIZ TABSTOPS", // 11 //$NON-NLS-1$
|
"OUTPUT VERTICAL TABSTOPS", // 14 //$NON-NLS-1$
|
||||||
"OUTPUT HORIZ TAB DISPOSITION", // 12 //$NON-NLS-1$
|
"OUTPUT VT DISPOSITION", // 15 //$NON-NLS-1$
|
||||||
"OUTPUT FORMFEED DISPOSITION", // 13 //$NON-NLS-1$
|
"OUTPUT LF DISPOSITION", // 16 //$NON-NLS-1$
|
||||||
"OUTPUT VERTICAL TABSTOPS", // 14 //$NON-NLS-1$
|
"EXTENDED ASCII", // 17 //$NON-NLS-1$
|
||||||
"OUTPUT VT DISPOSITION", // 15 //$NON-NLS-1$
|
"LOGOUT", // 18 //$NON-NLS-1$
|
||||||
"OUTPUT LF DISPOSITION", // 16 //$NON-NLS-1$
|
"BYTE MACRO", // 19 //$NON-NLS-1$
|
||||||
"EXTENDED ASCII", // 17 //$NON-NLS-1$
|
"DATA ENTRY TERMINAL", // 20 //$NON-NLS-1$
|
||||||
"LOGOUT", // 18 //$NON-NLS-1$
|
"SUPDUP", // 21 //$NON-NLS-1$
|
||||||
"BYTE MACRO", // 19 //$NON-NLS-1$
|
"SUPDUP OUTPUT", // 22 //$NON-NLS-1$
|
||||||
"DATA ENTRY TERMINAL", // 20 //$NON-NLS-1$
|
"SEND LOCATION", // 23 //$NON-NLS-1$
|
||||||
"SUPDUP", // 21 //$NON-NLS-1$
|
"TERMINAL TYPE", // 24 //$NON-NLS-1$
|
||||||
"SUPDUP OUTPUT", // 22 //$NON-NLS-1$
|
"END OF RECORD", // 25 //$NON-NLS-1$
|
||||||
"SEND LOCATION", // 23 //$NON-NLS-1$
|
"TACACS USER IDENTIFICATION", // 26 //$NON-NLS-1$
|
||||||
"TERMINAL TYPE", // 24 //$NON-NLS-1$
|
"OUTPUT MARKING", // 27 //$NON-NLS-1$
|
||||||
"END OF RECORD", // 25 //$NON-NLS-1$
|
"TERMINAL LOCATION NUMBER", // 28 //$NON-NLS-1$
|
||||||
"TACACS USER IDENTIFICATION", // 26 //$NON-NLS-1$
|
"3270 REGIME", // 29 //$NON-NLS-1$
|
||||||
"OUTPUT MARKING", // 27 //$NON-NLS-1$
|
"X.3 PAD", // 30 //$NON-NLS-1$
|
||||||
"TERMINAL LOCATION NUMBER", // 28 //$NON-NLS-1$
|
"NEGOTIATE ABOUT WINDOW SIZE", // 31 //$NON-NLS-1$
|
||||||
"3270 REGIME", // 29 //$NON-NLS-1$
|
"TERMINAL SPEED", // 32 //$NON-NLS-1$
|
||||||
"X.3 PAD", // 30 //$NON-NLS-1$
|
"REMOTE FLOW CONTROL", // 33 //$NON-NLS-1$
|
||||||
"NEGOTIATE ABOUT WINDOW SIZE", // 31 //$NON-NLS-1$
|
"LINEMODE", // 34 //$NON-NLS-1$
|
||||||
"TERMINAL SPEED", // 32 //$NON-NLS-1$
|
"X DISPLAY LOCATION", // 35 //$NON-NLS-1$
|
||||||
"REMOTE FLOW CONTROL", // 33 //$NON-NLS-1$
|
"ENVIRONMENT OPTION", // 36 //$NON-NLS-1$
|
||||||
"LINEMODE", // 34 //$NON-NLS-1$
|
"AUTHENTICATION OPTION", // 37 //$NON-NLS-1$
|
||||||
"X DISPLAY LOCATION", // 35 //$NON-NLS-1$
|
"ENCRYPTION OPTION", // 38 //$NON-NLS-1$
|
||||||
"ENVIRONMENT OPTION", // 36 //$NON-NLS-1$
|
"NEW ENVIRONMENT OPTION", // 39 //$NON-NLS-1$
|
||||||
"AUTHENTICATION OPTION", // 37 //$NON-NLS-1$
|
"TN3270E", // 40 //$NON-NLS-1$
|
||||||
"ENCRYPTION OPTION", // 38 //$NON-NLS-1$
|
"XAUTH", // 41 //$NON-NLS-1$
|
||||||
"NEW ENVIRONMENT OPTION", // 39 //$NON-NLS-1$
|
"CHARSET", // 42 //$NON-NLS-1$
|
||||||
"TN3270E", // 40 //$NON-NLS-1$
|
"REMOTE SERIAL PORT", // 43 //$NON-NLS-1$
|
||||||
"XAUTH", // 41 //$NON-NLS-1$
|
"COM PORT CONTROL OPTION", // 44 //$NON-NLS-1$
|
||||||
"CHARSET", // 42 //$NON-NLS-1$
|
"SUPPRESS LOCAL ECHO", // 45 //$NON-NLS-1$
|
||||||
"REMOTE SERIAL PORT", // 43 //$NON-NLS-1$
|
"START TLS", // 46 //$NON-NLS-1$
|
||||||
"COM PORT CONTROL OPTION", // 44 //$NON-NLS-1$
|
"KERMIT", // 47 //$NON-NLS-1$
|
||||||
"SUPPRESS LOCAL ECHO", // 45 //$NON-NLS-1$
|
"SEND URL", // 48 //$NON-NLS-1$
|
||||||
"START TLS", // 46 //$NON-NLS-1$
|
"FORWARD X", // 49 //$NON-NLS-1$
|
||||||
"KERMIT", // 47 //$NON-NLS-1$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 50 ... //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"SEND URL", // 48 //$NON-NLS-1$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"FORWARD X", // 49 //$NON-NLS-1$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 50 ... //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", // ... 137 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"TELOPT PRAGMA LOGON", // 138 //$NON-NLS-1$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"TELOPT SSPI LOGON", // 139 //$NON-NLS-1$
|
||||||
"?", "?", "?", "?", "?", "?", "?", // ... 137 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
|
"TELOPT PRAGMA HEARTBEAT", // 140 //$NON-NLS-1$
|
||||||
"TELOPT PRAGMA LOGON", // 138 //$NON-NLS-1$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 141 ... //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"TELOPT SSPI LOGON", // 139 //$NON-NLS-1$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"TELOPT PRAGMA HEARTBEAT", // 140 //$NON-NLS-1$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 141 ... //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"?", "?", "?", "?", // ... 254 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
"EXTENDED OPTIONS LIST" // 255 //$NON-NLS-1$
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
};
|
||||||
"?", "?", "?", "?", // ... 254 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
||||||
"EXTENDED OPTIONS LIST" // 255 //$NON-NLS-1$
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Negotiation state: Negotiation not yet started for this option. <p>
|
* Negotiation state: Negotiation not yet started for this option. <p>
|
||||||
*
|
*
|
||||||
* This constant and the others having similar names represent the states of a
|
* This constant and the others having similar names represent the states of a
|
||||||
* finite state automaton (FSA) that tracks the negotiation state of this option.
|
* finite state automaton (FSA) that tracks the negotiation state of this option.
|
||||||
* The initial state is NEGOTIATION_NOT_STARTED. The state machine is as follows
|
* The initial state is NEGOTIATION_NOT_STARTED. The state machine is as follows
|
||||||
* (with transitions labeled with letters in parentheses): <p>
|
* (with transitions labeled with letters in parentheses): <p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NEGOTIATION_NOT_STARTED -----> {@link #NEGOTIATION_IN_PROGRESS}
|
* NEGOTIATION_NOT_STARTED -----> {@link #NEGOTIATION_IN_PROGRESS}
|
||||||
* | (A) | ^
|
* | (A) | ^
|
||||||
* (C)| (B)| |(D)
|
* (C)| (B)| |(D)
|
||||||
* | V |
|
* | V |
|
||||||
* +--------> {@link #NEGOTIATION_DONE}
|
* +--------> {@link #NEGOTIATION_DONE}
|
||||||
* </pre> <p>
|
* </pre> <p>
|
||||||
*
|
*
|
||||||
* Once the FSA leaves state NEGOTIATION_NOT_STARTED, it never returns to that
|
* Once the FSA leaves state NEGOTIATION_NOT_STARTED, it never returns to that
|
||||||
* state. Transition A happens when the local endpoint sends an option command
|
* state. Transition A happens when the local endpoint sends an option command
|
||||||
* before receiving a command for the same option from the remote endpoint. <p>
|
* before receiving a command for the same option from the remote endpoint. <p>
|
||||||
*
|
*
|
||||||
* Transition B happens when the local endpoint receives a reply to an option
|
* Transition B happens when the local endpoint receives a reply to an option
|
||||||
* command sent earlier by the local endpoint. Receipt of that reply terminates
|
* command sent earlier by the local endpoint. Receipt of that reply terminates
|
||||||
* the negotiation. <p>
|
* the negotiation. <p>
|
||||||
*
|
*
|
||||||
* Transition D happens after negotiation is done and "something changes" (see the
|
* Transition D happens after negotiation is done and "something changes" (see the
|
||||||
* RFCs for the definition of "something changes"). Either endpoint can
|
* RFCs for the definition of "something changes"). Either endpoint can
|
||||||
* re-negotiate an option after a previous negotiation, but only if some external
|
* re-negotiate an option after a previous negotiation, but only if some external
|
||||||
* influence (such as the user or the OS) causes it to do so. Re-negotiation must
|
* influence (such as the user or the OS) causes it to do so. Re-negotiation must
|
||||||
* start more than {@link #NEGOTIATION_IGNORE_DURATION} milliseconds after the FSA
|
* start more than {@link #NEGOTIATION_IGNORE_DURATION} milliseconds after the FSA
|
||||||
* enters state NEGOTIATION_DONE or it will be ignored. This is how this client
|
* enters state NEGOTIATION_DONE or it will be ignored. This is how this client
|
||||||
* prevents negotiation loops. <p>
|
* prevents negotiation loops. <p>
|
||||||
*
|
*
|
||||||
* Transition C happens when the local endpoint receives an option command from the
|
* Transition C happens when the local endpoint receives an option command from the
|
||||||
* remote endpoint before sending a command for the same option. In that case, the
|
* remote endpoint before sending a command for the same option. In that case, the
|
||||||
* local endpoint replies immediately with an option command and the negotiation
|
* local endpoint replies immediately with an option command and the negotiation
|
||||||
* terminates. <p>
|
* terminates. <p>
|
||||||
*
|
*
|
||||||
* Some TELNET servers (e.g., the Solaris server), after sending WILL and receiving
|
* Some TELNET servers (e.g., the Solaris server), after sending WILL and receiving
|
||||||
* DONT, will reply with a superfluous WONT. Any such superfluous option command
|
* DONT, will reply with a superfluous WONT. Any such superfluous option command
|
||||||
* received from the remote endpoint while the option's FSA is in state
|
* received from the remote endpoint while the option's FSA is in state
|
||||||
* {@link #NEGOTIATION_DONE} will be ignored by the local endpoint.
|
* {@link #NEGOTIATION_DONE} will be ignored by the local endpoint.
|
||||||
*/
|
*/
|
||||||
protected static final int NEGOTIATION_NOT_STARTED = 0;
|
protected static final int NEGOTIATION_NOT_STARTED = 0;
|
||||||
|
|
||||||
/** Negotiation state: Negotiation is in progress for this option. */
|
/** Negotiation state: Negotiation is in progress for this option. */
|
||||||
protected static final int NEGOTIATION_IN_PROGRESS = 1;
|
protected static final int NEGOTIATION_IN_PROGRESS = 1;
|
||||||
|
|
||||||
/** Negotiation state: Negotiation has terminated for this option. */
|
/** Negotiation state: Negotiation has terminated for this option. */
|
||||||
protected static final int NEGOTIATION_DONE = 2;
|
protected static final int NEGOTIATION_DONE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of milliseconds following the end of negotiation of this option
|
* The number of milliseconds following the end of negotiation of this option
|
||||||
* before which the remote endpoint can re-negotiate the option. Any option
|
* before which the remote endpoint can re-negotiate the option. Any option
|
||||||
* command received from the remote endpoint before this time passes is ignored.
|
* command received from the remote endpoint before this time passes is ignored.
|
||||||
* This is used to prevent option negotiation loops.
|
* This is used to prevent option negotiation loops.
|
||||||
*
|
*
|
||||||
* @see #ignoreNegotiation()
|
* @see #ignoreNegotiation()
|
||||||
* @see #negotiationCompletionTime
|
* @see #negotiationCompletionTime
|
||||||
*/
|
*/
|
||||||
protected static final int NEGOTIATION_IGNORE_DURATION = 30000;
|
protected static final int NEGOTIATION_IGNORE_DURATION = 30000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field holds the current negotiation state for this option.
|
* This field holds the current negotiation state for this option.
|
||||||
*/
|
*/
|
||||||
protected int negotiationState = NEGOTIATION_NOT_STARTED;
|
protected int negotiationState = NEGOTIATION_NOT_STARTED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field holds the time when negotiation of this option most recently
|
* This field holds the time when negotiation of this option most recently
|
||||||
* terminated (i.e., entered state {@link #NEGOTIATION_DONE}). This is used to
|
* terminated (i.e., entered state {@link #NEGOTIATION_DONE}). This is used to
|
||||||
* determine whether an option command received from the remote endpoint after
|
* determine whether an option command received from the remote endpoint after
|
||||||
* negotiation has terminated for this option is to be ignored or interpreted as
|
* negotiation has terminated for this option is to be ignored or interpreted as
|
||||||
* the start of a new negotiation.
|
* the start of a new negotiation.
|
||||||
*
|
*
|
||||||
* @see #NEGOTIATION_IGNORE_DURATION
|
* @see #NEGOTIATION_IGNORE_DURATION
|
||||||
*/
|
*/
|
||||||
protected Date negotiationCompletionTime = new Date(0);
|
protected Date negotiationCompletionTime = new Date(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the total number of negotiations that have completed for this option.
|
* Holds the total number of negotiations that have completed for this option.
|
||||||
*/
|
*/
|
||||||
protected int negotiationCount = 0;
|
protected int negotiationCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the integer code representing the option.
|
* Holds the integer code representing the option.
|
||||||
*/
|
*/
|
||||||
protected byte option = 0;
|
protected byte option = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the OutputStream object that allows data to be sent to the remote endpoint
|
* Holds the OutputStream object that allows data to be sent to the remote endpoint
|
||||||
* of the TELNET connection.
|
* of the TELNET connection.
|
||||||
*/
|
*/
|
||||||
protected OutputStream outputStream;
|
protected OutputStream outputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if this option is for the local endpoint, false for the remote endpoint.
|
* True if this option is for the local endpoint, false for the remote endpoint.
|
||||||
*/
|
*/
|
||||||
protected boolean local = true;
|
protected boolean local = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field is true if the option is enabled, false if it is disabled. All
|
* This field is true if the option is enabled, false if it is disabled. All
|
||||||
* options are initially disabled until they are negotiated to be enabled. <p>
|
* options are initially disabled until they are negotiated to be enabled. <p>
|
||||||
*/
|
*/
|
||||||
protected boolean enabled = false;
|
protected boolean enabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field is true if the client desires the option to be enabled, false if the
|
* This field is true if the client desires the option to be enabled, false if the
|
||||||
* client desires the option to be disabled. This field does not represent the
|
* client desires the option to be disabled. This field does not represent the
|
||||||
* remote's endpoints desire (as expressed via WILL and WONT commands) -- it
|
* remote's endpoints desire (as expressed via WILL and WONT commands) -- it
|
||||||
* represnet the local endpoint's desire. <p>
|
* represnet the local endpoint's desire. <p>
|
||||||
*
|
*
|
||||||
* @see #setDesired(boolean)
|
* @see #setDesired(boolean)
|
||||||
*/
|
*/
|
||||||
protected boolean desired = false;
|
protected boolean desired = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. <p>
|
* Constructor. <p>
|
||||||
*
|
*
|
||||||
* @param option The integer code of this option.
|
* @param option The integer code of this option.
|
||||||
|
@ -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,9 +511,8 @@ 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,17 +564,16 @@ 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
|
||||||
// thread, and calls to write() can block, but blocking the display thread
|
// thread, and calls to write() can block, but blocking the display thread
|
||||||
// is _bad_ (it hangs the GUI).
|
// is _bad_ (it hangs the GUI).
|
||||||
|
|
||||||
Thread t=new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
outputStream.write(NAWSData);
|
outputStream.write(NAWSData);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,14 @@ import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||||
* @noreference This class is not intended to be referenced by clients.
|
* @noreference This class is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
public class TelnetSettings implements ITelnetSettings {
|
public class TelnetSettings implements ITelnetSettings {
|
||||||
protected String fHost;
|
protected String fHost;
|
||||||
protected String fNetworkPort;
|
protected String fNetworkPort;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ public class TelnetSettings implements ITelnetSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNetworkPort() {
|
public int getNetworkPort() {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(fNetworkPort);
|
return Integer.parseInt(fNetworkPort);
|
||||||
} catch (NumberFormatException numberFormatException) {
|
} catch (NumberFormatException numberFormatException) {
|
||||||
|
@ -56,20 +57,20 @@ public class TelnetSettings implements ITelnetSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return getHost() + ":" + getNetworkPortString(); //$NON-NLS-1$
|
return getHost() + ":" + getNetworkPortString(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fHost = store.get("Host", fProperties.getDefaultHost());//$NON-NLS-1$
|
fHost = store.get("Host", fProperties.getDefaultHost());//$NON-NLS-1$
|
||||||
fNetworkPort = store.get("NetworkPort", fProperties.getDefaultNetworkPort());//$NON-NLS-1$
|
fNetworkPort = store.get("NetworkPort", fProperties.getDefaultNetworkPort());//$NON-NLS-1$
|
||||||
fTimeout = store.get("Timeout","10");//$NON-NLS-1$ //$NON-NLS-2$
|
fTimeout = store.get("Timeout", "10");//$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fEndOfLine = store.get("EndOfLine", EOL_CRNUL);//$NON-NLS-1$
|
fEndOfLine = store.get("EndOfLine", EOL_CRNUL);//$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
store.put("Host", fHost);//$NON-NLS-1$
|
store.put("Host", fHost);//$NON-NLS-1$
|
||||||
store.put("NetworkPort", fNetworkPort);//$NON-NLS-1$
|
store.put("NetworkPort", fNetworkPort);//$NON-NLS-1$
|
||||||
store.put("Timeout", fTimeout);//$NON-NLS-1$
|
store.put("Timeout", fTimeout);//$NON-NLS-1$
|
||||||
|
@ -79,14 +80,16 @@ 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 {
|
||||||
return Integer.parseInt(fTimeout);
|
return Integer.parseInt(fTimeout);
|
||||||
} catch (NumberFormatException numberFormatException) {
|
} catch (NumberFormatException numberFormatException) {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimeoutString() {
|
public String getTimeoutString() {
|
||||||
return fTimeout;
|
return fTimeout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,11 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
private final TelnetSettings fTerminalSettings;
|
private final TelnetSettings fTerminalSettings;
|
||||||
|
|
||||||
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());
|
||||||
fTerminalSettings.setTimeout(fTimeout.getText());
|
fTerminalSettings.setTimeout(fTimeout.getText());
|
||||||
fTerminalSettings.setNetworkPort(getNetworkPort());
|
fTerminalSettings.setNetworkPort(getNetworkPort());
|
||||||
|
@ -59,31 +60,34 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings() {
|
public void loadSettings() {
|
||||||
if(fTerminalSettings!=null) {
|
if (fTerminalSettings != null) {
|
||||||
setHost(fTerminalSettings.getHost());
|
setHost(fTerminalSettings.getHost());
|
||||||
setTimeout(fTerminalSettings.getTimeoutString());
|
setTimeout(fTerminalSettings.getTimeoutString());
|
||||||
setNetworkPort(fTerminalSettings.getNetworkPortString());
|
setNetworkPort(fTerminalSettings.getNetworkPortString());
|
||||||
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);
|
||||||
if(strPortName==null) {
|
if (strPortName == null) {
|
||||||
strPortName=strNetworkPort; //fallback to verbatim port if not found
|
strPortName = strNetworkPort; //fallback to verbatim port if not found
|
||||||
}
|
}
|
||||||
int nIndex = fNetworkPortCombo.indexOf(strPortName);
|
int nIndex = fNetworkPortCombo.indexOf(strPortName);
|
||||||
|
|
||||||
|
@ -94,23 +98,28 @@ 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;
|
||||||
int messageType = IMessageProvider.NONE;
|
int messageType = IMessageProvider.NONE;
|
||||||
boolean valid = true;
|
boolean valid = true;
|
||||||
|
@ -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 {
|
||||||
|
@ -160,7 +178,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
GridLayout gridLayout = new GridLayout(2, false);
|
GridLayout gridLayout = new GridLayout(2, false);
|
||||||
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
@ -179,7 +197,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
fHostText.setLayoutData(gridData);
|
fHostText.setLayoutData(gridData);
|
||||||
fHostText.addModifyListener(new ModifyListener() {
|
fHostText.addModifyListener(new ModifyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
fireListeners(fHostText);
|
fireListeners(fHostText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -195,13 +213,13 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
fNetworkPortCombo.setLayoutData(gridData);
|
fNetworkPortCombo.setLayoutData(gridData);
|
||||||
fNetworkPortCombo.addModifyListener(new ModifyListener() {
|
fNetworkPortCombo.addModifyListener(new ModifyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
fireListeners(fNetworkPortCombo);
|
fireListeners(fNetworkPortCombo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fNetworkPortCombo.addSelectionListener(new SelectionAdapter() {
|
fNetworkPortCombo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
fireListeners(fNetworkPortCombo);
|
fireListeners(fNetworkPortCombo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -216,7 +234,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
fTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
fTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
fTimeout.addModifyListener(new ModifyListener() {
|
fTimeout.addModifyListener(new ModifyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
fireListeners(fTimeout);
|
fireListeners(fTimeout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -228,7 +246,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
fEndOfLineCombo.setLayoutData(gridData);
|
fEndOfLineCombo.setLayoutData(gridData);
|
||||||
fEndOfLineCombo.addSelectionListener(new SelectionAdapter() {
|
fEndOfLineCombo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
fireListeners(fEndOfLineCombo);
|
fireListeners(fEndOfLineCombo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel
|
||||||
*/
|
*/
|
||||||
public class TelnetWizardConfigurationPanel extends AbstractExtendedConfigurationPanel {
|
public class TelnetWizardConfigurationPanel extends AbstractExtendedConfigurationPanel {
|
||||||
|
|
||||||
public TelnetSettings telnetSettings;
|
public TelnetSettings telnetSettings;
|
||||||
private ISettingsPage telnetSettingsPage;
|
private ISettingsPage telnetSettingsPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,8 +45,8 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
* @param container The configuration panel container or <code>null</code>.
|
* @param container The configuration panel container or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public TelnetWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
public TelnetWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
||||||
super(container);
|
super(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
||||||
|
@ -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();
|
||||||
|
@ -69,7 +70,7 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
|
|
||||||
telnetSettingsPage = new TelnetSettingsPage(telnetSettings);
|
telnetSettingsPage = new TelnetSettingsPage(telnetSettings);
|
||||||
if (telnetSettingsPage instanceof AbstractSettingsPage) {
|
if (telnetSettingsPage instanceof AbstractSettingsPage) {
|
||||||
((AbstractSettingsPage)telnetSettingsPage).setHasControlDecoration(true);
|
((AbstractSettingsPage) telnetSettingsPage).setHasControlDecoration(true);
|
||||||
}
|
}
|
||||||
telnetSettingsPage.createControl(panel);
|
telnetSettingsPage.createControl(panel);
|
||||||
|
|
||||||
|
@ -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,54 +95,62 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#extractData(java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#extractData(java.util.Map)
|
||||||
*/
|
*/
|
||||||
@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());
|
||||||
data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(telnetSettings.getNetworkPort()));
|
data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(telnetSettings.getNetworkPort()));
|
||||||
data.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.valueOf(telnetSettings.getTimeout()));
|
data.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.valueOf(telnetSettings.getTimeout()));
|
||||||
data.put(ITerminalsConnectorConstants.PROP_TELNET_EOL, telnetSettings.getEndOfLine());
|
data.put(ITerminalsConnectorConstants.PROP_TELNET_EOL, telnetSettings.getEndOfLine());
|
||||||
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void fillSettingsForHost(String host){
|
protected void fillSettingsForHost(String host) {
|
||||||
if (host != null && host.length() != 0){
|
if (host != null && host.length() != 0) {
|
||||||
if (hostSettingsMap.containsKey(host)){
|
if (hostSettingsMap.containsKey(host)) {
|
||||||
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
||||||
if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
|
if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
|
||||||
telnetSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
telnetSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
|
||||||
|
@ -171,18 +181,20 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void saveSettingsForHost(boolean add){
|
protected void saveSettingsForHost(boolean add) {
|
||||||
String host = getHostFromSettings();
|
String host = getHostFromSettings();
|
||||||
if(host != null && host.length() != 0) {
|
if (host != null && host.length() != 0) {
|
||||||
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
Map<String, String> hostSettings = hostSettingsMap.get(host);
|
||||||
if (hostSettings == null && !add) {
|
if (hostSettings == null && !add) {
|
||||||
hostSettings=new HashMap<String, String>();
|
hostSettings = new HashMap<String, String>();
|
||||||
hostSettingsMap.put(host, hostSettings);
|
hostSettingsMap.put(host, hostSettings);
|
||||||
}
|
}
|
||||||
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());
|
||||||
|
@ -195,7 +207,7 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(){
|
public boolean isValid() {
|
||||||
return isEncodingValid() && telnetSettingsPage.validateSettings();
|
return isEncodingValid() && telnetSettingsPage.validateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,17 +215,17 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
||||||
saveSettingsForHost(true);
|
saveSettingsForHost(true);
|
||||||
super.doSaveWidgetValues(settings, idPrefix);
|
super.doSaveWidgetValues(settings, idPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected String getHostFromSettings() {
|
protected String getHostFromSettings() {
|
||||||
telnetSettingsPage.saveSettings();
|
telnetSettingsPage.saveSettings();
|
||||||
return telnetSettings.getHost();
|
return telnetSettings.getHost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,18 +91,19 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
*
|
*
|
||||||
* @return The terminal title string or <code>null</code>.
|
* @return The terminal title string or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
|
|
||||||
if (host != null) {
|
if (host != null) {
|
||||||
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()));
|
||||||
return NLS.bind(Messages.TelnetLauncherDelegate_terminalTitle, new String[]{host, date});
|
return NLS.bind(Messages.TelnetLauncherDelegate_terminalTitle, new String[] { host, date });
|
||||||
}
|
}
|
||||||
|
|
||||||
return Messages.TelnetLauncherDelegate_terminalTitle_default;
|
return Messages.TelnetLauncherDelegate_terminalTitle_default;
|
||||||
|
@ -116,32 +117,34 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
if (IMementoHandler.class.equals(adapter)) {
|
if (IMementoHandler.class.equals(adapter)) {
|
||||||
return mementoHandler;
|
return mementoHandler;
|
||||||
}
|
}
|
||||||
return super.getAdapter(adapter);
|
return super.getAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
||||||
Assert.isNotNull(properties);
|
Assert.isNotNull(properties);
|
||||||
|
|
||||||
// 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);
|
||||||
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
|
||||||
String port = value != null ? value.toString() : null;
|
String port = value != null ? value.toString() : null;
|
||||||
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
|
||||||
String timeout = value != null ? value.toString() : null;
|
String timeout = value != null ? value.toString() : null;
|
||||||
String endOfLine = (String)properties.get(ITerminalsConnectorConstants.PROP_TELNET_EOL);
|
String endOfLine = (String) properties.get(ITerminalsConnectorConstants.PROP_TELNET_EOL);
|
||||||
|
|
||||||
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,119 +106,138 @@ 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 {
|
||||||
fConnector=fTerminalConnectorFactory.makeConnector();
|
fConnector = fTerminalConnectorFactory.makeConnector();
|
||||||
fConnector.initialize();
|
fConnector.initialize();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fException=e;
|
fException = e;
|
||||||
fConnector=new TerminalConnectorImpl(){
|
fConnector = new TerminalConnectorImpl() {
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
// super.connect(control);
|
// super.connect(control);
|
||||||
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);
|
||||||
}
|
}
|
||||||
if(fConnector!=null && fStore!=null)
|
if (fConnector != null && fStore != null)
|
||||||
fConnector.load(fStore);
|
fConnector.load(fStore);
|
||||||
}
|
}
|
||||||
return fConnector;
|
return fConnector;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
} else {
|
} else {
|
||||||
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
|
||||||
// the values....
|
// the values....
|
||||||
if(fConnector!=null) {
|
if (fConnector != null) {
|
||||||
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())
|
||||||
connector=getConnectorImpl();
|
connector = getConnectorImpl();
|
||||||
// if we cannot create the connector then we cannot adapt...
|
// if we cannot create the connector then we cannot adapt...
|
||||||
if(connector!=null) {
|
if (connector != null) {
|
||||||
// maybe the connector is adaptable
|
// maybe the connector is adaptable
|
||||||
if(connector instanceof IAdaptable) {
|
if (connector instanceof IAdaptable) {
|
||||||
Object result =((IAdaptable)connector).getAdapter(adapter);
|
Object result = ((IAdaptable) connector).getAdapter(adapter);
|
||||||
// Not sure if the next block is needed....
|
// Not sure if the next block is needed....
|
||||||
if(result==null)
|
if (result == null)
|
||||||
//defer to the platform
|
//defer to the platform
|
||||||
result= Platform.getAdapterManager().getAdapter(connector, adapter);
|
result = Platform.getAdapterManager().getAdapter(connector, adapter);
|
||||||
if(result!=null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// maybe the real adapter is what we need....
|
// maybe the real adapter is what we need....
|
||||||
if(adapter.isInstance(connector))
|
if (adapter.isInstance(connector))
|
||||||
return connector;
|
return connector;
|
||||||
}
|
}
|
||||||
// maybe we have to be adapted....
|
// maybe we have to be adapted....
|
||||||
|
|
|
@ -29,19 +29,22 @@ 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
|
||||||
*/
|
*/
|
||||||
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,122 +53,144 @@ 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 {
|
|
||||||
fOriginal.write(fBuffer.toByteArray());
|
public void close() throws IOException {
|
||||||
|
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) {
|
||||||
flush();
|
flush();
|
||||||
ungrabOutput();
|
ungrabOutput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 TerminalFilterOutputStream fInjection;
|
private Interceptor fInterceptor;
|
||||||
|
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();
|
||||||
fInterceptor=null;
|
fInterceptor = null;
|
||||||
fInjection=null;
|
fInjection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* There can only be one injection stream active at a time. You must call close on the
|
/**
|
||||||
* returned output stream to end the injection.
|
* There can only be one injection stream active at a time. You must call close on the
|
||||||
* @param interceptor This is used handle bytes sent while the injection stream is active.
|
* returned output stream to end the injection.
|
||||||
* @return a output stream that can be used to write to the decorated stream.
|
* @param interceptor This is used handle bytes sent while the injection stream is active.
|
||||||
* @throws IOException
|
* @return a output stream that can be used to write to the decorated stream.
|
||||||
*/
|
* @throws IOException
|
||||||
public synchronized OutputStream grabOutput(Interceptor interceptor) throws IOException {
|
*/
|
||||||
if(fInjection!=null) {
|
public synchronized OutputStream grabOutput(Interceptor interceptor) throws IOException {
|
||||||
throw new IOException("Buffer in use"); //$NON-NLS-1$
|
if (fInjection != null) {
|
||||||
}
|
throw new IOException("Buffer in use"); //$NON-NLS-1$
|
||||||
fInterceptor=interceptor;
|
}
|
||||||
fInterceptor.begin(out);
|
fInterceptor = interceptor;
|
||||||
fInjection=new TerminalFilterOutputStream();
|
fInterceptor.begin(out);
|
||||||
return fInjection;
|
fInjection = new TerminalFilterOutputStream();
|
||||||
}
|
return fInjection;
|
||||||
/** See {@link #grabOutput(TerminalToRemoteInjectionOutputStream.Interceptor)}.
|
|
||||||
* @return injection output stream
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public synchronized OutputStream grabOutput() throws IOException {
|
|
||||||
return grabOutput(new BufferInterceptor());
|
|
||||||
}
|
|
||||||
synchronized public void close() throws IOException {
|
|
||||||
if(fInjection!=null) {
|
|
||||||
fInjection.close();
|
|
||||||
}
|
|
||||||
super.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** See {@link #grabOutput(TerminalToRemoteInjectionOutputStream.Interceptor)}.
|
||||||
|
* @return injection output stream
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public synchronized OutputStream grabOutput() throws IOException {
|
||||||
|
return grabOutput(new BufferInterceptor());
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public void close() throws IOException {
|
||||||
|
if (fInjection != null) {
|
||||||
|
fInjection.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 {
|
|
||||||
if(fInterceptor!=null)
|
synchronized public void write(byte[] b, int off, int len) throws IOException {
|
||||||
fInterceptor.write(b, off, len);
|
if (fInterceptor != null)
|
||||||
else
|
fInterceptor.write(b, off, len);
|
||||||
out.write(b, off, len);
|
else
|
||||||
|
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);
|
||||||
else
|
else
|
||||||
out.write(b);
|
out.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.
|
||||||
|
@ -60,16 +58,16 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
private class FieldAssist implements IContentProposalProvider {
|
private class FieldAssist implements IContentProposalProvider {
|
||||||
|
|
||||||
public IContentProposal[] getProposals(String contents, int position) {
|
public IContentProposal[] getProposals(String contents, int position) {
|
||||||
String prefix=contents.substring(0, position);
|
String prefix = contents.substring(0, position);
|
||||||
List<Proposal> result=new ArrayList<Proposal>();
|
List<Proposal> result = new ArrayList<Proposal>();
|
||||||
// show an entry only once
|
// show an entry only once
|
||||||
Set<String> seen=new HashSet<String>();
|
Set<String> seen = new HashSet<String>();
|
||||||
for (Iterator<String> iterator = fHistory.iterator(); iterator.hasNext();) {
|
for (Iterator<String> iterator = fHistory.iterator(); iterator.hasNext();) {
|
||||||
String history = iterator.next();
|
String history = iterator.next();
|
||||||
if(history.startsWith(prefix) && !seen.contains(history)) {
|
if (history.startsWith(prefix) && !seen.contains(history)) {
|
||||||
// the content is the rest of the history item
|
// the content is the rest of the history item
|
||||||
String content=history.substring(prefix.length());
|
String content = history.substring(prefix.length());
|
||||||
result.add(new Proposal(content,history));
|
result.add(new Proposal(content, history));
|
||||||
// don't add this proposal again
|
// don't add this proposal again
|
||||||
seen.add(history);
|
seen.add(history);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> fHistory=new ArrayList<String>();
|
final List<String> fHistory = new ArrayList<String>();
|
||||||
/**
|
/**
|
||||||
* Keeps a modifiable history while in history editing mode
|
* Keeps a modifiable history while in history editing mode
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +112,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
/**
|
/**
|
||||||
* The current position in the edit history
|
* The current position in the edit history
|
||||||
*/
|
*/
|
||||||
private int fEditHistoryPos=0;
|
private int fEditHistoryPos = 0;
|
||||||
/**
|
/**
|
||||||
* The limit of the history.
|
* The limit of the history.
|
||||||
*/
|
*/
|
||||||
|
@ -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.
|
||||||
|
@ -132,16 +135,17 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
protected void pushLine(String line) {
|
protected void pushLine(String line) {
|
||||||
endHistoryMode();
|
endHistoryMode();
|
||||||
// anything to remember?
|
// anything to remember?
|
||||||
if(line==null || line.trim().length()==0)
|
if (line == null || line.trim().length() == 0)
|
||||||
return;
|
return;
|
||||||
fHistory.add(0,line);
|
fHistory.add(0, line);
|
||||||
// ignore if the same as last
|
// ignore if the same as last
|
||||||
if(fHistory.size()>1 && line.equals(fHistory.get(1)))
|
if (fHistory.size() > 1 && line.equals(fHistory.get(1)))
|
||||||
fHistory.remove(0);
|
fHistory.remove(0);
|
||||||
// limit the history size.
|
// limit the history size.
|
||||||
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
|
||||||
|
@ -149,34 +153,36 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
public void setHistory(String history) {
|
public void setHistory(String history) {
|
||||||
endHistoryMode();
|
endHistoryMode();
|
||||||
fHistory.clear();
|
fHistory.clear();
|
||||||
if(history==null)
|
if (history == null)
|
||||||
return;
|
return;
|
||||||
// add history entries separated by '\n'
|
// add history entries separated by '\n'
|
||||||
// fHistory.addAll(Arrays.asList(history.split("\n"))); //$NON-NLS-1$
|
// fHistory.addAll(Arrays.asList(history.split("\n"))); //$NON-NLS-1$
|
||||||
//<J2ME CDC-1.1 Foundation-1.1 variant>
|
//<J2ME CDC-1.1 Foundation-1.1 variant>
|
||||||
StringTokenizer tok=new StringTokenizer(history,"\n"); //$NON-NLS-1$
|
StringTokenizer tok = new StringTokenizer(history, "\n"); //$NON-NLS-1$
|
||||||
while(tok.hasMoreElements())
|
while (tok.hasMoreElements())
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public String getHistory() {
|
public String getHistory() {
|
||||||
StringBuffer buff=new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
boolean sep=false;
|
boolean sep = false;
|
||||||
for (Iterator<String> iterator = fHistory.iterator(); iterator.hasNext();) {
|
for (Iterator<String> iterator = fHistory.iterator(); iterator.hasNext();) {
|
||||||
String line=iterator.next();
|
String line = iterator.next();
|
||||||
if(line.length()>0) {
|
if (line.length() > 0) {
|
||||||
if(sep)
|
if (sep)
|
||||||
buff.append("\n"); //$NON-NLS-1$
|
buff.append("\n"); //$NON-NLS-1$
|
||||||
else
|
else
|
||||||
sep=true;
|
sep = true;
|
||||||
buff.append(line);
|
buff.append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
|
@ -184,22 +190,23 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
* if the limit is reached.
|
* if the limit is reached.
|
||||||
*/
|
*/
|
||||||
public String move(String currLine, int count) {
|
public String move(String currLine, int count) {
|
||||||
if(!inHistoryMode()) {
|
if (!inHistoryMode()) {
|
||||||
fEditedHistory=new ArrayList<Object>(fHistory.size()+1);
|
fEditedHistory = new ArrayList<Object>(fHistory.size() + 1);
|
||||||
fEditedHistory.add(currLine);
|
fEditedHistory.add(currLine);
|
||||||
fEditedHistory.addAll(fHistory);
|
fEditedHistory.addAll(fHistory);
|
||||||
fEditHistoryPos=0;
|
fEditHistoryPos = 0;
|
||||||
}
|
}
|
||||||
fEditedHistory.set(fEditHistoryPos,currLine);
|
fEditedHistory.set(fEditHistoryPos, currLine);
|
||||||
if(fEditHistoryPos+count>=fEditedHistory.size())
|
if (fEditHistoryPos + count >= fEditedHistory.size())
|
||||||
return null;
|
return null;
|
||||||
if(fEditHistoryPos+count<0)
|
if (fEditHistoryPos + count < 0)
|
||||||
return null;
|
return null;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,41 +214,43 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
* @return the string to be shown in the command line
|
* @return the string to be shown in the command line
|
||||||
*/
|
*/
|
||||||
protected String escape() {
|
protected String escape() {
|
||||||
if(!inHistoryMode())
|
if (!inHistoryMode())
|
||||||
return null;
|
return null;
|
||||||
String line= (String) fEditedHistory.get(0);
|
String line = (String) fEditedHistory.get(0);
|
||||||
endHistoryMode();
|
endHistoryMode();
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End history editing
|
* End history editing
|
||||||
*/
|
*/
|
||||||
private void endHistoryMode() {
|
private void endHistoryMode() {
|
||||||
fEditedHistory=null;
|
fEditedHistory = null;
|
||||||
fEditHistoryPos=0;
|
fEditHistoryPos = 0;
|
||||||
}
|
}
|
||||||
public void createControl(final Composite parent,final ITerminalViewControl terminal) {
|
|
||||||
// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH);
|
public void createControl(final Composite parent, final ITerminalViewControl terminal) {
|
||||||
fSash = new Sash(parent,SWT.HORIZONTAL);
|
// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH);
|
||||||
|
fSash = new Sash(parent, SWT.HORIZONTAL);
|
||||||
final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
gd_sash.heightHint=5;
|
gd_sash.heightHint = 5;
|
||||||
fSash.setLayoutData(gd_sash);
|
fSash.setLayoutData(gd_sash);
|
||||||
fSash.addListener (SWT.Selection, new Listener () {
|
fSash.addListener(SWT.Selection, new Listener() {
|
||||||
public void handleEvent (Event e) {
|
public void handleEvent(Event e) {
|
||||||
if (e.detail == SWT.DRAG) {
|
if (e.detail == SWT.DRAG) {
|
||||||
// don't redraw during drag, it causes paint errors - bug 220971
|
// don't redraw during drag, it causes paint errors - bug 220971
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// no idea why this is needed
|
// no idea why this is needed
|
||||||
GridData gdata = (GridData) fInputField.getLayoutData();
|
GridData gdata = (GridData) fInputField.getLayoutData();
|
||||||
Rectangle sashRect = fSash.getBounds ();
|
Rectangle sashRect = fSash.getBounds();
|
||||||
Rectangle containerRect = parent.getClientArea ();
|
Rectangle containerRect = parent.getClientArea();
|
||||||
|
|
||||||
int h=fInputField.getLineHeight();
|
int h = fInputField.getLineHeight();
|
||||||
// make sure the input filed height is a multiple of the line height
|
// make sure the input filed height is a multiple of the line height
|
||||||
gdata.heightHint = Math.max(((containerRect.height-e.y-sashRect.height)/h)*h,h);
|
gdata.heightHint = Math.max(((containerRect.height - e.y - sashRect.height) / h) * h, h);
|
||||||
// do not show less then one line
|
// do not show less then one line
|
||||||
e.y=Math.min(e.y,containerRect.height-h);
|
e.y = Math.min(e.y, containerRect.height - h);
|
||||||
fInputField.setLayoutData(gdata);
|
fInputField.setLayoutData(gdata);
|
||||||
parent.layout();
|
parent.layout();
|
||||||
// else the content assist icon will be replicated
|
// else the content assist icon will be replicated
|
||||||
|
@ -250,17 +259,20 @@ 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);
|
||||||
GridData data=new GridData(SWT.FILL, SWT.FILL, true, false);
|
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||||
boolean installDecoration=true;
|
boolean installDecoration = true;
|
||||||
if(installDecoration) {
|
if (installDecoration) {
|
||||||
// The ContentAssistCommandAdapter says: "The client is responsible for
|
// The ContentAssistCommandAdapter says: "The client is responsible for
|
||||||
// ensuring that adequate space is reserved for the decoration."
|
// ensuring that adequate space is reserved for the decoration."
|
||||||
// TODO: what is the "adequate space"???
|
// TODO: what is the "adequate space"???
|
||||||
data.horizontalIndent=6;
|
data.horizontalIndent = 6;
|
||||||
}
|
}
|
||||||
fInputField.setLayoutData(data);
|
fInputField.setLayoutData(data);
|
||||||
fInputField.setFont(terminal.getFont());
|
fInputField.setFont(terminal.getFont());
|
||||||
|
@ -268,57 +280,56 @@ 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) {
|
||||||
// if the field assist has handled the key already then
|
// if the field assist has handled the key already then
|
||||||
// ignore it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659)
|
// ignore it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659)
|
||||||
if(!e.doit)
|
if (!e.doit)
|
||||||
return;
|
return;
|
||||||
if(e.character==SWT.CR || e.character==SWT.LF) {
|
if (e.character == SWT.CR || e.character == SWT.LF) {
|
||||||
e.doit=false;
|
e.doit = false;
|
||||||
String line=fInputField.getText();
|
String line = fInputField.getText();
|
||||||
if(!terminal.pasteString(line+'\r'))
|
if (!terminal.pasteString(line + '\r'))
|
||||||
return;
|
return;
|
||||||
pushLine(line);
|
pushLine(line);
|
||||||
setCommand("");//$NON-NLS-1$
|
setCommand("");//$NON-NLS-1$
|
||||||
} else if(e.keyCode==SWT.ARROW_UP || e.keyCode==SWT.PAGE_UP) {
|
} else if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.PAGE_UP) {
|
||||||
e.doit=false;
|
e.doit = false;
|
||||||
setCommand(move(fInputField.getText(),1));
|
setCommand(move(fInputField.getText(), 1));
|
||||||
} else if(e.keyCode==SWT.ARROW_DOWN || e.keyCode==SWT.PAGE_DOWN) {
|
} else if (e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.PAGE_DOWN) {
|
||||||
e.doit=false;
|
e.doit = false;
|
||||||
setCommand(move(fInputField.getText(),-1));
|
setCommand(move(fInputField.getText(), -1));
|
||||||
} else if(e.keyCode==SWT.ESC) {
|
} else if (e.keyCode == SWT.ESC) {
|
||||||
e.doit=false;
|
e.doit = false;
|
||||||
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;
|
||||||
fPanel.dispose();
|
fPanel.dispose();
|
||||||
fPanel=null;
|
fPanel = null;
|
||||||
fInputField.dispose();
|
fInputField.dispose();
|
||||||
fInputField=null;
|
fInputField = 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
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
||||||
* Terminal specific version of {@link org.eclipse.swt.events.MouseListener}
|
* Terminal specific version of {@link org.eclipse.swt.events.MouseListener}
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public interface ITerminalMouseListener {
|
public interface ITerminalMouseListener {
|
||||||
/**
|
/**
|
||||||
* Invoked when a double-click has happend inside the terminal control.<br>
|
* Invoked when a double-click has happend inside the terminal control.<br>
|
||||||
* <br>
|
* <br>
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -50,13 +50,15 @@ public interface ITerminalViewControl {
|
||||||
*/
|
*/
|
||||||
String getEncoding();
|
String getEncoding();
|
||||||
|
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
/**
|
|
||||||
* Sets the Terminal font
|
/**
|
||||||
* @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font
|
* Sets the Terminal font
|
||||||
* @param font
|
* @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given 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,51 +66,74 @@ 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();
|
|
||||||
void selectAll();
|
boolean isDisposed();
|
||||||
void clearTerminal();
|
|
||||||
void copy();
|
void selectAll();
|
||||||
void paste();
|
|
||||||
String getSelection();
|
void clearTerminal();
|
||||||
TerminalState getState();
|
|
||||||
Clipboard getClipboard();
|
void copy();
|
||||||
void disconnectTerminal();
|
|
||||||
void disposeTerminal();
|
void paste();
|
||||||
String getSettingsSummary();
|
|
||||||
ITerminalConnector[] getConnectors();
|
String getSelection();
|
||||||
void setFocus();
|
|
||||||
ITerminalConnector getTerminalConnector();
|
TerminalState getState();
|
||||||
void setConnector(ITerminalConnector connector);
|
|
||||||
void connectTerminal();
|
Clipboard getClipboard();
|
||||||
/**
|
|
||||||
* @param write a single character to terminal
|
void disconnectTerminal();
|
||||||
*/
|
|
||||||
void sendKey(char arg0);
|
void disposeTerminal();
|
||||||
|
|
||||||
|
String getSettingsSummary();
|
||||||
|
|
||||||
|
ITerminalConnector[] getConnectors();
|
||||||
|
|
||||||
|
void setFocus();
|
||||||
|
|
||||||
|
ITerminalConnector getTerminalConnector();
|
||||||
|
|
||||||
|
void setConnector(ITerminalConnector connector);
|
||||||
|
|
||||||
|
void connectTerminal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param write a single character to terminal
|
||||||
|
*/
|
||||||
|
void sendKey(char arg0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string write string to terminal
|
* @param string write string to terminal
|
||||||
*/
|
*/
|
||||||
public boolean pasteString(String string);
|
public boolean pasteString(String string);
|
||||||
|
|
||||||
boolean isConnected();
|
boolean isConnected();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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
|
||||||
ICommandInputField getCommandInputField();
|
*/
|
||||||
|
ICommandInputField getCommandInputField();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the maximum number of lines to display
|
* @return the maximum number of lines to display
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public interface ImageConsts {
|
||||||
public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$
|
public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$
|
||||||
public final static String IMAGE_DIR_LOCALTOOL = IMAGE_DIR_ROOT + "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
|
public final static String IMAGE_DIR_LOCALTOOL = IMAGE_DIR_ROOT + "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
|
||||||
public final static String IMAGE_DIR_DLCL = IMAGE_DIR_ROOT + "dlcl16/"; // disabled - size 16x16 //$NON-NLS-1$
|
public final static String IMAGE_DIR_DLCL = IMAGE_DIR_ROOT + "dlcl16/"; // disabled - size 16x16 //$NON-NLS-1$
|
||||||
public final static String IMAGE_DIR_ELCL = IMAGE_DIR_ROOT+ "elcl16/"; // enabled - size 16x16 //$NON-NLS-1$
|
public final static String IMAGE_DIR_ELCL = IMAGE_DIR_ROOT + "elcl16/"; // enabled - size 16x16 //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String IMAGE_CLCL_CLEAR_ALL = "ImageClclClearAll"; //$NON-NLS-1$
|
public static final String IMAGE_CLCL_CLEAR_ALL = "ImageClclClearAll"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -19,14 +19,14 @@ public class TerminalMessages extends NLS {
|
||||||
NLS.initializeMessages(TerminalMessages.class.getName(), TerminalMessages.class);
|
NLS.initializeMessages(TerminalMessages.class.getName(), TerminalMessages.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String TerminalError;
|
public static String TerminalError;
|
||||||
public static String SocketError;
|
public static String SocketError;
|
||||||
public static String IOError;
|
public static String IOError;
|
||||||
public static String CannotConnectTo;
|
public static String CannotConnectTo;
|
||||||
public static String NotInitialized;
|
public static String NotInitialized;
|
||||||
|
|
||||||
//Preference Page
|
//Preference Page
|
||||||
public static String INVERT_COLORS;
|
public static String INVERT_COLORS;
|
||||||
public static String BUFFERLINES;
|
public static String BUFFERLINES;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,15 @@ import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
public class TerminalPlugin extends AbstractUIPlugin {
|
public class TerminalPlugin extends AbstractUIPlugin {
|
||||||
private static TerminalPlugin plugin;
|
private static TerminalPlugin plugin;
|
||||||
public static final String PLUGIN_ID = "org.eclipse.tm.terminal.control"; //$NON-NLS-1$
|
public static final String PLUGIN_ID = "org.eclipse.tm.terminal.control"; //$NON-NLS-1$
|
||||||
public static final String HELP_VIEW = PLUGIN_ID + ".terminal_view"; //$NON-NLS-1$
|
public static final String HELP_VIEW = PLUGIN_ID + ".terminal_view"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
*/
|
*/
|
||||||
public TerminalPlugin() {
|
public TerminalPlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the shared instance.
|
* Returns the shared instance.
|
||||||
*/
|
*/
|
||||||
|
@ -50,7 +51,7 @@ public class TerminalPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +60,7 @@ public class TerminalPlugin extends AbstractUIPlugin {
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
plugin = null;
|
plugin = null;
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
|
@ -73,20 +74,24 @@ public class TerminalPlugin extends AbstractUIPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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);
|
||||||
|
|
|
@ -33,7 +33,7 @@ class EditActionAccelerators {
|
||||||
|
|
||||||
private void addAccelerator(String commandId) {
|
private void addAccelerator(String commandId) {
|
||||||
TriggerSequence[] bindings = bindingsFor(commandId);
|
TriggerSequence[] bindings = bindingsFor(commandId);
|
||||||
for (int i=0; i<bindings.length; ++i) {
|
for (int i = 0; i < bindings.length; ++i) {
|
||||||
if (bindings[i] instanceof KeySequence) {
|
if (bindings[i] instanceof KeySequence) {
|
||||||
KeyStroke[] keyStrokes = ((KeySequence) bindings[i]).getKeyStrokes();
|
KeyStroke[] keyStrokes = ((KeySequence) bindings[i]).getKeyStrokes();
|
||||||
if (keyStrokes.length != 0) {
|
if (keyStrokes.length != 0) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LoggingOutputStream extends FilterOutputStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
if(Logger.isLogEnabled())
|
if (Logger.isLogEnabled())
|
||||||
Logger.log("Received " + len + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$
|
Logger.log("Received " + len + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
Logger.encode(new String(b, 0, len)) + "'"); //$NON-NLS-1$
|
Logger.encode(new String(b, 0, len)) + "'"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -31,17 +31,17 @@ public class LoggingOutputStream extends FilterOutputStream {
|
||||||
// which logs character by character.....
|
// which logs character by character.....
|
||||||
//super.write(b, off, len);
|
//super.write(b, off, len);
|
||||||
if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
|
if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
|
||||||
for (int i = 0 ; i < len ; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
super.write(b[off + i]);
|
super.write(b[off + i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
if(Logger.isLogEnabled())
|
if (Logger.isLogEnabled())
|
||||||
Logger.log("Received " + 1 + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$
|
Logger.log("Received " + 1 + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
Logger.encode(new String(new byte[]{(byte)b}, 0, 1)) + "'"); //$NON-NLS-1$
|
Logger.encode(new String(new byte[] { (byte) b }, 0, 1)) + "'"); //$NON-NLS-1$
|
||||||
super.write(b);
|
super.write(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,14 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendString(String buffer) {
|
public void appendString(String buffer) {
|
||||||
fWriter.println("appendString(\""+buffer+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("appendString(\"" + buffer + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.appendString(buffer);
|
fBackend.appendString(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +37,12 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteCharacters(int n) {
|
public void deleteCharacters(int n) {
|
||||||
fWriter.println("deleteCharacters("+n+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("deleteCharacters(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.deleteCharacters(n);
|
fBackend.deleteCharacters(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteLines(int n) {
|
public void deleteLines(int n) {
|
||||||
fWriter.println("deleteLines("+n+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("deleteLines(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.deleteLines(n);
|
fBackend.deleteLines(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,12 +101,12 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertCharacters(int charactersToInsert) {
|
public void insertCharacters(int charactersToInsert) {
|
||||||
fWriter.println("insertCharacters("+charactersToInsert+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("insertCharacters(" + charactersToInsert + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.insertCharacters(charactersToInsert);
|
fBackend.insertCharacters(charactersToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertLines(int n) {
|
public void insertLines(int n) {
|
||||||
fWriter.println("insertLines("+n+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("insertLines(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.insertLines(n);
|
fBackend.insertLines(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,37 +116,37 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursor(int targetLine, int targetColumn) {
|
public void setCursor(int targetLine, int targetColumn) {
|
||||||
fWriter.println("setCursor("+targetLine+", "+targetColumn+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
fWriter.println("setCursor(" + targetLine + ", " + targetColumn + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
fBackend.setCursor(targetLine, targetColumn);
|
fBackend.setCursor(targetLine, targetColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorColumn(int targetColumn) {
|
public void setCursorColumn(int targetColumn) {
|
||||||
fWriter.println("setCursorColumn("+targetColumn+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setCursorColumn(" + targetColumn + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setCursorColumn(targetColumn);
|
fBackend.setCursorColumn(targetColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursorLine(int targetLine) {
|
public void setCursorLine(int targetLine) {
|
||||||
fWriter.println("setCursorLine("+targetLine+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setCursorLine(" + targetLine + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setCursorLine(targetLine);
|
fBackend.setCursorLine(targetLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultStyle(Style defaultStyle) {
|
public void setDefaultStyle(Style defaultStyle) {
|
||||||
fWriter.println("setDefaultStyle("+defaultStyle+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setDefaultStyle(" + defaultStyle + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setDefaultStyle(defaultStyle);
|
fBackend.setDefaultStyle(defaultStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimensions(int lines, int cols) {
|
public void setDimensions(int lines, int cols) {
|
||||||
fWriter.println("setDimensions("+lines+","+cols+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
fWriter.println("setDimensions(" + lines + "," + cols + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
fBackend.setDimensions(lines, cols);
|
fBackend.setDimensions(lines, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStyle(Style style) {
|
public void setStyle(Style style) {
|
||||||
fWriter.println("setStyle("+style+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setStyle(" + style + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setStyle(style);
|
fBackend.setStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVT100LineWrapping(boolean enable) {
|
public void setVT100LineWrapping(boolean enable) {
|
||||||
fWriter.println("setVT100LineWrapping("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setVT100LineWrapping(" + enable + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setVT100LineWrapping(enable);
|
fBackend.setVT100LineWrapping(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,22 +155,22 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInsertMode(boolean enable) {
|
public void setInsertMode(boolean enable) {
|
||||||
fWriter.println("setInsertMode("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setInsertMode(" + enable + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setInsertMode(enable);
|
fBackend.setInsertMode(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScrollRegion(int top, int bottom) {
|
public void setScrollRegion(int top, int bottom) {
|
||||||
fWriter.println("setScrollRegion("+top+','+bottom+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("setScrollRegion(" + top + ',' + bottom + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.setScrollRegion(top, bottom);
|
fBackend.setScrollRegion(top, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollUp(int lines) {
|
public void scrollUp(int lines) {
|
||||||
fWriter.println("scrollUp("+lines+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("scrollUp(" + lines + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.scrollUp(lines);
|
fBackend.scrollUp(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollDown(int lines) {
|
public void scrollDown(int lines) {
|
||||||
fWriter.println("scrollDown("+lines+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
fWriter.println("scrollDown(" + lines + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fBackend.scrollDown(lines);
|
fBackend.scrollDown(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -154,13 +154,13 @@ public class VT100Emulator implements ControlListener {
|
||||||
ansiParameters[i] = new StringBuffer();
|
ansiParameters[i] = new StringBuffer();
|
||||||
}
|
}
|
||||||
setInputStreamReader(reader);
|
setInputStreamReader(reader);
|
||||||
if(TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND))
|
if (TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND))
|
||||||
text=new VT100BackendTraceDecorator(new VT100EmulatorBackend(data),System.out);
|
text = new VT100BackendTraceDecorator(new VT100EmulatorBackend(data), System.out);
|
||||||
else
|
else
|
||||||
text=new VT100EmulatorBackend(data);
|
text = new VT100EmulatorBackend(data);
|
||||||
|
|
||||||
// text.setDimensions(24, 80);
|
// text.setDimensions(24, 80);
|
||||||
Style style=Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$ //$NON-NLS-2$
|
Style style = Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
text.setDefaultStyle(style);
|
text.setDefaultStyle(style);
|
||||||
text.setStyle(style);
|
text.setStyle(style);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
fReader = reader;
|
fReader = reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimensions(int lines,int cols) {
|
public void setDimensions(int lines, int cols) {
|
||||||
text.setDimensions(lines, cols);
|
text.setDimensions(lines, cols);
|
||||||
ITerminalConnector telnetConnection = getConnector();
|
ITerminalConnector telnetConnection = getConnector();
|
||||||
if (telnetConnection != null) {
|
if (telnetConnection != null) {
|
||||||
|
@ -236,22 +236,23 @@ 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
|
// /**
|
||||||
// * the remote host by class {@link org.eclipse.tm.internal.terminal.telnet.TelnetConnection} and
|
// * This method executes in the Display thread to process data received from
|
||||||
// * other implementors of {@link ITerminalConnector}, like the
|
// * the remote host by class {@link org.eclipse.tm.internal.terminal.telnet.TelnetConnection} and
|
||||||
// * SerialPortHandler.
|
// * other implementors of {@link ITerminalConnector}, like the
|
||||||
// * <p>
|
// * SerialPortHandler.
|
||||||
// * These connectors write text to the terminal's buffer through
|
// * <p>
|
||||||
// * {@link TerminalControl#writeToTerminal(String)} and then have
|
// * These connectors write text to the terminal's buffer through
|
||||||
// * this run method executed in the display thread. This method
|
// * {@link TerminalControl#writeToTerminal(String)} and then have
|
||||||
// * must not execute at the same time as methods
|
// * this run method executed in the display thread. This method
|
||||||
// * {@link #setNewText(StringBuffer)} and {@link #clearTerminal()}.
|
// * must not execute at the same time as methods
|
||||||
// * <p>
|
// * {@link #setNewText(StringBuffer)} and {@link #clearTerminal()}.
|
||||||
// * IMPORTANT: This method must be called in strict alternation with method
|
// * <p>
|
||||||
// * {@link #setNewText(StringBuffer)}.
|
// * IMPORTANT: This method must be called in strict alternation with method
|
||||||
// * <p>
|
// * {@link #setNewText(StringBuffer)}.
|
||||||
// */
|
// * <p>
|
||||||
|
// */
|
||||||
public void processText() {
|
public void processText() {
|
||||||
try {
|
try {
|
||||||
// Find the width and height of the terminal, and resize it to display an
|
// Find the width and height of the terminal, and resize it to display an
|
||||||
|
@ -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()) {
|
||||||
|
@ -309,7 +310,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
processNewline(); // Newline (Control-J)
|
processNewline(); // Newline (Control-J)
|
||||||
if(fCrAfterNewLine)
|
if (fCrAfterNewLine)
|
||||||
processCarriageReturn(); // Carriage Return (Control-M)
|
processCarriageReturn(); // Carriage Return (Control-M)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -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));
|
||||||
|
@ -838,15 +839,14 @@ public class VT100Emulator implements ControlListener {
|
||||||
|
|
||||||
ansiParameters[0].append('0');
|
ansiParameters[0].append('0');
|
||||||
}
|
}
|
||||||
Style style=text.getStyle();
|
Style style = text.getStyle();
|
||||||
// There are a non-zero number of ANSI parameters. Process each one in
|
// There are a non-zero number of ANSI parameters. Process each one in
|
||||||
// order.
|
// order.
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -896,15 +896,15 @@ public class VT100Emulator implements ControlListener {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 31:
|
case 31:
|
||||||
style = style.setForground("RED"); //$NON-NLS-1$
|
style = style.setForground("RED"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32:
|
case 32:
|
||||||
style = style.setForground("GREEN"); //$NON-NLS-1$
|
style = style.setForground("GREEN"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 33:
|
case 33:
|
||||||
style = style.setForground("YELLOW"); //$NON-NLS-1$
|
style = style.setForground("YELLOW"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 34:
|
case 34:
|
||||||
|
@ -912,7 +912,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 35:
|
case 35:
|
||||||
style = style.setForground("MAGENTA"); //$NON-NLS-1$
|
style = style.setForground("MAGENTA"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 36:
|
case 36:
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,7 +1024,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
top = getAnsiParameter(0);
|
top = getAnsiParameter(0);
|
||||||
bottom = getAnsiParameter(1);
|
bottom = getAnsiParameter(1);
|
||||||
}
|
}
|
||||||
text.setScrollRegion(top-1, bottom-1);
|
text.setScrollRegion(top - 1, bottom - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
||||||
|
@ -1137,15 +1137,14 @@ public class VT100Emulator implements ControlListener {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void processNonControlCharacters(char character) throws IOException {
|
private void processNonControlCharacters(char character) throws IOException {
|
||||||
StringBuffer buffer=new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(character);
|
buffer.append(character);
|
||||||
// Identify a contiguous sequence of non-control characters, starting at
|
// Identify a contiguous sequence of non-control characters, starting at
|
||||||
// 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.
|
||||||
*/
|
*/
|
||||||
|
@ -1251,8 +1249,8 @@ public class VT100Emulator implements ControlListener {
|
||||||
// to make it display an integral number of lines of text.
|
// to make it display an integral number of lines of text.
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// if(text.getColumns()!=80 && text.getLines()!=80)
|
// if(text.getColumns()!=80 && text.getLines()!=80)
|
||||||
// text.setDimensions(24, 80);
|
// text.setDimensions(24, 80);
|
||||||
// If we are in a TELNET connection and we know the dimensions of the terminal,
|
// If we are in a TELNET connection and we know the dimensions of the terminal,
|
||||||
// we give the size information to the TELNET connection object so it can
|
// we give the size information to the TELNET connection object so it can
|
||||||
// communicate it to the TELNET server. If we are in a serial connection,
|
// communicate it to the TELNET server. If we are in a serial connection,
|
||||||
|
@ -1267,7 +1265,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITerminalConnector getConnector() {
|
private ITerminalConnector getConnector() {
|
||||||
if(terminal.getTerminalConnector()!=null)
|
if (terminal.getTerminalConnector() != null)
|
||||||
return terminal.getTerminalConnector();
|
return terminal.getTerminalConnector();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1291,7 +1289,7 @@ public class VT100Emulator implements ControlListener {
|
||||||
* contain any text to move the cursor to any column in that line.
|
* contain any text to move the cursor to any column in that line.
|
||||||
*/
|
*/
|
||||||
private void moveCursor(int targetLine, int targetColumn) {
|
private void moveCursor(int targetLine, int targetColumn) {
|
||||||
text.setCursor(targetLine,targetColumn);
|
text.setCursor(targetLine, targetColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1330,42 +1328,43 @@ 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.
|
||||||
*/
|
*/
|
||||||
public void resetState() {
|
public void resetState() {
|
||||||
ansiState=ANSISTATE_INITIAL;
|
ansiState = ANSISTATE_INITIAL;
|
||||||
text.setStyle(text.getDefaultStyle());
|
text.setStyle(text.getDefaultStyle());
|
||||||
text.setScrollRegion(-1, -1);
|
text.setScrollRegion(-1, -1);
|
||||||
text.setInsertMode(false);
|
text.setInsertMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public OutputStream getOutputStream() {
|
// public OutputStream getOutputStream() {
|
||||||
// return fTerminalInputStream.getOutputStream();
|
// return fTerminalInputStream.getOutputStream();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffer for {@link #pushBackChar(char)}.
|
* Buffer for {@link #pushBackChar(char)}.
|
||||||
*/
|
*/
|
||||||
private int fNextChar=-1;
|
private int fNextChar = -1;
|
||||||
|
|
||||||
private char getNextChar() throws IOException {
|
private char getNextChar() throws IOException {
|
||||||
int c=-1;
|
int c = -1;
|
||||||
if(fNextChar!=-1) {
|
if (fNextChar != -1) {
|
||||||
c= fNextChar;
|
c = fNextChar;
|
||||||
fNextChar=-1;
|
fNextChar = -1;
|
||||||
} else {
|
} else {
|
||||||
c = fReader.read();
|
c = fReader.read();
|
||||||
}
|
}
|
||||||
// TODO: better end of file handling
|
// TODO: better end of file handling
|
||||||
if(c==-1)
|
if (c == -1)
|
||||||
c=0;
|
c = 0;
|
||||||
return (char)c;
|
return (char) c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasNextChar() throws IOException {
|
private boolean hasNextChar() throws IOException {
|
||||||
if(fNextChar>=0)
|
if (fNextChar >= 0)
|
||||||
return true;
|
return true;
|
||||||
return fReader.ready();
|
return fReader.ready();
|
||||||
}
|
}
|
||||||
|
@ -1378,20 +1377,25 @@ public class VT100Emulator implements ControlListener {
|
||||||
*/
|
*/
|
||||||
void pushBackChar(char c) {
|
void pushBackChar(char c) {
|
||||||
//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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,22 +26,27 @@ import org.eclipse.tm.terminal.model.Style;
|
||||||
public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
|
|
||||||
private static class ScrollRegion {
|
private static class ScrollRegion {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +96,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
private ScrollRegion fScrollRegion = ScrollRegion.FULL_WINDOW;
|
private ScrollRegion fScrollRegion = ScrollRegion.FULL_WINDOW;
|
||||||
|
|
||||||
public VT100EmulatorBackend(ITerminalTextData terminal) {
|
public VT100EmulatorBackend(ITerminalTextData terminal) {
|
||||||
fTerminal=terminal;
|
fTerminal = terminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -100,7 +105,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
public void clearAll() {
|
public void clearAll() {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
// clear the history
|
// clear the history
|
||||||
int n=fTerminal.getHeight();
|
int n = fTerminal.getHeight();
|
||||||
for (int line = 0; line < n; line++) {
|
for (int line = 0; line < n; line++) {
|
||||||
fTerminal.cleanLine(line);
|
fTerminal.cleanLine(line);
|
||||||
}
|
}
|
||||||
|
@ -109,34 +114,35 @@ 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)
|
||||||
*/
|
*/
|
||||||
public void setDimensions(int lines, int cols) {
|
public void setDimensions(int lines, int cols) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(lines==fLines && cols==fColumns)
|
if (lines == fLines && cols == fColumns)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
// relative cursor line
|
// relative cursor line
|
||||||
int cl=getCursorLine();
|
int cl = getCursorLine();
|
||||||
int cc=getCursorColumn();
|
int cc = getCursorColumn();
|
||||||
int height=fTerminal.getHeight();
|
int height = fTerminal.getHeight();
|
||||||
// absolute cursor line
|
// absolute cursor line
|
||||||
int acl=cl+height-fLines;
|
int acl = cl + height - fLines;
|
||||||
int newLines=Math.max(lines,height);
|
int newLines = Math.max(lines, height);
|
||||||
if(lines<fLines) {
|
if (lines < fLines) {
|
||||||
if(height==fLines) {
|
if (height == fLines) {
|
||||||
// if the terminal has no history, then resize by
|
// if the terminal has no history, then resize by
|
||||||
// setting the size to the new size
|
// setting the size to the new size
|
||||||
// TODO We are assuming that cursor line points at end of text
|
// TODO We are assuming that cursor line points at end of text
|
||||||
newLines=Math.max(lines, cl+1);
|
newLines = Math.max(lines, cl + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fLines=lines;
|
fLines = lines;
|
||||||
fColumns=cols;
|
fColumns = cols;
|
||||||
// make the terminal at least as high as we need lines
|
// make the terminal at least as high as we need lines
|
||||||
fTerminal.setDimensions(newLines, fColumns);
|
fTerminal.setDimensions(newLines, fColumns);
|
||||||
// compute relative cursor line
|
// compute relative cursor line
|
||||||
cl=acl-(newLines-fLines);
|
cl = acl - (newLines - fLines);
|
||||||
setCursor(cl, cc);
|
setCursor(cl, cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,24 +154,25 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
*/
|
*/
|
||||||
public int toAbsoluteLine(int line) {
|
public int toAbsoluteLine(int line) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void insertCharacters(int charactersToInsert) {
|
public void insertCharacters(int charactersToInsert) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
int n=charactersToInsert;
|
int n = charactersToInsert;
|
||||||
for (int col = fColumns-1; col >=fCursorColumn+n; col--) {
|
for (int col = fColumns - 1; col >= fCursorColumn + n; col--) {
|
||||||
char c=fTerminal.getChar(line, col-n);
|
char c = fTerminal.getChar(line, col - n);
|
||||||
Style style=fTerminal.getStyle(line, col-n);
|
Style style = fTerminal.getStyle(line, col - n);
|
||||||
fTerminal.setChar(line, col,c, style);
|
fTerminal.setChar(line, col, c, style);
|
||||||
}
|
}
|
||||||
int last=Math.min(fCursorColumn+n, fColumns);
|
int last = Math.min(fCursorColumn + n, fColumns);
|
||||||
for (int col = fCursorColumn; col <last; col++) {
|
for (int col = fCursorColumn; col < last; col++) {
|
||||||
fTerminal.setChar(line, col,'\000', null);
|
fTerminal.setChar(line, col, '\000', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,12 +183,13 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
public void eraseToEndOfScreen() {
|
public void eraseToEndOfScreen() {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
eraseLineToEnd();
|
eraseLineToEnd();
|
||||||
for (int line = toAbsoluteLine(fCursorLine+1); line < toAbsoluteLine(fLines); line++) {
|
for (int line = toAbsoluteLine(fCursorLine + 1); line < toAbsoluteLine(fLines); line++) {
|
||||||
fTerminal.cleanLine(line);
|
fTerminal.cleanLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (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,23 +221,25 @@ 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()
|
||||||
*/
|
*/
|
||||||
public void eraseLineToEnd() {
|
public void eraseLineToEnd() {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
for (int col = fCursorColumn; col < fColumns; col++) {
|
for (int col = fCursorColumn; col < fColumns; col++) {
|
||||||
fTerminal.setChar(line, col, '\000', null);
|
fTerminal.setChar(line, col, '\000', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToCursor()
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToCursor()
|
||||||
*/
|
*/
|
||||||
public void eraseLineToCursor() {
|
public void eraseLineToCursor() {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
for (int col = 0; col <= fCursorColumn; col++) {
|
for (int col = 0; col <= fCursorColumn; col++) {
|
||||||
fTerminal.setChar(line, col, '\000', null);
|
fTerminal.setChar(line, col, '\000', null);
|
||||||
}
|
}
|
||||||
|
@ -239,44 +251,47 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
*/
|
*/
|
||||||
public void insertLines(int n) {
|
public void insertLines(int n) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(!isCusorInScrollingRegion())
|
if (!isCusorInScrollingRegion())
|
||||||
return;
|
return;
|
||||||
assert n>0;
|
assert n > 0;
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
int nLines=Math.min(fTerminal.getHeight()-line, fScrollRegion.getBottomLine()-fCursorLine+1);
|
int nLines = Math.min(fTerminal.getHeight() - line, fScrollRegion.getBottomLine() - fCursorLine + 1);
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void deleteCharacters(int n) {
|
public void deleteCharacters(int n) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
for (int col = fCursorColumn+n; col < fColumns; col++) {
|
for (int col = fCursorColumn + n; col < fColumns; col++) {
|
||||||
char c=fTerminal.getChar(line, col);
|
char c = fTerminal.getChar(line, col);
|
||||||
Style style=fTerminal.getStyle(line, col);
|
Style style = fTerminal.getStyle(line, col);
|
||||||
fTerminal.setChar(line, col-n,c, style);
|
fTerminal.setChar(line, col - n, c, style);
|
||||||
}
|
}
|
||||||
int first=Math.max(fCursorColumn, fColumns-n);
|
int first = Math.max(fCursorColumn, fColumns - n);
|
||||||
for (int col = first; col <fColumns; col++) {
|
for (int col = first; col < fColumns; col++) {
|
||||||
fTerminal.setChar(line, col,'\000', null);
|
fTerminal.setChar(line, col, '\000', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteLines(int)
|
* @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteLines(int)
|
||||||
*/
|
*/
|
||||||
public void deleteLines(int n) {
|
public void deleteLines(int n) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(!isCusorInScrollingRegion())
|
if (!isCusorInScrollingRegion())
|
||||||
return;
|
return;
|
||||||
assert n>0;
|
assert n > 0;
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
int nLines=Math.min(fTerminal.getHeight()-line, fScrollRegion.getBottomLine()-fCursorLine+1);
|
int nLines = Math.min(fTerminal.getHeight() - line, fScrollRegion.getBottomLine() - fCursorLine + 1);
|
||||||
fTerminal.scroll(line, nLines, -n);
|
fTerminal.scroll(line, nLines, -n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCusorInScrollingRegion() {
|
private boolean isCusorInScrollingRegion() {
|
||||||
return fScrollRegion.contains(fCursorLine);
|
return fScrollRegion.contains(fCursorLine);
|
||||||
}
|
}
|
||||||
|
@ -304,39 +319,41 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
*/
|
*/
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(fStyle==null)
|
if (fStyle == null)
|
||||||
return fDefaultStyle;
|
return fDefaultStyle;
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void setStyle(Style style) {
|
public void setStyle(Style style) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void appendString(String buffer) {
|
public void appendString(String buffer) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
char[] chars=buffer.toCharArray();
|
char[] chars = buffer.toCharArray();
|
||||||
if (fInsertMode)
|
if (fInsertMode)
|
||||||
insertCharacters(chars.length);
|
insertCharacters(chars.length);
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line = toAbsoluteLine(fCursorLine);
|
||||||
int i=0;
|
int i = 0;
|
||||||
while (i < chars.length) {
|
while (i < chars.length) {
|
||||||
if(fWrapPending) {
|
if (fWrapPending) {
|
||||||
line = doLineWrap();
|
line = doLineWrap();
|
||||||
}
|
}
|
||||||
int n=Math.min(fColumns-fCursorColumn,chars.length-i);
|
int n = Math.min(fColumns - fCursorColumn, chars.length - i);
|
||||||
fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle);
|
fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle);
|
||||||
int col=fCursorColumn+n;
|
int col = fCursorColumn + n;
|
||||||
i+=n;
|
i += n;
|
||||||
// wrap needed?
|
// wrap needed?
|
||||||
if(col == fColumns) {
|
if (col == fColumns) {
|
||||||
if (fVT100LineWrapping) {
|
if (fVT100LineWrapping) {
|
||||||
// deferred line wrapping (eat_newline_glitch)
|
// deferred line wrapping (eat_newline_glitch)
|
||||||
setCursorColumn(col - 1);
|
setCursorColumn(col - 1);
|
||||||
|
@ -353,10 +370,10 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
|
|
||||||
private int doLineWrap() {
|
private int doLineWrap() {
|
||||||
int line;
|
int line;
|
||||||
line=toAbsoluteLine(fCursorLine);
|
line = toAbsoluteLine(fCursorLine);
|
||||||
fTerminal.setWrappedLine(line);
|
fTerminal.setWrappedLine(line);
|
||||||
doNewline();
|
doNewline();
|
||||||
line=toAbsoluteLine(fCursorLine);
|
line = toAbsoluteLine(fCursorLine);
|
||||||
setCursorColumn(0);
|
setCursorColumn(0);
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -367,15 +384,16 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
private void doNewline() {
|
private void doNewline() {
|
||||||
if (fCursorLine == fScrollRegion.getBottomLine())
|
if (fCursorLine == fScrollRegion.getBottomLine())
|
||||||
scrollUp(1);
|
scrollUp(1);
|
||||||
else if (fCursorLine+1>=fLines) {
|
else if (fCursorLine + 1 >= fLines) {
|
||||||
int h=fTerminal.getHeight();
|
int h = fTerminal.getHeight();
|
||||||
fTerminal.addLine();
|
fTerminal.addLine();
|
||||||
if(h!=fTerminal.getHeight())
|
if (h != fTerminal.getHeight())
|
||||||
setCursorLine(fCursorLine+1);
|
setCursorLine(fCursorLine + 1);
|
||||||
} else {
|
} else {
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
|
@ -415,11 +436,11 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
*/
|
*/
|
||||||
public void setCursorColumn(int targetColumn) {
|
public void setCursorColumn(int targetColumn) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(targetColumn<0)
|
if (targetColumn < 0)
|
||||||
targetColumn=0;
|
targetColumn = 0;
|
||||||
else if(targetColumn>=fColumns)
|
else if (targetColumn >= fColumns)
|
||||||
targetColumn=fColumns-1;
|
targetColumn = fColumns - 1;
|
||||||
fCursorColumn=targetColumn;
|
fCursorColumn = targetColumn;
|
||||||
fWrapPending = false;
|
fWrapPending = false;
|
||||||
// We make the assumption that nobody is changing the
|
// We make the assumption that nobody is changing the
|
||||||
// terminal cursor except this class!
|
// terminal cursor except this class!
|
||||||
|
@ -433,11 +454,11 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
*/
|
*/
|
||||||
public void setCursorLine(int targetLine) {
|
public void setCursorLine(int targetLine) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(targetLine<0)
|
if (targetLine < 0)
|
||||||
targetLine=0;
|
targetLine = 0;
|
||||||
else if(targetLine>=fLines)
|
else if (targetLine >= fLines)
|
||||||
targetLine=fLines-1;
|
targetLine = fLines - 1;
|
||||||
fCursorLine=targetLine;
|
fCursorLine = targetLine;
|
||||||
// We make the assumption that nobody is changing the
|
// We make the assumption that nobody is changing the
|
||||||
// terminal cursor except this class!
|
// terminal cursor except this class!
|
||||||
// This assumption gives a huge performance improvement
|
// This assumption gives a huge performance improvement
|
||||||
|
@ -477,25 +498,25 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
|
|
||||||
public void setScrollRegion(int top, int bottom) {
|
public void setScrollRegion(int top, int bottom) {
|
||||||
if (top < 0 || bottom < 0)
|
if (top < 0 || bottom < 0)
|
||||||
fScrollRegion = ScrollRegion.FULL_WINDOW;
|
fScrollRegion = ScrollRegion.FULL_WINDOW;
|
||||||
else if (top < bottom)
|
else if (top < bottom)
|
||||||
fScrollRegion = new ScrollRegion(top, bottom);
|
fScrollRegion = new ScrollRegion(top, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollUp(int n) {
|
public void scrollUp(int n) {
|
||||||
assert n>0;
|
assert n > 0;
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
int line = toAbsoluteLine(fScrollRegion.getTopLine());
|
int line = toAbsoluteLine(fScrollRegion.getTopLine());
|
||||||
int nLines = Math.min(fTerminal.getHeight()-line, fScrollRegion.getHeight());
|
int nLines = Math.min(fTerminal.getHeight() - line, fScrollRegion.getHeight());
|
||||||
fTerminal.scroll(line, nLines, -n);
|
fTerminal.scroll(line, nLines, -n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollDown(int n) {
|
public void scrollDown(int n) {
|
||||||
assert n>0;
|
assert n > 0;
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
int line = toAbsoluteLine(fScrollRegion.getTopLine());
|
int line = toAbsoluteLine(fScrollRegion.getTopLine());
|
||||||
int nLines = Math.min(fTerminal.getHeight()-line, fScrollRegion.getHeight());
|
int nLines = Math.min(fTerminal.getHeight() - line, fScrollRegion.getHeight());
|
||||||
fTerminal.scroll(line, nLines, n);
|
fTerminal.scroll(line, nLines, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,30 +125,29 @@ 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$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field holds a reference to a TerminalText object that performs all ANSI
|
* This field holds a reference to a TerminalText object that performs all ANSI
|
||||||
* text processing on data received from the remote host and controls how text is
|
* text processing on data received from the remote host and controls how text is
|
||||||
* displayed using the view's StyledText widget.
|
* displayed using the view's StyledText widget.
|
||||||
*/
|
*/
|
||||||
private final VT100Emulator fTerminalText;
|
private final VT100Emulator fTerminalText;
|
||||||
private Display fDisplay;
|
private Display fDisplay;
|
||||||
private TextCanvas fCtlText;
|
private TextCanvas fCtlText;
|
||||||
private Composite fWndParent;
|
private Composite fWndParent;
|
||||||
private Clipboard fClipboard;
|
private Clipboard fClipboard;
|
||||||
private KeyListener fKeyHandler;
|
private KeyListener fKeyHandler;
|
||||||
private final ITerminalListener fTerminalListener;
|
private final ITerminalListener fTerminalListener;
|
||||||
private String fMsg = ""; //$NON-NLS-1$
|
private String fMsg = ""; //$NON-NLS-1$
|
||||||
private TerminalMouseTrackListener fFocusListener;
|
private TerminalMouseTrackListener fFocusListener;
|
||||||
private ITerminalConnector fConnector;
|
private ITerminalConnector fConnector;
|
||||||
private final ITerminalConnector[] fConnectors;
|
private final ITerminalConnector[] fConnectors;
|
||||||
private final boolean fUseCommonPrefs;
|
private final boolean fUseCommonPrefs;
|
||||||
private boolean connectOnEnterIfClosed = true;
|
private boolean connectOnEnterIfClosed = true;
|
||||||
|
|
||||||
PipedInputStream fInputStream;
|
PipedInputStream fInputStream;
|
||||||
private static final String defaultEncoding = Charset.defaultCharset().name();
|
private static final String defaultEncoding = Charset.defaultCharset().name();
|
||||||
private String fEncoding = defaultEncoding;
|
private String fEncoding = defaultEncoding;
|
||||||
private InputStreamReader fInputStreamReader;
|
private InputStreamReader fInputStreamReader;
|
||||||
|
@ -166,10 +165,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
/**
|
/**
|
||||||
* Listens to changes in the preferences
|
* Listens to changes in the preferences
|
||||||
*/
|
*/
|
||||||
private final IPropertyChangeListener fPreferenceListener=new IPropertyChangeListener() {
|
private final IPropertyChangeListener fPreferenceListener = new IPropertyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
if(event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES)
|
if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES)
|
||||||
|| event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) {
|
|| event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) {
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
}
|
}
|
||||||
|
@ -177,7 +176,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
};
|
};
|
||||||
private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() {
|
private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) {
|
if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) {
|
||||||
onTerminalFontChanged();
|
onTerminalFontChanged();
|
||||||
}
|
}
|
||||||
|
@ -205,13 +204,14 @@ 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,
|
||||||
fConnectors=connectors;
|
boolean useCommonPrefs) {
|
||||||
|
fConnectors = connectors;
|
||||||
fUseCommonPrefs = useCommonPrefs;
|
fUseCommonPrefs = useCommonPrefs;
|
||||||
fTerminalListener=target;
|
fTerminalListener = target;
|
||||||
fTerminalModel=TerminalTextDataFactory.makeTerminalTextData();
|
fTerminalModel = TerminalTextDataFactory.makeTerminalTextData();
|
||||||
fTerminalModel.setMaxHeight(1000);
|
fTerminalModel.setMaxHeight(1000);
|
||||||
fInputStream=new PipedInputStream(8*1024);
|
fInputStream = new PipedInputStream(8 * 1024);
|
||||||
fTerminalText = new VT100Emulator(fTerminalModel, this, null);
|
fTerminalText = new VT100Emulator(fTerminalModel, this, null);
|
||||||
try {
|
try {
|
||||||
// Use Default Encoding as start, until setEncoding() is called
|
// Use Default Encoding as start, until setEncoding() is called
|
||||||
|
@ -229,7 +229,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEncoding(String encoding) throws UnsupportedEncodingException {
|
public void setEncoding(String encoding) throws UnsupportedEncodingException {
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
// TODO better use a standard remote-to-local encoding?
|
// TODO better use a standard remote-to-local encoding?
|
||||||
encoding = "ISO-8859-1"; //$NON-NLS-1$
|
encoding = "ISO-8859-1"; //$NON-NLS-1$
|
||||||
|
@ -243,12 +243,12 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
return fEncoding;
|
return fEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITerminalConnector[] getConnectors() {
|
public ITerminalConnector[] getConnectors() {
|
||||||
return fConnectors;
|
return fConnectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#copy()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#copy()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void copy() {
|
public void copy() {
|
||||||
copy(DND.CLIPBOARD);
|
copy(DND.CLIPBOARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,17 +273,17 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void paste() {
|
public void paste() {
|
||||||
paste(DND.CLIPBOARD);
|
paste(DND.CLIPBOARD);
|
||||||
// TODO paste in another thread.... to avoid blocking
|
// TODO paste in another thread.... to avoid blocking
|
||||||
// new Thread() {
|
// new Thread() {
|
||||||
// public void run() {
|
// public void run() {
|
||||||
// for (int i = 0; i < strText.length(); i++) {
|
// for (int i = 0; i < strText.length(); i++) {
|
||||||
// sendChar(strText.charAt(i), false);
|
// sendChar(strText.charAt(i), false);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }.start();
|
// }.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paste(int clipboardType) {
|
private void paste(int clipboardType) {
|
||||||
|
@ -296,8 +296,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @param strText the text to paste
|
* @param strText the text to paste
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean pasteString(String strText) {
|
public boolean pasteString(String strText) {
|
||||||
if(!isConnected())
|
if (!isConnected())
|
||||||
return false;
|
return false;
|
||||||
if (strText == null)
|
if (strText == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -316,10 +316,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#selectAll()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#selectAll()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAll() {
|
public void selectAll() {
|
||||||
getCtlText().selectAll();
|
getCtlText().selectAll();
|
||||||
if (fTerminalListener instanceof ITerminalListener2) {
|
if (fTerminalListener instanceof ITerminalListener2) {
|
||||||
((ITerminalListener2)fTerminalListener).setTerminalSelectionChanged();
|
((ITerminalListener2) fTerminalListener).setTerminalSelectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#sendKey(char)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#sendKey(char)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendKey(char character) {
|
public void sendKey(char character) {
|
||||||
Event event;
|
Event event;
|
||||||
KeyEvent keyEvent;
|
KeyEvent keyEvent;
|
||||||
|
|
||||||
|
@ -346,12 +346,12 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#clearTerminal()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#clearTerminal()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void clearTerminal() {
|
public void clearTerminal() {
|
||||||
// The TerminalText object does all text manipulation.
|
// The TerminalText object does all text manipulation.
|
||||||
getTerminalText().clearTerminal();
|
getTerminalText().clearTerminal();
|
||||||
getCtlText().clearSelection();
|
getCtlText().clearSelection();
|
||||||
if (fTerminalListener instanceof ITerminalListener2) {
|
if (fTerminalListener instanceof ITerminalListener2) {
|
||||||
((ITerminalListener2)fTerminalListener).setTerminalSelectionChanged();
|
((ITerminalListener2) fTerminalListener).setTerminalSelectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getClipboard()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getClipboard()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Clipboard getClipboard() {
|
public Clipboard getClipboard() {
|
||||||
return fClipboard;
|
return fClipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,10 +367,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @return non null selection
|
* @return non null selection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getSelection() {
|
public String getSelection() {
|
||||||
String txt= fCtlText.getSelectionText();
|
String txt = fCtlText.getSelectionText();
|
||||||
if(txt==null)
|
if (txt == null)
|
||||||
txt=""; //$NON-NLS-1$
|
txt = ""; //$NON-NLS-1$
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setFocus()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setFocus()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
getCtlText().setFocus();
|
getCtlText().setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isEmpty()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isEmpty()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return getCtlText().isEmpty();
|
return getCtlText().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isDisposed()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isDisposed()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisposed() {
|
public boolean isDisposed() {
|
||||||
return getCtlText().isDisposed();
|
return getCtlText().isDisposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,17 +402,17 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnected()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnected()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return fState==TerminalState.CONNECTED;
|
return fState == TerminalState.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disposeTerminal()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disposeTerminal()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void disposeTerminal() {
|
public void disposeTerminal() {
|
||||||
Logger.log("entered."); //$NON-NLS-1$
|
Logger.log("entered."); //$NON-NLS-1$
|
||||||
if(fUseCommonPrefs) {
|
if (fUseCommonPrefs) {
|
||||||
TerminalPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
|
TerminalPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
|
||||||
JFaceResources.getFontRegistry().removeListener(fFontListener);
|
JFaceResources.getFontRegistry().removeListener(fFontListener);
|
||||||
}
|
}
|
||||||
|
@ -422,16 +422,14 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectTerminal() {
|
public void connectTerminal() {
|
||||||
Logger.log("entered."); //$NON-NLS-1$
|
Logger.log("entered."); //$NON-NLS-1$
|
||||||
if(getTerminalConnector()==null)
|
if (getTerminalConnector() == null)
|
||||||
return;
|
return;
|
||||||
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;
|
||||||
|
@ -443,39 +441,42 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void disconnectTerminal() {
|
public void disconnectTerminal() {
|
||||||
Logger.log("entered."); //$NON-NLS-1$
|
Logger.log("entered."); //$NON-NLS-1$
|
||||||
|
|
||||||
//Disconnect the remote side first
|
//Disconnect the remote side first
|
||||||
if (getState()!=TerminalState.CLOSED) {
|
if (getState() != TerminalState.CLOSED) {
|
||||||
if(getTerminalConnector()!=null) {
|
if (getTerminalConnector() != null) {
|
||||||
getTerminalConnector().disconnect();
|
getTerminalConnector().disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Ensure that a new Job can be started; then clean up old Job.
|
//Ensure that a new Job can be started; then clean up old Job.
|
||||||
Job job;
|
Job job;
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
job = fJob;
|
job = fJob;
|
||||||
fJob = null;
|
fJob = null;
|
||||||
}
|
}
|
||||||
if (job!=null) {
|
if (job != null) {
|
||||||
job.cancel();
|
job.cancel();
|
||||||
// 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)
|
||||||
try {
|
t.interrupt();
|
||||||
job.join();
|
try {
|
||||||
} catch (InterruptedException e) {}
|
job.join();
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
fPollingTextCanvasModel.stopPolling();
|
fPollingTextCanvasModel.stopPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +487,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
do {
|
do {
|
||||||
if (!fDisplay.readAndDispatch())
|
if (!fDisplay.readAndDispatch())
|
||||||
fDisplay.sleep();
|
fDisplay.sleep();
|
||||||
} while (getState()==TerminalState.CONNECTING);
|
} while (getState() == TerminalState.CONNECTING);
|
||||||
|
|
||||||
if (getCtlText().isDisposed()) {
|
if (getCtlText().isDisposed()) {
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
|
@ -506,23 +507,23 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void startReaderJob() {
|
private synchronized void startReaderJob() {
|
||||||
if(fJob==null) {
|
if (fJob == null) {
|
||||||
fJob=new Job("Terminal data reader") { //$NON-NLS-1$
|
fJob = new Job("Terminal data reader") { //$NON-NLS-1$
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
IStatus status=Status.OK_STATUS;
|
IStatus status = Status.OK_STATUS;
|
||||||
try {
|
try {
|
||||||
while(true) {
|
while (true) {
|
||||||
while(fInputStream.available()==0 && !monitor.isCanceled()) {
|
while (fInputStream.available() == 0 && !monitor.isCanceled()) {
|
||||||
try {
|
try {
|
||||||
fInputStream.waitForAvailable(500);
|
fInputStream.waitForAvailable(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
//Do not disconnect terminal here because another reader job may already be running
|
//Do not disconnect terminal here because another reader job may already be running
|
||||||
status=Status.CANCEL_STATUS;
|
status = Status.CANCEL_STATUS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,8 +540,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
// clean the job: start a new one when the connection gets restarted
|
// clean the job: start a new one when the connection gets restarted
|
||||||
// Bug 208145: make sure we do not clean an other job that's already started (since it would become a Zombie)
|
// Bug 208145: make sure we do not clean an other job that's already started (since it would become a Zombie)
|
||||||
synchronized (VT100TerminalControl.this) {
|
synchronized (VT100TerminalControl.this) {
|
||||||
if (fJob==this) {
|
if (fJob == this) {
|
||||||
fJob=null;
|
fJob = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -593,7 +594,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Shell getShell() {
|
public Shell getShell() {
|
||||||
return getCtlText().getShell();
|
return getCtlText().getShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +602,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
try {
|
try {
|
||||||
int byteToSend = chKey;
|
int byteToSend = chKey;
|
||||||
OutputStream os = getOutputStream();
|
OutputStream os = getOutputStream();
|
||||||
if (os==null) {
|
if (os == null) {
|
||||||
// Bug 207785: NPE when trying to send char while no longer connected
|
// Bug 207785: NPE when trying to send char while no longer connected
|
||||||
Logger.log("NOT sending '" + byteToSend + "' because no longer connected"); //$NON-NLS-1$ //$NON-NLS-2$
|
Logger.log("NOT sending '" + byteToSend + "' because no longer connected"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
} else {
|
} else {
|
||||||
|
@ -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);
|
||||||
|
@ -667,7 +669,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setupTerminal(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setupTerminal(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setupTerminal(Composite parent) {
|
public void setupTerminal(Composite parent) {
|
||||||
Assert.isNotNull(parent);
|
Assert.isNotNull(parent);
|
||||||
boolean wasDisposed = true;
|
boolean wasDisposed = true;
|
||||||
TerminalState oldState = fState;
|
TerminalState oldState = fState;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -719,10 +723,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String)
|
* @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFont(String fontName) {
|
public void setFont(String fontName) {
|
||||||
Font font=JFaceResources.getFont(fontName);
|
Font font = JFaceResources.getFont(fontName);
|
||||||
getCtlText().setFont(font);
|
getCtlText().setFont(font);
|
||||||
if(fCommandInputField!=null) {
|
if (fCommandInputField != null) {
|
||||||
fCommandInputField.setFont(font);
|
fCommandInputField.setFont(font);
|
||||||
}
|
}
|
||||||
// Tell the TerminalControl singleton that the font has changed.
|
// Tell the TerminalControl singleton that the font has changed.
|
||||||
|
@ -734,10 +738,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(org.eclipse.swt.graphics.Font)
|
* @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(org.eclipse.swt.graphics.Font)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setFont(Font font) {
|
public void setFont(Font font) {
|
||||||
getCtlText().setFont(font);
|
getCtlText().setFont(font);
|
||||||
if(fCommandInputField!=null) {
|
if (fCommandInputField != null) {
|
||||||
fCommandInputField.setFont(font);
|
fCommandInputField.setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,40 +749,47 @@ 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() {
|
||||||
@Override
|
@Override
|
||||||
public void sizeChanged(int lines, int columns) {
|
public void sizeChanged(int lines, int columns) {
|
||||||
fTerminalText.setDimensions(lines, columns);
|
fTerminalText.setDimensions(lines, columns);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fCtlText.addMouseListener(new MouseAdapter() {
|
fCtlText.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseUp(MouseEvent e) {
|
public void mouseUp(MouseEvent e) {
|
||||||
// update selection used by middle mouse button paste
|
// update selection used by middle mouse button paste
|
||||||
if (e.button == 1 && getSelection().length() > 0) {
|
if (e.button == 1 && getSelection().length() > 0) {
|
||||||
copy(DND.SELECTION_CLIPBOARD);
|
copy(DND.SELECTION_CLIPBOARD);
|
||||||
|
@ -818,9 +829,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#displayTextInTerminal(java.lang.String)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#displayTextInTerminal(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
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));
|
||||||
|
@ -834,20 +846,21 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getRemoteToTerminalOutputStream() {
|
public OutputStream getRemoteToTerminalOutputStream() {
|
||||||
if(Logger.isLogEnabled()) {
|
if (Logger.isLogEnabled()) {
|
||||||
return new LoggingOutputStream(fInputStream.getOutputStream());
|
return new LoggingOutputStream(fInputStream.getOutputStream());
|
||||||
} else {
|
} else {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getOutputStream() {
|
public OutputStream getOutputStream() {
|
||||||
if(getTerminalConnector()!=null)
|
if (getTerminalConnector() != null)
|
||||||
return getTerminalConnector().getTerminalToRemoteStream();
|
return getTerminalConnector().getTerminalToRemoteStream();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -856,7 +869,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setMsg(java.lang.String)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setMsg(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setMsg(String msg) {
|
public void setMsg(String msg) {
|
||||||
fMsg = msg;
|
fMsg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -941,9 +959,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
|
|
||||||
protected class TerminalKeyHandler extends KeyAdapter {
|
protected class TerminalKeyHandler extends KeyAdapter {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
//TODO next 2 lines are probably obsolete now
|
//TODO next 2 lines are probably obsolete now
|
||||||
if (getState()==TerminalState.CONNECTING)
|
if (getState() == TerminalState.CONNECTING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO we should no longer handle copy & paste specially.
|
//TODO we should no longer handle copy & paste specially.
|
||||||
|
@ -981,7 +999,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
boolean altKeyPressed = (event.stateMask & SWT.ALT) != 0 && !ctrlKeyPressed;
|
boolean altKeyPressed = (event.stateMask & SWT.ALT) != 0 && !ctrlKeyPressed;
|
||||||
|
|
||||||
//if (!isConnected()) {
|
//if (!isConnected()) {
|
||||||
if (fState==TerminalState.CLOSED) {
|
if (fState == TerminalState.CLOSED) {
|
||||||
// Pressing ENTER while not connected causes us to connect.
|
// Pressing ENTER while not connected causes us to connect.
|
||||||
if (character == '\r' && isConnectOnEnterIfClosed()) {
|
if (character == '\r' && isConnectOnEnterIfClosed()) {
|
||||||
connectTerminal();
|
connectTerminal();
|
||||||
|
@ -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;
|
||||||
|
@ -1252,9 +1269,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
Field f1 = event.getClass().getField("keyLocation"); //$NON-NLS-1$
|
Field f1 = event.getClass().getField("keyLocation"); //$NON-NLS-1$
|
||||||
Field f2 = cmdEvent.getClass().getField("keyLocation"); //$NON-NLS-1$
|
Field f2 = cmdEvent.getClass().getField("keyLocation"); //$NON-NLS-1$
|
||||||
f2.set(cmdEvent, f1.get(event));
|
f2.set(cmdEvent, f1.get(event));
|
||||||
} catch(NoSuchFieldException nsfe) {
|
} catch (NoSuchFieldException nsfe) {
|
||||||
/* ignore, this is Eclipse 3.5 or earlier */
|
/* ignore, this is Eclipse 3.5 or earlier */
|
||||||
} catch(Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
cmdEvent.stateMask = event.stateMask;
|
cmdEvent.stateMask = event.stateMask;
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -1274,26 +1291,24 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTerminalTitle(String title) {
|
public void setTerminalTitle(String title) {
|
||||||
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;
|
||||||
fTerminalListener.setState(state);
|
fTerminalListener.setState(state);
|
||||||
// enable the (blinking) cursor if the terminal is connected
|
// enable the (blinking) cursor if the terminal is connected
|
||||||
runAsyncInDisplayThread(new Runnable() {
|
runAsyncInDisplayThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(fCtlText!=null && !fCtlText.isDisposed()) {
|
if (fCtlText != null && !fCtlText.isDisposed()) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
fCtlText.setCursorEnabled(true);
|
fCtlText.setCursorEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1305,73 +1320,76 @@ 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...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
if(getTerminalConnector()!=null)
|
if (getTerminalConnector() != null)
|
||||||
return getTerminalConnector().getSettingsSummary();
|
return getTerminalConnector().getSettingsSummary();
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setConnector(ITerminalConnector connector) {
|
public void setConnector(ITerminalConnector connector) {
|
||||||
fConnector=connector;
|
fConnector = connector;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICommandInputField getCommandInputField() {
|
public ICommandInputField getCommandInputField() {
|
||||||
return fCommandInputField;
|
return fCommandInputField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCommandInputField(ICommandInputField inputField) {
|
public void setCommandInputField(ICommandInputField inputField) {
|
||||||
if(fCommandInputField!=null)
|
if (fCommandInputField != null)
|
||||||
fCommandInputField.dispose();
|
fCommandInputField.dispose();
|
||||||
fCommandInputField=inputField;
|
fCommandInputField = inputField;
|
||||||
if(fCommandInputField!=null)
|
if (fCommandInputField != null)
|
||||||
fCommandInputField.createControl(fWndParent, this);
|
fCommandInputField.createControl(fWndParent, this);
|
||||||
if(fWndParent.isVisible())
|
if (fWndParent.isVisible())
|
||||||
fWndParent.layout(true);
|
fWndParent.layout(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBufferLineLimit() {
|
public int getBufferLineLimit() {
|
||||||
return fTerminalModel.getMaxHeight();
|
return fTerminalModel.getMaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBufferLineLimit(int bufferLineLimit) {
|
public void setBufferLineLimit(int bufferLineLimit) {
|
||||||
if(bufferLineLimit<=0)
|
if (bufferLineLimit <= 0)
|
||||||
return;
|
return;
|
||||||
synchronized (fTerminalModel) {
|
synchronized (fTerminalModel) {
|
||||||
if(fTerminalModel.getHeight()>bufferLineLimit)
|
if (fTerminalModel.getHeight() > bufferLineLimit)
|
||||||
fTerminalModel.setDimensions(bufferLineLimit, fTerminalModel.getWidth());
|
fTerminalModel.setDimensions(bufferLineLimit, fTerminalModel.getWidth());
|
||||||
fTerminalModel.setMaxHeight(bufferLineLimit);
|
fTerminalModel.setMaxHeight(bufferLineLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isScrollLock() {
|
public boolean isScrollLock() {
|
||||||
return fCtlText.isScrollLock();
|
return fCtlText.isScrollLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setScrollLock(boolean on) {
|
public void setScrollLock(boolean on) {
|
||||||
fCtlText.setScrollLock(on);
|
fCtlText.setScrollLock(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInvertedColors(boolean invert) {
|
public void setInvertedColors(boolean invert) {
|
||||||
fCtlText.setInvertedColors(invert);
|
fCtlText.setInvertedColors(invert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1379,7 +1397,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setConnectOnEnterIfClosed(boolean)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setConnectOnEnterIfClosed(boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void setConnectOnEnterIfClosed(boolean on) {
|
public final void setConnectOnEnterIfClosed(boolean on) {
|
||||||
connectOnEnterIfClosed = on;
|
connectOnEnterIfClosed = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1387,33 +1405,33 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnectOnEnterIfClosed()
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnectOnEnterIfClosed()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean isConnectOnEnterIfClosed() {
|
public final boolean isConnectOnEnterIfClosed() {
|
||||||
return connectOnEnterIfClosed;
|
return connectOnEnterIfClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVT100LineWrapping(boolean enable) {
|
public void setVT100LineWrapping(boolean enable) {
|
||||||
getTerminalText().setVT100LineWrapping(enable);
|
getTerminalText().setVT100LineWrapping(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVT100LineWrapping() {
|
public boolean isVT100LineWrapping() {
|
||||||
return getTerminalText().isVT100LineWrapping();
|
return getTerminalText().isVT100LineWrapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableApplicationCursorKeys(boolean enable) {
|
public void enableApplicationCursorKeys(boolean enable) {
|
||||||
fApplicationCursorKeys = enable;
|
fApplicationCursorKeys = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMouseListener(ITerminalMouseListener listener) {
|
public void addMouseListener(ITerminalMouseListener listener) {
|
||||||
getCtlText().addTerminalMouseListener(listener);
|
getCtlText().addTerminalMouseListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeMouseListener(ITerminalMouseListener listener) {
|
public void removeMouseListener(ITerminalMouseListener listener) {
|
||||||
getCtlText().removeTerminalMouseListener(listener);
|
getCtlText().removeTerminalMouseListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}
|
||||||
*
|
*
|
||||||
|
@ -54,17 +53,19 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
|
|
||||||
public SnapshotChanges(int nLines) {
|
public SnapshotChanges(int nLines) {
|
||||||
setChangedLinesLength(nLines);
|
setChangedLinesLength(nLines);
|
||||||
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;
|
||||||
fLastChangedLine=-1;
|
fLastChangedLine = -1;
|
||||||
fInterestWindowStartLine=windowStart;
|
fInterestWindowStartLine = windowStart;
|
||||||
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
|
||||||
|
@ -82,12 +84,13 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
* It used to be package protected, and it is public only for Unit Tests.
|
* It used to be package protected, and it is public only for Unit Tests.
|
||||||
*/
|
*/
|
||||||
public boolean isInInterestWindow(int line, int size) {
|
public boolean isInInterestWindow(int line, int size) {
|
||||||
if(fInterestWindowSize<=0)
|
if (fInterestWindowSize <= 0)
|
||||||
return true;
|
return true;
|
||||||
if(line+size<=fInterestWindowStartLine || line>=fInterestWindowStartLine+fInterestWindowSize)
|
if (line + size <= fInterestWindowStartLine || line >= fInterestWindowStartLine + fInterestWindowSize)
|
||||||
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
|
||||||
|
@ -96,12 +99,13 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
* It used to be package protected, and it is public only for Unit Tests.
|
* It used to be package protected, and it is public only for Unit Tests.
|
||||||
*/
|
*/
|
||||||
public boolean isInInterestWindow(int line) {
|
public boolean isInInterestWindow(int line) {
|
||||||
if(fInterestWindowSize<=0)
|
if (fInterestWindowSize <= 0)
|
||||||
return true;
|
return true;
|
||||||
if(line<fInterestWindowStartLine || line>=fInterestWindowStartLine+fInterestWindowSize)
|
if (line < fInterestWindowStartLine || line >= fInterestWindowStartLine + fInterestWindowSize)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line
|
* @param line
|
||||||
* @return the line within the window
|
* @return the line within the window
|
||||||
|
@ -110,12 +114,13 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
* It used to be package protected, and it is public only for Unit Tests.
|
* It used to be package protected, and it is public only for Unit Tests.
|
||||||
*/
|
*/
|
||||||
public int fitLineToWindow(int line) {
|
public int fitLineToWindow(int line) {
|
||||||
if(fInterestWindowSize<=0)
|
if (fInterestWindowSize <= 0)
|
||||||
return line;
|
return line;
|
||||||
if(line<fInterestWindowStartLine)
|
if (line < fInterestWindowStartLine)
|
||||||
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!
|
||||||
|
@ -129,99 +134,110 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
* move the window correctly!
|
* move the window correctly!
|
||||||
*/
|
*/
|
||||||
public int fitSizeToWindow(int line, int size) {
|
public int fitSizeToWindow(int line, int size) {
|
||||||
if(fInterestWindowSize<=0)
|
if (fInterestWindowSize <= 0)
|
||||||
return size;
|
return size;
|
||||||
if(line<fInterestWindowStartLine) {
|
if (line < fInterestWindowStartLine) {
|
||||||
size-=fInterestWindowStartLine-line;
|
size -= fInterestWindowStartLine - line;
|
||||||
line=fInterestWindowStartLine;
|
line = fInterestWindowStartLine;
|
||||||
}
|
}
|
||||||
if(line+size>fInterestWindowStartLine+fInterestWindowSize)
|
if (line + size > fInterestWindowStartLine + fInterestWindowSize)
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void markLineChanged(int line) {
|
public void markLineChanged(int line) {
|
||||||
if(!isInInterestWindow(line))
|
if (!isInInterestWindow(line))
|
||||||
return;
|
return;
|
||||||
line=fitLineToWindow(line);
|
line = fitLineToWindow(line);
|
||||||
if(line<fFirstChangedLine)
|
if (line < fFirstChangedLine)
|
||||||
fFirstChangedLine=line;
|
fFirstChangedLine = line;
|
||||||
if(line>fLastChangedLine)
|
if (line > fLastChangedLine)
|
||||||
fLastChangedLine=line;
|
fLastChangedLine = line;
|
||||||
// in case the terminal got resized we expand
|
// in case the terminal got resized we expand
|
||||||
// don't remember the changed line because
|
// don't remember the changed line because
|
||||||
// there is nothing to copy
|
// there is nothing to copy
|
||||||
if(line<getChangedLineLength()) {
|
if (line < getChangedLineLength()) {
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void markLinesChanged(int line, int n) {
|
public void markLinesChanged(int line, int n) {
|
||||||
if(n<=0 || !isInInterestWindow(line,n))
|
if (n <= 0 || !isInInterestWindow(line, n))
|
||||||
return;
|
return;
|
||||||
// do not exceed the bounds of fChangedLines
|
// do not exceed the bounds of fChangedLines
|
||||||
// the terminal might have been resized and
|
// the terminal might have been resized and
|
||||||
// we can only keep changes for the size of the
|
// we can only keep changes for the size of the
|
||||||
// previous terminal
|
// previous terminal
|
||||||
n=fitSizeToWindow(line, n);
|
n = fitSizeToWindow(line, n);
|
||||||
line=fitLineToWindow(line);
|
line = fitLineToWindow(line);
|
||||||
int m=Math.min(line+n, getChangedLineLength());
|
int m = Math.min(line + n, getChangedLineLength());
|
||||||
for (int i = line; i < m; i++) {
|
for (int i = line; i < m; i++) {
|
||||||
setChangedLine(i,true);
|
setChangedLine(i, true);
|
||||||
}
|
}
|
||||||
// this sets fFirstChangedLine as well
|
// this sets fFirstChangedLine as well
|
||||||
markLineChanged(line);
|
markLineChanged(line);
|
||||||
// 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()
|
||||||
*/
|
*/
|
||||||
public void convertScrollingIntoChanges() {
|
public void convertScrollingIntoChanges() {
|
||||||
markLinesChanged(fScrollWindowStartLine,fScrollWindowSize);
|
markLinesChanged(fScrollWindowStartLine, fScrollWindowSize);
|
||||||
fScrollWindowStartLine=0;
|
fScrollWindowStartLine = 0;
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void scroll(int startLine, int size, int shift) {
|
public void scroll(int startLine, int size, int shift) {
|
||||||
size=fitSizeToWindow(startLine, size);
|
size = fitSizeToWindow(startLine, size);
|
||||||
startLine=fitLineToWindow(startLine);
|
startLine = fitLineToWindow(startLine);
|
||||||
// let's track only negative shifts
|
// let's track only negative shifts
|
||||||
if(fScrollDontTrack) {
|
if (fScrollDontTrack) {
|
||||||
// we are in a state where we cannot track scrolling
|
// we are in a state where we cannot track scrolling
|
||||||
// so let's simply mark the scrolled lines as changed
|
// so let's simply mark the scrolled lines as changed
|
||||||
markLinesChanged(startLine, size);
|
markLinesChanged(startLine, size);
|
||||||
} else if(shift>=0) {
|
} else if (shift >= 0) {
|
||||||
// we cannot handle positive scroll
|
// we cannot handle positive scroll
|
||||||
// forget about clever caching of scroll events
|
// forget about clever caching of scroll events
|
||||||
doNotTrackScrollingAnymore();
|
doNotTrackScrollingAnymore();
|
||||||
|
@ -229,12 +245,12 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
markLinesChanged(startLine, size);
|
markLinesChanged(startLine, size);
|
||||||
} else {
|
} else {
|
||||||
// we have already scrolled
|
// we have already scrolled
|
||||||
if(fScrollWindowShift<0) {
|
if (fScrollWindowShift < 0) {
|
||||||
// we have already scrolled
|
// we have already scrolled
|
||||||
if(fScrollWindowStartLine==startLine && fScrollWindowSize==size) {
|
if (fScrollWindowStartLine == startLine && fScrollWindowSize == size) {
|
||||||
// we are scrolling the same region again?
|
// we are scrolling the same region again?
|
||||||
fScrollWindowShift+=shift;
|
fScrollWindowShift += shift;
|
||||||
scrollChangesLinesWithNegativeShift(startLine,size,shift);
|
scrollChangesLinesWithNegativeShift(startLine, size, shift);
|
||||||
} else {
|
} else {
|
||||||
// mark all lines in the old scroll region as changed
|
// mark all lines in the old scroll region as changed
|
||||||
doNotTrackScrollingAnymore();
|
doNotTrackScrollingAnymore();
|
||||||
|
@ -243,28 +259,30 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// first scroll in this change -- we just notify it
|
// first scroll in this change -- we just notify it
|
||||||
fScrollWindowStartLine=startLine;
|
fScrollWindowStartLine = startLine;
|
||||||
fScrollWindowSize=size;
|
fScrollWindowSize = size;
|
||||||
fScrollWindowShift=shift;
|
fScrollWindowShift = shift;
|
||||||
scrollChangesLinesWithNegativeShift(startLine,size,shift);
|
scrollChangesLinesWithNegativeShift(startLine, size, shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some incompatible scrolling occurred. We cannot do the
|
* Some incompatible scrolling occurred. We cannot do the
|
||||||
* scroll optimization anymore...
|
* scroll optimization anymore...
|
||||||
*/
|
*/
|
||||||
private void doNotTrackScrollingAnymore() {
|
private void doNotTrackScrollingAnymore() {
|
||||||
if(fScrollWindowSize>0) {
|
if (fScrollWindowSize > 0) {
|
||||||
// convert the current scrolling into changes
|
// convert the current scrolling into changes
|
||||||
markLinesChanged(fScrollWindowStartLine, fScrollWindowSize);
|
markLinesChanged(fScrollWindowStartLine, fScrollWindowSize);
|
||||||
fScrollWindowStartLine=0;
|
fScrollWindowStartLine = 0;
|
||||||
fScrollWindowSize=0;
|
fScrollWindowSize = 0;
|
||||||
fScrollWindowShift=0;
|
fScrollWindowShift = 0;
|
||||||
}
|
}
|
||||||
// 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
|
||||||
*
|
*
|
||||||
|
@ -273,75 +291,82 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
* @param shift must be negative!
|
* @param shift must be negative!
|
||||||
*/
|
*/
|
||||||
private void scrollChangesLinesWithNegativeShift(int line, int n, int shift) {
|
private void scrollChangesLinesWithNegativeShift(int line, int n, int shift) {
|
||||||
assert shift <0 || throwRuntimeException();
|
assert shift < 0 || throwRuntimeException();
|
||||||
// scroll the region
|
// scroll the region
|
||||||
// don't run out of bounds!
|
// don't run out of bounds!
|
||||||
int m=Math.min(line+n+shift,getChangedLineLength()+shift);
|
int m = Math.min(line + n + shift, getChangedLineLength() + shift);
|
||||||
for (int i = line; i < m; i++) {
|
for (int i = line; i < m; i++) {
|
||||||
setChangedLine(i, hasLineChanged(i-shift));
|
setChangedLine(i, hasLineChanged(i - shift));
|
||||||
// move the first changed line up.
|
// move the first changed line up.
|
||||||
// We don't have to move the maximum down,
|
// We don't have to move the maximum down,
|
||||||
// because with a shift scroll, the max is moved
|
// because with a shift scroll, the max is moved
|
||||||
// my the next loop in this method
|
// my the next loop in this method
|
||||||
if(i<fFirstChangedLine && hasLineChanged(i)) {
|
if (i < fFirstChangedLine && hasLineChanged(i)) {
|
||||||
fFirstChangedLine=i;
|
fFirstChangedLine = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// mark the "opened" lines as changed
|
// mark the "opened" lines as changed
|
||||||
for (int i = Math.max(0,line+n+shift); i < line+n; i++) {
|
for (int i = Math.max(0, line + n + shift); i < line + n; i++) {
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void setAllChanged(int height) {
|
public void setAllChanged(int height) {
|
||||||
fScrollWindowStartLine=0;
|
fScrollWindowStartLine = 0;
|
||||||
fScrollWindowSize=0;
|
fScrollWindowSize = 0;
|
||||||
fScrollWindowShift=0;
|
fScrollWindowShift = 0;
|
||||||
fFirstChangedLine=fitLineToWindow(0);
|
fFirstChangedLine = fitLineToWindow(0);
|
||||||
fLastChangedLine=fFirstChangedLine+fitSizeToWindow(0, height)-1;
|
fLastChangedLine = fFirstChangedLine + fitSizeToWindow(0, height) - 1;
|
||||||
// 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)
|
||||||
*/
|
*/
|
||||||
public void copyChangedLines(ITerminalTextData dest, ITerminalTextData source) {
|
public void copyChangedLines(ITerminalTextData dest, ITerminalTextData source) {
|
||||||
int n=Math.min(fLastChangedLine+1,source.getHeight());
|
int n = Math.min(fLastChangedLine + 1, source.getHeight());
|
||||||
for (int i = fFirstChangedLine; i < n ; i++) {
|
for (int i = fFirstChangedLine; i < n; i++) {
|
||||||
if(hasLineChanged(i))
|
if (hasLineChanged(i))
|
||||||
dest.copyLine(source,i,i);
|
dest.copyLine(source, i, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,25 +379,25 @@ public class SnapshotChanges implements ISnapshotChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInterestWindow(int startLine, int size) {
|
public void setInterestWindow(int startLine, int size) {
|
||||||
int oldStartLine=fInterestWindowStartLine;
|
int oldStartLine = fInterestWindowStartLine;
|
||||||
int oldSize=fInterestWindowSize;
|
int oldSize = fInterestWindowSize;
|
||||||
fInterestWindowStartLine=startLine;
|
fInterestWindowStartLine = startLine;
|
||||||
fInterestWindowSize=size;
|
fInterestWindowSize = size;
|
||||||
if(oldSize>0) {
|
if (oldSize > 0) {
|
||||||
int shift=oldStartLine-startLine;
|
int shift = oldStartLine - startLine;
|
||||||
if(shift==0) {
|
if (shift == 0) {
|
||||||
if(size>oldSize) {
|
if (size > oldSize) {
|
||||||
// add lines to the end
|
// add lines to the end
|
||||||
markLinesChanged(oldStartLine+oldSize, size-oldSize);
|
markLinesChanged(oldStartLine + oldSize, size - oldSize);
|
||||||
}
|
}
|
||||||
// else no lines within the window have changed
|
// else no lines within the window have changed
|
||||||
|
|
||||||
} else if(Math.abs(shift)<size) {
|
} else if (Math.abs(shift) < size) {
|
||||||
if(shift<0) {
|
if (shift < 0) {
|
||||||
// we can scroll
|
// we can scroll
|
||||||
scroll(startLine, oldSize, shift);
|
scroll(startLine, oldSize, shift);
|
||||||
// mark the lines at the end as new
|
// mark the lines at the end as new
|
||||||
for (int i = oldStartLine+oldSize; i < startLine+size; i++) {
|
for (int i = oldStartLine + oldSize; i < startLine + size; i++) {
|
||||||
markLineChanged(i);
|
markLineChanged(i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -386,11 +411,12 @@ 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)
|
||||||
*/
|
*/
|
||||||
public boolean hasLineChanged(int line) {
|
public boolean hasLineChanged(int line) {
|
||||||
if(line<fChangedLines.length)
|
if (line < fChangedLines.length)
|
||||||
return fChangedLines[line];
|
return fChangedLines[line];
|
||||||
// since the height of the terminal could
|
// since the height of the terminal could
|
||||||
// have changed but we have tracked only changes
|
// have changed but we have tracked only changes
|
||||||
|
@ -398,13 +424,16 @@ 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){
|
|
||||||
fChangedLines[line]=changed;
|
void setChangedLine(int line, boolean 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,10 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
/**
|
/**
|
||||||
* A list of active snapshots
|
* A list of active snapshots
|
||||||
*/
|
*/
|
||||||
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:
|
||||||
|
@ -46,13 +47,13 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
* @return a string representation of the content
|
* @return a string representation of the content
|
||||||
*/
|
*/
|
||||||
static public String toMultiLineText(ITerminalTextDataReadOnly term, int start, int len) {
|
static public String toMultiLineText(ITerminalTextDataReadOnly term, int start, int len) {
|
||||||
if(len<0)
|
if (len < 0)
|
||||||
len=term.getHeight();
|
len = term.getHeight();
|
||||||
StringBuffer buff=new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
int width=term.getWidth();
|
int width = term.getWidth();
|
||||||
int n=Math.min(len,term.getHeight()-start);
|
int n = Math.min(len, term.getHeight() - start);
|
||||||
for (int line = start; line < n; line++) {
|
for (int line = start; line < n; line++) {
|
||||||
if(line>0)
|
if (line > 0)
|
||||||
buff.append("\n"); //$NON-NLS-1$
|
buff.append("\n"); //$NON-NLS-1$
|
||||||
for (int column = 0; column < width; column++) {
|
for (int column = 0; column < width; column++) {
|
||||||
buff.append(term.getChar(line, column));
|
buff.append(term.getChar(line, column));
|
||||||
|
@ -83,71 +84,86 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
public TerminalTextData() {
|
public TerminalTextData() {
|
||||||
this(new TerminalTextDataFastScroll());
|
this(new TerminalTextDataFastScroll());
|
||||||
|
|
||||||
// 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();
|
||||||
if(w==width && h==height)
|
if (w == width && h == height)
|
||||||
return;
|
return;
|
||||||
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) {
|
||||||
if(oldHeight<newHeight)
|
if (oldHeight < newHeight)
|
||||||
sendLinesChangedToSnapshot(oldHeight, newHeight-oldHeight);
|
sendLinesChangedToSnapshot(oldHeight, newHeight - oldHeight);
|
||||||
else
|
else
|
||||||
sendLinesChangedToSnapshot(newHeight,oldHeight-newHeight);
|
sendLinesChangedToSnapshot(newHeight, oldHeight - newHeight);
|
||||||
} else {
|
} else {
|
||||||
sendLinesChangedToSnapshot(0, oldHeight);
|
sendLinesChangedToSnapshot(0, oldHeight);
|
||||||
}
|
}
|
||||||
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,12 +172,13 @@ 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
|
||||||
* @param n number of changed lines
|
* @param n number of changed lines
|
||||||
*/
|
*/
|
||||||
protected void sendLinesChangedToSnapshot(int line,int n) {
|
protected void sendLinesChangedToSnapshot(int line, int n) {
|
||||||
for (int i = 0; i < fSnapshots.length; i++) {
|
for (int i = 0; i < fSnapshots.length; i++) {
|
||||||
fSnapshots[i].markLinesChanged(line, n);
|
fSnapshots[i].markLinesChanged(line, n);
|
||||||
}
|
}
|
||||||
|
@ -173,47 +190,50 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
* @param size size of scrolled region (number of lines)
|
* @param size size of scrolled region (number of lines)
|
||||||
* @param shift delta by which the region is scrolled
|
* @param shift delta by which the region is scrolled
|
||||||
*/
|
*/
|
||||||
protected void sendScrolledToSnapshots(int startLine,int size, int shift) {
|
protected void sendScrolledToSnapshots(int startLine, int size, int shift) {
|
||||||
for (int i = 0; i < fSnapshots.length; i++) {
|
for (int i = 0; i < fSnapshots.length; i++) {
|
||||||
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
|
||||||
*/
|
*/
|
||||||
protected void removeSnapshot(TerminalTextDataSnapshot snapshot) {
|
protected void removeSnapshot(TerminalTextDataSnapshot snapshot) {
|
||||||
// poor mans approach to modify the array
|
// poor mans approach to modify the array
|
||||||
List<TerminalTextDataSnapshot> list=new ArrayList<TerminalTextDataSnapshot>();
|
List<TerminalTextDataSnapshot> list = new ArrayList<TerminalTextDataSnapshot>();
|
||||||
list.addAll(Arrays.asList(fSnapshots));
|
list.addAll(Arrays.asList(fSnapshots));
|
||||||
list.remove(snapshot);
|
list.remove(snapshot);
|
||||||
fSnapshots=list.toArray(new TerminalTextDataSnapshot[list.size()]);
|
fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITerminalTextDataSnapshot makeSnapshot() {
|
public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
// poor mans approach to modify the array
|
// poor mans approach to modify the array
|
||||||
TerminalTextDataSnapshot snapshot=new TerminalTextDataSnapshot(this);
|
TerminalTextDataSnapshot snapshot = new TerminalTextDataSnapshot(this);
|
||||||
snapshot.markDimensionsChanged();
|
snapshot.markDimensionsChanged();
|
||||||
List<TerminalTextDataSnapshot> list=new ArrayList<TerminalTextDataSnapshot>();
|
List<TerminalTextDataSnapshot> list = new ArrayList<TerminalTextDataSnapshot>();
|
||||||
list.addAll(Arrays.asList(fSnapshots));
|
list.addAll(Arrays.asList(fSnapshots));
|
||||||
list.add(snapshot);
|
list.add(snapshot);
|
||||||
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();
|
||||||
// was is an append or a scroll?
|
// was is an append or a scroll?
|
||||||
int newHeight=getHeight();
|
int newHeight = getHeight();
|
||||||
if(newHeight>oldHeight) {
|
if (newHeight > oldHeight) {
|
||||||
//the line was appended
|
//the line was appended
|
||||||
sendLinesChangedToSnapshot(oldHeight, 1);
|
sendLinesChangedToSnapshot(oldHeight, 1);
|
||||||
int width=getWidth();
|
int width = getWidth();
|
||||||
sendDimensionsChanged(oldHeight, width, newHeight, width);
|
sendDimensionsChanged(oldHeight, width, newHeight, width);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -225,44 +245,54 @@ public class TerminalTextData implements ITerminalTextData {
|
||||||
|
|
||||||
public void copy(ITerminalTextData source) {
|
public void copy(ITerminalTextData source) {
|
||||||
fData.copy(source);
|
fData.copy(source);
|
||||||
fCursorLine=source.getCursorLine();
|
fCursorLine = source.getCursorLine();
|
||||||
fCursorColumn=source.getCursorColumn();
|
fCursorColumn = source.getCursorColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
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,19 +31,23 @@ 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) {
|
|
||||||
fMaxHeight=maxHeight;
|
public TerminalTextDataFastScroll(ITerminalTextData data, int maxHeight) {
|
||||||
fData=data;
|
fMaxHeight = maxHeight;
|
||||||
|
fData = data;
|
||||||
fData.setDimensions(maxHeight, fData.getWidth());
|
fData.setDimensions(maxHeight, fData.getWidth());
|
||||||
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,23 +56,26 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
private boolean throwRuntimeException() {
|
private boolean throwRuntimeException() {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param line
|
* @param line
|
||||||
* @return the actual line number in {@link #fData}
|
* @return the actual line number in {@link #fData}
|
||||||
*/
|
*/
|
||||||
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
|
||||||
*/
|
*/
|
||||||
void moveOffset(int delta) {
|
void moveOffset(int delta) {
|
||||||
assert Math.abs(delta)<fMaxHeight || throwRuntimeException();
|
assert Math.abs(delta) < fMaxHeight || throwRuntimeException();
|
||||||
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,20 +85,22 @@ 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());
|
||||||
} else {
|
} else {
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copy(ITerminalTextData source) {
|
public void copy(ITerminalTextData source) {
|
||||||
int n=source.getHeight();
|
int n = source.getHeight();
|
||||||
setDimensions(source.getHeight(),source.getWidth());
|
setDimensions(source.getHeight(), source.getWidth());
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
fData.copyLine(source, i, getPositionOfLine(i));
|
fData.copyLine(source, i, getPositionOfLine(i));
|
||||||
}
|
}
|
||||||
|
@ -102,19 +111,19 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) {
|
||||||
assert (destStartLine>=0 && destStartLine+length<=fHeight) || throwRuntimeException();
|
assert (destStartLine >= 0 && destStartLine + length <= fHeight) || throwRuntimeException();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
fData.copyLine(source, i+sourceStartLine, getPositionOfLine(i+destStartLine));
|
fData.copyLine(source, i + sourceStartLine, getPositionOfLine(i + destStartLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public char getChar(int line, int column) {
|
public char getChar(int line, int column) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
return fData.getChar(getPositionOfLine(line), column);
|
return fData.getChar(getPositionOfLine(line), column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getChars(int line) {
|
public char[] getChars(int line) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
return fData.getChars(getPositionOfLine(line));
|
return fData.getChars(getPositionOfLine(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +132,7 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) {
|
public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
return fData.getLineSegments(getPositionOfLine(line), startCol, numberOfCols);
|
return fData.getLineSegments(getPositionOfLine(line), startCol, numberOfCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,12 +141,12 @@ public class TerminalTextDataFastScroll implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle(int line, int column) {
|
public Style getStyle(int line, int column) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
return fData.getStyle(getPositionOfLine(line), column);
|
return fData.getStyle(getPositionOfLine(line), column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style[] getStyles(int line) {
|
public Style[] getStyles(int line) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
return fData.getStyles(getPositionOfLine(line));
|
return fData.getStyles(getPositionOfLine(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,111 +157,119 @@ 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) {
|
||||||
cleanLines(startLine, fMaxHeight-startLine);
|
cleanLines(startLine, fMaxHeight - startLine);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(size==fHeight) {
|
if (size == fHeight) {
|
||||||
// This is the case this class is optimized for!
|
// This is the case this class is optimized for!
|
||||||
moveOffset(-shift);
|
moveOffset(-shift);
|
||||||
// we only have to clean the lines that appear by the move
|
// we only have to clean the lines that appear by the move
|
||||||
if(shift<0) {
|
if (shift < 0) {
|
||||||
cleanLines(Math.max(startLine, startLine+size+shift),Math.min(-shift, getHeight()-startLine));
|
cleanLines(Math.max(startLine, startLine + size + shift), Math.min(-shift, getHeight() - startLine));
|
||||||
} else {
|
} else {
|
||||||
cleanLines(startLine, Math.min(shift, getHeight()-startLine));
|
cleanLines(startLine, Math.min(shift, getHeight() - startLine));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we have to copy the lines.
|
// we have to copy the lines.
|
||||||
if(shift<0) {
|
if (shift < 0) {
|
||||||
// move the region up
|
// move the region up
|
||||||
// shift is negative!!
|
// shift is negative!!
|
||||||
for (int i = startLine; i < startLine+size+shift; i++) {
|
for (int i = startLine; i < startLine + size + shift; i++) {
|
||||||
fData.copyLine(fData, getPositionOfLine(i-shift), getPositionOfLine(i));
|
fData.copyLine(fData, getPositionOfLine(i - shift), getPositionOfLine(i));
|
||||||
}
|
}
|
||||||
// then clean the opened lines
|
// then clean the opened lines
|
||||||
cleanLines(Math.max(0, startLine+size+shift),Math.min(-shift, getHeight()-startLine));
|
cleanLines(Math.max(0, startLine + size + shift), Math.min(-shift, getHeight() - startLine));
|
||||||
} else {
|
} else {
|
||||||
for (int i = startLine+size-1; i >=startLine && i-shift>=0; i--) {
|
for (int i = startLine + size - 1; i >= startLine && i - shift >= 0; i--) {
|
||||||
fData.copyLine(fData, getPositionOfLine(i-shift), getPositionOfLine(i));
|
fData.copyLine(fData, getPositionOfLine(i - shift), getPositionOfLine(i));
|
||||||
}
|
}
|
||||||
cleanLines(startLine, Math.min(shift, getHeight()-startLine));
|
cleanLines(startLine, Math.min(shift, getHeight() - startLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChar(int line, int column, char c, Style style) {
|
public void setChar(int line, int column, char c, Style style) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
fData.setChar(getPositionOfLine(line), column, c, style);
|
fData.setChar(getPositionOfLine(line), 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) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
fData.setChars(getPositionOfLine(line), column, chars, start, len, style);
|
fData.setChars(getPositionOfLine(line), 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) {
|
||||||
assert (line>=0 && line<fHeight) || throwRuntimeException();
|
assert (line >= 0 && line < fHeight) || throwRuntimeException();
|
||||||
fData.setChars(getPositionOfLine(line), column, chars, style);
|
fData.setChars(getPositionOfLine(line), 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();
|
||||||
assert width>=0 || throwRuntimeException();
|
assert width >= 0 || throwRuntimeException();
|
||||||
if(height > fMaxHeight)
|
if (height > fMaxHeight)
|
||||||
setMaxHeight(height);
|
setMaxHeight(height);
|
||||||
fHeight=height;
|
fHeight = height;
|
||||||
if(width!=fData.getWidth())
|
if (width != fData.getWidth())
|
||||||
fData.setDimensions(fMaxHeight, width);
|
fData.setDimensions(fMaxHeight, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHeight(int maxHeight) {
|
public void setMaxHeight(int maxHeight) {
|
||||||
assert maxHeight>=fHeight || throwRuntimeException();
|
assert maxHeight >= fHeight || throwRuntimeException();
|
||||||
// move everything to offset0
|
// move everything to offset0
|
||||||
int start=getPositionOfLine(0);
|
int start = getPositionOfLine(0);
|
||||||
if(start!=0) {
|
if (start != 0) {
|
||||||
// invent a more efficient algorithm....
|
// invent a more efficient algorithm....
|
||||||
ITerminalTextData buffer=new TerminalTextDataStore();
|
ITerminalTextData buffer = new TerminalTextDataStore();
|
||||||
// create a buffer with the expected height
|
// create a buffer with the expected height
|
||||||
buffer.setDimensions(maxHeight, getWidth());
|
buffer.setDimensions(maxHeight, getWidth());
|
||||||
int n=Math.min(fMaxHeight-start,maxHeight);
|
int n = Math.min(fMaxHeight - start, maxHeight);
|
||||||
// copy the first part
|
// copy the first part
|
||||||
buffer.copyRange(fData, start, 0, n);
|
buffer.copyRange(fData, start, 0, n);
|
||||||
// copy the second part
|
// copy the second part
|
||||||
if(n<maxHeight)
|
if (n < maxHeight)
|
||||||
buffer.copyRange(fData, 0, n, Math.min(fMaxHeight-n,maxHeight-n));
|
buffer.copyRange(fData, 0, n, Math.min(fMaxHeight - n, maxHeight - n));
|
||||||
// copy the buffer back to our data
|
// copy the buffer back to our data
|
||||||
fData.copy(buffer);
|
fData.copy(buffer);
|
||||||
shiftOffset(-start);
|
shiftOffset(-start);
|
||||||
} else {
|
} else {
|
||||||
fData.setDimensions(maxHeight, fData.getWidth());
|
fData.setDimensions(maxHeight, fData.getWidth());
|
||||||
}
|
}
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
// snapshot does not need internal synchronisation
|
// snapshot does not need internal synchronisation
|
||||||
final TerminalTextDataWindow fSnapshot;
|
final TerminalTextDataWindow fSnapshot;
|
||||||
// this variable is synchronized on fTerminal!
|
// this variable is synchronized on fTerminal!
|
||||||
private SnapshotOutOfDateListener[] fListener=new SnapshotOutOfDateListener[0];
|
private SnapshotOutOfDateListener[] fListener = new SnapshotOutOfDateListener[0];
|
||||||
// this variable is synchronized on fTerminal!
|
// this variable is synchronized on fTerminal!
|
||||||
private boolean fListenersNeedNotify;
|
private boolean fListenersNeedNotify;
|
||||||
private int fInterestWindowSize;
|
private int fInterestWindowSize;
|
||||||
|
@ -60,9 +60,10 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
fCurrentChanges.setTerminalChanged();
|
fCurrentChanges.setTerminalChanged();
|
||||||
fFutureChanges = new SnapshotChanges(fTerminal.getHeight());
|
fFutureChanges = new SnapshotChanges(fTerminal.getHeight());
|
||||||
fFutureChanges.markLinesChanged(0, fTerminal.getHeight());
|
fFutureChanges.markLinesChanged(0, fTerminal.getHeight());
|
||||||
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()
|
||||||
*/
|
*/
|
||||||
|
@ -89,12 +91,12 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
// make sure terminal does not change while we make the snapshot
|
// make sure terminal does not change while we make the snapshot
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
// let's make the future changes current
|
// let's make the future changes current
|
||||||
fCurrentChanges=fFutureChanges;
|
fCurrentChanges = fFutureChanges;
|
||||||
fFutureChanges=new SnapshotChanges(fTerminal.getHeight());
|
fFutureChanges = new SnapshotChanges(fTerminal.getHeight());
|
||||||
fFutureChanges.setInterestWindow(fInterestWindowStartLine, fInterestWindowSize);
|
fFutureChanges.setInterestWindow(fInterestWindowStartLine, fInterestWindowSize);
|
||||||
// and update the snapshot
|
// and update the snapshot
|
||||||
if(fSnapshot.getHeight()!=fTerminal.getHeight()||fSnapshot.getWidth()!=fTerminal.getWidth()) {
|
if (fSnapshot.getHeight() != fTerminal.getHeight() || fSnapshot.getWidth() != fTerminal.getWidth()) {
|
||||||
if(fInterestWindowSize==-1)
|
if (fInterestWindowSize == -1)
|
||||||
fSnapshot.setWindow(0, fTerminal.getHeight());
|
fSnapshot.setWindow(0, fTerminal.getHeight());
|
||||||
// if the dimensions have changed, we need a full copy
|
// if the dimensions have changed, we need a full copy
|
||||||
fSnapshot.copy(fTerminal);
|
fSnapshot.copy(fTerminal);
|
||||||
|
@ -102,17 +104,17 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
fCurrentChanges.setAllChanged(fTerminal.getHeight());
|
fCurrentChanges.setAllChanged(fTerminal.getHeight());
|
||||||
} else {
|
} else {
|
||||||
// first we do the scroll on the copy
|
// first we do the scroll on the copy
|
||||||
int start=fCurrentChanges.getScrollWindowStartLine();
|
int start = fCurrentChanges.getScrollWindowStartLine();
|
||||||
int lines=Math.min(fCurrentChanges.getScrollWindowSize(), fSnapshot.getHeight()-start);
|
int lines = Math.min(fCurrentChanges.getScrollWindowSize(), fSnapshot.getHeight() - start);
|
||||||
fSnapshot.scroll(start, lines, fCurrentChanges.getScrollWindowShift());
|
fSnapshot.scroll(start, lines, fCurrentChanges.getScrollWindowShift());
|
||||||
// and then create the snapshot of the changed lines
|
// and then create the snapshot of the changed lines
|
||||||
fCurrentChanges.copyChangedLines(fSnapshot, fTerminal);
|
fCurrentChanges.copyChangedLines(fSnapshot, fTerminal);
|
||||||
}
|
}
|
||||||
fListenersNeedNotify=true;
|
fListenersNeedNotify = true;
|
||||||
fSnapshot.setCursorLine(fTerminal.getCursorLine());
|
fSnapshot.setCursorLine(fTerminal.getCursorLine());
|
||||||
fSnapshot.setCursorColumn(fTerminal.getCursorColumn());
|
fSnapshot.setCursorColumn(fTerminal.getCursorColumn());
|
||||||
}
|
}
|
||||||
if(!detectScrolling) {
|
if (!detectScrolling) {
|
||||||
// let's pretend there was no scrolling and
|
// let's pretend there was no scrolling and
|
||||||
// convert the scrolling into line changes
|
// convert the scrolling into line changes
|
||||||
fCurrentChanges.convertScrollingIntoChanges();
|
fCurrentChanges.convertScrollingIntoChanges();
|
||||||
|
@ -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,13 +198,14 @@ 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
|
||||||
* @param n
|
* @param n
|
||||||
*/
|
*/
|
||||||
void markLinesChanged(int line,int n) {
|
void markLinesChanged(int line, int n) {
|
||||||
fFutureChanges.markLinesChanged(line,n);
|
fFutureChanges.markLinesChanged(line, n);
|
||||||
fFutureChanges.setTerminalChanged();
|
fFutureChanges.setTerminalChanged();
|
||||||
notifyListers();
|
notifyListers();
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
@ -218,86 +228,87 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot {
|
||||||
* @param shift
|
* @param shift
|
||||||
*/
|
*/
|
||||||
void scroll(int startLine, int size, int shift) {
|
void scroll(int startLine, int size, int shift) {
|
||||||
fFutureChanges.scroll(startLine,size,shift);
|
fFutureChanges.scroll(startLine, size, shift);
|
||||||
fFutureChanges.setTerminalChanged();
|
fFutureChanges.setTerminalChanged();
|
||||||
notifyListers();
|
notifyListers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies listeners about the change
|
* Notifies listeners about the change
|
||||||
*/
|
*/
|
||||||
private void notifyListers() {
|
private void notifyListers() {
|
||||||
// this code has to be called from a block synchronized on fTerminal
|
// this code has to be called from a block synchronized on fTerminal
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
if(fListenersNeedNotify) {
|
if (fListenersNeedNotify) {
|
||||||
for (int i = 0; i < fListener.length; i++) {
|
for (int i = 0; i < fListener.length; i++) {
|
||||||
fListener[i].snapshotOutOfDate(this);
|
fListener[i].snapshotOutOfDate(this);
|
||||||
}
|
}
|
||||||
fListenersNeedNotify=false;
|
fListenersNeedNotify = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITerminalTextDataSnapshot makeSnapshot() {
|
public ITerminalTextDataSnapshot makeSnapshot() {
|
||||||
return fSnapshot.makeSnapshot();
|
return fSnapshot.makeSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void addListener(SnapshotOutOfDateListener listener) {
|
synchronized public void addListener(SnapshotOutOfDateListener listener) {
|
||||||
List<SnapshotOutOfDateListener> list=new ArrayList<SnapshotOutOfDateListener>();
|
List<SnapshotOutOfDateListener> list = new ArrayList<SnapshotOutOfDateListener>();
|
||||||
list.addAll(Arrays.asList(fListener));
|
list.addAll(Arrays.asList(fListener));
|
||||||
list.add(listener);
|
list.add(listener);
|
||||||
fListener=list.toArray(new SnapshotOutOfDateListener[list.size()]);
|
fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void removeListener(SnapshotOutOfDateListener listener) {
|
synchronized public void removeListener(SnapshotOutOfDateListener listener) {
|
||||||
List<SnapshotOutOfDateListener> list=new ArrayList<SnapshotOutOfDateListener>();
|
List<SnapshotOutOfDateListener> list = new ArrayList<SnapshotOutOfDateListener>();
|
||||||
list.addAll(Arrays.asList(fListener));
|
list.addAll(Arrays.asList(fListener));
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInterestWindow(int startLine, int size) {
|
public void setInterestWindow(int startLine, int size) {
|
||||||
assert startLine>=0 || throwRuntimeException();
|
assert startLine >= 0 || throwRuntimeException();
|
||||||
assert size>=0 || throwRuntimeException();
|
assert size >= 0 || throwRuntimeException();
|
||||||
fInterestWindowStartLine=startLine;
|
fInterestWindowStartLine = startLine;
|
||||||
fInterestWindowSize=size;
|
fInterestWindowSize = size;
|
||||||
fSnapshot.setWindow(startLine, size);
|
fSnapshot.setWindow(startLine, size);
|
||||||
fFutureChanges.setInterestWindow(startLine, size);
|
fFutureChanges.setInterestWindow(startLine, size);
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,11 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
final private BitSet fWrappedLines = new BitSet();
|
final private BitSet fWrappedLines = new BitSet();
|
||||||
|
|
||||||
public TerminalTextDataStore() {
|
public TerminalTextDataStore() {
|
||||||
fChars=new char[0][];
|
fChars = new char[0][];
|
||||||
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,43 +50,45 @@ 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)
|
||||||
*/
|
*/
|
||||||
public void setDimensions(int height, int width) {
|
public void setDimensions(int height, int width) {
|
||||||
assert height>=0 || throwRuntimeException();
|
assert height >= 0 || throwRuntimeException();
|
||||||
assert width>=0 || throwRuntimeException();
|
assert width >= 0 || throwRuntimeException();
|
||||||
// just extend the region
|
// just extend the region
|
||||||
if(height>fChars.length) {
|
if (height > fChars.length) {
|
||||||
int h=4*height/3;
|
int h = 4 * height / 3;
|
||||||
if(fMaxHeight>0 && h>fMaxHeight)
|
if (fMaxHeight > 0 && h > fMaxHeight)
|
||||||
h=fMaxHeight;
|
h = fMaxHeight;
|
||||||
fStyle=(Style[][]) resizeArray(fStyle, height);
|
fStyle = (Style[][]) resizeArray(fStyle, height);
|
||||||
fChars=(char[][]) resizeArray(fChars, height);
|
fChars = (char[][]) resizeArray(fChars, height);
|
||||||
}
|
}
|
||||||
// clean the new lines
|
// clean the new lines
|
||||||
if(height>fHeight) {
|
if (height > fHeight) {
|
||||||
for (int i = fHeight; i < height; i++) {
|
for (int i = fHeight; i < height; i++) {
|
||||||
cleanLine(i);
|
cleanLine(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// set dimensions after successful resize!
|
// set dimensions after successful resize!
|
||||||
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.
|
||||||
|
@ -96,7 +99,7 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
*/
|
*/
|
||||||
private Object resizeArray(Object origArray, int newSize) {
|
private Object resizeArray(Object origArray, int newSize) {
|
||||||
int oldSize = Array.getLength(origArray);
|
int oldSize = Array.getLength(origArray);
|
||||||
if(oldSize==newSize)
|
if (oldSize == newSize)
|
||||||
return origArray;
|
return origArray;
|
||||||
Class<?> elementType = origArray.getClass().getComponentType();
|
Class<?> elementType = origArray.getClass().getComponentType();
|
||||||
Object newArray = Array.newInstance(elementType, newSize);
|
Object newArray = Array.newInstance(elementType, newSize);
|
||||||
|
@ -106,74 +109,75 @@ 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)
|
||||||
*/
|
*/
|
||||||
public LineSegment[] getLineSegments(int line, int column, int len) {
|
public LineSegment[] getLineSegments(int line, int column, int len) {
|
||||||
// get the styles and chars for this line
|
// get the styles and chars for this line
|
||||||
Style[] styles=fStyle[line];
|
Style[] styles = fStyle[line];
|
||||||
char[] chars=fChars[line];
|
char[] chars = fChars[line];
|
||||||
int col=column;
|
int col = column;
|
||||||
int n=column+len;
|
int n = column + len;
|
||||||
|
|
||||||
// expand the line if needed....
|
// expand the line if needed....
|
||||||
if(styles==null)
|
if (styles == null)
|
||||||
styles=new Style[n];
|
styles = new Style[n];
|
||||||
else if(styles.length<n)
|
else if (styles.length < n)
|
||||||
styles=(Style[]) resizeArray(styles, n);
|
styles = (Style[]) resizeArray(styles, n);
|
||||||
|
|
||||||
if(chars==null)
|
if (chars == null)
|
||||||
chars=new char[n];
|
chars = new char[n];
|
||||||
else if(chars.length<n)
|
else if (chars.length < n)
|
||||||
chars=(char[]) resizeArray(chars, n);
|
chars = (char[]) resizeArray(chars, n);
|
||||||
|
|
||||||
// and create the line segments
|
// and create the line segments
|
||||||
Style style=styles[column];
|
Style style = styles[column];
|
||||||
List<LineSegment> segments=new ArrayList<LineSegment>();
|
List<LineSegment> segments = new ArrayList<LineSegment>();
|
||||||
for (int i = column; i < n; i++) {
|
for (int i = column; i < n; i++) {
|
||||||
if(styles[i]!=style) {
|
if (styles[i] != style) {
|
||||||
segments.add(new LineSegment(col,new String(chars,col,i-col),style));
|
segments.add(new LineSegment(col, new String(chars, col, i - col), style));
|
||||||
style=styles[i];
|
style = styles[i];
|
||||||
col=i;
|
col = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(col < n) {
|
if (col < n) {
|
||||||
segments.add(new LineSegment(col,new String(chars,col,n-col),style));
|
segments.add(new LineSegment(col, new String(chars, col, n - col), style));
|
||||||
}
|
}
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public char getChar(int line, int column) {
|
public char getChar(int line, int column) {
|
||||||
assert column<fWidth || throwRuntimeException();
|
assert column < fWidth || throwRuntimeException();
|
||||||
if(fChars[line]==null||column>=fChars[line].length)
|
if (fChars[line] == null || column >= fChars[line].length)
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public Style getStyle(int line, int column) {
|
public Style getStyle(int line, int column) {
|
||||||
assert column<fWidth || throwRuntimeException();
|
assert column < fWidth || throwRuntimeException();
|
||||||
if(fStyle[line]==null || column>=fStyle[line].length)
|
if (fStyle[line] == null || column >= fStyle[line].length)
|
||||||
return null;
|
return null;
|
||||||
return fStyle[line][column];
|
return fStyle[line][column];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ensureLineLength(int iLine, int length) {
|
void ensureLineLength(int iLine, int length) {
|
||||||
if(length>fWidth)
|
if (length > fWidth)
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
if(fChars[iLine]==null) {
|
if (fChars[iLine] == null) {
|
||||||
fChars[iLine]=new char[length];
|
fChars[iLine] = new char[length];
|
||||||
} else if(fChars[iLine].length<length) {
|
} else if (fChars[iLine].length < length) {
|
||||||
fChars[iLine]=(char[]) resizeArray(fChars[iLine],length);
|
fChars[iLine] = (char[]) resizeArray(fChars[iLine], length);
|
||||||
}
|
}
|
||||||
if(fStyle[iLine]==null) {
|
if (fStyle[iLine] == null) {
|
||||||
fStyle[iLine]=new Style[length];
|
fStyle[iLine] = new Style[length];
|
||||||
} else if(fStyle[iLine].length<length) {
|
} else if (fStyle[iLine].length < length) {
|
||||||
fStyle[iLine]=(Style[]) resizeArray(fStyle[iLine],length);
|
fStyle[iLine] = (Style[]) resizeArray(fStyle[iLine], length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,58 +185,62 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChar(int, int, char, org.eclipse.tm.internal.terminal.text.Style)
|
* @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChar(int, int, char, org.eclipse.tm.internal.terminal.text.Style)
|
||||||
*/
|
*/
|
||||||
public void setChar(int line, int column, char c, Style style) {
|
public void setChar(int line, int column, char c, Style style) {
|
||||||
ensureLineLength(line,column+1);
|
ensureLineLength(line, column + 1);
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
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) {
|
||||||
ensureLineLength(line,column+len);
|
ensureLineLength(line, column + len);
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
fChars[line][column+i]=chars[i+start];
|
fChars[line][column + i] = chars[i + start];
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
public void scroll(int startLine, int size, int shift) {
|
public void scroll(int startLine, int size, int shift) {
|
||||||
assert startLine+size <= getHeight() || throwRuntimeException();
|
assert startLine + size <= getHeight() || throwRuntimeException();
|
||||||
if(shift<0) {
|
if (shift < 0) {
|
||||||
// move the region up
|
// move the region up
|
||||||
// shift is negative!!
|
// shift is negative!!
|
||||||
for (int i = startLine; i < startLine+size+shift; i++) {
|
for (int i = startLine; i < startLine + size + shift; i++) {
|
||||||
fChars[i]=fChars[i-shift];
|
fChars[i] = fChars[i - shift];
|
||||||
fStyle[i]=fStyle[i-shift];
|
fStyle[i] = fStyle[i - shift];
|
||||||
fWrappedLines.set(i, fWrappedLines.get(i-shift));
|
fWrappedLines.set(i, fWrappedLines.get(i - shift));
|
||||||
}
|
}
|
||||||
// then clean the opened lines
|
// then clean the opened lines
|
||||||
cleanLines(Math.max(startLine, startLine+size+shift),Math.min(-shift, getHeight()-startLine));
|
cleanLines(Math.max(startLine, startLine + size + shift), Math.min(-shift, getHeight() - startLine));
|
||||||
// cleanLines(Math.max(0, startLine+size+shift),Math.min(-shift, getHeight()-startLine));
|
// cleanLines(Math.max(0, startLine+size+shift),Math.min(-shift, getHeight()-startLine));
|
||||||
} else {
|
} else {
|
||||||
for (int i = startLine+size-1; i >=startLine && i-shift>=0; i--) {
|
for (int i = startLine + size - 1; i >= startLine && i - shift >= 0; i--) {
|
||||||
fChars[i]=fChars[i-shift];
|
fChars[i] = fChars[i - shift];
|
||||||
fStyle[i]=fStyle[i-shift];
|
fStyle[i] = fStyle[i - shift];
|
||||||
fWrappedLines.set(i, fWrappedLines.get(i-shift));
|
fWrappedLines.set(i, fWrappedLines.get(i - shift));
|
||||||
}
|
}
|
||||||
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
|
||||||
* @param len
|
* @param len
|
||||||
*/
|
*/
|
||||||
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++) {
|
||||||
cleanLine(i);
|
cleanLine(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,9 +250,9 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
* Lines are separated by '\n'. No style information is returned.
|
* Lines are separated by '\n'. No style information is returned.
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buff=new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
for (int line = 0; line < getHeight(); line++) {
|
for (int line = 0; line < getHeight(); line++) {
|
||||||
if(line>0)
|
if (line > 0)
|
||||||
buff.append("\n"); //$NON-NLS-1$
|
buff.append("\n"); //$NON-NLS-1$
|
||||||
for (int column = 0; column < fWidth; column++) {
|
for (int column = 0; column < fWidth; column++) {
|
||||||
buff.append(getChar(line, column));
|
buff.append(getChar(line, column));
|
||||||
|
@ -253,65 +261,65 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
return buff.toString();
|
return buff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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());
|
||||||
} else {
|
} else {
|
||||||
scroll(0,getHeight(),-1);
|
scroll(0, getHeight(), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copy(ITerminalTextData source) {
|
public void copy(ITerminalTextData source) {
|
||||||
fWidth=source.getWidth();
|
fWidth = source.getWidth();
|
||||||
int n=source.getHeight();
|
int n = source.getHeight();
|
||||||
if(getHeight()!=n) {
|
if (getHeight() != n) {
|
||||||
fChars=new char[n][];
|
fChars = new char[n][];
|
||||||
fStyle=new Style[n][];
|
fStyle = new Style[n][];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
copyLine(source, i, i);
|
copyLine(source, i, i);
|
||||||
}
|
}
|
||||||
fHeight=n;
|
fHeight = n;
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
|
||||||
fChars[destLine]=source.getChars(sourceLine);
|
fChars[destLine] = source.getChars(sourceLine);
|
||||||
fStyle[destLine]=source.getStyles(sourceLine);
|
fStyle[destLine] = source.getStyles(sourceLine);
|
||||||
fWrappedLines.set(destLine, source.isWrappedLine(sourceLine));
|
fWrappedLines.set(destLine, source.isWrappedLine(sourceLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getChars(int line) {
|
public char[] getChars(int line) {
|
||||||
if(fChars[line]==null)
|
if (fChars[line] == null)
|
||||||
return null;
|
return null;
|
||||||
return fChars[line].clone();
|
return fChars[line].clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style[] getStyles(int line) {
|
public Style[] getStyles(int line) {
|
||||||
if(fStyle[line]==null)
|
if (fStyle[line] == null)
|
||||||
return null;
|
return null;
|
||||||
return fStyle[line].clone();
|
return fStyle[line].clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLine(int line, char[] chars, Style[] styles) {
|
public void setLine(int line, char[] chars, Style[] styles) {
|
||||||
fChars[line]=chars.clone();
|
fChars[line] = chars.clone();
|
||||||
fStyle[line]=styles.clone();
|
fStyle[line] = styles.clone();
|
||||||
fWrappedLines.clear(line);
|
fWrappedLines.clear(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHeight(int height) {
|
public void setMaxHeight(int height) {
|
||||||
fMaxHeight=height;
|
fMaxHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
|
@ -319,25 +327,31 @@ public class TerminalTextDataStore implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanLine(int line) {
|
public void cleanLine(int line) {
|
||||||
fChars[line]=null;
|
fChars[line] = null;
|
||||||
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,23 +45,25 @@ 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
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
return fData.getChar(line-fWindowStartLine, column);
|
return fData.getChar(line - fWindowStartLine, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getChars(int line) {
|
public char[] getChars(int line) {
|
||||||
if(!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return null;
|
return null;
|
||||||
return fData.getChars(line-fWindowStartLine);
|
return fData.getChars(line - fWindowStartLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
|
@ -66,9 +71,9 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) {
|
public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) {
|
||||||
if(!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return new LineSegment[]{new LineSegment(startCol,new String(new char[numberOfCols]),null)};
|
return new LineSegment[] { new LineSegment(startCol, new String(new char[numberOfCols]), null) };
|
||||||
return fData.getLineSegments(line-fWindowStartLine, startCol, numberOfCols);
|
return fData.getLineSegments(line - fWindowStartLine, startCol, numberOfCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
|
@ -76,15 +81,15 @@ public class TerminalTextDataWindow implements ITerminalTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle(int line, int column) {
|
public Style getStyle(int line, int column) {
|
||||||
if(!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return null;
|
return null;
|
||||||
return fData.getStyle(line-fWindowStartLine, column);
|
return fData.getStyle(line - fWindowStartLine, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style[] getStyles(int line) {
|
public Style[] getStyles(int line) {
|
||||||
if(!isInWindow(line))
|
if (!isInWindow(line))
|
||||||
return null;
|
return null;
|
||||||
return fData.getStyles(line-fWindowStartLine);
|
return fData.getStyles(line - fWindowStartLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
@ -94,114 +99,135 @@ 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());
|
||||||
} else {
|
} else {
|
||||||
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());
|
||||||
int n=Math.min(fWindowSize, source.getHeight()-fWindowStartLine);
|
int n = Math.min(fWindowSize, source.getHeight() - fWindowStartLine);
|
||||||
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;
|
||||||
int sStart=sourceStartLine;
|
int sStart = sourceStartLine;
|
||||||
// if start outside our range, cut the length to copy
|
// if start outside our range, cut the length to copy
|
||||||
if(dStart<0) {
|
if (dStart < 0) {
|
||||||
n+=dStart;
|
n += dStart;
|
||||||
sStart-=dStart;
|
sStart -= dStart;
|
||||||
dStart=0;
|
dStart = 0;
|
||||||
}
|
}
|
||||||
// do not exceed the window size
|
// do not exceed the window size
|
||||||
n=Math.min(n,fWindowSize);
|
n = Math.min(n, fWindowSize);
|
||||||
if(n>0)
|
if (n > 0)
|
||||||
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;
|
||||||
int start=startLine-fWindowStartLine;
|
int start = startLine - fWindowStartLine;
|
||||||
// if start outside our range, cut the length to copy
|
// if start outside our range, cut the length to copy
|
||||||
if(start<0) {
|
if (start < 0) {
|
||||||
n+=start;
|
n += start;
|
||||||
start=0;
|
start = 0;
|
||||||
}
|
}
|
||||||
n=Math.min(n,fWindowSize-start);
|
n = Math.min(n, fWindowSize - start);
|
||||||
// do not exceed the window size
|
// do not exceed the window size
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,13 @@ package org.eclipse.tm.internal.terminal.preferences;
|
||||||
*/
|
*/
|
||||||
public interface ITerminalConstants {
|
public interface ITerminalConstants {
|
||||||
|
|
||||||
public static final String PREF_HAS_MIGRATED = "TerminalPref.migrated"; //$NON-NLS-1$
|
public static final String PREF_HAS_MIGRATED = "TerminalPref.migrated"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String PREF_BUFFERLINES = "TerminalPrefBufferLines"; //$NON-NLS-1$
|
public static final String PREF_BUFFERLINES = "TerminalPrefBufferLines"; //$NON-NLS-1$
|
||||||
public static final String PREF_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$
|
public static final String PREF_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$
|
||||||
public static final int DEFAULT_BUFFERLINES = 1000;
|
public static final int DEFAULT_BUFFERLINES = 1000;
|
||||||
public static final boolean DEFAULT_INVERT_COLORS = false;
|
public static final boolean DEFAULT_INVERT_COLORS = false;
|
||||||
|
|
||||||
public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$
|
public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,25 +35,28 @@ 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;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -40,16 +40,16 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#addListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#addListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener)
|
||||||
*/
|
*/
|
||||||
public void addListener(Listener listener) {
|
public void addListener(Listener listener) {
|
||||||
Assert.isNotNull(listener);
|
Assert.isNotNull(listener);
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#removeListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener)
|
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#removeListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener)
|
||||||
*/
|
*/
|
||||||
public void removeListener(Listener listener) {
|
public void removeListener(Listener listener) {
|
||||||
Assert.isNotNull(listener);
|
Assert.isNotNull(listener);
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,8 +61,9 @@ 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))
|
||||||
((Listener)l).onSettingsPageChanged(control);
|
continue;
|
||||||
|
((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$
|
||||||
|
@ -149,7 +151,7 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro
|
||||||
protected final void updateControlDecoration(Control control, String message, int messageType) {
|
protected final void updateControlDecoration(Control control, String message, int messageType) {
|
||||||
Assert.isNotNull(control);
|
Assert.isNotNull(control);
|
||||||
|
|
||||||
ControlDecoration controlDecoration = (ControlDecoration)control.getData("controlDecoration"); //$NON-NLS-1$
|
ControlDecoration controlDecoration = (ControlDecoration) control.getData("controlDecoration"); //$NON-NLS-1$
|
||||||
if (controlDecoration != null) {
|
if (controlDecoration != null) {
|
||||||
// The description is the same as the message
|
// The description is the same as the message
|
||||||
controlDecoration.setDescriptionText(message);
|
controlDecoration.setDescriptionText(message);
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,20 +104,20 @@ public interface ITerminalConnector extends IAdaptable {
|
||||||
*/
|
*/
|
||||||
boolean isLocalEcho();
|
boolean isLocalEcho();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the remote site that the size of the terminal has changed.
|
* Notify the remote site that the size of the terminal has changed.
|
||||||
* @param newWidth
|
* @param newWidth
|
||||||
* @param newHeight
|
* @param newHeight
|
||||||
*/
|
*/
|
||||||
void setTerminalSize(int newWidth, int newHeight);
|
void setTerminalSize(int newWidth, int newHeight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the terminal to remote stream (bytes written to this stream will
|
* @return the terminal to remote stream (bytes written to this stream will
|
||||||
* be sent to the remote site). For the stream in the other direction (remote to
|
* be sent to the remote site). For the stream in the other direction (remote to
|
||||||
* terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()}
|
* terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()}
|
||||||
* @since org.eclipse.tm.terminal 2.0
|
* @since org.eclipse.tm.terminal 2.0
|
||||||
*/
|
*/
|
||||||
OutputStream getTerminalToRemoteStream();
|
OutputStream getTerminalToRemoteStream();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the state of this connection. Is typically called before
|
* Load the state of this connection. Is typically called before
|
||||||
|
|
|
@ -44,17 +44,17 @@ import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public final class Logger {
|
public final class Logger {
|
||||||
public static final String TRACE_DEBUG_LOG = "org.eclipse.tm.terminal.control/debug/log"; //$NON-NLS-1$
|
public static final String TRACE_DEBUG_LOG = "org.eclipse.tm.terminal.control/debug/log"; //$NON-NLS-1$
|
||||||
public static final String TRACE_DEBUG_LOG_CHAR = "org.eclipse.tm.terminal.control/debug/log/char"; //$NON-NLS-1$
|
public static final String TRACE_DEBUG_LOG_CHAR = "org.eclipse.tm.terminal.control/debug/log/char"; //$NON-NLS-1$
|
||||||
public static final String TRACE_DEBUG_LOG_VT100BACKEND = "org.eclipse.tm.terminal.control/debug/log/VT100Backend"; //$NON-NLS-1$
|
public static final String TRACE_DEBUG_LOG_VT100BACKEND = "org.eclipse.tm.terminal.control/debug/log/VT100Backend"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static PrintStream logStream;
|
private static PrintStream logStream;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Any of the three known debugging options turns on the creation of the log file
|
// Any of the three known debugging options turns on the creation of the log file
|
||||||
boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG)
|
boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG)
|
||||||
|| TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR)
|
|| TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR)
|
||||||
|| TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND);
|
|| TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND);
|
||||||
|
|
||||||
// Log only if tracing is enabled
|
// Log only if tracing is enabled
|
||||||
if (createLogFile && TerminalPlugin.getDefault() != null) {
|
if (createLogFile && TerminalPlugin.getDefault() != null) {
|
||||||
|
@ -80,48 +80,64 @@ public final class Logger {
|
||||||
*/
|
*/
|
||||||
public static final String encode(String message) {
|
public static final String encode(String message) {
|
||||||
boolean encoded = false;
|
boolean encoded = false;
|
||||||
StringBuffer buf = new StringBuffer(message.length()+32);
|
StringBuffer buf = new StringBuffer(message.length() + 32);
|
||||||
for (int i=0; i<message.length(); i++) {
|
for (int i = 0; i < message.length(); i++) {
|
||||||
char c=message.charAt(i);
|
char c = message.charAt(i);
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case '\\':
|
case '\\':
|
||||||
case '\'':
|
case '\'':
|
||||||
buf.append('\\'); buf.append(c); encoded=true;
|
buf.append('\\');
|
||||||
break;
|
buf.append(c);
|
||||||
case '\r':
|
encoded = true;
|
||||||
buf.append('\\'); buf.append('r'); encoded=true;
|
break;
|
||||||
break;
|
case '\r':
|
||||||
case '\n':
|
buf.append('\\');
|
||||||
buf.append('\\'); buf.append('n'); encoded=true;
|
buf.append('r');
|
||||||
break;
|
encoded = true;
|
||||||
case '\t':
|
break;
|
||||||
buf.append('\\'); buf.append('t'); encoded=true;
|
case '\n':
|
||||||
break;
|
buf.append('\\');
|
||||||
case '\f':
|
buf.append('n');
|
||||||
buf.append('\\'); buf.append('f'); encoded=true;
|
encoded = true;
|
||||||
break;
|
break;
|
||||||
case '\b':
|
case '\t':
|
||||||
buf.append('\\'); buf.append('b'); encoded=true;
|
buf.append('\\');
|
||||||
break;
|
buf.append('t');
|
||||||
default:
|
encoded = true;
|
||||||
if (c <= '\u000f') {
|
break;
|
||||||
buf.append('\\'); buf.append('x'); buf.append('0');
|
case '\f':
|
||||||
buf.append(Integer.toHexString(c));
|
buf.append('\\');
|
||||||
encoded=true;
|
buf.append('f');
|
||||||
} else if (c>=' ' && c<'\u007f') {
|
encoded = true;
|
||||||
buf.append(c);
|
break;
|
||||||
} else if (c <= '\u00ff') {
|
case '\b':
|
||||||
buf.append('\\'); buf.append('x');
|
buf.append('\\');
|
||||||
buf.append(Integer.toHexString(c));
|
buf.append('b');
|
||||||
encoded=true;
|
encoded = true;
|
||||||
} else {
|
break;
|
||||||
buf.append('\\'); buf.append('u');
|
default:
|
||||||
if (c<='\u0fff') {
|
if (c <= '\u000f') {
|
||||||
buf.append('0');
|
buf.append('\\');
|
||||||
}
|
buf.append('x');
|
||||||
buf.append(Integer.toHexString(c));
|
buf.append('0');
|
||||||
encoded=true;
|
buf.append(Integer.toHexString(c));
|
||||||
|
encoded = true;
|
||||||
|
} else if (c >= ' ' && c < '\u007f') {
|
||||||
|
buf.append(c);
|
||||||
|
} else if (c <= '\u00ff') {
|
||||||
|
buf.append('\\');
|
||||||
|
buf.append('x');
|
||||||
|
buf.append(Integer.toHexString(c));
|
||||||
|
encoded = true;
|
||||||
|
} else {
|
||||||
|
buf.append('\\');
|
||||||
|
buf.append('u');
|
||||||
|
if (c <= '\u0fff') {
|
||||||
|
buf.append('0');
|
||||||
}
|
}
|
||||||
|
buf.append(Integer.toHexString(c));
|
||||||
|
encoded = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (encoded) {
|
if (encoded) {
|
||||||
|
@ -135,14 +151,14 @@ public final class Logger {
|
||||||
* @return true if logging is enabled.
|
* @return true if logging is enabled.
|
||||||
*/
|
*/
|
||||||
public static final boolean isLogEnabled() {
|
public static final boolean isLogEnabled() {
|
||||||
return (logStream!=null);
|
return (logStream != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the specified message. Do not append a newline to parameter
|
* Logs the specified message. Do not append a newline to parameter
|
||||||
* <i>message</i>. This method does that for you.
|
* <i>message</i>. This method does that for you.
|
||||||
*
|
*
|
||||||
* @param message A String containing the message to log.
|
* @param message A String containing the message to log.
|
||||||
*/
|
*/
|
||||||
public static final void log(String message) {
|
public static final void log(String message) {
|
||||||
if (logStream != null) {
|
if (logStream != null) {
|
||||||
|
@ -156,7 +172,7 @@ public final class Logger {
|
||||||
String methodName = caller.getMethodName();
|
String methodName = caller.getMethodName();
|
||||||
className = className.substring(className.lastIndexOf('.') + 1);
|
className = className.substring(className.lastIndexOf('.') + 1);
|
||||||
|
|
||||||
logStream.println(className + "." + methodName + ":" + lineNumber + ": " + message); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
logStream.println(className + "." + methodName + ":" + lineNumber + ": " + message); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||||
logStream.flush();
|
logStream.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,14 +184,15 @@ 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();
|
||||||
}
|
}
|
||||||
// Additional Tracing for debug purposes:
|
// Additional Tracing for debug purposes:
|
||||||
// Read my own stack to get the class name, method name, and line number
|
// Read my own stack to get the class name, method name, and line number
|
||||||
// of where this method was called
|
// of where this method was called
|
||||||
if(logStream!=null) {
|
if (logStream != null) {
|
||||||
StackTraceElement caller = new Throwable().getStackTrace()[1];
|
StackTraceElement caller = new Throwable().getStackTrace()[1];
|
||||||
int lineNumber = caller.getLineNumber();
|
int lineNumber = caller.getLineNumber();
|
||||||
String className = caller.getClassName();
|
String className = caller.getClassName();
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,19 +41,20 @@ import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnect
|
||||||
public class TerminalConnectorExtension {
|
public class TerminalConnectorExtension {
|
||||||
static private ITerminalConnector makeConnector(final IConfigurationElement config) {
|
static private ITerminalConnector makeConnector(final IConfigurationElement config) {
|
||||||
String id = config.getAttribute("id"); //$NON-NLS-1$
|
String id = config.getAttribute("id"); //$NON-NLS-1$
|
||||||
if(id==null || id.length()==0)
|
if (id == null || id.length() == 0)
|
||||||
id=config.getAttribute("class"); //$NON-NLS-1$
|
id = config.getAttribute("class"); //$NON-NLS-1$
|
||||||
String name= config.getAttribute("name"); //$NON-NLS-1$
|
String name = config.getAttribute("name"); //$NON-NLS-1$
|
||||||
if(name==null || name.length()==0) {
|
if (name == null || name.length() == 0) {
|
||||||
name=id;
|
name = id;
|
||||||
}
|
}
|
||||||
String hidden = config.getAttribute("hidden"); //$NON-NLS-1$
|
String hidden = config.getAttribute("hidden"); //$NON-NLS-1$
|
||||||
boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false;
|
boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false;
|
||||||
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,14 +69,16 @@ 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of available terminal connectors (connection types).
|
* Return a list of available terminal connectors (connection types).
|
||||||
*
|
*
|
||||||
|
@ -89,8 +92,9 @@ 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()
|
||||||
List<ITerminalConnector> result=new ArrayList<ITerminalConnector>();
|
.getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$
|
||||||
|
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]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,17 +30,17 @@ public class TerminalState {
|
||||||
/**
|
/**
|
||||||
* The terminal is not connected.
|
* The terminal is not connected.
|
||||||
*/
|
*/
|
||||||
public final static TerminalState CLOSED=new TerminalState("CLOSED"); //$NON-NLS-1$
|
public final static TerminalState CLOSED = new TerminalState("CLOSED"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The terminal is about to connect.
|
* The terminal is about to connect.
|
||||||
*/
|
*/
|
||||||
public final static TerminalState CONNECTING=new TerminalState("CONNECTING..."); //$NON-NLS-1$
|
public final static TerminalState CONNECTING = new TerminalState("CONNECTING..."); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The terminal is connected.
|
* The terminal is connected.
|
||||||
*/
|
*/
|
||||||
public final static TerminalState CONNECTED=new TerminalState("CONNECTED"); //$NON-NLS-1$
|
public final static TerminalState CONNECTED = new TerminalState("CONNECTED"); //$NON-NLS-1$
|
||||||
|
|
||||||
private final String fState;
|
private final String fState;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
*/
|
*/
|
||||||
public abstract class TerminalConnectorImpl {
|
public abstract class TerminalConnectorImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TerminalControl associated with this connector.
|
* The TerminalControl associated with this connector.
|
||||||
* Required for advertising state changes when needed.
|
* Required for advertising state changes when needed.
|
||||||
*/
|
*/
|
||||||
|
@ -81,11 +81,11 @@ public abstract class TerminalConnectorImpl {
|
||||||
// Do nothing by default
|
// Do nothing by default
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the terminal to remote stream (bytes written to this stream will
|
* @return the terminal to remote stream (bytes written to this stream will
|
||||||
* be sent to the remote site). For the stream in the other direction (remote to
|
* be sent to the remote site). For the stream in the other direction (remote to
|
||||||
* terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()}
|
* terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()}
|
||||||
*/
|
*/
|
||||||
abstract public OutputStream getTerminalToRemoteStream();
|
abstract public OutputStream getTerminalToRemoteStream();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +140,7 @@ public abstract class TerminalConnectorImpl {
|
||||||
// do nothing by default
|
// do nothing by default
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the remote site that the size of the terminal has changed.
|
* Notify the remote site that the size of the terminal has changed.
|
||||||
*
|
*
|
||||||
* Concrete connectors should override this if they have the possibility to
|
* Concrete connectors should override this if they have the possibility to
|
||||||
|
|
|
@ -32,13 +32,13 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
private final ITerminalTextDataSnapshot fSnapshot;
|
private final ITerminalTextDataSnapshot fSnapshot;
|
||||||
private int fLines;
|
private int fLines;
|
||||||
|
|
||||||
private int fSelectionStartLine=-1;
|
private int fSelectionStartLine = -1;
|
||||||
private int fSeletionEndLine;
|
private int fSeletionEndLine;
|
||||||
private int fSelectionStartCoumn;
|
private int fSelectionStartCoumn;
|
||||||
private int fSelectionEndColumn;
|
private int fSelectionEndColumn;
|
||||||
private ITerminalTextDataSnapshot fSelectionSnapshot;
|
private ITerminalTextDataSnapshot fSelectionSnapshot;
|
||||||
private String fCurrentSelection=""; //$NON-NLS-1$
|
private String fCurrentSelection = ""; //$NON-NLS-1$
|
||||||
private final Point fSelectionAnchor=new Point(0,0);
|
private final Point fSelectionAnchor = new Point(0, 0);
|
||||||
/**
|
/**
|
||||||
* do not update while update is running
|
* do not update while update is running
|
||||||
*/
|
*/
|
||||||
|
@ -46,9 +46,10 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
private int fCols;
|
private int fCols;
|
||||||
|
|
||||||
public AbstractTextCanvasModel(ITerminalTextDataSnapshot snapshot) {
|
public AbstractTextCanvasModel(ITerminalTextDataSnapshot snapshot) {
|
||||||
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,13 +64,15 @@ 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();
|
||||||
listener.dimensionsChanged(width,height);
|
listener.dimensionsChanged(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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,36 +84,39 @@ 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;
|
||||||
try {
|
try {
|
||||||
fSnapshot.updateSnapshot(false);
|
fSnapshot.updateSnapshot(false);
|
||||||
if(fSnapshot.hasTerminalChanged())
|
if (fSnapshot.hasTerminalChanged())
|
||||||
fireTerminalDataChanged();
|
fireTerminalDataChanged();
|
||||||
// TODO why does hasDimensionsChanged not work??????
|
// TODO why does hasDimensionsChanged not work??????
|
||||||
// if(fSnapshot.hasDimensionsChanged())
|
// if(fSnapshot.hasDimensionsChanged())
|
||||||
// fireDimensionsChanged();
|
// fireDimensionsChanged();
|
||||||
if(fLines!=fSnapshot.getHeight() || fCols!=fSnapshot.getWidth()) {
|
if (fLines != fSnapshot.getHeight() || fCols != fSnapshot.getWidth()) {
|
||||||
fireDimensionsChanged(fSnapshot.getWidth(),fSnapshot.getHeight());
|
fireDimensionsChanged(fSnapshot.getWidth(), fSnapshot.getHeight());
|
||||||
fLines=fSnapshot.getHeight();
|
fLines = fSnapshot.getHeight();
|
||||||
fCols=fSnapshot.getWidth();
|
fCols = fSnapshot.getWidth();
|
||||||
}
|
}
|
||||||
int y=fSnapshot.getFirstChangedLine();
|
int y = fSnapshot.getFirstChangedLine();
|
||||||
// has any line changed?
|
// has any line changed?
|
||||||
if(y<Integer.MAX_VALUE) {
|
if (y < Integer.MAX_VALUE) {
|
||||||
int height=fSnapshot.getLastChangedLine()-y+1;
|
int height = fSnapshot.getLastChangedLine() - y + 1;
|
||||||
fireCellRangeChanged(0, y, fSnapshot.getWidth(), height);
|
fireCellRangeChanged(0, y, fSnapshot.getWidth(), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
fInUpdate=false;
|
fInUpdate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,53 +138,54 @@ 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
|
||||||
*/
|
*/
|
||||||
protected void updateCursor() {
|
protected void updateCursor() {
|
||||||
if(!fCursorIsEnabled)
|
if (!fCursorIsEnabled)
|
||||||
return;
|
return;
|
||||||
int cursorLine=getSnapshot().getCursorLine();
|
int cursorLine = getSnapshot().getCursorLine();
|
||||||
int cursorColumn=getSnapshot().getCursorColumn();
|
int cursorColumn = getSnapshot().getCursorColumn();
|
||||||
// if cursor at the end put it to the end of the
|
// if cursor at the end put it to the end of the
|
||||||
// last line...
|
// last line...
|
||||||
if(cursorLine>=getSnapshot().getHeight()) {
|
if (cursorLine >= getSnapshot().getHeight()) {
|
||||||
cursorLine=getSnapshot().getHeight()-1;
|
cursorLine = getSnapshot().getHeight() - 1;
|
||||||
cursorColumn=getSnapshot().getWidth()-1;
|
cursorColumn = getSnapshot().getWidth() - 1;
|
||||||
}
|
}
|
||||||
// has the cursor moved?
|
// has the cursor moved?
|
||||||
if(fCursorLine!=cursorLine || fCursorColumn!=cursorColumn) {
|
if (fCursorLine != cursorLine || fCursorColumn != cursorColumn) {
|
||||||
// hide the old cursor!
|
// hide the old cursor!
|
||||||
fShowCursor=false;
|
fShowCursor = false;
|
||||||
// clean the previous cursor
|
// clean the previous cursor
|
||||||
// bug 206363: paint also the char to the left and right of the cursor - see also below
|
// bug 206363: paint also the char to the left and right of the cursor - see also below
|
||||||
int col=fCursorColumn;
|
int col = fCursorColumn;
|
||||||
int width=2;
|
int width = 2;
|
||||||
if(col>0) {
|
if (col > 0) {
|
||||||
col--;
|
col--;
|
||||||
width++;
|
width++;
|
||||||
}
|
}
|
||||||
fireCellRangeChanged(col, fCursorLine, width, 1);
|
fireCellRangeChanged(col, fCursorLine, width, 1);
|
||||||
// the cursor is shown when it moves!
|
// the cursor is shown when it moves!
|
||||||
fShowCursor=true;
|
fShowCursor = true;
|
||||||
fCursorTime=System.currentTimeMillis();
|
fCursorTime = System.currentTimeMillis();
|
||||||
fCursorLine=cursorLine;
|
fCursorLine = cursorLine;
|
||||||
fCursorColumn=cursorColumn;
|
fCursorColumn = cursorColumn;
|
||||||
// and draw the new cursor
|
// and draw the new cursor
|
||||||
fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1);
|
fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
long t=System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
// TODO make the cursor blink time customisable
|
// TODO make the cursor blink time customisable
|
||||||
if(t-fCursorTime>500) {
|
if (t - fCursorTime > 500) {
|
||||||
fShowCursor=!fShowCursor;
|
fShowCursor = !fShowCursor;
|
||||||
fCursorTime=t;
|
fCursorTime = t;
|
||||||
// on some windows machines, there is some left
|
// on some windows machines, there is some left
|
||||||
// over when updating the cursor .
|
// over when updating the cursor .
|
||||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=206363
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=206363
|
||||||
int col=fCursorColumn;
|
int col = fCursorColumn;
|
||||||
int width=2;
|
int width = 2;
|
||||||
if(col>0) {
|
if (col > 0) {
|
||||||
col--;
|
col--;
|
||||||
width++;
|
width++;
|
||||||
}
|
}
|
||||||
|
@ -187,25 +193,29 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getSelectionEnd() {
|
public Point getSelectionEnd() {
|
||||||
if(fSelectionStartLine<0)
|
if (fSelectionStartLine < 0)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
return new Point(fSelectionEndColumn, fSeletionEndLine);
|
return new Point(fSelectionEndColumn, fSeletionEndLine);
|
||||||
|
@ -215,57 +225,60 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
if (fSelectionStartLine < 0)
|
if (fSelectionStartLine < 0)
|
||||||
return null;
|
return null;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(int startLine, int endLine, int startColumn, int endColumn) {
|
public void setSelection(int startLine, int endLine, int startColumn, int endColumn) {
|
||||||
// System.err.println(startLine+","+endLine+","+startColumn+","+endColumn);
|
// System.err.println(startLine+","+endLine+","+startColumn+","+endColumn);
|
||||||
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) {
|
||||||
if(fSelectionSnapshot==null) {
|
if (fSelectionSnapshot == null) {
|
||||||
fSelectionSnapshot=fSnapshot.getTerminalTextData().makeSnapshot();
|
fSelectionSnapshot = fSnapshot.getTerminalTextData().makeSnapshot();
|
||||||
fSelectionSnapshot.updateSnapshot(true);
|
fSelectionSnapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
} else if(fSelectionSnapshot!=null) {
|
} else if (fSelectionSnapshot != null) {
|
||||||
fSelectionSnapshot.detach();
|
fSelectionSnapshot.detach();
|
||||||
fSelectionSnapshot=null;
|
fSelectionSnapshot = null;
|
||||||
}
|
}
|
||||||
int oldStart=fSelectionStartLine;
|
int oldStart = fSelectionStartLine;
|
||||||
int oldEnd=fSeletionEndLine;
|
int oldEnd = fSeletionEndLine;
|
||||||
fSelectionStartLine = startLine;
|
fSelectionStartLine = startLine;
|
||||||
fSeletionEndLine = endLine;
|
fSeletionEndLine = endLine;
|
||||||
fSelectionStartCoumn = startColumn;
|
fSelectionStartCoumn = startColumn;
|
||||||
fSelectionEndColumn = endColumn;
|
fSelectionEndColumn = endColumn;
|
||||||
if(fSelectionSnapshot!=null) {
|
if (fSelectionSnapshot != null) {
|
||||||
fSelectionSnapshot.setInterestWindow(0, fSelectionSnapshot.getHeight());
|
fSelectionSnapshot.setInterestWindow(0, fSelectionSnapshot.getHeight());
|
||||||
}
|
}
|
||||||
int changedStart;
|
int changedStart;
|
||||||
int changedEnd;
|
int changedEnd;
|
||||||
if(oldStart<0) {
|
if (oldStart < 0) {
|
||||||
changedStart=fSelectionStartLine;
|
changedStart = fSelectionStartLine;
|
||||||
changedEnd=fSeletionEndLine;
|
changedEnd = fSeletionEndLine;
|
||||||
} else if(fSelectionStartLine<0) {
|
} else if (fSelectionStartLine < 0) {
|
||||||
changedStart=oldStart;
|
changedStart = oldStart;
|
||||||
changedEnd=oldEnd;
|
changedEnd = oldEnd;
|
||||||
} else {
|
} else {
|
||||||
changedStart=Math.min(oldStart, fSelectionStartLine);
|
changedStart = Math.min(oldStart, fSelectionStartLine);
|
||||||
changedEnd=Math.max(oldEnd, fSeletionEndLine);
|
changedEnd = Math.max(oldEnd, fSeletionEndLine);
|
||||||
}
|
}
|
||||||
if(changedStart>=0) {
|
if (changedStart >= 0) {
|
||||||
fireCellRangeChanged(0, changedStart, fSnapshot.getWidth(), changedEnd-changedStart+1);
|
fireCellRangeChanged(0, changedStart, fSnapshot.getWidth(), changedEnd - changedStart + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,33 +313,35 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
* @return the currently selected text
|
* @return the currently selected text
|
||||||
*/
|
*/
|
||||||
private String extractSelectedText() {
|
private String extractSelectedText() {
|
||||||
if(fSelectionStartLine<0 || fSelectionStartCoumn<0 || fSelectionSnapshot==null)
|
if (fSelectionStartLine < 0 || fSelectionStartCoumn < 0 || fSelectionSnapshot == null)
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
StringBuffer buffer=new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
for (int line = fSelectionStartLine; line <= fSeletionEndLine; line++) {
|
for (int line = fSelectionStartLine; line <= fSeletionEndLine; line++) {
|
||||||
String text;
|
String text;
|
||||||
char[] chars=fSelectionSnapshot.getChars(line);
|
char[] chars = fSelectionSnapshot.getChars(line);
|
||||||
if(chars!=null) {
|
if (chars != null) {
|
||||||
text=new String(chars);
|
text = new String(chars);
|
||||||
if(line==fSeletionEndLine && fSelectionEndColumn >= 0)
|
if (line == fSeletionEndLine && fSelectionEndColumn >= 0)
|
||||||
text=text.substring(0, Math.min(fSelectionEndColumn+1,text.length()));
|
text = text.substring(0, Math.min(fSelectionEndColumn + 1, text.length()));
|
||||||
if(line==fSelectionStartLine)
|
if (line == fSelectionStartLine)
|
||||||
text=text.substring(Math.min(fSelectionStartCoumn,text.length()));
|
text = text.substring(Math.min(fSelectionStartCoumn, text.length()));
|
||||||
text=scrubLine(text);
|
text = scrubLine(text);
|
||||||
} else {
|
} else {
|
||||||
text=""; //$NON-NLS-1$
|
text = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
buffer.append(text);
|
buffer.append(text);
|
||||||
if(line < fSeletionEndLine && !fSelectionSnapshot.isWrappedLine(line))
|
if (line < fSeletionEndLine && !fSelectionSnapshot.isWrappedLine(line))
|
||||||
buffer.append('\n');
|
buffer.append('\n');
|
||||||
}
|
}
|
||||||
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)
|
||||||
|
@ -338,7 +353,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
|
||||||
}
|
}
|
||||||
// check if the content of the selection has changed. If the content has
|
// check if the content of the selection has changed. If the content has
|
||||||
// changed, clear the selection
|
// changed, clear the selection
|
||||||
if (fCurrentSelection.length()>0 && fSelectionSnapshot != null
|
if (fCurrentSelection.length() > 0 && fSelectionSnapshot != null
|
||||||
&& fSelectionSnapshot.getFirstChangedLine() <= fSeletionEndLine
|
&& fSelectionSnapshot.getFirstChangedLine() <= fSeletionEndLine
|
||||||
&& fSelectionSnapshot.getLastChangedLine() >= fSelectionStartLine) {
|
&& fSelectionSnapshot.getLastChangedLine() >= fSelectionStartLine) {
|
||||||
// has the selected text changed?
|
// has the selected text changed?
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -35,13 +34,13 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
super(parent, style);
|
super(parent, style);
|
||||||
addListener(SWT.MouseWheel, new Listener() {
|
addListener(SWT.MouseWheel, new Listener() {
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
if(getVerticalBar().isVisible()) {
|
if (getVerticalBar().isVisible()) {
|
||||||
int delta=-fCellHeight;
|
int delta = -fCellHeight;
|
||||||
if(event.count<0)
|
if (event.count < 0)
|
||||||
delta=-delta;
|
delta = -delta;
|
||||||
scrollYDelta(delta);
|
scrollYDelta(delta);
|
||||||
}
|
}
|
||||||
event.doit=false;
|
event.doit = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,36 +50,37 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
* iterates over all cells in the clipping rectangle and paints them.
|
* iterates over all cells in the clipping rectangle and paints them.
|
||||||
*/
|
*/
|
||||||
protected void paint(GC gc) {
|
protected void paint(GC gc) {
|
||||||
Rectangle clipping=gc.getClipping();
|
Rectangle clipping = gc.getClipping();
|
||||||
if(clipping.width==0 || clipping.height==0)
|
if (clipping.width == 0 || clipping.height == 0)
|
||||||
return;
|
return;
|
||||||
Rectangle clientArea= getScreenRectInVirtualSpace();
|
Rectangle clientArea = getScreenRectInVirtualSpace();
|
||||||
// Beginning coordinates
|
// Beginning coordinates
|
||||||
int xOffset=clientArea.x;
|
int xOffset = clientArea.x;
|
||||||
int yOffset=clientArea.y;
|
int yOffset = clientArea.y;
|
||||||
int colFirst=virtualXToCell(xOffset+clipping.x);
|
int colFirst = virtualXToCell(xOffset + clipping.x);
|
||||||
if(colFirst>getCols())
|
if (colFirst > getCols())
|
||||||
colFirst=getCols();
|
colFirst = getCols();
|
||||||
else if (colFirst < 0) {
|
else if (colFirst < 0) {
|
||||||
colFirst = 0;
|
colFirst = 0;
|
||||||
}
|
}
|
||||||
int rowFirst=virtualYToCell(yOffset+clipping.y);
|
int rowFirst = virtualYToCell(yOffset + clipping.y);
|
||||||
// End coordinates
|
// End coordinates
|
||||||
int colLast=virtualXToCell(xOffset+clipping.x+clipping.width+fCellWidth);
|
int colLast = virtualXToCell(xOffset + clipping.x + clipping.width + fCellWidth);
|
||||||
if(colLast>getCols())
|
if (colLast > getCols())
|
||||||
colLast=getCols();
|
colLast = getCols();
|
||||||
int rowLast=virtualYToCell(yOffset+clipping.y+clipping.height+fCellHeight);
|
int rowLast = virtualYToCell(yOffset + clipping.y + clipping.height + fCellHeight);
|
||||||
if(rowLast>getRows())
|
if (rowLast > getRows())
|
||||||
rowLast=getRows();
|
rowLast = getRows();
|
||||||
// System.out.println(rowFirst+"->"+rowLast+" "+System.currentTimeMillis());
|
// System.out.println(rowFirst+"->"+rowLast+" "+System.currentTimeMillis());
|
||||||
// draw the cells
|
// draw the cells
|
||||||
for(int row=rowFirst;row<=rowLast;row++) {
|
for (int row = rowFirst; row <= rowLast; row++) {
|
||||||
int cx=colFirst*fCellWidth-xOffset;
|
int cx = colFirst * fCellWidth - xOffset;
|
||||||
int cy=row*fCellHeight-yOffset;
|
int cy = row * fCellHeight - yOffset;
|
||||||
drawLine(gc,row,cx,cy,colFirst,colLast);
|
drawLine(gc, row, cx, cy, colFirst, colLast);
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
@ -113,63 +114,64 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
int virtualXToCell(int x) {
|
int virtualXToCell(int x) {
|
||||||
return x/fCellWidth;
|
return x / fCellWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int virtualYToCell(int y) {
|
int virtualYToCell(int y) {
|
||||||
return y/fCellHeight;
|
return y / fCellHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Point screenPointToCell(int x, int y) {
|
protected Point screenPointToCell(int x, int y) {
|
||||||
x=screenXtoVirtual(x)/fCellWidth;
|
x = screenXtoVirtual(x) / fCellWidth;
|
||||||
y=screenYtoVirtual(y)/fCellHeight;
|
y = screenYtoVirtual(y) / fCellHeight;
|
||||||
return new Point(x,y);
|
return new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point screenPointToCell(Point point) {
|
Point screenPointToCell(Point point) {
|
||||||
return screenPointToCell(point.x,point.y);
|
return screenPointToCell(point.x, point.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Point cellToOriginOnScreen(int x, int y) {
|
protected Point cellToOriginOnScreen(int x, int y) {
|
||||||
x=virtualXtoScreen(fCellWidth*x);
|
x = virtualXtoScreen(fCellWidth * x);
|
||||||
y=virtualYtoScreen(fCellHeight*y);
|
y = virtualYtoScreen(fCellHeight * y);
|
||||||
return new Point(x,y);
|
return new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point cellToOriginOnScreen(Point cell) {
|
Point cellToOriginOnScreen(Point cell) {
|
||||||
return cellToOriginOnScreen(cell.x,cell.y);
|
return cellToOriginOnScreen(cell.x, cell.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle getCellScreenRect(Point cell) {
|
Rectangle getCellScreenRect(Point cell) {
|
||||||
return getCellScreenRect(cell.x,cell.y);
|
return getCellScreenRect(cell.x, cell.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle getCellScreenRect(int x, int y) {
|
Rectangle getCellScreenRect(int x, int y) {
|
||||||
x=fCellWidth*virtualXtoScreen(x);
|
x = fCellWidth * virtualXtoScreen(x);
|
||||||
y=fCellHeight*virtualYtoScreen(y);
|
y = fCellHeight * virtualYtoScreen(y);
|
||||||
return new Rectangle(x,y,fCellWidth,fCellHeight);
|
return new Rectangle(x, y, fCellWidth, fCellHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rectangle getCellVirtualRect(Point cell) {
|
protected Rectangle getCellVirtualRect(Point cell) {
|
||||||
return getCellVirtualRect(cell.x,cell.y);
|
return getCellVirtualRect(cell.x, cell.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle getCellVirtualRect(int x, int y) {
|
Rectangle getCellVirtualRect(int x, int y) {
|
||||||
x=fCellWidth*x;
|
x = fCellWidth * x;
|
||||||
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);
|
||||||
// End coordinates
|
// End coordinates
|
||||||
int xE=virtualXToCell(x+width);
|
int xE = virtualXToCell(x + width);
|
||||||
// if(xE>getCols())
|
// if(xE>getCols())
|
||||||
// xE=getCols();
|
// xE=getCols();
|
||||||
int yE=virtualYToCell(y+height);
|
int yE = virtualYToCell(y + height);
|
||||||
// if(yE>getRows())
|
// if(yE>getRows())
|
||||||
// yE=getRows();
|
// yE=getRows();
|
||||||
visibleCellRectangleChanged(cellX,cellY,xE-cellX,yE-cellY);
|
visibleCellRectangleChanged(cellX, cellY, xE - cellX, yE - cellY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -206,7 +208,7 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void scrollY(ScrollBar vBar) {
|
protected void scrollY(ScrollBar vBar) {
|
||||||
int vSelection = vBar.getSelection ();
|
int vSelection = vBar.getSelection();
|
||||||
Rectangle bounds = getVirtualBounds();
|
Rectangle bounds = getVirtualBounds();
|
||||||
int y = -vSelection;
|
int y = -vSelection;
|
||||||
int cellHeight = getCellHeight();
|
int cellHeight = getCellHeight();
|
||||||
|
@ -219,8 +221,8 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int deltaY = y - bounds.y;
|
int deltaY = y - bounds.y;
|
||||||
if(deltaY!=0) {
|
if (deltaY != 0) {
|
||||||
scrollSmart(0,deltaY);
|
scrollSmart(0, deltaY);
|
||||||
setVirtualOrigin(bounds.x, bounds.y += deltaY);
|
setVirtualOrigin(bounds.x, bounds.y += deltaY);
|
||||||
}
|
}
|
||||||
if (-bounds.y + getRows() * getCellHeight() >= bounds.height) {
|
if (-bounds.y + getRows() * getCellHeight() >= bounds.height) {
|
||||||
|
|
|
@ -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,19 +62,22 @@ 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!
|
||||||
*/
|
*/
|
||||||
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,11 +96,13 @@ 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)
|
||||||
// wait until not full
|
// wait until not full
|
||||||
wait();
|
wait();
|
||||||
|
@ -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
|
||||||
|
@ -120,7 +126,7 @@ public class PipedInputStream extends InputStream {
|
||||||
*/
|
*/
|
||||||
public int read() throws InterruptedException {
|
public int read() throws InterruptedException {
|
||||||
while (fUsedSlots == 0) {
|
while (fUsedSlots == 0) {
|
||||||
if(fClosed)
|
if (fClosed)
|
||||||
return -1;
|
return -1;
|
||||||
// wait until not empty
|
// wait until not empty
|
||||||
wait();
|
wait();
|
||||||
|
@ -132,10 +138,11 @@ 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) {
|
||||||
if(fClosed)
|
if (fClosed)
|
||||||
return 0;
|
return 0;
|
||||||
// wait until not empty
|
// wait until not empty
|
||||||
wait();
|
wait();
|
||||||
|
@ -147,15 +154,17 @@ public class PipedInputStream extends InputStream {
|
||||||
fTakePos = (fTakePos + len) % fBuffer.length;
|
fTakePos = (fTakePos + len) % fBuffer.length;
|
||||||
boolean wasFull = fUsedSlots == fBuffer.length;
|
boolean wasFull = fUsedSlots == fBuffer.length;
|
||||||
fUsedSlots -= len;
|
fUsedSlots -= len;
|
||||||
if(wasFull)
|
if (wasFull)
|
||||||
notifyAll();
|
notifyAll();
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -171,11 +180,11 @@ public class PipedInputStream extends InputStream {
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
try {
|
try {
|
||||||
synchronized (fQueue) {
|
synchronized (fQueue) {
|
||||||
if(fQueue.isClosed())
|
if (fQueue.isClosed())
|
||||||
throw new IOException("Stream is closed!"); //$NON-NLS-1$
|
throw new IOException("Stream is closed!"); //$NON-NLS-1$
|
||||||
int written=0;
|
int written = 0;
|
||||||
while(written<len) {
|
while (written < len) {
|
||||||
if(fQueue.getFreeSlots()==0) {
|
if (fQueue.getFreeSlots() == 0) {
|
||||||
// if no slots available, write one byte and block
|
// if no slots available, write one byte and block
|
||||||
// until free slots are available
|
// until free slots are available
|
||||||
fQueue.write(b[off + written]);
|
fQueue.write(b[off + written]);
|
||||||
|
@ -183,9 +192,9 @@ public class PipedInputStream extends InputStream {
|
||||||
} else {
|
} else {
|
||||||
// if slots are available, write as much as
|
// if slots are available, write as much as
|
||||||
// we can in one junk
|
// we can in one junk
|
||||||
int n=Math.min(fQueue.getFreeSlots(), len-written);
|
int n = Math.min(fQueue.getFreeSlots(), len - written);
|
||||||
fQueue.write(b, off + written, n);
|
fQueue.write(b, off + written, n);
|
||||||
written+=n;
|
written += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,34 +205,38 @@ public class PipedInputStream extends InputStream {
|
||||||
|
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
try {
|
try {
|
||||||
synchronized(fQueue) {
|
synchronized (fQueue) {
|
||||||
if(fQueue.isClosed())
|
if (fQueue.isClosed())
|
||||||
throw new IOException("Stream is closed!"); //$NON-NLS-1$
|
throw new IOException("Stream is closed!"); //$NON-NLS-1$
|
||||||
fQueue.write((byte)b);
|
fQueue.write((byte) b);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public PipedInputStream(int bufferSize) {
|
public PipedInputStream(int bufferSize) {
|
||||||
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)}
|
||||||
|
@ -231,25 +244,27 @@ public class PipedInputStream extends InputStream {
|
||||||
* for the buffer to become ready
|
* for the buffer to become ready
|
||||||
*/
|
*/
|
||||||
public void waitForAvailable(long millis) throws InterruptedException {
|
public void waitForAvailable(long millis) throws InterruptedException {
|
||||||
synchronized(fQueue) {
|
synchronized (fQueue) {
|
||||||
if(fQueue.available()==0 && !fQueue.fClosed)
|
if (fQueue.available() == 0 && !fQueue.fClosed)
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
public int available() {
|
public int available() {
|
||||||
synchronized(fQueue) {
|
synchronized (fQueue) {
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
try {
|
try {
|
||||||
synchronized (fQueue) {
|
synchronized (fQueue) {
|
||||||
return fQueue.read();
|
return fQueue.read();
|
||||||
|
@ -259,20 +274,21 @@ public class PipedInputStream extends InputStream {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 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
|
* Closing a <tt>PipedInputStream</tt> is the same as closing the output stream.
|
||||||
* throw an <tt>IOException</tt>.
|
* The stream will allow reading data that's still in the pipe after which it will
|
||||||
*/
|
* throw an <tt>IOException</tt>.
|
||||||
|
*/
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
synchronized(fQueue) {
|
synchronized (fQueue) {
|
||||||
fQueue.close();
|
fQueue.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(byte[] cbuf, int off, int len) throws IOException {
|
public int read(byte[] cbuf, int off, int len) throws IOException {
|
||||||
int n=0;
|
int n = 0;
|
||||||
if(len==0)
|
if (len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
// read as much as we can using a single synchronized statement
|
// read as much as we can using a single synchronized statement
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -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,17 +29,20 @@ 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;
|
||||||
Display.getDefault().timerExec(fPollInterval, new Runnable(){
|
Display.getDefault().timerExec(fPollInterval, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
update();
|
update();
|
||||||
Display.getDefault().timerExec(fPollInterval, this);
|
Display.getDefault().timerExec(fPollInterval, this);
|
||||||
|
|
|
@ -47,27 +47,30 @@ public class StyleMap {
|
||||||
private static final String RED = "red"; //$NON-NLS-1$
|
private static final String RED = "red"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$
|
private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$
|
||||||
String fFontName=ITerminalConstants.FONT_DEFINITION;
|
String fFontName = ITerminalConstants.FONT_DEFINITION;
|
||||||
Map<StyleColor, Color> fColorMapForeground=new HashMap<StyleColor, Color>();
|
Map<StyleColor, Color> fColorMapForeground = new HashMap<StyleColor, Color>();
|
||||||
Map<StyleColor, Color> fColorMapBackground=new HashMap<StyleColor, Color>();
|
Map<StyleColor, Color> fColorMapBackground = new HashMap<StyleColor, Color>();
|
||||||
Map<StyleColor, Color> fColorMapIntense=new HashMap<StyleColor, Color>();
|
Map<StyleColor, Color> fColorMapIntense = new HashMap<StyleColor, Color>();
|
||||||
private Point fCharSize;
|
private Point fCharSize;
|
||||||
private final Style fDefaultStyle;
|
private final Style fDefaultStyle;
|
||||||
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);
|
||||||
setColor(fColorMapForeground, WHITE_FOREGROUND, 50, 50, 50);
|
setColor(fColorMapForeground, WHITE_FOREGROUND, 50, 50, 50);
|
||||||
setColor(fColorMapForeground, BLACK, 229, 229, 229);
|
setColor(fColorMapForeground, BLACK, 229, 229, 229);
|
||||||
|
@ -86,7 +89,7 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBackgroundColors() {
|
private void initBackgroundColors() {
|
||||||
if(fInvertColors) {
|
if (fInvertColors) {
|
||||||
setColor(fColorMapBackground, WHITE, 0, 0, 0);
|
setColor(fColorMapBackground, WHITE, 0, 0, 0);
|
||||||
setColor(fColorMapBackground, WHITE_FOREGROUND, 50, 50, 50); // only used when colors are inverse
|
setColor(fColorMapBackground, WHITE_FOREGROUND, 50, 50, 50); // only used when colors are inverse
|
||||||
setColor(fColorMapBackground, BLACK, 255, 255, 255);
|
setColor(fColorMapBackground, BLACK, 255, 255, 255);
|
||||||
|
@ -105,7 +108,7 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initIntenseColors() {
|
private void initIntenseColors() {
|
||||||
if(fInvertColors) {
|
if (fInvertColors) {
|
||||||
setColor(fColorMapIntense, WHITE, 127, 127, 127);
|
setColor(fColorMapIntense, WHITE, 127, 127, 127);
|
||||||
setColor(fColorMapIntense, WHITE_FOREGROUND, 0, 0, 0); // only used when colors are inverse
|
setColor(fColorMapIntense, WHITE_FOREGROUND, 0, 0, 0); // only used when colors are inverse
|
||||||
setColor(fColorMapIntense, BLACK, 255, 255, 255);
|
setColor(fColorMapIntense, BLACK, 255, 255, 255);
|
||||||
|
@ -124,11 +127,11 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setColor(Map<StyleColor, Color> colorMap, String name, int r, int g, int b) {
|
private void setColor(Map<StyleColor, Color> colorMap, String name, int r, int g, int b) {
|
||||||
String colorName=PREFIX+r+"-"+g+"-"+b; //$NON-NLS-1$//$NON-NLS-2$
|
String colorName = PREFIX + r + "-" + g + "-" + b; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
Color color=JFaceResources.getColorRegistry().get(colorName);
|
Color color = JFaceResources.getColorRegistry().get(colorName);
|
||||||
if(color==null) {
|
if (color == null) {
|
||||||
JFaceResources.getColorRegistry().put(colorName, new RGB(r,g,b));
|
JFaceResources.getColorRegistry().put(colorName, new RGB(r, g, b));
|
||||||
color=JFaceResources.getColorRegistry().get(colorName);
|
color = JFaceResources.getColorRegistry().get(colorName);
|
||||||
}
|
}
|
||||||
colorMap.put(StyleColor.getStyleColor(name), color);
|
colorMap.put(StyleColor.getStyleColor(name), color);
|
||||||
colorMap.put(StyleColor.getStyleColor(name.toUpperCase()), color);
|
colorMap.put(StyleColor.getStyleColor(name.toUpperCase()), color);
|
||||||
|
@ -138,66 +141,74 @@ public class StyleMap {
|
||||||
style = defaultIfNull(style);
|
style = defaultIfNull(style);
|
||||||
Map<StyleColor, Color> map = style.isBold() ? fColorMapIntense : fColorMapForeground;
|
Map<StyleColor, Color> map = style.isBold() ? fColorMapIntense : fColorMapForeground;
|
||||||
//Map map = fColorMapForeground;
|
//Map map = fColorMapForeground;
|
||||||
if(style.isReverse())
|
if (style.isReverse())
|
||||||
return getColor(map ,style.getBackground());
|
return getColor(map, style.getBackground());
|
||||||
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())
|
||||||
return getColor(fColorMapBackground,style.getForground());
|
return getColor(fColorMapBackground, style.getForground());
|
||||||
else
|
else
|
||||||
return getColor(fColorMapBackground,style.getBackground());
|
return getColor(fColorMapBackground, style.getBackground());
|
||||||
}
|
}
|
||||||
Color getColor(Map<StyleColor, Color> map,StyleColor color) {
|
|
||||||
Color c=map.get(color);
|
Color getColor(Map<StyleColor, Color> map, StyleColor color) {
|
||||||
if(c==null) {
|
Color c = map.get(color);
|
||||||
c=Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
|
if (c == null) {
|
||||||
|
c = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
|
||||||
}
|
}
|
||||||
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;
|
||||||
fInvertColors=invert;
|
fInvertColors = invert;
|
||||||
initColors();
|
initColors();
|
||||||
}
|
}
|
||||||
// static Font getBoldFont(Font font) {
|
// static Font getBoldFont(Font font) {
|
||||||
// FontData fontDatas[] = font.getFontData();
|
// FontData fontDatas[] = font.getFontData();
|
||||||
// FontData data = fontDatas[0];
|
// FontData data = fontDatas[0];
|
||||||
// return new Font(Display.getCurrent(), data.getName(), data.getHeight(), data.getStyle()|SWT.BOLD);
|
// return new Font(Display.getCurrent(), data.getName(), data.getHeight(), data.getStyle()|SWT.BOLD);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public Font getFont(Style style) {
|
public Font getFont(Style style) {
|
||||||
style = defaultIfNull(style);
|
style = defaultIfNull(style);
|
||||||
if(style.isBold()) {
|
if (style.isBold()) {
|
||||||
return JFaceResources.getFontRegistry().getBold(fFontName);
|
return JFaceResources.getFontRegistry().getBold(fFontName);
|
||||||
} else if(style.isUnderline()) {
|
} else if (style.isUnderline()) {
|
||||||
return JFaceResources.getFontRegistry().getItalic(fFontName);
|
return JFaceResources.getFontRegistry().getItalic(fFontName);
|
||||||
|
|
||||||
}
|
}
|
||||||
return JFaceResources.getFontRegistry().get(fFontName);
|
return JFaceResources.getFontRegistry().get(fFontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
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.
|
||||||
|
@ -205,8 +216,8 @@ public class StyleMap {
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public void updateFont(String fontName) {
|
public void updateFont(String fontName) {
|
||||||
Display display=Display.getCurrent();
|
Display display = Display.getCurrent();
|
||||||
GC gc = new GC (display);
|
GC gc = new GC(display);
|
||||||
if (JFaceResources.getFontRegistry().hasValueFor(fontName)) {
|
if (JFaceResources.getFontRegistry().hasValueFor(fontName)) {
|
||||||
fFontName = fontName;
|
fFontName = fontName;
|
||||||
} else {
|
} else {
|
||||||
|
@ -214,35 +225,35 @@ public class StyleMap {
|
||||||
fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$
|
fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
gc.setFont(getFont());
|
gc.setFont(getFont());
|
||||||
fCharSize = gc.textExtent ("W"); //$NON-NLS-1$
|
fCharSize = gc.textExtent("W"); //$NON-NLS-1$
|
||||||
fProportional=false;
|
fProportional = false;
|
||||||
|
|
||||||
for (char c = ' '; c <= '~'; c++) {
|
for (char c = ' '; c <= '~'; c++) {
|
||||||
// consider only the first 128 chars for deciding if a font
|
// consider only the first 128 chars for deciding if a font
|
||||||
// is proportional. Collect char width as a side-effect.
|
// is proportional. Collect char width as a side-effect.
|
||||||
if(measureChar(gc, c, true))
|
if (measureChar(gc, c, true))
|
||||||
fProportional=true;
|
fProportional = true;
|
||||||
}
|
}
|
||||||
if(fProportional) {
|
if (fProportional) {
|
||||||
// Widest char minus the padding on the left and right:
|
// Widest char minus the padding on the left and right:
|
||||||
// Looks much better for small fonts
|
// Looks much better for small fonts
|
||||||
fCharSize.x-=2;
|
fCharSize.x -= 2;
|
||||||
// Collect width of the upper characters (for offset calculation)
|
// Collect width of the upper characters (for offset calculation)
|
||||||
for (char c = '~'+1; c < fOffsets.length; c++) {
|
for (char c = '~' + 1; c < fOffsets.length; c++) {
|
||||||
measureChar(gc, c,false);
|
measureChar(gc, c, false);
|
||||||
}
|
}
|
||||||
// Calculate offsets based on each character's width and the bounding box
|
// Calculate offsets based on each character's width and the bounding box
|
||||||
for (int i = ' '; i < fOffsets.length; i++) {
|
for (int i = ' '; i < fOffsets.length; i++) {
|
||||||
fOffsets[i]=(fCharSize.x-fOffsets[i])/2;
|
fOffsets[i] = (fCharSize.x - fOffsets[i]) / 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Non-Proportional: Reset all offsets (eg after font change)
|
// Non-Proportional: Reset all offsets (eg after font change)
|
||||||
for (int i = 0; i < fOffsets.length; i++) {
|
for (int i = 0; i < fOffsets.length; i++) {
|
||||||
fOffsets[i]=0;
|
fOffsets[i] = 0;
|
||||||
}
|
}
|
||||||
String t = "The quick brown Fox jumps over the Lazy Dog."; //$NON-NLS-1$
|
String t = "The quick brown Fox jumps over the Lazy Dog."; //$NON-NLS-1$
|
||||||
Point ext=gc.textExtent(t);
|
Point ext = gc.textExtent(t);
|
||||||
if(ext.x != fCharSize.x * t.length()) {
|
if (ext.x != fCharSize.x * t.length()) {
|
||||||
//Bug 475422: On OSX with Retina display and due to scaling,
|
//Bug 475422: On OSX with Retina display and due to scaling,
|
||||||
//a text many be shorter than the sum of its bounding boxes.
|
//a text many be shorter than the sum of its bounding boxes.
|
||||||
//Because even with fixed width font, bounding box size
|
//Because even with fixed width font, bounding box size
|
||||||
|
@ -252,17 +263,18 @@ public class StyleMap {
|
||||||
//is painted individually into its proper bounding box, rather
|
//is painted individually into its proper bounding box, rather
|
||||||
//than using an optimization where Strings would be drawn as
|
//than using an optimization where Strings would be drawn as
|
||||||
//a whole. This fixes the "fractional bounding box" problem.
|
//a whole. This fixes the "fractional bounding box" problem.
|
||||||
fProportional=true;
|
fProportional = true;
|
||||||
}
|
}
|
||||||
//measure font in boldface, too, and if wider then treat like proportional
|
//measure font in boldface, too, and if wider then treat like proportional
|
||||||
gc.setFont(getFont(fDefaultStyle.setBold(true)));
|
gc.setFont(getFont(fDefaultStyle.setBold(true)));
|
||||||
Point charSizeBold = gc.textExtent("W"); //$NON-NLS-1$
|
Point charSizeBold = gc.textExtent("W"); //$NON-NLS-1$
|
||||||
if (fCharSize.x != charSizeBold.x) {
|
if (fCharSize.x != charSizeBold.x) {
|
||||||
fProportional=true;
|
fProportional = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gc.dispose ();
|
gc.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param gc
|
* @param gc
|
||||||
* @param c
|
* @param c
|
||||||
|
@ -270,28 +282,30 @@ public class StyleMap {
|
||||||
* @return true if the the font is proportional
|
* @return true if the the font is proportional
|
||||||
*/
|
*/
|
||||||
private boolean measureChar(GC gc, char c, boolean updateMax) {
|
private boolean measureChar(GC gc, char c, boolean updateMax) {
|
||||||
boolean proportional=false;
|
boolean proportional = false;
|
||||||
Point ext=gc.textExtent(String.valueOf(c));
|
Point ext = gc.textExtent(String.valueOf(c));
|
||||||
if(ext.x>0 && ext.y>0 && (fCharSize.x!=ext.x || fCharSize.y!=ext.y)) {
|
if (ext.x > 0 && ext.y > 0 && (fCharSize.x != ext.x || fCharSize.y != ext.y)) {
|
||||||
proportional=true;
|
proportional = true;
|
||||||
if(updateMax) {
|
if (updateMax) {
|
||||||
fCharSize.x=Math.max(fCharSize.x, ext.x);
|
fCharSize.x = Math.max(fCharSize.x, ext.x);
|
||||||
fCharSize.y=Math.max(fCharSize.y, ext.y);
|
fCharSize.y = Math.max(fCharSize.y, ext.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
* @return the offset in x direction to center this character
|
* @return the offset in x direction to center this character
|
||||||
*/
|
*/
|
||||||
public int getCharOffset(char c) {
|
public int getCharOffset(char c) {
|
||||||
if(c>=fOffsets.length)
|
if (c >= fOffsets.length)
|
||||||
return 0;
|
return 0;
|
||||||
return fOffsets[c];
|
return fOffsets[c];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -82,8 +81,8 @@ public class TextCanvas extends GridCanvas {
|
||||||
// since it allows switching the terminal viewport small/large as needed,
|
// since it allows switching the terminal viewport small/large as needed,
|
||||||
// without destroying the backing store. For a complete solution,
|
// without destroying the backing store. For a complete solution,
|
||||||
// Bug 196462 tracks the request for a user-defined fixed-widow-size-mode.
|
// Bug 196462 tracks the request for a user-defined fixed-widow-size-mode.
|
||||||
private int fMinColumns=80;
|
private int fMinColumns = 80;
|
||||||
private int fMinLines=4;
|
private int fMinLines = 4;
|
||||||
private boolean fCursorEnabled;
|
private boolean fCursorEnabled;
|
||||||
private boolean fResizing;
|
private boolean fResizing;
|
||||||
|
|
||||||
|
@ -91,23 +90,28 @@ public class TextCanvas extends GridCanvas {
|
||||||
* Create a new CellCanvas with the given SWT style bits.
|
* Create a new CellCanvas with the given SWT style bits.
|
||||||
* (SWT.H_SCROLL and SWT.V_SCROLL are automatically added).
|
* (SWT.H_SCROLL and SWT.V_SCROLL are automatically added).
|
||||||
*/
|
*/
|
||||||
public TextCanvas(Composite parent, ITextCanvasModel model, int style,ILinelRenderer cellRenderer) {
|
public TextCanvas(Composite parent, ITextCanvasModel model, int style, ILinelRenderer cellRenderer) {
|
||||||
super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL);
|
super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||||
fCellRenderer=cellRenderer;
|
fCellRenderer = cellRenderer;
|
||||||
setCellWidth(fCellRenderer.getCellWidth());
|
setCellWidth(fCellRenderer.getCellWidth());
|
||||||
setCellHeight(fCellRenderer.getCellHeight());
|
setCellHeight(fCellRenderer.getCellHeight());
|
||||||
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())
|
||||||
repaintRange(col,line,width,height);
|
return;
|
||||||
|
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) {
|
||||||
|
@ -117,15 +121,17 @@ public class TextCanvas extends GridCanvas {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// let the cursor blink if the text canvas gets the focus...
|
// let the cursor blink if the text canvas gets the focus...
|
||||||
addFocusListener(new FocusListener(){
|
addFocusListener(new FocusListener() {
|
||||||
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) {
|
||||||
if (fMouseListeners.size() > 0) {
|
if (fMouseListeners.size() > 0) {
|
||||||
Point pt = screenPointToCell(e.x, e.y);
|
Point pt = screenPointToCell(e.x, e.y);
|
||||||
|
@ -136,18 +142,19 @@ 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);
|
||||||
fHasSelection=false;
|
fHasSelection = false;
|
||||||
if((e.stateMask&SWT.SHIFT)!=0) {
|
if ((e.stateMask & SWT.SHIFT) != 0) {
|
||||||
Point anchor=fCellCanvasModel.getSelectionAnchor();
|
Point anchor = fCellCanvasModel.getSelectionAnchor();
|
||||||
if(anchor!=null)
|
if (anchor != null)
|
||||||
fDraggingStart=anchor;
|
fDraggingStart = anchor;
|
||||||
} else {
|
} else {
|
||||||
fCellCanvasModel.setSelectionAnchor(fDraggingStart);
|
fCellCanvasModel.setSelectionAnchor(fDraggingStart);
|
||||||
}
|
}
|
||||||
fDraggingEnd=null;
|
fDraggingEnd = null;
|
||||||
}
|
}
|
||||||
if (fMouseListeners.size() > 0) {
|
if (fMouseListeners.size() > 0) {
|
||||||
Point pt = screenPointToCell(e.x, e.y);
|
Point pt = screenPointToCell(e.x, e.y);
|
||||||
|
@ -158,14 +165,15 @@ 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);
|
||||||
if(fHasSelection)
|
if (fHasSelection)
|
||||||
setSelection(screenPointToCell(e.x, e.y));
|
setSelection(screenPointToCell(e.x, e.y));
|
||||||
else
|
else
|
||||||
fCellCanvasModel.setSelection(-1,-1,-1,-1);
|
fCellCanvasModel.setSelection(-1, -1, -1, -1);
|
||||||
fDraggingStart=null;
|
fDraggingStart = null;
|
||||||
}
|
}
|
||||||
if (fMouseListeners.size() > 0) {
|
if (fMouseListeners.size() > 0) {
|
||||||
Point pt = screenPointToCell(e.x, e.y);
|
Point pt = screenPointToCell(e.x, e.y);
|
||||||
|
@ -197,15 +205,15 @@ public class TextCanvas extends GridCanvas {
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
private void updateHasSelection(MouseEvent e) {
|
private void updateHasSelection(MouseEvent e) {
|
||||||
if(fDraggingStart!=null) {
|
if (fDraggingStart != null) {
|
||||||
Point p=screenPointToCell(e.x, e.y);
|
Point p = screenPointToCell(e.x, e.y);
|
||||||
if(fDraggingStart.x!=p.x||fDraggingStart.y!=p.y)
|
if (fDraggingStart.x != p.x || fDraggingStart.y != p.y)
|
||||||
fHasSelection=true;
|
fHasSelection = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSelection(Point p) {
|
void setSelection(Point p) {
|
||||||
if (fDraggingStart !=null && !p.equals(fDraggingEnd)) {
|
if (fDraggingStart != null && !p.equals(fDraggingEnd)) {
|
||||||
fDraggingEnd = p;
|
fDraggingEnd = p;
|
||||||
if (compare(p, fDraggingStart) < 0) {
|
if (compare(p, fDraggingStart) < 0) {
|
||||||
// bug 219589 - make sure selection start coordinates are non-negative
|
// bug 219589 - make sure selection start coordinates are non-negative
|
||||||
|
@ -234,6 +242,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILinelRenderer getCellRenderer() {
|
public ILinelRenderer getCellRenderer() {
|
||||||
return fCellRenderer;
|
return fCellRenderer;
|
||||||
}
|
}
|
||||||
|
@ -255,30 +264,30 @@ public class TextCanvas extends GridCanvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onResize(boolean init) {
|
protected void onResize(boolean init) {
|
||||||
if(fResizeListener!=null) {
|
if (fResizeListener != null) {
|
||||||
Rectangle bonds=getClientArea();
|
Rectangle bonds = getClientArea();
|
||||||
int cellHeight = getCellHeight();
|
int cellHeight = getCellHeight();
|
||||||
int cellWidth = getCellWidth();
|
int cellWidth = getCellWidth();
|
||||||
int lines=bonds.height/cellHeight;
|
int lines = bonds.height / cellHeight;
|
||||||
int columns=bonds.width/cellWidth;
|
int columns = bonds.width / cellWidth;
|
||||||
// when the view is minimised, its size is set to 0
|
// when the view is minimised, its size is set to 0
|
||||||
// we don't sent this to the terminal!
|
// we don't sent this to the terminal!
|
||||||
if((lines>0 && columns>0) || init) {
|
if ((lines > 0 && columns > 0) || init) {
|
||||||
if(columns<fMinColumns) {
|
if (columns < fMinColumns) {
|
||||||
if(!isHorizontalBarVisble()) {
|
if (!isHorizontalBarVisble()) {
|
||||||
setHorizontalBarVisible(true);
|
setHorizontalBarVisible(true);
|
||||||
bonds=getClientArea();
|
bonds = getClientArea();
|
||||||
lines=bonds.height/cellHeight;
|
lines = bonds.height / cellHeight;
|
||||||
}
|
}
|
||||||
columns=fMinColumns;
|
columns = fMinColumns;
|
||||||
} else if(columns>=fMinColumns && isHorizontalBarVisble()) {
|
} else if (columns >= fMinColumns && isHorizontalBarVisble()) {
|
||||||
setHorizontalBarVisible(false);
|
setHorizontalBarVisible(false);
|
||||||
bonds=getClientArea();
|
bonds = getClientArea();
|
||||||
lines=bonds.height/cellHeight;
|
lines = bonds.height / cellHeight;
|
||||||
columns=bonds.width/cellWidth;
|
columns = bonds.width / cellWidth;
|
||||||
}
|
}
|
||||||
if(lines<fMinLines)
|
if (lines < fMinLines)
|
||||||
lines=fMinLines;
|
lines = fMinLines;
|
||||||
fResizeListener.sizeChanged(lines, columns);
|
fResizeListener.sizeChanged(lines, columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +308,7 @@ public class TextCanvas extends GridCanvas {
|
||||||
Rectangle virtualBounds = getVirtualBounds();
|
Rectangle virtualBounds = getVirtualBounds();
|
||||||
setRedraw(false);
|
setRedraw(false);
|
||||||
try {
|
try {
|
||||||
setVirtualExtend(getCols()*getCellWidth(),getRows()*getCellHeight());
|
setVirtualExtend(getCols() * getCellWidth(), getRows() * getCellHeight());
|
||||||
getParent().layout();
|
getParent().layout();
|
||||||
if (fResizing) {
|
if (fResizing) {
|
||||||
// scroll to end if view port was near last line
|
// scroll to end if view port was near last line
|
||||||
|
@ -311,21 +320,23 @@ 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);
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
Rectangle v=getViewRectangle();
|
Rectangle v = getViewRectangle();
|
||||||
if(v.y!=-y) {
|
if (v.y != -y) {
|
||||||
setVirtualOrigin(v.x,y);
|
setVirtualOrigin(v.x, y);
|
||||||
}
|
}
|
||||||
// make sure the scroll area is correct:
|
// make sure the scroll area is correct:
|
||||||
scrollY(getVerticalBar());
|
scrollY(getVerticalBar());
|
||||||
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,16 +392,18 @@ 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.setSelectionAnchor(new Point(0,0));
|
fCellCanvasModel.getTerminalText().getWidth());
|
||||||
|
fCellCanvasModel.setSelectionAnchor(new Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public void clearSelection() {
|
public void clearSelection() {
|
||||||
fCellCanvasModel.setSelection(-1,-1,-1,-1);
|
fCellCanvasModel.setSelection(-1, -1, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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,23 +434,24 @@ 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
|
||||||
* terminaldata
|
* terminaldata
|
||||||
*/
|
*/
|
||||||
public void addResizeHandler(ResizeListener listener) {
|
public void addResizeHandler(ResizeListener listener) {
|
||||||
if(fResizeListener!=null)
|
if (fResizeListener != null)
|
||||||
throw new IllegalArgumentException("There can be at most one listener at the moment!"); //$NON-NLS-1$
|
throw new IllegalArgumentException("There can be at most one listener at the moment!"); //$NON-NLS-1$
|
||||||
fResizeListener=listener;
|
fResizeListener = listener;
|
||||||
|
|
||||||
// Bug 281328: [terminal] The very first few characters might be missing in
|
// Bug 281328: [terminal] The very first few characters might be missing in
|
||||||
// the terminal control if opened and connected programmatically
|
// the terminal control if opened and connected programmatically
|
||||||
//
|
//
|
||||||
// In case the terminal had not been visible yet or is too small (less than one
|
// In case the terminal had not been visible yet or is too small (less than one
|
||||||
// line visible), the terminal should have a minimum size to avoid RuntimeExceptions.
|
// line visible), the terminal should have a minimum size to avoid RuntimeExceptions.
|
||||||
Rectangle bonds=getClientArea();
|
Rectangle bonds = getClientArea();
|
||||||
if (bonds.height<getCellHeight() || bonds.width<getCellWidth()) {
|
if (bonds.height < getCellHeight() || bonds.width < getCellWidth()) {
|
||||||
//Widget not realized yet, or minimized to < 1 item:
|
//Widget not realized yet, or minimized to < 1 item:
|
||||||
//Just tell the listener our min size
|
//Just tell the listener our min size
|
||||||
fResizeListener.sizeChanged(getMinLines(), getMinColumns());
|
fResizeListener.sizeChanged(getMinLines(), getMinColumns());
|
||||||
|
@ -470,8 +494,8 @@ public class TextCanvas extends GridCanvas {
|
||||||
* @param enabled enabling means that the cursor blinks
|
* @param enabled enabling means that the cursor blinks
|
||||||
*/
|
*/
|
||||||
public void setCursorEnabled(boolean enabled) {
|
public void setCursorEnabled(boolean enabled) {
|
||||||
if(enabled!=fCursorEnabled) {
|
if (enabled != fCursorEnabled) {
|
||||||
fCursorEnabled=enabled;
|
fCursorEnabled = enabled;
|
||||||
fCellCanvasModel.setCursorEnabled(fCursorEnabled);
|
fCellCanvasModel.setCursorEnabled(fCursorEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,4 +509,3 @@ public class TextCanvas extends GridCanvas {
|
||||||
fMouseListeners.remove(listener);
|
fMouseListeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,56 +31,61 @@ 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()
|
||||||
fillBackground(gc, x, y, getCellWidth()*(colLast-colFirst), getCellHeight());
|
|| colFirst - colLast == 0) {
|
||||||
|
fillBackground(gc, x, y, getCellWidth() * (colLast - colFirst), getCellHeight());
|
||||||
} else {
|
} else {
|
||||||
colLast=Math.min(colLast, getTerminalText().getWidth());
|
colLast = Math.min(colLast, getTerminalText().getWidth());
|
||||||
LineSegment[] segments=getTerminalText().getLineSegments(line, colFirst, colLast-colFirst);
|
LineSegment[] segments = getTerminalText().getLineSegments(line, colFirst, colLast - colFirst);
|
||||||
for (int i = 0; i < segments.length; i++) {
|
for (int i = 0; i < segments.length; i++) {
|
||||||
LineSegment segment=segments[i];
|
LineSegment segment = segments[i];
|
||||||
Style style=segment.getStyle();
|
Style style = segment.getStyle();
|
||||||
setupGC(gc, style);
|
setupGC(gc, style);
|
||||||
String text=segment.getText();
|
String text = segment.getText();
|
||||||
drawText(gc, x, y, colFirst, segment.getColumn(), text);
|
drawText(gc, x, y, colFirst, segment.getColumn(), text);
|
||||||
drawCursor(model, gc, line, x, y, colFirst);
|
drawCursor(model, gc, line, x, y, colFirst);
|
||||||
}
|
}
|
||||||
if(fModel.hasLineSelection(line)) {
|
if (fModel.hasLineSelection(line)) {
|
||||||
gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
||||||
gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION));
|
gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION));
|
||||||
Point start=model.getSelectionStart();
|
Point start = model.getSelectionStart();
|
||||||
Point end=model.getSelectionEnd();
|
Point end = model.getSelectionEnd();
|
||||||
char[] chars=model.getTerminalText().getChars(line);
|
char[] chars = model.getTerminalText().getChars(line);
|
||||||
if(chars==null)
|
if (chars == null)
|
||||||
return;
|
return;
|
||||||
int offset=0;
|
int offset = 0;
|
||||||
if(start.y==line)
|
if (start.y == line)
|
||||||
offset=start.x;
|
offset = start.x;
|
||||||
offset=Math.max(offset, colFirst);
|
offset = Math.max(offset, colFirst);
|
||||||
int len;
|
int len;
|
||||||
if(end.y==line)
|
if (end.y == line)
|
||||||
len=end.x-offset+1;
|
len = end.x - offset + 1;
|
||||||
else
|
else
|
||||||
len=chars.length-offset+1;
|
len = chars.length - offset + 1;
|
||||||
len=Math.min(len,chars.length-offset);
|
len = Math.min(len, chars.length - offset);
|
||||||
if(len>0) {
|
if (len > 0) {
|
||||||
String text=new String(chars,offset,len);
|
String text = new String(chars, offset, len);
|
||||||
drawText(gc, x, y, colFirst, offset, text);
|
drawText(gc, x, y, colFirst, offset, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,9 +93,9 @@ public class TextLineRenderer implements ILinelRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillBackground(GC gc, int x, int y, int width, int height) {
|
private void fillBackground(GC gc, int x, int y, int width, int height) {
|
||||||
Color bg=gc.getBackground();
|
Color bg = gc.getBackground();
|
||||||
gc.setBackground(getDefaultBackgroundColor());
|
gc.setBackground(getDefaultBackgroundColor());
|
||||||
gc.fillRectangle (x,y,width,height);
|
gc.fillRectangle(x, y, width, height);
|
||||||
gc.setBackground(bg);
|
gc.setBackground(bg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,68 +106,74 @@ public class TextLineRenderer implements ILinelRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) {
|
private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) {
|
||||||
if(!model.isCursorOn())
|
if (!model.isCursorOn())
|
||||||
return;
|
return;
|
||||||
int cursorLine=model.getCursorLine();
|
int cursorLine = model.getCursorLine();
|
||||||
|
|
||||||
if(row==cursorLine) {
|
if (row == cursorLine) {
|
||||||
int cursorColumn=model.getCursorColumn();
|
int cursorColumn = model.getCursorColumn();
|
||||||
if(cursorColumn<getTerminalText().getWidth()) {
|
if (cursorColumn < getTerminalText().getWidth()) {
|
||||||
Style style=getTerminalText().getStyle(row, cursorColumn);
|
Style style = getTerminalText().getStyle(row, cursorColumn);
|
||||||
if(style==null) {
|
if (style == null) {
|
||||||
// TODO make the cursor color customizable
|
// TODO make the cursor color customizable
|
||||||
style=Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$//$NON-NLS-2$
|
style = Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
}
|
||||||
style=style.setReverse(!style.isReverse());
|
style = style.setReverse(!style.isReverse());
|
||||||
setupGC(gc,style);
|
setupGC(gc, style);
|
||||||
String text=String.valueOf(getTerminalText().getChar(row, cursorColumn));
|
String text = String.valueOf(getTerminalText().getChar(row, cursorColumn));
|
||||||
drawText(gc, x, y, colFirst, cursorColumn, text);
|
drawText(gc, x, y, colFirst, cursorColumn, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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()) {
|
||||||
// draw the background
|
// draw the background
|
||||||
// TODO why does this not work???????
|
// TODO why does this not work???????
|
||||||
// gc.fillRectangle(x,y,fStyleMap.getFontWidth()*text.length(),fStyleMap.getFontHeight());
|
// gc.fillRectangle(x,y,fStyleMap.getFontWidth()*text.length(),fStyleMap.getFontHeight());
|
||||||
for (int i = 0; i < text.length(); i++) {
|
for (int i = 0; i < text.length(); i++) {
|
||||||
char c=text.charAt(i);
|
char c = text.charAt(i);
|
||||||
int xx=x+offset+i*fStyleMap.getFontWidth();
|
int xx = x + offset + i * fStyleMap.getFontWidth();
|
||||||
// TODO why do I have to draw the background character by character??????
|
// TODO why do I have to draw the background character by character??????
|
||||||
gc.fillRectangle(xx,y,fStyleMap.getFontWidth(),fStyleMap.getFontHeight());
|
gc.fillRectangle(xx, y, fStyleMap.getFontWidth(), fStyleMap.getFontHeight());
|
||||||
if(c!=' ' && c!='\000') {
|
if (c != ' ' && c != '\000') {
|
||||||
gc.drawString(String.valueOf(c),fStyleMap.getCharOffset(c)+xx,y,true);
|
gc.drawString(String.valueOf(c), fStyleMap.getCharOffset(c) + xx, y, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
text=text.replace('\000', ' ');
|
text = text.replace('\000', ' ');
|
||||||
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()) {
|
||||||
gc.setForeground(c);
|
gc.setForeground(c);
|
||||||
}
|
}
|
||||||
c=fStyleMap.getBackgroundColor(style);
|
c = fStyleMap.getBackgroundColor(style);
|
||||||
if(c!=gc.getBackground()) {
|
if (c != gc.getBackground()) {
|
||||||
gc.setBackground(c);
|
gc.setBackground(c);
|
||||||
}
|
}
|
||||||
Font f=fStyleMap.getFont(style);
|
Font f = fStyleMap.getFont(style);
|
||||||
if(f!=gc.getFont()) {
|
if (f != gc.getFont()) {
|
||||||
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;
|
||||||
|
@ -32,7 +31,7 @@ import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
||||||
*/
|
*/
|
||||||
public abstract class VirtualCanvas extends Canvas {
|
public abstract class VirtualCanvas extends Canvas {
|
||||||
|
|
||||||
private final Rectangle fVirtualBounds = new Rectangle(0,0,0,0);
|
private final Rectangle fVirtualBounds = new Rectangle(0, 0, 0, 0);
|
||||||
private Rectangle fClientArea;
|
private Rectangle fClientArea;
|
||||||
/**
|
/**
|
||||||
* prevent infinite loop in {@link #updateScrollbars()}
|
* prevent infinite loop in {@link #updateScrollbars()}
|
||||||
|
@ -41,8 +40,8 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
private static boolean fInUpdateScrollbarsLogged;
|
private static boolean fInUpdateScrollbarsLogged;
|
||||||
|
|
||||||
public VirtualCanvas(Composite parent, int style) {
|
public VirtualCanvas(Composite parent, int style) {
|
||||||
super(parent, style|SWT.NO_BACKGROUND|SWT.NO_REDRAW_RESIZE);
|
super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
|
||||||
fClientArea=getClientArea();
|
fClientArea = getClientArea();
|
||||||
addListener(SWT.Paint, new Listener() {
|
addListener(SWT.Paint, new Listener() {
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
paint(event.gc);
|
paint(event.gc);
|
||||||
|
@ -50,59 +49,62 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
});
|
});
|
||||||
addListener(SWT.Resize, new Listener() {
|
addListener(SWT.Resize, new Listener() {
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
fClientArea=getClientArea();
|
fClientArea = getClientArea();
|
||||||
onResize();
|
onResize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getVerticalBar().addListener(SWT.Selection, new Listener() {
|
getVerticalBar().addListener(SWT.Selection, new Listener() {
|
||||||
public void handleEvent(Event e) {
|
public void handleEvent(Event e) {
|
||||||
scrollY((ScrollBar)e.widget);
|
scrollY((ScrollBar) e.widget);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
getHorizontalBar().addListener(SWT.Selection, new Listener() {
|
getHorizontalBar().addListener(SWT.Selection, new Listener() {
|
||||||
public void handleEvent(Event e) {
|
public void handleEvent(Event e) {
|
||||||
scrollX((ScrollBar)e.widget);
|
scrollX((ScrollBar) e.widget);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
fVirtualBounds.x = -hSelection;
|
fVirtualBounds.x = -hSelection;
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void scrollY(ScrollBar vBar) {
|
protected void scrollY(ScrollBar vBar) {
|
||||||
int vSelection = vBar.getSelection ();
|
int vSelection = vBar.getSelection();
|
||||||
int destY = -vSelection - fVirtualBounds.y;
|
int destY = -vSelection - fVirtualBounds.y;
|
||||||
if(destY!=0) {
|
if (destY != 0) {
|
||||||
fVirtualBounds.y = -vSelection;
|
fVirtualBounds.y = -vSelection;
|
||||||
scrollSmart(0,destY);
|
scrollSmart(0, destY);
|
||||||
updateViewRectangle();
|
updateViewRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
scroll (deltaX, deltaY, 0, 0, rect.width, rect.height, false);
|
scroll(deltaX, deltaY, 0, 0, rect.width, rect.height, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,37 +112,37 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
* @param rect in virtual space
|
* @param rect in virtual space
|
||||||
*/
|
*/
|
||||||
protected void revealRect(Rectangle rect) {
|
protected void revealRect(Rectangle rect) {
|
||||||
Rectangle visibleRect=getScreenRectInVirtualSpace();
|
Rectangle visibleRect = getScreenRectInVirtualSpace();
|
||||||
// scroll the X part
|
// scroll the X part
|
||||||
int deltaX=0;
|
int deltaX = 0;
|
||||||
if(rect.x<visibleRect.x) {
|
if (rect.x < visibleRect.x) {
|
||||||
deltaX=rect.x-visibleRect.x;
|
deltaX = rect.x - visibleRect.x;
|
||||||
} else if(visibleRect.x+visibleRect.width<rect.x+rect.width){
|
} else if (visibleRect.x + visibleRect.width < rect.x + rect.width) {
|
||||||
deltaX=(rect.x+rect.width)-(visibleRect.x+visibleRect.width);
|
deltaX = (rect.x + rect.width) - (visibleRect.x + visibleRect.width);
|
||||||
}
|
}
|
||||||
if(deltaX!=0) {
|
if (deltaX != 0) {
|
||||||
getHorizontalBar().setSelection(-fVirtualBounds.x+deltaX);
|
getHorizontalBar().setSelection(-fVirtualBounds.x + deltaX);
|
||||||
scrollX(getHorizontalBar());
|
scrollX(getHorizontalBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
// scroll the Y part
|
// scroll the Y part
|
||||||
int deltaY=0;
|
int deltaY = 0;
|
||||||
if(rect.y<visibleRect.y){
|
if (rect.y < visibleRect.y) {
|
||||||
deltaY=rect.y-visibleRect.y;
|
deltaY = rect.y - visibleRect.y;
|
||||||
} else if(visibleRect.y+visibleRect.height<rect.y+rect.height){
|
} else if (visibleRect.y + visibleRect.height < rect.y + rect.height) {
|
||||||
deltaY=(rect.y+rect.height)-(visibleRect.y+visibleRect.height);
|
deltaY = (rect.y + rect.height) - (visibleRect.y + visibleRect.height);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(deltaY!=0) {
|
if (deltaY != 0) {
|
||||||
getVerticalBar().setSelection(-fVirtualBounds.y+deltaY);
|
getVerticalBar().setSelection(-fVirtualBounds.y + deltaY);
|
||||||
scrollY(getVerticalBar());
|
scrollY(getVerticalBar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void repaint(Rectangle r) {
|
protected void repaint(Rectangle r) {
|
||||||
if(isDisposed())
|
if (isDisposed())
|
||||||
return;
|
return;
|
||||||
if(inClipping(r,fClientArea)) {
|
if (inClipping(r, fClientArea)) {
|
||||||
redraw(r.x, r.y, r.width, r.height, true);
|
redraw(r.x, r.y, r.width, r.height, true);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -152,58 +154,64 @@ 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;
|
||||||
int marginWidth = (clipping.x+clipping.width) - width;
|
int marginWidth = (clipping.x + clipping.width) - width;
|
||||||
int marginHeight = (clipping.y+clipping.height) - height;
|
int marginHeight = (clipping.y + clipping.height) - height;
|
||||||
if(marginWidth>0||marginHeight>0){
|
if (marginWidth > 0 || marginHeight > 0) {
|
||||||
Color bg=getBackground();
|
Color bg = getBackground();
|
||||||
gc.setBackground(getTerminalBackgroundColor());
|
gc.setBackground(getTerminalBackgroundColor());
|
||||||
if (marginWidth > 0) {
|
if (marginWidth > 0) {
|
||||||
gc.fillRectangle (width, clipping.y, marginWidth, clipping.height);
|
gc.fillRectangle(width, clipping.y, marginWidth, clipping.height);
|
||||||
}
|
}
|
||||||
if (marginHeight > 0) {
|
if (marginHeight > 0) {
|
||||||
gc.fillRectangle (clipping.x, height, clipping.width, marginHeight);
|
gc.fillRectangle(clipping.x, height, clipping.width, marginHeight);
|
||||||
}
|
}
|
||||||
gc.setBackground(bg);
|
gc.setBackground(bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
protected boolean inClipping(Rectangle clipping, Rectangle r) {
|
protected boolean inClipping(Rectangle clipping, Rectangle r) {
|
||||||
// TODO check if this is OK in all cases (the <=!)
|
// TODO check if this is OK in all cases (the <=!)
|
||||||
//
|
//
|
||||||
if(r.x+r.width<=clipping.x)
|
if (r.x + r.width <= clipping.x)
|
||||||
return false;
|
return false;
|
||||||
if(clipping.x+clipping.width<=r.x)
|
if (clipping.x + clipping.width <= r.x)
|
||||||
return false;
|
return false;
|
||||||
if(r.y+r.height<=clipping.y)
|
if (r.y + r.height <= clipping.y)
|
||||||
return false;
|
return false;
|
||||||
if(clipping.y+clipping.height<=r.y)
|
if (clipping.y + clipping.height <= r.y)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
protected Rectangle getRectInVirtualSpace(Rectangle r) {
|
protected Rectangle getRectInVirtualSpace(Rectangle r) {
|
||||||
return new Rectangle(r.x-fVirtualBounds.x,r.y-fVirtualBounds.y,r.width,r.height);
|
return new Rectangle(r.x - fVirtualBounds.x, r.y - fVirtualBounds.y, r.width, r.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,11 +220,12 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
* @param height height of the display area
|
* @param height height of the display area
|
||||||
*/
|
*/
|
||||||
protected void setVirtualExtend(int width, int height) {
|
protected void setVirtualExtend(int width, int height) {
|
||||||
fVirtualBounds.width=width;
|
fVirtualBounds.width = width;
|
||||||
fVirtualBounds.height=height;
|
fVirtualBounds.height = height;
|
||||||
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!
|
||||||
|
@ -227,54 +236,60 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
*/
|
*/
|
||||||
protected void setVirtualOrigin(int x, int y) {
|
protected void setVirtualOrigin(int x, int y) {
|
||||||
if (fVirtualBounds.x != x || fVirtualBounds.y != y) {
|
if (fVirtualBounds.x != x || fVirtualBounds.y != y) {
|
||||||
fVirtualBounds.x=x;
|
fVirtualBounds.x = x;
|
||||||
fVirtualBounds.y=y;
|
fVirtualBounds.y = y;
|
||||||
getHorizontalBar().setSelection(-x);
|
getHorizontalBar().setSelection(-x);
|
||||||
getVerticalBar().setSelection(-y);
|
getVerticalBar().setSelection(-y);
|
||||||
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
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
fViewRectangle.width=fClientArea.width;
|
fViewRectangle.width = fClientArea.width;
|
||||||
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,63 +301,69 @@ 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
|
||||||
*/
|
*/
|
||||||
private void updateScrollbars() {
|
private void updateScrollbars() {
|
||||||
// don't get into infinite loops....
|
// don't get into infinite loops....
|
||||||
if(!fInUpdateScrollbars) {
|
if (!fInUpdateScrollbars) {
|
||||||
fInUpdateScrollbars=true;
|
fInUpdateScrollbars = true;
|
||||||
try {
|
try {
|
||||||
doUpdateScrollbar();
|
doUpdateScrollbar();
|
||||||
} finally {
|
} finally {
|
||||||
fInUpdateScrollbars=false;
|
fInUpdateScrollbars = false;
|
||||||
}
|
}
|
||||||
} 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,
|
||||||
new RuntimeException()));
|
"Unexpected Recursion in terminal", //$NON-NLS-1$
|
||||||
|
new RuntimeException()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doUpdateScrollbar() {
|
private void doUpdateScrollbar() {
|
||||||
Rectangle clientArea= getClientArea();
|
Rectangle clientArea = getClientArea();
|
||||||
ScrollBar horizontal= getHorizontalBar();
|
ScrollBar horizontal = getHorizontalBar();
|
||||||
// even if setVisible was called on the scrollbar, isVisible
|
// even if setVisible was called on the scrollbar, isVisible
|
||||||
// returns false if its parent is not visible.
|
// returns false if its parent is not visible.
|
||||||
if(!isVisible() || horizontal.isVisible()) {
|
if (!isVisible() || horizontal.isVisible()) {
|
||||||
horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement());
|
horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement());
|
||||||
int max= fVirtualBounds.width;
|
int max = fVirtualBounds.width;
|
||||||
horizontal.setMaximum(max);
|
horizontal.setMaximum(max);
|
||||||
horizontal.setThumb(clientArea.width);
|
horizontal.setThumb(clientArea.width);
|
||||||
}
|
}
|
||||||
ScrollBar vertical= getVerticalBar();
|
ScrollBar vertical = getVerticalBar();
|
||||||
// even if setVisible was called on the scrollbar, isVisible
|
// even if setVisible was called on the scrollbar, isVisible
|
||||||
// returns false if its parent is not visible.
|
// returns false if its parent is not visible.
|
||||||
if(!isVisible() || vertical.isVisible()) {
|
if (!isVisible() || vertical.isVisible()) {
|
||||||
vertical.setPageIncrement(clientArea.height - vertical.getIncrement());
|
vertical.setPageIncrement(clientArea.height - vertical.getIncrement());
|
||||||
int max= fVirtualBounds.height;
|
int max = fVirtualBounds.height;
|
||||||
vertical.setMaximum(max);
|
vertical.setMaximum(max);
|
||||||
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,18 +116,21 @@ 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
|
||||||
* @param sourceLine
|
* @param sourceLine
|
||||||
* @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.
|
||||||
|
@ -136,9 +139,10 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
|
||||||
* @param destStartLine
|
* @param destStartLine
|
||||||
* @param length
|
* @param length
|
||||||
*/
|
*/
|
||||||
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,26 +10,30 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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$
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,8 +28,10 @@ public class Style {
|
||||||
private final boolean fBlink;
|
private final boolean fBlink;
|
||||||
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,66 +39,86 @@ 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) {
|
|
||||||
Style style = new Style(forground,background, bold, blink,underline,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 cached;
|
Style cached;
|
||||||
synchronized (fgStyles) {
|
synchronized (fgStyles) {
|
||||||
cached=fgStyles.get(style);
|
cached = fgStyles.get(style);
|
||||||
if(cached==null) {
|
if (cached == null) {
|
||||||
cached=style;
|
cached = style;
|
||||||
fgStyles.put(cached, cached);
|
fgStyles.put(cached, cached);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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,21 +154,22 @@ 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$
|
||||||
result.append(fForground);
|
result.append(fForground);
|
||||||
result.append(", background="); //$NON-NLS-1$
|
result.append(", background="); //$NON-NLS-1$
|
||||||
result.append(fBackground);
|
result.append(fBackground);
|
||||||
if(fBlink)
|
if (fBlink)
|
||||||
result.append(", blink"); //$NON-NLS-1$
|
result.append(", blink"); //$NON-NLS-1$
|
||||||
if(fBold)
|
if (fBold)
|
||||||
result.append(", bold"); //$NON-NLS-1$
|
result.append(", bold"); //$NON-NLS-1$
|
||||||
if(fBlink)
|
if (fBlink)
|
||||||
result.append(", blink"); //$NON-NLS-1$
|
result.append(", blink"); //$NON-NLS-1$
|
||||||
if(fReverse)
|
if (fReverse)
|
||||||
result.append(", reverse"); //$NON-NLS-1$
|
result.append(", reverse"); //$NON-NLS-1$
|
||||||
if(fUnderline)
|
if (fUnderline)
|
||||||
result.append(", underline"); //$NON-NLS-1$
|
result.append(", underline"); //$NON-NLS-1$
|
||||||
result.append(")"); //$NON-NLS-1$
|
result.append(")"); //$NON-NLS-1$
|
||||||
return result.toString();
|
return result.toString();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue