From 63d1d2bbeef223b1568df5fb00a3a1bbe969adb5 Mon Sep 17 00:00:00 2001 From: nickboldt Date: Tue, 28 Aug 2018 12:54:02 -0400 Subject: [PATCH 01/76] Move terminal files into subfolder Change-Id: Ibab77ef2ba53f4fd91363269330955eca5fd2bb3 Signed-off-by: nickboldt --- .../.classpath | 7 + .../.cvsignore | 1 + .../.gitignore | 1 + .../org.eclipse.tm.terminal.control/.options | 3 + .../org.eclipse.tm.terminal.control/.project | 34 + .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 100 ++ .../HelpContexts.xml | 18 + .../META-INF/MANIFEST.MF | 25 + .../README.txt | 18 + .../about.html | 28 + .../org.eclipse.tm.terminal.control/about.ini | 27 + .../about.properties | 24 + .../build.properties | 36 + ...rg.eclipse.tm.terminal.stylesheet.dark.css | 15 + .../icons/clcl16/clear_co.gif | Bin 0 -> 595 bytes .../icons/dlcl16/clear_co.gif | Bin 0 -> 364 bytes .../icons/elcl16/clear_co.gif | Bin 0 -> 595 bytes .../plugin.properties | 42 + .../plugin.xml | 275 ++++ .../org.eclipse.tm.terminal.control/pom.xml | 17 + .../schema/connectors.exsd | 111 ++ .../terminal/connector/TerminalConnector.java | 223 +++ ...TerminalToRemoteInjectionOutputStream.java | 169 ++ .../control/CommandInputFieldWithHistory.java | 322 ++++ .../terminal/control/ICommandInputField.java | 35 + .../terminal/control/ITerminalListener.java | 33 + .../terminal/control/ITerminalListener2.java | 27 + .../control/ITerminalMouseListener.java | 43 + .../control/ITerminalViewControl.java | 133 ++ .../control/TerminalViewControlFactory.java | 44 + .../actions/AbstractTerminalAction.java | 101 ++ .../control/actions/ActionMessages.java | 34 + .../control/actions/ActionMessages.properties | 25 + .../terminal/control/actions/ImageConsts.java | 31 + .../actions/TerminalActionClearAll.java | 53 + .../control/actions/TerminalActionCopy.java | 67 + .../control/actions/TerminalActionCut.java | 54 + .../control/actions/TerminalActionPaste.java | 69 + .../actions/TerminalActionSelectAll.java | 50 + .../control/impl/ITerminalControlForText.java | 41 + .../control/impl/TerminalMessages.java | 32 + .../control/impl/TerminalMessages.properties | 28 + .../terminal/control/impl/TerminalPlugin.java | 92 ++ .../emulator/EditActionAccelerators.java | 68 + .../emulator/IVT100EmulatorBackend.java | 222 +++ .../emulator/LoggingOutputStream.java | 48 + .../emulator/VT100BackendTraceDecorator.java | 176 ++ .../terminal/emulator/VT100Emulator.java | 1396 ++++++++++++++++ .../emulator/VT100EmulatorBackend.java | 502 ++++++ .../emulator/VT100TerminalControl.java | 1414 +++++++++++++++++ .../terminal/model/ISnapshotChanges.java | 90 ++ .../terminal/model/SnapshotChanges.java | 408 +++++ .../model/SynchronizedTerminalTextData.java | 107 ++ .../terminal/model/TerminalTextData.java | 274 ++++ .../model/TerminalTextDataFastScroll.java | 259 +++ .../model/TerminalTextDataSnapshot.java | 303 ++++ .../terminal/model/TerminalTextDataStore.java | 344 ++++ .../model/TerminalTextDataWindow.java | 207 +++ .../preferences/ITerminalConstants.java | 32 + .../TerminalPreferenceInitializer.java | 39 + .../preferences/TerminalPreferencePage.java | 75 + .../provisional/api/AbstractSettingsPage.java | 181 +++ .../provisional/api/ISettingsPage.java | 80 + .../provisional/api/ISettingsStore.java | 45 + .../provisional/api/ITerminalConnector.java | 147 ++ .../provisional/api/ITerminalControl.java | 160 ++ .../terminal/provisional/api/Logger.java | 195 +++ .../provisional/api/NullSettingsStore.java | 39 + .../api/TerminalConnectorExtension.java | 98 ++ .../provisional/api/TerminalState.java | 52 + .../api/provider/TerminalConnectorImpl.java | 152 ++ .../textcanvas/AbstractTextCanvasModel.java | 380 +++++ .../terminal/textcanvas/GridCanvas.java | 232 +++ .../terminal/textcanvas/ILinelRenderer.java | 37 + .../terminal/textcanvas/ITextCanvasModel.java | 95 ++ .../textcanvas/ITextCanvasModelListener.java | 24 + .../terminal/textcanvas/PipedInputStream.java | 312 ++++ .../textcanvas/PollingTextCanvasModel.java | 49 + .../terminal/textcanvas/StyleMap.java | 296 ++++ .../terminal/textcanvas/TextCanvas.java | 486 ++++++ .../terminal/textcanvas/TextLineRenderer.java | 168 ++ .../terminal/textcanvas/VirtualCanvas.java | 348 ++++ .../tm/terminal/model/ITerminalTextData.java | 150 ++ .../model/ITerminalTextDataReadOnly.java | 85 + .../model/ITerminalTextDataSnapshot.java | 226 +++ .../tm/terminal/model/LineSegment.java | 35 + .../org/eclipse/tm/terminal/model/Style.java | 154 ++ .../eclipse/tm/terminal/model/StyleColor.java | 54 + .../model/TerminalTextDataFactory.java | 20 + .../org.eclipse.tm.terminal.control/tm32.png | Bin 0 -> 1349 bytes 91 files changed, 12754 insertions(+) create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.classpath create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.gitignore create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.options create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.project create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/README.txt create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/about.html create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/about.ini create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/about.properties create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/build.properties create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/icons/clcl16/clear_co.gif create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/icons/dlcl16/clear_co.gif create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/icons/elcl16/clear_co.gif create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/pom.xml create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/tm32.png diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath new file mode 100644 index 00000000000..25d360efcad --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore b/terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore new file mode 100644 index 00000000000..ba077a4031a --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.gitignore b/terminal/plugins/org.eclipse.tm.terminal.control/.gitignore new file mode 100644 index 00000000000..ae3c1726048 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.options b/terminal/plugins/org.eclipse.tm.terminal.control/.options new file mode 100644 index 00000000000..7e591a4d4e7 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.options @@ -0,0 +1,3 @@ +org.eclipse.tm.terminal.control/debug/log = false +org.eclipse.tm.terminal.control/debug/log/char = false +org.eclipse.tm.terminal.control/debug/log/VT100Backend = false diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.project b/terminal/plugins/org.eclipse.tm.terminal.control/.project new file mode 100644 index 00000000000..11e18c380e4 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.project @@ -0,0 +1,34 @@ + + + org.eclipse.tm.terminal.control + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..775bde20f32 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java=UTF-8 diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..eb9982c343a --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,100 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml b/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml new file mode 100644 index 00000000000..761da672632 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml @@ -0,0 +1,18 @@ + + + + + + The Terminal View supports direct connections to remote systems via serial or network connections. + + + \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..c1d11b97017 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -0,0 +1,25 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true +Bundle-Version: 4.4.0.qualifier +Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui +Bundle-ActivationPolicy: lazy +Eclipse-LazyStart: true +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ClassPath: . +Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true, + org.eclipse.tm.internal.terminal.control, + org.eclipse.tm.internal.terminal.control.actions, + org.eclipse.tm.internal.terminal.control.impl;x-internal:=true, + org.eclipse.tm.internal.terminal.emulator;x-internal:=true, + org.eclipse.tm.internal.terminal.model;x-internal:=true, + org.eclipse.tm.internal.terminal.preferences, + org.eclipse.tm.internal.terminal.provisional.api, + org.eclipse.tm.internal.terminal.provisional.api.provider, + org.eclipse.tm.internal.terminal.textcanvas;x-internal:=true, + org.eclipse.tm.terminal.model diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/README.txt b/terminal/plugins/org.eclipse.tm.terminal.control/README.txt new file mode 100644 index 00000000000..c88bc696e29 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/README.txt @@ -0,0 +1,18 @@ +Terminal README +=============== + +The Terminal is a UI-less model of a grid of characters, +plus an SWT widget that's updated asynchronously for +maximum performance. The widget can be hooked up to various +ITerminalConnectors providing an InputStream, OutputStream, +and a method for setting the Terminal Size. + +The widget processes ANSI control characters, including NUL, +backspace, carriage return, linefeed, and a subset of ANSI +escape sequences sufficient to allow use of screen-oriented +applications, such as vi, Emacs, and any GNU readline-enabled +application (Bash, bc, ncftp, etc.). + +This is not yet a fully compliant vt100 / vt102 terminal +emulator! + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.html b/terminal/plugins/org.eclipse.tm.terminal.control/about.html new file mode 100644 index 00000000000..d4cc693f9f0 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 5, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.ini b/terminal/plugins/org.eclipse.tm.terminal.control/about.ini new file mode 100644 index 00000000000..3adc27ab587 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.ini @@ -0,0 +1,27 @@ +# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +aboutText=%blurb + +# Property "windowImage" contains path to window icon (16x16) +# needed for primary features only + +# Property "featureImage" contains path to feature image (32x32) +featureImage=tm32.png + +# Property "aboutImage" contains path to product image (500x330 or 115x164) +# needed for primary features only + +# Property "appName" contains name of the application (not translated) +# needed for primary features only + +# Property "welcomePage" contains path to welcome page (special XML-based format) +# optional + +# Property "welcomePerspective" contains the id of the perspective in which the +# welcome page is to be opened. +# optional \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties new file mode 100644 index 00000000000..20c5c53d3e3 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -0,0 +1,24 @@ +################################################################################ +# Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Martin Oberhuber - initial API and implementation +################################################################################ +# about.properties +# contains externalized strings for about.ini +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# fill-ins are supplied by about.mappings +# This file should be translated. +# +# Do not translate any values surrounded by {} + +blurb=Target Management Terminal Widget\n\ +\n\ +Version: {featureVersion}\n\ +\n\ +(c) Copyright Wind River Systems, Inc. and others 2003, 2018. All rights reserved.\n\ +Visit http://www.eclipse.org/tm diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties new file mode 100644 index 00000000000..6d04269c268 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties @@ -0,0 +1,36 @@ +############################################################################### +# Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Initial Contributors: +# The following Wind River employees contributed to the Terminal component +# that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, +# Helmut Haigermoser and Ted Williams. +# +# Contributors: +# Michael Scharf (Wind River) - split into core, view and connector plugins +# Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Anna Dushistova (MontaVista) - added icons +############################################################################### +bin.includes = .,\ + META-INF/,\ + plugin.xml,\ + plugin.properties,\ + .options,\ + README.txt,\ + about.html,\ + about.ini,\ + about.properties,\ + tm32.png,\ + icons/,\ + HelpContexts.xml,\ + css/ + +source.. = src/ +output.. = bin/ +src.includes = schema/,\ + about.html + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css b/terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css new file mode 100644 index 00000000000..ab89d9e1313 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2014, 2015 vogella GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Lars Vogel - initial API and implementation + ******************************************************************************/ + +IEclipsePreferences#org-eclipse-tm-terminal-control { + preferences: + "TerminalPrefInvertColors=true" +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/icons/clcl16/clear_co.gif b/terminal/plugins/org.eclipse.tm.terminal.control/icons/clcl16/clear_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..af30a42f83d2f91801206463e1f4601a747dd38e GIT binary patch literal 595 zcmZ?wbhEHb6krfwc*el+;Qr&!Uw{Aj`RCh@zn{MT*?;oxyHCG9ef|CO*PkChf49xr z*E9dn%Iz0#-hcJ>)9(*oeotO@Y}T67i#DHMvE%ZZJy-8O|Ni97&*$%czWwy;^S9r3 zo`1jp^2fthKi+)${p!QdZ$ExNd-wC(&%YnO{{Hms_tzi4zyJI_W5&cyo7UdHe|Of* z{<*XJmMv^wG_UL6rjotu%lB?5-?_GG%gWmI%NmdGpZDg~qvKl(k8UnLx~2Hg#?qZ@ zs#Y&v%S5&t*x!DuCAn{q`0`asHmv0urNPAKQAvYB_$;} zIXNyaE;cqcGBPqWG&DFkI4CG6FfcG6Ai&?>-_OtQ|Ns9C0}2#>vM@3*gfi%WTmgy` z2KEgNp{C6(&7tib?WP<(y|$*E9cHRboKu+W?9C^J>Z%9|aC6C9+u2x5)MuAemSmLN zAgMReQb|NuXu%?WgNcR`5^M(!OBhcylH0yhfQMJnWTKUV_?0Uxu3jz-u0F1z+G3{` zuzEW)`F=drwRH^dde6KTp?5HjDwPt!%ua0$DEtSh$2VJr-3M iJ8pc$DH7Bta2KY#wb zefxI%_U+rYZQHbI)0#DFRqv0~ApMGF@$oHuXY?Afzt&YU@8#*FFH zr%#(U?f?J(3={yxpDc_F4B8AjATvOIVqoh$Ae!bOv##%ivfAOCFau8&wgXGj^h7d5 zgbic_SR0;xy2Hivydi4sR4$3$c5$5yZN&+Ub^IH-l?#g4`GgtjB!mRJx|kGH)9(*oeotO@Y}T67i#DHMvE%ZZJy-8O|Ni97&*$%czWwy;^S9r3 zo`1jp^2fthKi+)${p!QdZ$ExNd-wC(&%YnO{{Hms_tzi4zyJI_W5&cyo7UdHe|Of* z{<*XJmMv^wG_UL6rjotu%lB?5-?_GG%gWmI%NmdGpZDg~qvKl(k8UnLx~2Hg#?qZ@ zs#Y&v%S5&t*x!DuCAn{q`0`asHmv0urNPAKQAvYB_$;} zIXNyaE;cqcGBPqWG&DFkI4CG6FfcG6Ai&?>-_OtQ|Ns9C0}2#>vM@3*gfi%WTmgy` z2KEgNp{C6(&7tib?WP<(y|$*E9cHRboKu+W?9C^J>Z%9|aC6C9+u2x5)MuAemSmLN zAgMReQb|NuXu%?WgNcR`5^M(!OBhcylH0yhfQMJnWTKUV_?0Uxu3jz-u0F1z+G3{` zuzEW)`F=drwRH^dde6KTp?5HjDwPt!%ua0$DEtSh$2VJr-3M iJ8pc$DH7Bta + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %terminal.font.description + + + + + + + + + + + + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml new file mode 100644 index 00000000000..566656faba0 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.eclipse.tm.terminal + org.eclipse.tm.terminal.maven-build + 4.4.0-SNAPSHOT + ../../admin/pom-build.xml + + + 4.4.0-SNAPSHOT + org.eclipse.tm.terminal.control + eclipse-plugin + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd b/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd new file mode 100644 index 00000000000..58681ba9028 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A class extending TerminalConnectorImpl + + + + + + + + + + Uniquely identify this connector for programmatic access. Clients will use this ID in order to find and instantiate it. + + + + + + + The name of the connection (used in the UI) + + + + + + + + + + When set to "true", the terminal connector will not be visible to the user in connector selections. + + + + + + + + + + + + + + + + Copyright (c) 2006 - 2015 Wind River Systems, Inc. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + +Contributors: +Michael Scharf (Wind River) - initial API and implementation +Martin Oberhuber (Wind River) - fixed copyright headers and beautified +Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point + + + + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java new file mode 100644 index 00000000000..cfbdabe8c88 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Michael Scharf (Wind River) - [200541] Extract from TerminalConnectorExtension.TerminalConnectorProxy + * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl + * Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.connector; + +import java.io.OutputStream; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; +import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; +import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl; + +/** + * An {@link ITerminalConnector} instance, also known as terminal connection + * type, for maintaining a single terminal connection. + * + * It provides all terminal connector functions that can be provided by static + * markup without loading the actual implementation class. The actual + * {@link TerminalConnectorImpl} implementation class is lazily loaded by the + * provided {@link TerminalConnector.Factory} interface when needed. class, and + * delegates to the actual implementation when needed. The following methods can + * be called without initializing the contributed implementation class: + * {@link #getId()}, {@link #getName()}, {@link #getSettingsSummary()},{@link #load(ISettings)}, + * {@link #setTerminalSize(int, int)}, {@link #save(ISettings)}, + * {@link #getAdapter(Class)} + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * Clients can get terminal connector instances through the + * {@link TerminalConnectorExtension} class. + * @since org.eclipse.tm.terminal 2.0 + */ +public class TerminalConnector implements ITerminalConnector { + /** + * Creates an instance of TerminalConnectorImpl. This is used to lazily load + * classed defined in extensions. + * + * @since org.eclipse.tm.terminal 2.0 + */ + public interface Factory { + /** + * Factory method to create the actual terminal connector implementation + * when needed. + * + * @return a Connector + * @throws Exception + */ + TerminalConnectorImpl makeConnector() throws Exception; + } + /** + * The factory for creating impl instances. + */ + private final TerminalConnector.Factory fTerminalConnectorFactory; + /** + * The (display) name of the TerminalConnector + */ + private final String fName; + /** + * The unique id the connector + */ + private final String fId; + /** + * Flag to mark the connector as hidden. + */ + private final boolean fHidden; + /** + * The connector + */ + private TerminalConnectorImpl fConnector; + /** + * If the initialization of the class specified in the extension fails, + * this variable contains the error + */ + private Exception fException; + /** + * The store might be set before the real connector is initialized. + * This keeps the value until the connector is created. + */ + private ISettingsStore fStore; + /** + * Constructor for the terminal connector. + * + * @param terminalConnectorFactory Factory for lazily instantiating the + * TerminalConnectorImpl when needed. + * @param id terminal connector ID. The connector is publicly known under + * this ID. + * @param name translatable name to display the connector in the UI. + */ + public TerminalConnector(TerminalConnector.Factory terminalConnectorFactory, String id, String name, boolean hidden) { + fTerminalConnectorFactory = terminalConnectorFactory; + fId = id; + fName = name; + fHidden = hidden; + } + public String getInitializationErrorMessage() { + getConnectorImpl(); + if(fException!=null) + return fException.getLocalizedMessage(); + return null; + } + public String getId() { + return fId; + } + public String getName() { + return fName; + } + public boolean isHidden() { + return fHidden; + } + private TerminalConnectorImpl getConnectorImpl() { + if(!isInitialized()) { + try { + fConnector=fTerminalConnectorFactory.makeConnector(); + fConnector.initialize(); + } catch (Exception e) { + fException=e; + fConnector=new TerminalConnectorImpl(){ + public void connect(ITerminalControl control) { + // super.connect(control); + control.setState(TerminalState.CLOSED); + control.setMsg(getInitializationErrorMessage()); + } + public OutputStream getTerminalToRemoteStream() { + return null; + } + public String getSettingsSummary() { + return null; + }}; + // that's the place where we log the exception + Logger.logException(e); + } + if(fConnector!=null && fStore!=null) + fConnector.load(fStore); + } + return fConnector; + } + + public boolean isInitialized() { + return fConnector!=null || fException!=null; + } + public void connect(ITerminalControl control) { + getConnectorImpl().connect(control); + } + public void disconnect() { + getConnectorImpl().disconnect(); + } + public OutputStream getTerminalToRemoteStream() { + return getConnectorImpl().getTerminalToRemoteStream(); + } + public String getSettingsSummary() { + if(fConnector!=null) + return getConnectorImpl().getSettingsSummary(); + else + return TerminalMessages.NotInitialized; + } + public boolean isLocalEcho() { + return getConnectorImpl().isLocalEcho(); + } + public void load(ISettingsStore store) { + if(fConnector==null) { + fStore=store; + } else { + getConnectorImpl().load(store); + } + } + @Override + public void setDefaultSettings() { + getConnectorImpl().setDefaultSettings(); + } + public void save(ISettingsStore store) { + // no need to save the settings: it cannot have changed + // because we are not initialized.... + if(fConnector!=null) + getConnectorImpl().save(store); + } + public void setTerminalSize(int newWidth, int newHeight) { + // we assume that setTerminalSize is called also after + // the terminal has been initialized. Else we would have to cache + // the values.... + if(fConnector!=null) { + fConnector.setTerminalSize(newWidth, newHeight); + } + } + public Object getAdapter(Class adapter) { + TerminalConnectorImpl connector=null; + if(isInitialized()) + connector=getConnectorImpl(); + // if we cannot create the connector then we cannot adapt... + if(connector!=null) { + // maybe the connector is adaptable + if(connector instanceof IAdaptable) { + Object result =((IAdaptable)connector).getAdapter(adapter); + // Not sure if the next block is needed.... + if(result==null) + //defer to the platform + result= Platform.getAdapterManager().getAdapter(connector, adapter); + if(result!=null) + return result; + } + // maybe the real adapter is what we need.... + if(adapter.isInstance(connector)) + return connector; + } + // maybe we have to be adapted.... + return Platform.getAdapterManager().getAdapter(this, adapter); + } +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java new file mode 100644 index 00000000000..7db522edc4c --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2008, 2017 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.connector; + +import java.io.ByteArrayOutputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * @noextend This class is not intended to be subclassed by clients. + * @noreference This class is not intended to be referenced by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * This class used to be package-protected. It is public only for access by the Unit Tests. + */ +public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream { + /** + * This class handles bytes written to the {@link TerminalToRemoteInjectionOutputStream}. + */ + static abstract public class Interceptor { + protected OutputStream fOriginal; + /** + * @param original the injection into the original stream begins + * @throws IOException + */ + public void begin(OutputStream original) throws IOException { + fOriginal=original; + } + /** + * @param b a byte was written to the {@link TerminalToRemoteInjectionOutputStream}. + * @throws IOException + */ + public void write(int b) throws IOException { + } + /** + * @param b bytes written to the {@link TerminalToRemoteInjectionOutputStream}. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @throws IOException + */ + public void write(byte[] b, int off, int len) throws IOException { + } + /** + * The injection into the normal stream ends. + * @throws IOException + */ + public void close() throws IOException { + } + public void flush() { + } + } + static public class BufferInterceptor extends Interceptor { + private final ByteArrayOutputStream fBuffer=new ByteArrayOutputStream(); + public void close() throws IOException { + fOriginal.write(fBuffer.toByteArray()); + } + public void write(byte[] b, int off, int len) throws IOException { + fBuffer.write(b, off, len); + } + public void write(int b) throws IOException { + fBuffer.write(b); + } + } + private class TerminalFilterOutputStream extends OutputStream { + final private Object fLock=TerminalToRemoteInjectionOutputStream.this; + public void close() throws IOException { + synchronized(fLock) { + if(fInjection==this) { + flush(); + ungrabOutput(); + } + } + } + public void write(byte[] b, int off, int len) throws IOException { + synchronized(fLock) { + checkStream(); + out.write(b, off, len); + } + } + public void write(byte[] b) throws IOException { + synchronized(fLock) { + checkStream(); + out.write(b); + } + } + public void flush() throws IOException { + synchronized(fLock) { + checkStream(); + out.flush(); + } + } + public void write(int b) throws IOException { + synchronized(fLock) { + checkStream(); + out.write(b); + } + } + private void checkStream() throws IOException { + if(fInjection!=this) + throw new IOException("Stream is closed"); //$NON-NLS-1$ + } + } + private Interceptor fInterceptor; + private TerminalFilterOutputStream fInjection; + public TerminalToRemoteInjectionOutputStream(OutputStream out) { + super(out); + } + synchronized protected void ungrabOutput() throws IOException { + if(fInterceptor!=null) { + fInterceptor.close(); + fInterceptor=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. + * @param interceptor This is used handle bytes sent while the injection stream is active. + * @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) { + throw new IOException("Buffer in use"); //$NON-NLS-1$ + } + fInterceptor=interceptor; + fInterceptor.begin(out); + 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(); + } + synchronized public void flush() throws IOException { + if(fInterceptor!=null) + fInterceptor.flush(); + out.flush(); + } + synchronized public void write(byte[] b, int off, int len) throws IOException { + if(fInterceptor!=null) + fInterceptor.write(b, off, len); + else + out.write(b, off, len); + } + synchronized public void write(int b) throws IOException { + if(fInterceptor!=null) + fInterceptor.write(b); + else + out.write(b); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java new file mode 100644 index 00000000000..ffcdc4a4934 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -0,0 +1,322 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial implementation + * Michael Scharf (Wing River) - [211659] Add field assist to terminal input field + * Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable + * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1 + * Michael Scharf (Wing River) - [236458] Fix 168197 lost the last entry + * Anton Leherbauer (Wind River) - [220971] The optional terminal input line has redraw problems when resizing + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; + +import org.eclipse.jface.fieldassist.IContentProposal; +import org.eclipse.jface.fieldassist.IContentProposalProvider; +import org.eclipse.jface.fieldassist.TextContentAdapter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Sash; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; + + + +/** + * Manages the Command History for the command line input + * of the terminal control. + *
  • + *
      Navigate with ARROW_UP,ARROW_DOWN,PAGE_UP,PAGE_DOWN + *
        ESC to cancel history editing + *
          History can be edited (by moving up and edit) but changes are + * not persistent (like in bash). + *
            If the same command is entered multiple times in a row, + * only one entry is kept in the history. + * + * + */ +public class CommandInputFieldWithHistory implements ICommandInputField { + private class FieldAssist implements IContentProposalProvider { + + public IContentProposal[] getProposals(String contents, int position) { + String prefix=contents.substring(0, position); + List result=new ArrayList(); + // show an entry only once + Set seen=new HashSet(); + for (Iterator iterator = fHistory.iterator(); iterator.hasNext();) { + String history = iterator.next(); + if(history.startsWith(prefix) && !seen.contains(history)) { + // the content is the rest of the history item + String content=history.substring(prefix.length()); + result.add(new Proposal(content,history)); + // don't add this proposal again + seen.add(history); + } + } + return result.toArray(new IContentProposal[result.size()]); + } + + } + private static class Proposal implements IContentProposal { + + private final String fContent; + private final String fLabel; + Proposal(String content, String label) { + fContent= content; + fLabel= label; + } + public String getContent() { + return fContent; + } + + public String getLabel() { + return fLabel; + } + + public String getDescription() { + return null; + } + + public int getCursorPosition() { + return fContent.length(); + } + } + + final List fHistory=new ArrayList(); + /** + * Keeps a modifiable history while in history editing mode + */ + List fEditedHistory; + /** + * The current position in the edit history + */ + private int fEditHistoryPos=0; + /** + * The limit of the history. + */ + private final int fMaxSize; + /** + * The input text field. + */ + private Text fInputField; + private Sash fSash; + private Composite fPanel; + public CommandInputFieldWithHistory(int maxHistorySize) { + fMaxSize=maxHistorySize; + } + /** + * Add a line to the history. + * @param line The line to be added to the history. + */ + protected void pushLine(String line) { + endHistoryMode(); + // anything to remember? + if(line==null || line.trim().length()==0) + return; + fHistory.add(0,line); + // ignore if the same as last + if(fHistory.size()>1 && line.equals(fHistory.get(1))) + fHistory.remove(0); + // limit the history size. + if(fHistory.size()>=fMaxSize) + fHistory.remove(fHistory.size()-1); + } + /** + * Sets the history + * @param history or null + */ + public void setHistory(String history) { + endHistoryMode(); + fHistory.clear(); + if(history==null) + return; + // add history entries separated by '\n' + // fHistory.addAll(Arrays.asList(history.split("\n"))); //$NON-NLS-1$ + // + StringTokenizer tok=new StringTokenizer(history,"\n"); //$NON-NLS-1$ + while(tok.hasMoreElements()) + fHistory.add((String) tok.nextElement()); + // + } + /** + * @return the current content of the history buffer and new line separated list + */ + public String getHistory() { + StringBuffer buff=new StringBuffer(); + boolean sep=false; + for (Iterator iterator = fHistory.iterator(); iterator.hasNext();) { + String line=iterator.next(); + if(line.length()>0) { + if(sep) + buff.append("\n"); //$NON-NLS-1$ + else + sep=true; + buff.append(line); + } + } + return buff.toString(); + } + /** + * @param currLine Line of text to be moved in history + * @param count (+1 or -1) for forward and backward movement. -1 goes back + * @return the new string to be displayed in the command line or null, + * if the limit is reached. + */ + public String move(String currLine, int count) { + if(!inHistoryMode()) { + fEditedHistory=new ArrayList(fHistory.size()+1); + fEditedHistory.add(currLine); + fEditedHistory.addAll(fHistory); + fEditHistoryPos=0; + } + fEditedHistory.set(fEditHistoryPos,currLine); + if(fEditHistoryPos+count>=fEditedHistory.size()) + return null; + if(fEditHistoryPos+count<0) + return null; + fEditHistoryPos+=count; + return (String) fEditedHistory.get(fEditHistoryPos); + } + private boolean inHistoryMode() { + return fEditedHistory!=null; + } + + /** + * Exit the history movements and go to position 0; + * @return the string to be shown in the command line + */ + protected String escape() { + if(!inHistoryMode()) + return null; + String line= (String) fEditedHistory.get(0); + endHistoryMode(); + return line; + } + /** + * End history editing + */ + private void endHistoryMode() { + fEditedHistory=null; + fEditHistoryPos=0; + } + public void createControl(final Composite parent,final ITerminalViewControl terminal) { +// 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); + gd_sash.heightHint=5; + fSash.setLayoutData(gd_sash); + fSash.addListener (SWT.Selection, new Listener () { + public void handleEvent (Event e) { + if (e.detail == SWT.DRAG) { + // don't redraw during drag, it causes paint errors - bug 220971 + return; + } + // no idea why this is needed + GridData gdata = (GridData) fInputField.getLayoutData(); + Rectangle sashRect = fSash.getBounds (); + Rectangle containerRect = parent.getClientArea (); + + int h=fInputField.getLineHeight(); + // 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); + // do not show less then one line + e.y=Math.min(e.y,containerRect.height-h); + fInputField.setLayoutData(gdata); + parent.layout(); + // else the content assist icon will be replicated + parent.redraw(); + } + }); + fPanel = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; layout.marginHeight = 0; layout.marginTop = 0; layout.marginBottom = 2; + fPanel.setLayout(layout); + fPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + fInputField=new Text(fPanel, SWT.MULTI|SWT.BORDER|SWT.WRAP|SWT.V_SCROLL); + GridData data=new GridData(SWT.FILL, SWT.FILL, true, false); + boolean installDecoration=true; + if(installDecoration) { + // The ContentAssistCommandAdapter says: "The client is responsible for + // ensuring that adequate space is reserved for the decoration." + // TODO: what is the "adequate space"??? + data.horizontalIndent=6; + } + fInputField.setLayoutData(data); + fInputField.setFont(terminal.getFont()); + // Register field assist *before* the key listener. + // Else the ENTER key is sent *first* to the input field + // and then to the field assist popup. + // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659) + new ContentAssistCommandAdapter( + fInputField, + new TextContentAdapter(), + new FieldAssist(), + null, + null, + installDecoration); + fInputField.addKeyListener(new KeyListener(){ + public void keyPressed(KeyEvent e) { + // if the field assist has handled the key already then + // ignore it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659) + if(!e.doit) + return; + if(e.character==SWT.CR || e.character==SWT.LF) { + e.doit=false; + String line=fInputField.getText(); + if(!terminal.pasteString(line+'\r')) + return; + pushLine(line); + setCommand("");//$NON-NLS-1$ + } else if(e.keyCode==SWT.ARROW_UP || e.keyCode==SWT.PAGE_UP) { + e.doit=false; + setCommand(move(fInputField.getText(),1)); + } else if(e.keyCode==SWT.ARROW_DOWN || e.keyCode==SWT.PAGE_DOWN) { + e.doit=false; + setCommand(move(fInputField.getText(),-1)); + } else if(e.keyCode==SWT.ESC) { + e.doit=false; + setCommand(escape()); + } + } + private void setCommand(String line) { + if(line==null) + return; + fInputField.setText(line); + fInputField.setSelection(fInputField.getCharCount()); + } + public void keyReleased(KeyEvent e) { + } + }); + } + public void setFont(Font font) { + fInputField.setFont(font); + fInputField.getParent().layout(true); + } + public void dispose() { + fSash.dispose(); + fSash=null; + fPanel.dispose(); + fPanel=null; + fInputField.dispose(); + fInputField=null; + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java new file mode 100644 index 00000000000..a65a61c5170 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Composite; + +/** + * Interface to create a command input control. + * + */ +public interface ICommandInputField { + /** + * @param parent + * @param terminal + */ + void createControl(Composite parent, ITerminalViewControl terminal); + + void dispose(); + /** + * Sets the font of a control created with {@link #createControl(Composite, ITerminalViewControl)} + * @param control + * @param font the new text font + */ + void setFont(Font font); + +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java new file mode 100644 index 00000000000..587abfd8162 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; + +/** + * Provided by a view implementation. + * @author Michael Scharf + * + */ +public interface ITerminalListener { + /** + * Called when the state of the connection has changed. + * @param state + */ + void setState(TerminalState state); + + /** + * Set the title of the terminal. + * @param title + */ + void setTerminalTitle(String title); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java new file mode 100644 index 00000000000..76bc56d1cf4 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +/** + * Terminal listener allowing to listen to terminal selection changes. + * + * @since 4.1 + */ +public interface ITerminalListener2 extends ITerminalListener { + + /** + * selection has been changed internally e.g. select all + * clients might want to react on that + * NOTE: this does not include mouse selections + * those are handled in separate MouseListeners + * TODO should be unified + */ + void setTerminalSelectionChanged(); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java new file mode 100644 index 00000000000..d72c26c9a84 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015 CWI. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Davy Landman (CWI) - [475267][api] Initial definition of interface + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; + +/** + * Terminal specific version of {@link org.eclipse.swt.events.MouseListener} + * @since 4.1 + */ +public interface ITerminalMouseListener { + /** + * Invoked when a double-click has happend inside the terminal control.
            + *
            + * Important: the event fires for every click, even outside the text region. + * @param terminalText a read-only view of the current terminal text + * @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); + /** + * Invoked when a mouse button is pushed down inside the terminal control.
            + *
            + * Important: the event fires for every mouse down, even outside the text region. + * @param terminalText a read-only view of the current terminal text + * @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); + /** + * Invoked when a mouse button is released inside the terminal control.
            + *
            + * Important: the event fires for every mouse up, even outside the text region. + * @param terminalText a read-only view of the current terminal text + * @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values + */ + void mouseUp(ITerminalTextDataReadOnly terminalText, int line, int column, int button); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java new file mode 100644 index 00000000000..904897c3df9 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use + * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + * Davy Landman (CWI) - [475267][api] Allow custom mouse listeners + ******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import java.io.UnsupportedEncodingException; + +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Control; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; + +/** + * @author Michael Scharf + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ITerminalViewControl { + /** + * Set the encoding that the Terminal uses to decode byte streams into + * characters. + * + * @see ITerminalControl#setEncoding(String) + * @since org.eclipse.tm.terminal 2.0 + */ + void setEncoding(String encoding) throws UnsupportedEncodingException; + + /** + * Get the Terminal's current encoding. + * + * @return the current Encoding of the Terminal. + * @see ITerminalControl#getEncoding() + * @since org.eclipse.tm.terminal 2.0 + */ + String getEncoding(); + + boolean isEmpty(); + /** + * Sets the Terminal font + * @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font + * @param font + */ + void setFont(Font font); + /** + * Sets the font for the Terminal, using a JFace symbolic font name, such + * that bold and italic variants can be leveraged. + * @since 3.2 + * @param fontName + */ + void setFont(String fontName); + void setInvertedColors(boolean invert); + Font getFont(); + /** + * @return the text control + */ + Control getControl(); + /** + * @return the root of all controls + */ + Control getRootControl(); + boolean isDisposed(); + void selectAll(); + void clearTerminal(); + void copy(); + void paste(); + String getSelection(); + TerminalState getState(); + Clipboard getClipboard(); + void disconnectTerminal(); + 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 + */ + public boolean pasteString(String string); + + boolean isConnected(); + + /** + * @param inputField null means no input field is shown + */ + void setCommandInputField(ICommandInputField inputField); + /** + * @return null or the current input field + */ + ICommandInputField getCommandInputField(); + + /** + * @return the maximum number of lines to display + * in the terminal view. -1 means unlimited. + */ + public int getBufferLineLimit(); + + /** + * @param bufferLineLimit the maximum number of lines to show + * in the terminal view. -1 means unlimited. + */ + public void setBufferLineLimit(int bufferLineLimit); + boolean isScrollLock(); + void setScrollLock(boolean on); + + /** + * @since 4.1 + */ + void addMouseListener(ITerminalMouseListener listener); + /** + * @since 4.1 + */ + void removeMouseListener(ITerminalMouseListener listener); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java new file mode 100644 index 00000000000..9ccbdaa37eb --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; + +public class TerminalViewControlFactory { + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + */ + public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { + return makeControl(target, wndParent, connectors, false); + } + + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + * @param useCommonPrefs If true, the Terminal widget will pick up settings + * from the org.eclipse.tm.terminal.TerminalPreferencePage Preference page. + * Otherwise, clients need to maintain settings themselves. + * @since 3.2 + */ + public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) { + return new VT100TerminalControl(target, wndParent, connectors, useCommonPrefs); + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java new file mode 100644 index 00000000000..08561b872eb --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - Adapted from TerminalAction + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; + +public abstract class AbstractTerminalAction extends Action { + private final ITerminalViewControl fTarget; + + public AbstractTerminalAction(String strId) { + this(null, strId, 0); + } + + public AbstractTerminalAction(ITerminalViewControl target, + String strId) { + this(target, strId, 0); + } + + public AbstractTerminalAction(ITerminalViewControl target, + String strId, int style) { + super("", style); //$NON-NLS-1$ + + fTarget = target; + + setId(strId); + } + + abstract public void run(); + + protected void setupAction(String strText, String strToolTip, + String strImage, String strEnabledImage, String strDisabledImage, + boolean bEnabled) { + setupAction(strText, strToolTip, strImage, strEnabledImage, + strDisabledImage, bEnabled, TerminalPlugin.getDefault() + .getImageRegistry()); + } + + protected void setupAction(String strText, String strToolTip, + String strHoverImage, String strEnabledImage, + String strDisabledImage, boolean bEnabled, + ImageRegistry imageRegistry) { + setupAction(strText, strToolTip, imageRegistry + .getDescriptor(strHoverImage), imageRegistry + .getDescriptor(strEnabledImage), imageRegistry + .getDescriptor(strDisabledImage), bEnabled); + } + + protected void setupAction(String strText, String strToolTip, + ImageDescriptor hoverImage, ImageDescriptor enabledImage, + ImageDescriptor disabledImage, boolean bEnabled) { + setText(strText); + setToolTipText(strToolTip); + setEnabled(bEnabled); + if (enabledImage != null) { + setImageDescriptor(enabledImage); + } + if (disabledImage != null) { + setDisabledImageDescriptor(disabledImage); + } + if (hoverImage != null) { + setHoverImageDescriptor(hoverImage); + } + } + + /** + * Return the terminal instance on which the action should operate. + * + * @return the terminal instance on which the action should operate. + */ + protected ITerminalViewControl getTarget() { + return fTarget; + } + + /** + * Subclasses can update their action + * + * @param aboutToShow true before the menu is shown -- false when the menu + * gets hidden + */ + public void updateAction(boolean aboutToShow) { + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java new file mode 100644 index 00000000000..ddcc65bbfb3 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.osgi.util.NLS; + +public class ActionMessages extends NLS { + static { + NLS.initializeMessages(ActionMessages.class.getName(), + ActionMessages.class); + } + + public static String COPY; + public static String CUT; + public static String PASTE; + public static String SELECTALL; + public static String CLEARALL; + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties new file mode 100644 index 00000000000..558ab80213d --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties @@ -0,0 +1,25 @@ +############################################################################### +# Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Initial Contributors: +# The following Wind River employees contributed to the Terminal component +# that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, +# Helmut Haigermoser and Ted Williams. +# +# Contributors: +# Michael Scharf (Wind River) - split into core, view and connector plugins +# Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin +############################################################################### + +# NLS_MESSAGEFORMAT_NONE + +COPY = Copy +CUT = Cut +PASTE = Paste +SELECTALL = Select All +CLEARALL = Clear Terminal diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java new file mode 100644 index 00000000000..eda9eff1f19 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - extracted from TerminalConsts + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +public interface ImageConsts { + 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_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 static final String IMAGE_CLCL_CLEAR_ALL = "ImageClclClearAll"; //$NON-NLS-1$ + + public static final String IMAGE_DLCL_CLEAR_ALL = "ImageDlclClearAll"; //$NON-NLS-1$ + + public static final String IMAGE_ELCL_CLEAR_ALL = "ImageElclClearAll"; //$NON-NLS-1$ +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java new file mode 100644 index 00000000000..85650f6e504 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + * Uwe Stieber (Wind River) - [260372] [terminal] Certain terminal actions are enabled if no target terminal control is available + ********************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; + +public class TerminalActionClearAll extends AbstractTerminalAction { + public TerminalActionClearAll() { + super(TerminalActionClearAll.class.getName()); + + setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, + ImageConsts.IMAGE_CLCL_CLEAR_ALL, + ImageConsts.IMAGE_ELCL_CLEAR_ALL, + ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); + } + + public TerminalActionClearAll(ITerminalViewControl target) { + super(target, TerminalActionClearAll.class.getName()); + + setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, + ImageConsts.IMAGE_CLCL_CLEAR_ALL, + ImageConsts.IMAGE_ELCL_CLEAR_ALL, + ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.clearTerminal(); + } + } + + public void updateAction(boolean aboutToShow) { + ITerminalViewControl target = getTarget(); + setEnabled(target != null && !target.isEmpty()); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java new file mode 100644 index 00000000000..49260c160c3 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + * Uwe Stieber (Wind River) - [260372] [terminal] Certain terminal actions are enabled if no target terminal control is available + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class TerminalActionCopy extends AbstractTerminalAction { + public TerminalActionCopy() { + super(TerminalActionCopy.class.getName()); + setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$ + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.COPY, ActionMessages.COPY, si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); + } + + public TerminalActionCopy(ITerminalViewControl target) { + super(target, TerminalActionCopy.class.getName()); + setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$ + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.COPY, ActionMessages.COPY, si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + String selection = target.getSelection(); + + if (!selection.equals("")) {//$NON-NLS-1$ + target.copy(); + } else { + target.sendKey('\u0003'); + } + } + } + + public void updateAction(boolean aboutToShow) { + ITerminalViewControl target = getTarget(); + boolean bEnabled = target != null; + if (aboutToShow && bEnabled) { + bEnabled = target.getSelection().length() > 0; + } + setEnabled(bEnabled); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java new file mode 100644 index 00000000000..63532bdeb1e --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Uwe Stieber (Wind River) - [260372] [terminal] Certain terminal actions are enabled if no target terminal control is available + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class TerminalActionCut extends AbstractTerminalAction { + public TerminalActionCut() { + super(TerminalActionCut.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.CUT, ActionMessages.CUT, si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); + } + + public TerminalActionCut(ITerminalViewControl target) { + super(target, TerminalActionCut.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.CUT, ActionMessages.CUT, si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.sendKey('\u0018'); + } + } + + public void updateAction(boolean aboutToShow) { + // Cut is always disabled + setEnabled(false); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java new file mode 100644 index 00000000000..ca1011c3be2 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + * Uwe Stieber (Wind River) - [260372] [terminal] Certain terminal actions are enabled if no target terminal control is available + * Uwe Stieber (Wind River) - [294719] [terminal] SWT Widget disposed in TerminalActionPaste + * Martin Oberhuber (Wind River) - [296212] Cannot paste text into terminal on some Linux hosts + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class TerminalActionPaste extends AbstractTerminalAction { + public TerminalActionPaste() { + super(TerminalActionPaste.class.getName()); + setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$ + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.PASTE, ActionMessages.PASTE, + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), + false); + } + + public TerminalActionPaste(ITerminalViewControl target) { + super(target, TerminalActionPaste.class.getName()); + setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$ + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.PASTE, ActionMessages.PASTE, + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), + false); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.paste(); + } + } + + public void updateAction(boolean aboutToShow) { + ITerminalViewControl target = getTarget(); + boolean bEnabled = target != null && target.getClipboard() != null && !target.getClipboard().isDisposed(); + if (bEnabled) { + String strText = (String) target.getClipboard().getContents( + TextTransfer.getInstance()); + bEnabled = ((strText != null) && (!strText.equals("")) && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$ + } + setEnabled(bEnabled); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java new file mode 100644 index 00000000000..a91ec1cb9b0 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + * Uwe Stieber (Wind River) - [260372] [terminal] Certain terminal actions are enabled if no target terminal control is available + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; + +public class TerminalActionSelectAll extends AbstractTerminalAction { + public TerminalActionSelectAll() { + super(TerminalActionSelectAll.class.getName()); + + setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, + (ImageDescriptor) null, null, null, false); + } + + public TerminalActionSelectAll(ITerminalViewControl target) { + super(target, TerminalActionSelectAll.class.getName()); + + setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, + (ImageDescriptor) null, null, null, false); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.selectAll(); + } + } + + public void updateAction(boolean aboutToShow) { + ITerminalViewControl target = getTarget(); + setEnabled(target != null && !target.isEmpty()); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java new file mode 100644 index 00000000000..f15468023e7 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anton Leherbauer (Wind River) - [458398] Add support for normal/application cursor keys mode + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.impl; + +import java.io.OutputStream; + +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; + +/** + * need a better name! + * @author Michael Scharf + * + */ +public interface ITerminalControlForText { + + TerminalState getState(); + void setState(TerminalState state); + void setTerminalTitle(String title); + + ITerminalConnector getTerminalConnector(); + + OutputStream getOutputStream(); + + /** + * Enable/disable Application Cursor Keys mode (DECCKM) + * @param enable + */ + void enableApplicationCursorKeys(boolean enable); + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java new file mode 100644 index 00000000000..137d67acee6 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.impl; + +import org.eclipse.osgi.util.NLS; + +public class TerminalMessages extends NLS { + static { + NLS.initializeMessages(TerminalMessages.class.getName(), TerminalMessages.class); + } + + public static String TerminalError; + public static String SocketError; + public static String IOError; + public static String CannotConnectTo; + public static String NotInitialized; + + //Preference Page + public static String INVERT_COLORS; + public static String BUFFERLINES; + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties new file mode 100644 index 00000000000..dd249e27d29 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties @@ -0,0 +1,28 @@ +############################################################################### +# Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Initial Contributors: +# The following Wind River employees contributed to the Terminal component +# that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, +# Helmut Haigermoser and Ted Williams. +# +# Contributors: +# Michael Scharf (Wind River) - split into core, view and connector plugins +# Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget +############################################################################### + +# NLS_MESSAGEFORMAT_VAR + +TerminalError = Terminal Error +SocketError = Socket Error +IOError = IO Error +CannotConnectTo = Cannot initialize {0}:\n{1} +NotInitialized = Not Initialized + +INVERT_COLORS = Invert terminal colors +BUFFERLINES = Terminal buffer lines: diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java new file mode 100644 index 00000000000..de791f818d1 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.impl; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.tm.internal.terminal.control.actions.ImageConsts; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class TerminalPlugin extends AbstractUIPlugin { + private static TerminalPlugin plugin; + 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$ + + /** + * The constructor. + */ + public TerminalPlugin() { + } + /** + * Returns the shared instance. + */ + public static TerminalPlugin getDefault() { + return plugin; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static boolean isOptionEnabled(String strOption) { + String strEnabled = Platform.getDebugOption(strOption); + if (strEnabled == null) + return false; + + return new Boolean(strEnabled).booleanValue(); + } + + @Override + protected void initializeImageRegistry(ImageRegistry imageRegistry) { + try { + // Local toolbars + putImageInRegistry(imageRegistry, ImageConsts.IMAGE_CLCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_LOCALTOOL + "clear_co.gif"); //$NON-NLS-1$ + // Enabled local toolbars + putImageInRegistry(imageRegistry, ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_ELCL + "clear_co.gif"); //$NON-NLS-1$ + // Disabled local toolbars + putImageInRegistry(imageRegistry, ImageConsts.IMAGE_DLCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_DLCL + "clear_co.gif"); //$NON-NLS-1$ + } catch (MalformedURLException malformedURLException) { + malformedURLException.printStackTrace(); + } + } + + protected void putImageInRegistry(ImageRegistry imageRegistry, String strKey, String relativePath) throws MalformedURLException { + URL url = TerminalPlugin.getDefault().getBundle().getEntry(relativePath); + ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); + imageRegistry.put(strKey, imageDescriptor); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java new file mode 100644 index 00000000000..e95d69e86e2 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2013, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tm.internal.terminal.emulator; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jface.bindings.TriggerSequence; +import org.eclipse.jface.bindings.keys.KeySequence; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.bindings.keys.SWTKeySupport; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.keys.IBindingService; + +class EditActionAccelerators { + private static final String COPY_COMMAND_ID = "org.eclipse.tm.terminal.copy"; //$NON-NLS-1$ + private static final String PASTE_COMMAND_ID = "org.eclipse.tm.terminal.paste"; //$NON-NLS-1$ + + private final Map commandIdsByAccelerator = new HashMap(); + + private void load() { + addAccelerator(COPY_COMMAND_ID); + addAccelerator(PASTE_COMMAND_ID); + } + + private void addAccelerator(String commandId) { + TriggerSequence[] bindings = bindingsFor(commandId); + for (int i=0; i + * + * There are never any ANSI control characters or escape sequences in the + * text being displayed by this method (this includes newlines, carriage + * returns, and tabs). + *

            + */ + void appendString(String buffer); + + /** + * Process a newline (Control-J) character. A newline (NL) character just + * moves the cursor to the same column on the next line, creating new lines + * when the cursor reaches the bottom edge of the terminal. This is + * counter-intuitive, especially to UNIX programmers who are taught that + * writing a single NL to a terminal is sufficient to move the cursor to the + * first column of the next line, as if a carriage return (CR) and a NL were + * written. + *

            + * + * UNIX terminals typically display a NL character as a CR followed by a NL + * because the terminal device typically has the ONLCR attribute bit set + * (see the termios(4) man page for details), which causes the terminal + * device driver to translate NL to CR + NL on output. The terminal itself + * (i.e., a hardware terminal or a terminal emulator, like xterm or this + * code) _always_ interprets a CR to mean "move the cursor to the beginning + * of the current line" and a NL to mean "move the cursor to the same column + * on the next line". + *

            + */ + void processNewline(); + + /** + * This method returns the relative line number of the line containing the + * cursor. The returned line number is relative to the topmost visible line, + * which has relative line number 0. + * + * @return The relative line number of the line containing the cursor. + */ + int getCursorLine(); + + int getCursorColumn(); + + /** + * This method moves the cursor to the specified line and column. Parameter + * targetLine is the line number of a screen line, so it has a + * minimum value of 0 (the topmost screen line) and a maximum value of + * heightInLines - 1 (the bottommost screen line). A line does not have to + * contain any text to move the cursor to any column in that line. + */ + void setCursor(int targetLine, int targetColumn); + + void setCursorColumn(int targetColumn); + + void setCursorLine(int targetLine); + + int getLines(); + + int getColumns(); + + /** + * Enables VT100 line wrapping mode (default is off). + * This corresponds to the VT100 'eat_newline_glitch' terminal capability. + * If enabled, writing to the rightmost column does not cause + * an immediate wrap to the next line. Instead the line wrap occurs on the + * next output character. + * + * @param enable whether to enable or disable VT100 line wrapping mode + */ + void setVT100LineWrapping(boolean enable); + + /** + * @return whether VT100 line wrapping mode is enabled + */ + boolean isVT100LineWrapping(); + + /** + * Enables/disables insert mode (IRM). + * + * @param enable whether to enable insert mode + */ + void setInsertMode(boolean enable); + + /** + * Set scrolling region. Negative values reset the scroll region. + * + * @param top top line of scroll region + * @param bottom bottom line of scroll region + */ + void setScrollRegion(int top, int bottom); + + /** + * Scroll text upwards. + * + * @param lines number of lines to scroll + */ + void scrollUp(int lines); + + /** + * Scroll text downwards. + * + * @param lines number of lines to scroll + */ + void scrollDown(int lines); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java new file mode 100644 index 00000000000..20c176f30a0 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.emulator; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.eclipse.tm.internal.terminal.provisional.api.Logger; + +public class LoggingOutputStream extends FilterOutputStream { + + public LoggingOutputStream(OutputStream out) { + super(out); + } + + public void write(byte[] b, int off, int len) throws IOException { + if(Logger.isLogEnabled()) + Logger.log("Received " + len + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$ + Logger.encode(new String(b, 0, len)) + "'"); //$NON-NLS-1$ + + // we cannot call super.write, because this would call our write + // which logs character by character..... + //super.write(b, off, len); + if ((off | len | (b.length - (len + off)) | (off + len)) < 0) + throw new IndexOutOfBoundsException(); + + for (int i = 0 ; i < len ; i++) { + super.write(b[off + i]); + } + } + + public void write(int b) throws IOException { + if(Logger.isLogEnabled()) + Logger.log("Received " + 1 + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$ + Logger.encode(new String(new byte[]{(byte)b}, 0, 1)) + "'"); //$NON-NLS-1$ + super.write(b); + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java new file mode 100644 index 00000000000..78531437ee6 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode + * Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode + * Anton Leherbauer (Wind River) - [458402] Add support for scroll up/down and scroll region + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.emulator; + +import java.io.PrintStream; + +import org.eclipse.tm.terminal.model.Style; + +public class VT100BackendTraceDecorator implements IVT100EmulatorBackend { + final IVT100EmulatorBackend fBackend; + final PrintStream fWriter; + public VT100BackendTraceDecorator(IVT100EmulatorBackend backend, PrintStream out) { + fBackend = backend; + fWriter=out; + } + + public void appendString(String buffer) { + fWriter.println("appendString(\""+buffer+"\")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.appendString(buffer); + } + + public void clearAll() { + fWriter.println("clearAll()"); //$NON-NLS-1$ + fBackend.clearAll(); + } + + public void deleteCharacters(int n) { + fWriter.println("deleteCharacters("+n+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.deleteCharacters(n); + } + + public void deleteLines(int n) { + fWriter.println("deleteLines("+n+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.deleteLines(n); + } + + public void eraseAll() { + fWriter.println("eraseAll()"); //$NON-NLS-1$ + fBackend.eraseAll(); + } + + public void eraseLine() { + fWriter.println("eraseLine()"); //$NON-NLS-1$ + fBackend.eraseLine(); + } + + public void eraseLineToCursor() { + fWriter.println("eraseLineToCursor()"); //$NON-NLS-1$ + fBackend.eraseLineToCursor(); + } + + public void eraseLineToEnd() { + fWriter.println("eraseLineToEnd()"); //$NON-NLS-1$ + fBackend.eraseLineToEnd(); + } + + public void eraseToCursor() { + fWriter.println("eraseToCursor()"); //$NON-NLS-1$ + fBackend.eraseToCursor(); + } + + public void eraseToEndOfScreen() { + fWriter.println("eraseToEndOfScreen()"); //$NON-NLS-1$ + fBackend.eraseToEndOfScreen(); + } + + public int getColumns() { + return fBackend.getColumns(); + } + + public int getCursorColumn() { + return fBackend.getCursorColumn(); + } + + public int getCursorLine() { + return fBackend.getCursorLine(); + } + + public Style getDefaultStyle() { + return fBackend.getDefaultStyle(); + } + + public int getLines() { + return fBackend.getLines(); + } + + public Style getStyle() { + return fBackend.getStyle(); + } + + public void insertCharacters(int charactersToInsert) { + fWriter.println("insertCharacters("+charactersToInsert+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.insertCharacters(charactersToInsert); + } + + public void insertLines(int n) { + fWriter.println("insertLines("+n+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.insertLines(n); + } + + public void processNewline() { + fWriter.println("processNewline()"); //$NON-NLS-1$ + fBackend.processNewline(); + } + + public void setCursor(int targetLine, int targetColumn) { + fWriter.println("setCursor("+targetLine+", "+targetColumn+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + fBackend.setCursor(targetLine, targetColumn); + } + + public void setCursorColumn(int targetColumn) { + fWriter.println("setCursorColumn("+targetColumn+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setCursorColumn(targetColumn); + } + + public void setCursorLine(int targetLine) { + fWriter.println("setCursorLine("+targetLine+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setCursorLine(targetLine); + } + + public void setDefaultStyle(Style defaultStyle) { + fWriter.println("setDefaultStyle("+defaultStyle+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setDefaultStyle(defaultStyle); + } + + public void setDimensions(int lines, int cols) { + fWriter.println("setDimensions("+lines+","+cols+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + fBackend.setDimensions(lines, cols); + } + + public void setStyle(Style style) { + fWriter.println("setStyle("+style+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setStyle(style); + } + + public void setVT100LineWrapping(boolean enable) { + fWriter.println("setVT100LineWrapping("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setVT100LineWrapping(enable); + } + + public boolean isVT100LineWrapping() { + return fBackend.isVT100LineWrapping(); + } + + public void setInsertMode(boolean enable) { + fWriter.println("setInsertMode("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setInsertMode(enable); + } + + public void setScrollRegion(int top, int bottom) { + fWriter.println("setScrollRegion("+top+','+bottom+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.setScrollRegion(top, bottom); + } + + public void scrollUp(int lines) { + fWriter.println("scrollUp("+lines+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.scrollUp(lines); + } + + public void scrollDown(int lines) { + fWriter.println("scrollDown("+lines+")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.scrollDown(lines); + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java new file mode 100644 index 00000000000..5e6817a0979 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -0,0 +1,1396 @@ +/******************************************************************************* + * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Michael Scharf (Wind River) - [209746] There are cases where some colors not displayed correctly + * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1 + * Michael Scharf (Wind River) - [262996] get rid of TerminalState.OPENED + * Martin Oberhuber (Wind River) - [334969] Fix multi-command SGR sequence + * Kris De Volder (VMWare) - [392107] Switched interpretation for ESC[0K and ESC[1K sequences + * Martin Oberhuber (Wind River) - [401386] Regression: No header on top due to incorrect ESC[K interpretation + * Martin Oberhuber (Wind River) - [401480] Handle ESC[39;49m and ESC[G + * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode + * Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode + * Anton Leherbauer (Wind River) - [458398] Add support for normal/application cursor keys mode + * Anton Leherbauer (Wind River) - [458402] Add support for scroll up/down and scroll region + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.emulator; + +import java.io.IOException; +import java.io.Reader; + +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; +import org.eclipse.tm.terminal.model.ITerminalTextData; +import org.eclipse.tm.terminal.model.Style; + +/** + * This class processes character data received from the remote host and + * displays it to the user using the Terminal view's StyledText widget. This + * class processes ANSI control characters, including NUL, backspace, carriage + * return, linefeed, and a subset of ANSI escape sequences sufficient to allow + * use of screen-oriented applications, such as vi, Emacs, and any GNU + * readline-enabled application (Bash, bc, ncftp, etc.). + *

            + * + * @author Fran Litterio + * @author Chris Thew + */ +public class VT100Emulator implements ControlListener { + /** This is a character processing state: Initial state. */ + private static final int ANSISTATE_INITIAL = 0; + + /** This is a character processing state: We've seen an escape character. */ + private static final int ANSISTATE_ESCAPE = 1; + + /** + * This is a character processing state: We've seen a '[' after an escape + * character. Expecting a parameter character or a command character next. + */ + private static final int ANSISTATE_EXPECTING_PARAMETER_OR_COMMAND = 2; + + /** + * This is a character processing state: We've seen a ']' after an escape + * character. We are now expecting an operating system command that + * reprograms an intelligent terminal. + */ + private static final int ANSISTATE_EXPECTING_OS_COMMAND = 3; + + /** + * This is a character processing state: We've seen a '[?' after an escape + * character. Expecting a parameter character or a command character next. + */ + private static final int ANSISTATE_EXPECTING_DEC_PRIVATE_COMMAND = 4; + + /** + * This is a character processing state: We've seen one of ()*+-./ after an escape + * character. Expecting a character set designation character. + */ + private static final int ANSISTATE_EXPECTING_CHARSET_DESIGNATION = 5; + + + /** + * This field holds the current state of the Finite TerminalState Automaton (FSA) + * that recognizes ANSI escape sequences. + * + * @see #processNewText() + */ + private int ansiState = ANSISTATE_INITIAL; + + /** + * This field holds a reference to the {@link TerminalControl} object that + * instantiates this class. + */ + private final ITerminalControlForText terminal; + + /** + * This field holds a reference to the StyledText widget that is used to + * display text to the user. + */ + final private IVT100EmulatorBackend text; + /** + * This field hold the saved absolute line number of the cursor when + * processing the "ESC 7" and "ESC 8" command sequences. + */ + private int savedCursorLine = 0; + + /** + * This field hold the saved column number of the cursor when processing the + * "ESC 7" and "ESC 8" command sequences. + */ + private int savedCursorColumn = 0; + + /** + * This field holds an array of StringBuffer objects, each of which is one + * parameter from the current ANSI escape sequence. For example, when + * parsing the escape sequence "\e[20;10H", this array holds the strings + * "20" and "10". + */ + private final StringBuffer[] ansiParameters = new StringBuffer[16]; + + /** + * This field holds the OS-specific command found in an escape sequence of + * the form "\e]...\u0007". + */ + private final StringBuffer ansiOsCommand = new StringBuffer(128); + + /** + * This field holds the index of the next unused element of the array stored + * in field {@link #ansiParameters}. + */ + private int nextAnsiParameter = 0; + + Reader fReader; + + boolean fCrAfterNewLine; + /** + * The constructor. + */ + public VT100Emulator(ITerminalTextData data, ITerminalControlForText terminal, Reader reader) { + super(); + + Logger.log("entered"); //$NON-NLS-1$ + + this.terminal = terminal; + + for (int i = 0; i < ansiParameters.length; ++i) { + ansiParameters[i] = new StringBuffer(); + } + setInputStreamReader(reader); + if(TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) + text=new VT100BackendTraceDecorator(new VT100EmulatorBackend(data),System.out); + else + text=new VT100EmulatorBackend(data); + +// text.setDimensions(24, 80); + Style style=Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$ //$NON-NLS-2$ + text.setDefaultStyle(style); + text.setStyle(style); + } + + /** + * Set the reader that this Terminal gets its input from. + * + * The reader can be changed while the Terminal is running, but a change of + * the reader likely loses some characters which have not yet been fully + * read. Changing the reader can be done in order to change the selected + * Encoding, though. This is typically done when the Terminal is + * constructed, i.e. before it really starts operation; or, when the user + * manually selects a different encoding and thus doesn't care about losing + * old characters. + * + * @param reader the new Reader + */ + public void setInputStreamReader(Reader reader) { + fReader = reader; + } + + public void setDimensions(int lines,int cols) { + text.setDimensions(lines, cols); + ITerminalConnector telnetConnection = getConnector(); + if (telnetConnection != null) { + telnetConnection.setTerminalSize(text.getColumns(), text.getLines()); + } + + } + + /** + * This method performs clean up when this VT100Emulator object is no longer + * needed. After calling this method, no other method on this object should + * be called. + */ + public void dispose() { + } + + /** + * This method is required by interface ControlListener. It allows us to + * know when the StyledText widget is moved. + */ + public void controlMoved(ControlEvent event) { + Logger.log("entered"); //$NON-NLS-1$ + // Empty. + } + + /** + * This method is required by interface ControlListener. It allows us to + * know when the StyledText widget is resized. + */ + public void controlResized(ControlEvent event) { + Logger.log("entered"); //$NON-NLS-1$ + adjustTerminalDimensions(); + } + + /** + * This method erases all text from the Terminal view. + */ + public void clearTerminal() { + Logger.log("entered"); //$NON-NLS-1$ + text.clearAll(); + } + + /** + * This method is called when the user changes the Terminal view's font. We + * attempt to recompute the pixel width of the new font's characters and fix + * the terminal's dimensions. + */ + public void fontChanged() { + Logger.log("entered"); //$NON-NLS-1$ + + if (text != null) + 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 +// * other implementors of {@link ITerminalConnector}, like the +// * SerialPortHandler. +// *

            +// * These connectors write text to the terminal's buffer through +// * {@link TerminalControl#writeToTerminal(String)} and then have +// * this run method executed in the display thread. This method +// * must not execute at the same time as methods +// * {@link #setNewText(StringBuffer)} and {@link #clearTerminal()}. +// *

            +// * IMPORTANT: This method must be called in strict alternation with method +// * {@link #setNewText(StringBuffer)}. +// *

            +// */ + public void processText() { + try { + // Find the width and height of the terminal, and resize it to display an + // integral number of lines and columns. + + adjustTerminalDimensions(); + + // Restore the caret offset, process and display the new text, then save + // the caret offset. See the documentation for field caretOffset for + // details. + + // ISSUE: Is this causing the scroll-to-bottom-on-output behavior? + + try { + processNewText(); + } catch (IOException e) { + Logger.logException(e); + } + + } catch (Exception ex) { + Logger.logException(ex); + } + } + /** + * This method scans the newly received text, processing ANSI control + * characters and escape sequences and displaying normal text. + * @throws IOException + */ + private void processNewText() throws IOException { + Logger.log("entered"); //$NON-NLS-1$ + + + // Scan the newly received text. + + while (hasNextChar()) { + char character = getNextChar(); + + switch (ansiState) { + case ANSISTATE_INITIAL: + switch (character) { + case '\u0000': + break; // NUL character. Ignore it. + + case '\u0007': + processBEL(); // BEL (Control-G) + break; + + case '\b': + processBackspace(); // Backspace + break; + + case '\t': + processTab(); // Tab. + break; + + case '\n': + processNewline(); // Newline (Control-J) + if(fCrAfterNewLine) + processCarriageReturn(); // Carriage Return (Control-M) + break; + + case '\r': + processCarriageReturn(); // Carriage Return (Control-M) + break; + + case '\u001b': + ansiState = ANSISTATE_ESCAPE; // Escape. + break; + + default: + processNonControlCharacters(character); + break; + } + break; + + case ANSISTATE_ESCAPE: + // We've seen an escape character. Here, we process the character + // immediately following the escape. + + switch (character) { + case '[': + ansiState = ANSISTATE_EXPECTING_PARAMETER_OR_COMMAND; + nextAnsiParameter = 0; + + // Erase the parameter strings in preparation for optional + // parameter characters. + + for (int i = 0; i < ansiParameters.length; ++i) { + ansiParameters[i].delete(0, ansiParameters[i].length()); + } + break; + + case ']': + ansiState = ANSISTATE_EXPECTING_OS_COMMAND; + ansiOsCommand.delete(0, ansiOsCommand.length()); + break; + + case ')': + case '(': + case '*': + case '+': + case '-': + case '.': + case '/': + ansiState = ANSISTATE_EXPECTING_CHARSET_DESIGNATION; + break; + + case '7': + // Save cursor position and character attributes + + ansiState = ANSISTATE_INITIAL; + savedCursorLine = relativeCursorLine(); + savedCursorColumn = getCursorColumn(); + break; + + case '8': + // Restore cursor and attributes to previously saved + // position + + ansiState = ANSISTATE_INITIAL; + moveCursor(savedCursorLine, savedCursorColumn); + break; + + case 'c': + // Reset the terminal + ansiState = ANSISTATE_INITIAL; + resetTerminal(); + break; + + default: + Logger + .log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + ansiState = ANSISTATE_INITIAL; + break; + } + break; + + case ANSISTATE_EXPECTING_PARAMETER_OR_COMMAND: + if (character == '?') { + ansiState = ANSISTATE_EXPECTING_DEC_PRIVATE_COMMAND; + break; + } + + // Parameters can appear after the '[' in an escape sequence, but they + // are optional. + + if (character == '@' || (character >= 'A' && character <= 'Z') + || (character >= 'a' && character <= 'z')) { + ansiState = ANSISTATE_INITIAL; + processAnsiCommandCharacter(character); + } else { + processAnsiParameterCharacter(character); + } + break; + + case ANSISTATE_EXPECTING_OS_COMMAND: + // A BEL (\u0007) character marks the end of the OSC sequence. + + if (character == '\u0007') { + ansiState = ANSISTATE_INITIAL; + processAnsiOsCommand(); + } else { + ansiOsCommand.append(character); + } + break; + + case ANSISTATE_EXPECTING_DEC_PRIVATE_COMMAND: + // Parameters can appear after the '[?' in an escape sequence, but they + // are optional. + + if (character == '@' || (character >= 'A' && character <= 'Z') + || (character >= 'a' && character <= 'z')) { + ansiState = ANSISTATE_INITIAL; + processDecPrivateCommandCharacter(character); + } else { + processAnsiParameterCharacter(character); + } + break; + + case ANSISTATE_EXPECTING_CHARSET_DESIGNATION: + if (character != '%') + ansiState = ANSISTATE_INITIAL; + // Character set designation commands are ignored + break; + + default: + // This should never happen! If it does happen, it means there is a + // bug in the FSA. For robustness, we return to the initial + // state. + + Logger.log("INVALID ANSI FSA STATE: " + ansiState); //$NON-NLS-1$ + ansiState = ANSISTATE_INITIAL; + break; + } + } + } + private void resetTerminal() { + text.eraseAll(); + text.setCursor(0, 0); + text.setStyle(text.getDefaultStyle()); + text.setScrollRegion(-1, -1); + text.setInsertMode(false); + terminal.enableApplicationCursorKeys(false); + } + /** + * 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 + * title. + */ + private void processAnsiOsCommand() { + if (ansiOsCommand.charAt(0) != '0' || ansiOsCommand.charAt(1) != ';') { + Logger + .log("Ignoring unsupported ANSI OSC sequence: '" + ansiOsCommand + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + terminal.setTerminalTitle(ansiOsCommand.substring(2)); + } + + /** + * This method dispatches control to various processing methods based on the + * command character found in the most recently received ANSI escape + * sequence. This method only handles command characters that follow the + * ANSI standard Control Sequence Introducer (CSI), which is "\e[...", where + * "..." is an optional ';'-separated sequence of numeric parameters. + *

            + */ + private void processAnsiCommandCharacter(char ansiCommandCharacter) { + // If the width or height of the terminal is ridiculously small (one line or + // column or less), don't even try to process the escape sequence. This avoids + // throwing an exception (SPR 107450). The display will be messed up, but what + // did you user expect by making the terminal so small? + + switch (ansiCommandCharacter) { + case '@': + // Insert character(s). + processAnsiCommand_atsign(); + break; + + case 'A': + // Move cursor up N lines (default 1). + processAnsiCommand_A(); + break; + + case 'B': + // Move cursor down N lines (default 1). + processAnsiCommand_B(); + break; + + case 'C': + // Move cursor forward N columns (default 1). + processAnsiCommand_C(); + break; + + case 'D': + // Move cursor backward N columns (default 1). + processAnsiCommand_D(); + break; + + case 'd': + // Line Position Absolute [row] (default = [1,column]) (VPA). + processAnsiCommand_d(); + break; + + case 'E': + // Move cursor to first column of Nth next line (default 1). + processAnsiCommand_E(); + break; + + case 'F': + // Move cursor to first column of Nth previous line (default 1). + processAnsiCommand_F(); + break; + + case 'G': + // Move to column N of current line (default 1). + processAnsiCommand_G(); + break; + + case 'H': + // Set cursor Position. + processAnsiCommand_H(); + break; + + case 'h': + // Reset Mode. + processAnsiCommand_h(); + break; + + case 'J': + // Erase part or all of display. Cursor does not move. + processAnsiCommand_J(); + break; + + case 'K': + // Erase in line (cursor does not move). + processAnsiCommand_K(); + break; + + case 'L': + // Insert line(s) (current line moves down). + processAnsiCommand_L(); + break; + + case 'l': + // Set Mode. + processAnsiCommand_l(); + break; + + case 'M': + // Delete line(s). + processAnsiCommand_M(); + break; + + case 'm': + // Set Graphics Rendition (SGR). + processAnsiCommand_m(); + break; + + case 'n': + // Device Status Report (DSR). + processAnsiCommand_n(); + break; + + case 'P': + // Delete character(s). + processAnsiCommand_P(); + break; + + case 'r': + // Set Scrolling Region. + processAnsiCommand_r(); + break; + + case 'S': + // Scroll up. + processAnsiCommand_S(); + break; + + case 'T': + // Scroll down. + processAnsiCommand_T(); + break; + + case 'X': + // Erase character. + // Emacs, vi, and GNU readline don't seem to use this command, so we ignore + // it for now. + break; + + case 'Z': + // Cursor back tab. + // Emacs, vi, and GNU readline don't seem to use this command, so we ignore + // it for now. + break; + + default: + Logger.log("Ignoring unsupported ANSI command character: '" + //$NON-NLS-1$ + ansiCommandCharacter + "'"); //$NON-NLS-1$ + break; + } + } + + /** + * This method dispatches control to various processing methods based on the + * command character found in the most recently received DEC private mode escape + * sequence. This method only handles command characters that follow the + * control sequence CSI ? + */ + private void processDecPrivateCommandCharacter(char commandCharacter) { + switch (commandCharacter) { + case 'h': + // DEC Private Mode Set (DECSET) + processDecPrivateCommand_h(); + break; + + case 'l': + // DEC Private Mode Reset (DECRST) + processDecPrivateCommand_l(); + break; + + default: + Logger.log("Ignoring unsupported DEC private command character: '" + //$NON-NLS-1$ + commandCharacter + "'"); //$NON-NLS-1$ + break; + } + } + + /** + * This method makes room for N characters on the current line at the cursor + * position. Text under the cursor moves right without wrapping at the end + * of the line. + */ + private void processAnsiCommand_atsign() { + int charactersToInsert = getAnsiParameter(0); + text.insertCharacters(charactersToInsert); + } + + /** + * This method moves the cursor up by the number of lines specified by the + * escape sequence parameter (default 1). + */ + private void processAnsiCommand_A() { + moveCursorUp(getAnsiParameter(0)); + } + + /** + * This method moves the cursor down by the number of lines specified by the + * escape sequence parameter (default 1). + */ + private void processAnsiCommand_B() { + moveCursorDown(getAnsiParameter(0)); + } + + /** + * This method moves the cursor forward by the number of columns specified + * by the escape sequence parameter (default 1). + */ + private void processAnsiCommand_C() { + moveCursorForward(getAnsiParameter(0)); + } + + /** + * This method moves the cursor backward by the number of columns specified + * by the escape sequence parameter (default 1). + */ + private void processAnsiCommand_D() { + moveCursorBackward(getAnsiParameter(0)); + } + + /** + * This method moves the cursor to a specific row. + */ + private void processAnsiCommand_d() { + // Line Position Absolute [row] (default = [1,column]) (VPA). + text.setCursorLine(getAnsiParameter(0) - 1); + } + + /** + * This method moves the cursor to the first column of the Nth next line, + * where N is specified by the ANSI parameter (default 1). + */ + private void processAnsiCommand_E() { + int linesToMove = getAnsiParameter(0); + + moveCursor(relativeCursorLine() + linesToMove, 0); + } + + /** + * This method moves the cursor to the first column of the Nth previous + * line, where N is specified by the ANSI parameter (default 1). + */ + private void processAnsiCommand_F() { + int linesToMove = getAnsiParameter(0); + + moveCursor(relativeCursorLine() - linesToMove, 0); + } + + /** + * This method moves the cursor within the current line to the column + * specified by the ANSI parameter (default is column 1). + */ + private void processAnsiCommand_G() { + moveCursor(relativeCursorLine(), getAnsiParameter(0) - 1); + } + + /** + * This method sets the cursor to a position specified by the escape + * sequence parameters (default is the upper left corner of the screen). + */ + private void processAnsiCommand_H() { + moveCursor(getAnsiParameter(0) - 1, getAnsiParameter(1) - 1); + } + + /** + * This method sets terminal modes. + */ + private void processAnsiCommand_h() { + if (getAnsiParameter(0) == 4) { + // set insert mode + text.setInsertMode(true); + } + } + + /** + * This method deletes some (or all) of the text on the screen without + * moving the cursor. + */ + private void processAnsiCommand_J() { + int ansiParameter; + + if (ansiParameters[0].length() == 0) + ansiParameter = 0; + else + ansiParameter = getAnsiParameter(0); + + switch (ansiParameter) { + case 0: + text.eraseToEndOfScreen(); + break; + + case 1: + // Erase from beginning to current position (inclusive). + text.eraseToCursor(); + break; + + case 2: + // Erase entire display. + + text.eraseAll(); + break; + + default: + Logger.log("Unexpected J-command parameter: " + ansiParameter); //$NON-NLS-1$ + break; + } + } + + /** + * This method deletes some (or all) of the text in the current line without + * moving the cursor. + */ + private void processAnsiCommand_K() { + //Bug 401386: missing parameter must be interpreted as 0, and not 1 like most other defaults. + int ansiParameter = 0; + if (ansiParameters[0].length() > 0) + ansiParameter = getAnsiParameter(0); + + switch (ansiParameter) { + case 0: + // Erase from current position to end (inclusive). + text.eraseLineToEnd(); + break; + + case 1: + // Erase from beginning to current position (inclusive). + text.eraseLineToCursor(); + break; + + case 2: + // Erase entire line. + text.eraseLine(); + break; + + default: + Logger.log("Unexpected K-command parameter: " + ansiParameter); //$NON-NLS-1$ + break; + } + } + + /** + * Insert one or more blank lines. The current line of text moves down. Text + * that falls off the bottom of the screen is deleted. + */ + private void processAnsiCommand_L() { + text.insertLines(getAnsiParameter(0)); + } + + /** + * This method resets terminal modes. + */ + private void processAnsiCommand_l() { + if (getAnsiParameter(0) == 4) { + // reset insert mode + text.setInsertMode(false); + } + } + + /** + * Delete one or more lines of text. Any lines below the deleted lines move + * up, which we implement by appending newlines to the end of the text. + */ + private void processAnsiCommand_M() { + text.deleteLines(getAnsiParameter(0)); + } + + /** + * This method sets a new graphics rendition mode, such as + * foreground/background color, bold/normal text, and reverse video. + */ + private void processAnsiCommand_m() { + if (ansiParameters[0].length() == 0) { + // This a special case: when no ANSI parameter is specified, act like a + // single parameter equal to 0 was specified. + + ansiParameters[0].append('0'); + } + Style style=text.getStyle(); + // There are a non-zero number of ANSI parameters. Process each one in + // order. + + int totalParameters = ansiParameters.length; + int parameterIndex = 0; + + while (parameterIndex < totalParameters + && ansiParameters[parameterIndex].length() > 0) { + int ansiParameter = getAnsiParameter(parameterIndex); + + switch (ansiParameter) { + case 0: + // Reset all graphics modes. + style = text.getDefaultStyle(); + break; + + case 1: + style = style.setBold(true); + break; + + case 4: + style = style.setUnderline(true); + break; + + case 5: + style = style.setBlink(true); + break; + + case 7: + style = style.setReverse(true); + break; + + case 10: // Set primary font. Ignored. + break; + + case 21: + case 22: + style = style.setBold(false); + break; + + case 24: + style = style.setUnderline(false); + break; + + case 25: + style = style.setBlink(false); + break; + + case 27: + style = style.setReverse(false); + break; + + case 30: + style = style.setForground("BLACK"); //$NON-NLS-1$ + break; + + case 31: + style = style.setForground("RED"); //$NON-NLS-1$ + break; + + case 32: + style = style.setForground("GREEN"); //$NON-NLS-1$ + break; + + case 33: + style = style.setForground("YELLOW"); //$NON-NLS-1$ + break; + + case 34: + style = style.setForground("BLUE"); //$NON-NLS-1$ + break; + + case 35: + style = style.setForground("MAGENTA"); //$NON-NLS-1$ + break; + + case 36: + style = style.setForground("CYAN"); //$NON-NLS-1$ + break; + + case 37: + style = style.setForground("WHITE_FOREGROUND"); //$NON-NLS-1$ + break; + + case 39: //Foreground: Default + style = style.setForground(text.getDefaultStyle().getForground()); + break; + + case 40: + style = style.setBackground("BLACK"); //$NON-NLS-1$ + break; + + case 41: + style = style.setBackground("RED"); //$NON-NLS-1$ + break; + + case 42: + style = style.setBackground("GREEN"); //$NON-NLS-1$ + break; + + case 43: + style = style.setBackground("YELLOW"); //$NON-NLS-1$ + break; + + case 44: + style = style.setBackground("BLUE"); //$NON-NLS-1$ + break; + + case 45: + style = style.setBackground("MAGENTA"); //$NON-NLS-1$ + break; + + case 46: + style = style.setBackground("CYAN"); //$NON-NLS-1$ + break; + + case 47: + style = style.setBackground("WHITE"); //$NON-NLS-1$ + break; + + case 49: //Background: Default + style = style.setBackground(text.getDefaultStyle().getBackground()); + break; + + default: + Logger + .log("Unsupported graphics rendition parameter: " + ansiParameter); //$NON-NLS-1$ + break; + } + + ++parameterIndex; + } + text.setStyle(style); + } + + /** + * This method responds to an ANSI Device Status Report (DSR) command from + * the remote endpoint requesting the ready status or the cursor position. + * Requests for other kinds of status are ignored. + */ + private void processAnsiCommand_n() { + String reply; + + if (getAnsiParameter(0) == 5) { + // Report that the terminal is ready and has no malfunctions. + reply = "\u001b[0n"; //$NON-NLS-1$ + + } else if (getAnsiParameter(0) == 6) { + // Send the ANSI cursor position (which is 1-based) to the remote + // endpoint. + reply = "\u001b[" + (relativeCursorLine() + 1) + ";" + //$NON-NLS-1$ //$NON-NLS-2$ + (getCursorColumn() + 1) + "R"; //$NON-NLS-1$ + + } else { + // Do nothing if the numeric parameter was not 5 or 6. + return; + } + + try { + terminal.getOutputStream().write(reply.getBytes("ISO-8859-1")); //$NON-NLS-1$ + terminal.getOutputStream().flush(); + } catch (IOException ex) { + Logger.log("Caught IOException!"); //$NON-NLS-1$ + } + } + + /** + * Deletes one or more characters starting at the current cursor position. + * Characters on the same line and to the right of the deleted characters + * move left. If there are no characters on the current line at or to the + * right of the cursor column, no text is deleted. + */ + private void processAnsiCommand_P() { + text.deleteCharacters(getAnsiParameter(0)); + } + + /** + * Set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM). + */ + private void processAnsiCommand_r() { + int top = 0; + int bottom = 0; + if (ansiParameters[0].length() > 0 && ansiParameters[1].length() > 0) { + top = getAnsiParameter(0); + bottom = getAnsiParameter(1); + } + text.setScrollRegion(top-1, bottom-1); + } + + /** + * Scroll up n lines (default = 1 line). + */ + private void processAnsiCommand_S() { + text.scrollUp(getAnsiParameter(0)); + } + + /** + * Scroll down n lines (default = 1 line). + */ + private void processAnsiCommand_T() { + text.scrollDown(getAnsiParameter(0)); + } + + private void processDecPrivateCommand_h() { + int param = getAnsiParameter(0); + switch (param) { + case 1: + // Enable Application Cursor Keys (DECCKM) + terminal.enableApplicationCursorKeys(true); + break; + case 47: + case 1047: + case 1048: + case 1049: + // Use Alternate Screen Buffer (ignored). + break; + default: + Logger.log("Unsupported command parameter: CSI ?" + param + 'h'); //$NON-NLS-1$ + break; + } + } + + private void processDecPrivateCommand_l() { + int param = getAnsiParameter(0); + switch (param) { + case 1: + // Enable Normal Cursor Keys (DECCKM) + terminal.enableApplicationCursorKeys(false); + break; + case 47: + case 1047: + case 1048: + case 1049: + // Use Normal Screen Buffer (ignored, but reset scroll region). + text.setScrollRegion(-1, -1); + break; + default: + Logger.log("Unsupported command parameter: CSI ?" + param + 'l'); //$NON-NLS-1$ + break; + } + } + + /** + * This method returns one of the numeric ANSI parameters received in the + * most recent escape sequence. + * + * @return The parameterIndexth numeric ANSI parameter or -1 if the + * index is out of range. + */ + private int getAnsiParameter(int parameterIndex) { + if (parameterIndex < 0 || parameterIndex >= ansiParameters.length) { + // This should never happen. + return -1; + } + + String parameter = ansiParameters[parameterIndex].toString(); + + if (parameter.length() == 0) + return 1; + + int parameterValue = 1; + + // Don't trust the remote endpoint to send well formed numeric + // parameters. + + try { + parameterValue = Integer.parseInt(parameter); + } catch (NumberFormatException ex) { + parameterValue = 1; + } + + return parameterValue; + } + + /** + * This method processes a single parameter character in an ANSI escape + * sequence. Parameters are the (optional) characters between the leading + * "\e[" and the command character in an escape sequence (e.g., in the + * escape sequence "\e[20;10H", the parameter characters are "20;10"). + * Parameters are integers separated by one or more ';'s. + */ + private void processAnsiParameterCharacter(char ch) { + if (ch == ';') { + ++nextAnsiParameter; + } else { + if (nextAnsiParameter < ansiParameters.length) + ansiParameters[nextAnsiParameter].append(ch); + } + } + /** + * This method processes a contiguous sequence of non-control characters. + * This is a performance optimization, so that we don't have to insert or + * append each non-control character individually to the StyledText widget. + * A non-control character is any character that passes the condition in the + * below while loop. + * @throws IOException + */ + private void processNonControlCharacters(char character) throws IOException { + StringBuffer buffer=new StringBuffer(); + buffer.append(character); + // Identify a contiguous sequence of non-control characters, starting at + // firstNonControlCharacterIndex in newText. + while(hasNextChar()) { + character=getNextChar(); + if(character == '\u0000' || character == '\b' || character == '\t' + || character == '\u0007' || character == '\n' + || character == '\r' || character == '\u001b') { + pushBackChar(character); + break; + } + buffer.append(character); + } + + // Now insert the sequence of non-control characters in the StyledText widget + // at the location of the cursor. + + displayNewText(buffer.toString()); + } + + /** + * This method displays a subset of the newly-received text in the Terminal + * view, wrapping text at the right edge of the screen and overwriting text + * when the cursor is not at the very end of the screen's text. + *

            + * + * There are never any ANSI control characters or escape sequences in the + * text being displayed by this method (this includes newlines, carriage + * returns, and tabs). + *

            + */ + private void displayNewText(String buffer) { + text.appendString(buffer); + } + + + /** + * Process a BEL (Control-G) character. + */ + private void processBEL() { + // TODO + //Display.getDefault().beep(); + } + + /** + * Process a backspace (Control-H) character. + */ + private void processBackspace() { + moveCursorBackward(1); + } + + /** + * Process a tab (Control-I) character. We don't insert a tab character into + * the StyledText widget. Instead, we move the cursor forward to the next + * tab stop, without altering any of the text. Tab stops are every 8 + * columns. The cursor will never move past the rightmost column. + */ + private void processTab() { + moveCursorForward(8 - (getCursorColumn() % 8)); + } + + /** + * Process a newline (Control-J) character. A newline (NL) character just + * moves the cursor to the same column on the next line, creating new lines + * when the cursor reaches the bottom edge of the terminal. This is + * counter-intuitive, especially to UNIX programmers who are taught that + * writing a single NL to a terminal is sufficient to move the cursor to the + * first column of the next line, as if a carriage return (CR) and a NL were + * written. + *

            + * + * UNIX terminals typically display a NL character as a CR followed by a NL + * because the terminal device typically has the ONLCR attribute bit set + * (see the termios(4) man page for details), which causes the terminal + * device driver to translate NL to CR + NL on output. The terminal itself + * (i.e., a hardware terminal or a terminal emulator, like xterm or this + * code) _always_ interprets a CR to mean "move the cursor to the beginning + * of the current line" and a NL to mean "move the cursor to the same column + * on the next line". + *

            + */ + private void processNewline() { + text.processNewline(); + } + + /** + * Process a Carriage Return (Control-M). + */ + private void processCarriageReturn() { + text.setCursorColumn(0); + } + + /** + * This method computes the width of the terminal in columns and its height + * in lines, then adjusts the width and height of the view's StyledText + * widget so that it displays an integral number of lines and columns of + * text. The adjustment is always to shrink the widget vertically or + * horizontally, because if the control were to grow, it would be clipped by + * the edges of the view window (i.e., the view window does not become + * larger to accommodate its contents becoming larger). + *

            + * + * This method must be called immediately before each time text is written + * to the terminal so that we can properly line wrap text. Because it is + * called so frequently, it must be fast when there is no resizing to be + * done. + *

            + */ + private void adjustTerminalDimensions() { + // Compute how many pixels we need to shrink the StyledText control vertically + // to make it display an integral number of lines of text. + + // TODO +// if(text.getColumns()!=80 && text.getLines()!=80) +// text.setDimensions(24, 80); + // 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 + // communicate it to the TELNET server. If we are in a serial connection, + // there is nothing we can do to tell the remote host about the size of the + // terminal. + ITerminalConnector telnetConnection = getConnector(); + // TODO MSA: send only if dimensions have really changed! + if (telnetConnection != null) { + telnetConnection.setTerminalSize(text.getColumns(), text.getLines()); + } + + } + + private ITerminalConnector getConnector() { + if(terminal.getTerminalConnector()!=null) + return terminal.getTerminalConnector(); + return null; + } + + /** + * This method returns the relative line number of the line containing the + * cursor. The returned line number is relative to the topmost visible line, + * which has relative line number 0. + * + * @return The relative line number of the line containing the cursor. + */ + private int relativeCursorLine() { + return text.getCursorLine(); + } + + /** + * This method moves the cursor to the specified line and column. Parameter + * targetLine is the line number of a screen line, so it has a + * minimum value of 0 (the topmost screen line) and a maximum value of + * heightInLines - 1 (the bottommost screen line). A line does not have to + * contain any text to move the cursor to any column in that line. + */ + private void moveCursor(int targetLine, int targetColumn) { + text.setCursor(targetLine,targetColumn); + } + + /** + * This method moves the cursor down lines lines, but won't move the + * cursor past the bottom of the screen. This method does not cause any + * scrolling. + */ + private void moveCursorDown(int lines) { + moveCursor(relativeCursorLine() + lines, getCursorColumn()); + } + + /** + * This method moves the cursor up lines lines, but won't move the + * cursor past the top of the screen. This method does not cause any + * scrolling. + */ + private void moveCursorUp(int lines) { + moveCursor(relativeCursorLine() - lines, getCursorColumn()); + } + + /** + * This method moves the cursor forward columns columns, but won't + * move the cursor past the right edge of the screen, nor will it move the + * cursor onto the next line. This method does not cause any scrolling. + */ + private void moveCursorForward(int columnsToMove) { + moveCursor(relativeCursorLine(), getCursorColumn() + columnsToMove); + } + + /** + * This method moves the cursor backward columnsToMove columns, but + * won't move the cursor past the left edge of the screen, nor will it move + * the cursor onto the previous line. This method does not cause any + * scrolling. + */ + private void moveCursorBackward(int columnsToMove) { + moveCursor(relativeCursorLine(), getCursorColumn() - columnsToMove); + } + /** + * 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. + */ + public void resetState() { + ansiState=ANSISTATE_INITIAL; + text.setStyle(text.getDefaultStyle()); + text.setScrollRegion(-1, -1); + text.setInsertMode(false); + } + +// public OutputStream getOutputStream() { +// return fTerminalInputStream.getOutputStream(); +// } + + /** + * Buffer for {@link #pushBackChar(char)}. + */ + private int fNextChar=-1; + + private char getNextChar() throws IOException { + int c=-1; + if(fNextChar!=-1) { + c= fNextChar; + fNextChar=-1; + } else { + c = fReader.read(); + } + // TODO: better end of file handling + if(c==-1) + c=0; + return (char)c; + } + + private boolean hasNextChar() throws IOException { + if(fNextChar>=0) + return true; + return fReader.ready(); + } + + /** + * Put back one character to the stream. This method can push + * back exactly one character. The character is the next character + * returned by {@link #getNextChar} + * @param c the character to be pushed back. + */ + void pushBackChar(char c) { + //assert fNextChar!=-1: "Already a character waiting:"+fNextChar; //$NON-NLS-1$ + fNextChar=c; + } + private int getCursorColumn() { + return text.getCursorColumn(); + } + public boolean isCrAfterNewLine() { + return fCrAfterNewLine; + } + public void setCrAfterNewLine(boolean crAfterNewLine) { + fCrAfterNewLine = crAfterNewLine; + } + void setVT100LineWrapping(boolean enable) { + text.setVT100LineWrapping(enable); + } + boolean isVT100LineWrapping() { + return text.isVT100LineWrapping(); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java new file mode 100644 index 00000000000..a6ea4e5d23b --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -0,0 +1,502 @@ +/******************************************************************************* + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [206329] Changing terminal size right after connect does not scroll properly + * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode + * Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode + * Anton Leherbauer (Wind River) - [458402] Add support for scroll up/down and scroll region + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.emulator; + +import org.eclipse.tm.terminal.model.ITerminalTextData; +import org.eclipse.tm.terminal.model.Style; + +/** + * @noextend This class is not intended to be subclassed by clients. + * @noreference This class not intended to be referenced by clients. + * It used to be package protected, and it is public only for Unit Tests. + * + */ +public class VT100EmulatorBackend implements IVT100EmulatorBackend { + + private static class ScrollRegion { + static final ScrollRegion FULL_WINDOW = new ScrollRegion(0, Integer.MAX_VALUE-1); + private final int fTop; + private final int fBottom; + ScrollRegion(int top, int bottom) { + fTop = top; + fBottom = bottom; + } + boolean contains(int line) { + return line >= fTop && line <= fBottom; + } + int getTopLine() { + return fTop; + } + int getBottomLine() { + return fBottom; + } + int getHeight() { + return fBottom - fTop + 1; + } + } + + /** + * This field holds the number of the column in which the cursor is + * logically positioned. The leftmost column on the screen is column 0, and + * column numbers increase to the right. The maximum value of this field is + * {@link #widthInColumns} - 1. We track the cursor column using this field + * to avoid having to recompute it repeatly using StyledText method calls. + *

            + * + * The StyledText widget that displays text has a vertical bar (called the + * "caret") that appears _between_ character cells, but ANSI terminals have + * the concept of a cursor that appears _in_ a character cell, so we need a + * convention for which character cell the cursor logically occupies when + * the caret is physically between two cells. The convention used in this + * class is that the cursor is logically in column N when the caret is + * physically positioned immediately to the _left_ of column N. + *

            + * + * When fCursorColumn is N, the next character output to the terminal appears + * in column N. When a character is output to the rightmost column on a + * given line (column widthInColumns - 1), the cursor moves to column 0 on + * the next line after the character is drawn (this is the default line wrapping + * mode). If VT100 line wrapping mode is enabled, the cursor does not move + * to the next line until the next character is printed (this is known as + * the VT100 'eat_newline_glitch'). + * If the cursor is in the bottommost line when line wrapping + * occurs, the topmost visible line is scrolled off the top edge of the + * screen. + *

            + */ + private int fCursorColumn; + private int fCursorLine; + /* true if last output occurred on rightmost column + * and next output requires line wrap */ + private boolean fWrapPending; + private boolean fInsertMode; + private Style fDefaultStyle; + private Style fStyle; + int fLines; + int fColumns; + final private ITerminalTextData fTerminal; + private boolean fVT100LineWrapping; + private ScrollRegion fScrollRegion = ScrollRegion.FULL_WINDOW; + + public VT100EmulatorBackend(ITerminalTextData terminal) { + fTerminal=terminal; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#clearAll() + */ + public void clearAll() { + synchronized (fTerminal) { + // clear the history + int n=fTerminal.getHeight(); + for (int line = 0; line < n; line++) { + fTerminal.cleanLine(line); + } + fTerminal.setDimensions(fLines, fTerminal.getWidth()); + setStyle(getDefaultStyle()); + setCursor(0, 0); + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDimensions(int, int) + */ + public void setDimensions(int lines, int cols) { + synchronized (fTerminal) { + if(lines==fLines && cols==fColumns) + return; // nothing to do + // relative cursor line + int cl=getCursorLine(); + int cc=getCursorColumn(); + int height=fTerminal.getHeight(); + // absolute cursor line + int acl=cl+height-fLines; + int newLines=Math.max(lines,height); + if(lines=fCursorColumn+n; col--) { + char c=fTerminal.getChar(line, col-n); + Style style=fTerminal.getStyle(line, col-n); + fTerminal.setChar(line, col,c, style); + } + int last=Math.min(fCursorColumn+n, fColumns); + for (int col = fCursorColumn; col 0; + int line=toAbsoluteLine(fCursorLine); + int nLines=Math.min(fTerminal.getHeight()-line, fScrollRegion.getBottomLine()-fCursorLine+1); + fTerminal.scroll(line, nLines, n); + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteCharacters(int) + */ + public void deleteCharacters(int n) { + synchronized (fTerminal) { + int line=toAbsoluteLine(fCursorLine); + for (int col = fCursorColumn+n; col < fColumns; col++) { + char c=fTerminal.getChar(line, col); + Style style=fTerminal.getStyle(line, col); + fTerminal.setChar(line, col-n,c, style); + } + int first=Math.max(fCursorColumn, fColumns-n); + for (int col = first; col 0; + int line=toAbsoluteLine(fCursorLine); + int nLines=Math.min(fTerminal.getHeight()-line, fScrollRegion.getBottomLine()-fCursorLine+1); + fTerminal.scroll(line, nLines, -n); + } + } + private boolean isCusorInScrollingRegion() { + return fScrollRegion.contains(fCursorLine); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getDefaultStyle() + */ + public Style getDefaultStyle() { + synchronized (fTerminal) { + return fDefaultStyle; + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDefaultStyle(org.eclipse.tm.terminal.model.Style) + */ + public void setDefaultStyle(Style defaultStyle) { + synchronized (fTerminal) { + fDefaultStyle = defaultStyle; + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getStyle() + */ + public Style getStyle() { + synchronized (fTerminal) { + if(fStyle==null) + return fDefaultStyle; + return fStyle; + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setStyle(org.eclipse.tm.terminal.model.Style) + */ + public void setStyle(Style style) { + synchronized (fTerminal) { + fStyle=style; + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#appendString(java.lang.String) + */ + public void appendString(String buffer) { + synchronized (fTerminal) { + char[] chars=buffer.toCharArray(); + if (fInsertMode) + insertCharacters(chars.length); + int line=toAbsoluteLine(fCursorLine); + int i=0; + while (i < chars.length) { + if(fWrapPending) { + line = doLineWrap(); + } + int n=Math.min(fColumns-fCursorColumn,chars.length-i); + fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle); + int col=fCursorColumn+n; + i+=n; + // wrap needed? + if(col == fColumns) { + if (fVT100LineWrapping) { + // deferred line wrapping (eat_newline_glitch) + setCursorColumn(col - 1); + fWrapPending = true; + } else { + line = doLineWrap(); + } + } else { + setCursorColumn(col); + } + } + } + } + + private int doLineWrap() { + int line; + line=toAbsoluteLine(fCursorLine); + fTerminal.setWrappedLine(line); + doNewline(); + line=toAbsoluteLine(fCursorLine); + setCursorColumn(0); + return line; + } + + /** + * MUST be called from a synchronized block! + */ + private void doNewline() { + if (fCursorLine == fScrollRegion.getBottomLine()) + scrollUp(1); + else if (fCursorLine+1>=fLines) { + int h=fTerminal.getHeight(); + fTerminal.addLine(); + if(h!=fTerminal.getHeight()) + setCursorLine(fCursorLine+1); + } else { + setCursorLine(fCursorLine+1); + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#processNewline() + */ + public void processNewline() { + synchronized (fTerminal) { + doNewline(); + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorLine() + */ + public int getCursorLine() { + synchronized (fTerminal) { + return fCursorLine; + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorColumn() + */ + public int getCursorColumn() { + synchronized (fTerminal) { + return fCursorColumn; + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursor(int, int) + */ + public void setCursor(int targetLine, int targetColumn) { + synchronized (fTerminal) { + setCursorLine(targetLine); + setCursorColumn(targetColumn); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursorColumn(int) + */ + public void setCursorColumn(int targetColumn) { + synchronized (fTerminal) { + if(targetColumn<0) + targetColumn=0; + else if(targetColumn>=fColumns) + targetColumn=fColumns-1; + fCursorColumn=targetColumn; + fWrapPending = false; + // We make the assumption that nobody is changing the + // terminal cursor except this class! + // This assumption gives a huge performance improvement + fTerminal.setCursorColumn(targetColumn); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursorLine(int) + */ + public void setCursorLine(int targetLine) { + synchronized (fTerminal) { + if(targetLine<0) + targetLine=0; + else if(targetLine>=fLines) + targetLine=fLines-1; + fCursorLine=targetLine; + // We make the assumption that nobody is changing the + // terminal cursor except this class! + // This assumption gives a huge performance improvement + fTerminal.setCursorLine(toAbsoluteLine(targetLine)); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getLines() + */ + public int getLines() { + synchronized (fTerminal) { + return fLines; + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getColumns() + */ + public int getColumns() { + synchronized (fTerminal) { + return fColumns; + } + } + + public void setVT100LineWrapping(boolean enable) { + fVT100LineWrapping = enable; + } + + public boolean isVT100LineWrapping() { + return fVT100LineWrapping; + } + + public void setInsertMode(boolean enable) { + fInsertMode = enable; + } + + public void setScrollRegion(int top, int bottom) { + if (top < 0 || bottom < 0) + fScrollRegion = ScrollRegion.FULL_WINDOW; + else if (top < bottom) + fScrollRegion = new ScrollRegion(top, bottom); + } + + public void scrollUp(int n) { + assert n>0; + synchronized (fTerminal) { + int line = toAbsoluteLine(fScrollRegion.getTopLine()); + int nLines = Math.min(fTerminal.getHeight()-line, fScrollRegion.getHeight()); + fTerminal.scroll(line, nLines, -n); + } + } + + public void scrollDown(int n) { + assert n>0; + synchronized (fTerminal) { + int line = toAbsoluteLine(fScrollRegion.getTopLine()); + int nLines = Math.min(fTerminal.getHeight()-line, fScrollRegion.getHeight()); + fTerminal.scroll(line, nLines, n); + } + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java new file mode 100644 index 00000000000..b5d62b5ded9 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -0,0 +1,1414 @@ +/******************************************************************************* + * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [206892] State handling: Only allow connect when CLOSED + * Martin Oberhuber (Wind River) - [206883] Serial Terminal leaks Jobs + * Martin Oberhuber (Wind River) - [208145] Terminal prints garbage after quick disconnect/reconnect + * Martin Oberhuber (Wind River) - [207785] NPE when trying to send char while no longer connected + * Michael Scharf (Wind River) - [209665] Add ability to log byte streams from terminal + * Ruslan Sychev (Xored Software) - [217675] NPE or SWTException when closing Terminal View while connection establishing + * Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable + * Martin Oberhuber (Wind River) - [168197] Replace JFace MessagDialog by SWT MessageBox + * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use + * Michael Scharf (Wind River) - [237398] Terminal get Invalid Thread Access when the title is set + * Martin Oberhuber (Wind River) - [240745] Pressing Ctrl+F1 in the Terminal should bring up context help + * Michael Scharf (Wind River) - [240098] The cursor should not blink when the terminal is disconnected + * Anton Leherbauer (Wind River) - [335021] Middle mouse button copy/paste does not work with the terminal + * Max Stepanov (Appcelerator) - [339768] Fix ANSI code for PgUp / PgDn + * Pawel Piech (Wind River) - [333613] "Job found still running" after shutdown + * Martin Oberhuber (Wind River) - [348700] Terminal unusable after disconnect + * Simon Bernard (Sierra Wireless) - [351424] [terminal] Terminal does not support del and insert key + * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode + * Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers + * Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND + * Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty + * Martin Oberhuber (Wind River) - [436612] Restore Eclipse 3.4 compatibility by using Reflection + * Anton Leherbauer (Wind River) - [458398] Add support for normal/application cursor keys mode + * Anton Leherbauer (Wind River) - [420928] Terminal widget leaks memory + * Davy Landman (CWI) - [475267][api] Allow custom mouse listeners + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.emulator; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.net.SocketException; +import java.nio.charset.Charset; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.bindings.Binding; +import org.eclipse.jface.bindings.keys.KeySequence; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.bindings.keys.SWTKeySupport; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.tm.internal.terminal.control.ICommandInputField; +import org.eclipse.tm.internal.terminal.control.ITerminalListener; +import org.eclipse.tm.internal.terminal.control.ITerminalListener2; +import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText; +import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; +import org.eclipse.tm.internal.terminal.textcanvas.PipedInputStream; +import org.eclipse.tm.internal.terminal.textcanvas.PollingTextCanvasModel; +import org.eclipse.tm.internal.terminal.textcanvas.TextCanvas; +import org.eclipse.tm.internal.terminal.textcanvas.TextLineRenderer; +import org.eclipse.tm.terminal.model.ITerminalTextData; +import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; +import org.eclipse.tm.terminal.model.TerminalTextDataFactory; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.contexts.IContextActivation; +import org.eclipse.ui.contexts.IContextService; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.keys.IBindingService; + +/** + * + * This class was originally written to use nested classes, which unfortunately makes + * this source file larger and more complex than it needs to be. In particular, the + * methods in the nested classes directly access the fields of the enclosing class. + * One day we should pull the nested classes out into their own source files (but still + * in this package). + * + * @author Chris Thew + */ +public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl +{ + protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$ + + /** + * 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 + * displayed using the view's StyledText widget. + */ + private final VT100Emulator fTerminalText; + private Display fDisplay; + private TextCanvas fCtlText; + private Composite fWndParent; + private Clipboard fClipboard; + private KeyListener fKeyHandler; + private final ITerminalListener fTerminalListener; + private String fMsg = ""; //$NON-NLS-1$ + private TerminalFocusListener fFocusListener; + private ITerminalConnector fConnector; + private final ITerminalConnector[] fConnectors; + private final boolean fUseCommonPrefs; + private boolean connectOnEnterIfClosed = true; + + PipedInputStream fInputStream; + private static final String defaultEncoding = Charset.defaultCharset().name(); + private String fEncoding = defaultEncoding; + private InputStreamReader fInputStreamReader; + + private ICommandInputField fCommandInputField; + + private volatile TerminalState fState; + + private final ITerminalTextData fTerminalModel; + + private final EditActionAccelerators editActionAccelerators = new EditActionAccelerators(); + + private boolean fApplicationCursorKeys; + + /** + * Listens to changes in the preferences + */ + private final IPropertyChangeListener fPreferenceListener=new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + if(event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) + || event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) { + updatePreferences(); + } + } + }; + private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) { + onTerminalFontChanged(); + } + } + }; + + /** + * Is protected by synchronize on this + */ + volatile private Job fJob; + + private PollingTextCanvasModel fPollingTextCanvasModel; + + public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { + this(target, wndParent, connectors, false); + } + + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + * @param useCommonPrefs If true, the Terminal widget will pick up settings + * from the org.eclipse.tm.terminal.TerminalPreferencePage Preference page. + * Otherwise, clients need to maintain settings themselves. + * @since 3.2 + */ + public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) { + fConnectors=connectors; + fUseCommonPrefs = useCommonPrefs; + fTerminalListener=target; + fTerminalModel=TerminalTextDataFactory.makeTerminalTextData(); + fTerminalModel.setMaxHeight(1000); + fInputStream=new PipedInputStream(8*1024); + fTerminalText = new VT100Emulator(fTerminalModel, this, null); + try { + // Use Default Encoding as start, until setEncoding() is called + setEncoding(null); + } catch (UnsupportedEncodingException e) { + // Should never happen + e.printStackTrace(); + // Fall back to local Platform Default Encoding + fEncoding = defaultEncoding; + fInputStreamReader = new InputStreamReader(fInputStream); + fTerminalText.setInputStreamReader(fInputStreamReader); + } + + setupTerminal(wndParent); + } + + @Override + public void setEncoding(String encoding) throws UnsupportedEncodingException { + if (encoding == null) { + // TODO better use a standard remote-to-local encoding? + encoding = "ISO-8859-1"; //$NON-NLS-1$ + // TODO or better use the local default encoding? + // encoding = defaultEncoding; + } + fInputStreamReader = new InputStreamReader(fInputStream, encoding); + // remember encoding if above didn't throw an exception + fEncoding = encoding; + fTerminalText.setInputStreamReader(fInputStreamReader); + } + + @Override + public String getEncoding() { + return fEncoding; + } + + @Override + public ITerminalConnector[] getConnectors() { + return fConnectors; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#copy() + */ + @Override + public void copy() { + copy(DND.CLIPBOARD); + } + + private void copy(int clipboardType) { + String selection = getSelection(); + if (selection.length() > 0) { + Object[] data = new Object[] { selection }; + Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; + fClipboard.setContents(data, types, clipboardType); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste() + */ + @Override + public void paste() { + paste(DND.CLIPBOARD); +// TODO paste in another thread.... to avoid blocking +// new Thread() { +// public void run() { +// for (int i = 0; i < strText.length(); i++) { +// sendChar(strText.charAt(i), false); +// } +// +// } +// }.start(); + } + + private void paste(int clipboardType) { + TextTransfer textTransfer = TextTransfer.getInstance(); + String strText = (String) fClipboard.getContents(textTransfer, clipboardType); + pasteString(strText); + } + + /** + * @param strText the text to paste + */ + @Override + public boolean pasteString(String strText) { + if(!isConnected()) + return false; + if (strText == null) + return false; + if (!fEncoding.equals(defaultEncoding)) { + sendString(strText); + } else { + // TODO I do not understand why pasteString would do this here... + for (int i = 0; i < strText.length(); i++) { + sendChar(strText.charAt(i), false); + } + } + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#selectAll() + */ + @Override + public void selectAll() { + getCtlText().selectAll(); + if (fTerminalListener instanceof ITerminalListener2) { + ((ITerminalListener2)fTerminalListener).setTerminalSelectionChanged(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#sendKey(char) + */ + @Override + public void sendKey(char character) { + Event event; + KeyEvent keyEvent; + + event = new Event(); + event.widget = getCtlText(); + event.character = character; + event.keyCode = 0; + event.stateMask = 0; + event.doit = true; + keyEvent = new KeyEvent(event); + + fKeyHandler.keyPressed(keyEvent); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#clearTerminal() + */ + @Override + public void clearTerminal() { + // The TerminalText object does all text manipulation. + getTerminalText().clearTerminal(); + getCtlText().clearSelection(); + if (fTerminalListener instanceof ITerminalListener2) { + ((ITerminalListener2)fTerminalListener).setTerminalSelectionChanged(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getClipboard() + */ + @Override + public Clipboard getClipboard() { + return fClipboard; + } + + /** + * @return non null selection + */ + @Override + public String getSelection() { + String txt= fCtlText.getSelectionText(); + if(txt==null) + txt=""; //$NON-NLS-1$ + return txt; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setFocus() + */ + @Override + public void setFocus() { + getCtlText().setFocus(); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isEmpty() + */ + @Override + public boolean isEmpty() { + return getCtlText().isEmpty(); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isDisposed() + */ + @Override + public boolean isDisposed() { + return getCtlText().isDisposed(); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnected() + */ + @Override + public boolean isConnected() { + return fState==TerminalState.CONNECTED; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disposeTerminal() + */ + @Override + public void disposeTerminal() { + Logger.log("entered."); //$NON-NLS-1$ + if(fUseCommonPrefs) { + TerminalPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); + JFaceResources.getFontRegistry().removeListener(fFontListener); + } + disconnectTerminal(); + fClipboard.dispose(); + getTerminalText().dispose(); + } + + @Override + public void connectTerminal() { + Logger.log("entered."); //$NON-NLS-1$ + if(getTerminalConnector()==null) + return; + fTerminalText.resetState(); + fApplicationCursorKeys = false; + if(fConnector.getInitializationErrorMessage()!=null) { + showErrorMessage(NLS.bind( + TerminalMessages.CannotConnectTo, + fConnector.getName(), + fConnector.getInitializationErrorMessage())); + // we cannot connect because the connector was not initialized + return; + } + // clean the error message + setMsg(""); //$NON-NLS-1$ + getTerminalConnector().connect(this); + waitForConnect(); + } + + @Override + public ITerminalConnector getTerminalConnector() { + return fConnector; + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disconnectTerminal() + */ + @Override + public void disconnectTerminal() { + Logger.log("entered."); //$NON-NLS-1$ + + //Disconnect the remote side first + if (getState()!=TerminalState.CLOSED) { + if(getTerminalConnector()!=null) { + getTerminalConnector().disconnect(); + } + } + + //Ensure that a new Job can be started; then clean up old Job. + Job job; + synchronized(this) { + job = fJob; + fJob = null; + } + if (job!=null) { + job.cancel(); + // 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). + Thread t = job.getThread(); + if(t!=null) t.interrupt(); + try { + job.join(); + } catch (InterruptedException e) {} + } + fPollingTextCanvasModel.stopPolling(); + } + + private void waitForConnect() { + Logger.log("entered."); //$NON-NLS-1$ + + // TODO Eliminate the nested dispatch loop + do { + if (!fDisplay.readAndDispatch()) + fDisplay.sleep(); + } while (getState()==TerminalState.CONNECTING); + + if (getCtlText().isDisposed()) { + disconnectTerminal(); + return; + } + if (getMsg().length() > 0) { + showErrorMessage(getMsg()); + disconnectTerminal(); + return; + } + if (getCtlText().isFocusControl()) { + if (getState() == TerminalState.CONNECTED) + fFocusListener.captureKeyEvents(true); + } + fPollingTextCanvasModel.startPolling(); + startReaderJob(); + } + + private synchronized void startReaderJob() { + if(fJob==null) { + fJob=new Job("Terminal data reader") { //$NON-NLS-1$ + @Override + protected IStatus run(IProgressMonitor monitor) { + IStatus status=Status.OK_STATUS; + try { + while(true) { + while(fInputStream.available()==0 && !monitor.isCanceled()) { + try { + fInputStream.waitForAvailable(500); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + if(monitor.isCanceled()) { + //Do not disconnect terminal here because another reader job may already be running + status=Status.CANCEL_STATUS; + break; + } + try { + // TODO: should block when no text is available! + fTerminalText.processText(); + } catch (Exception e) { + disconnectTerminal(); + status=new Status(IStatus.ERROR,TerminalPlugin.PLUGIN_ID,e.getLocalizedMessage(),e); + break; + } + } + } finally { + // 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) + synchronized (VT100TerminalControl.this) { + if (fJob==this) { + fJob=null; + } + } + } + return status; + } + + }; + fJob.setSystem(true); + fJob.schedule(); + } + } + + private void showErrorMessage(String message) { + String strTitle = TerminalMessages.TerminalError; + // [168197] Replace JFace MessagDialog by SWT MessageBox + //MessageDialog.openError( getShell(), strTitle, message); + MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK); + mb.setText(strTitle); + mb.setMessage(message); + mb.open(); + } + + protected void sendString(String string) { + Logger.log(string); + try { + // Send the string after converting it to an array of bytes using the + // platform's default character encoding. + // + // TODO: Find a way to force this to use the ISO Latin-1 encoding. + // TODO: handle Encoding Errors in a better way + + getOutputStream().write(string.getBytes(fEncoding)); + getOutputStream().flush(); + } catch (SocketException socketException) { + displayTextInTerminal(socketException.getMessage()); + + String strMsg = TerminalMessages.SocketError + + "!\n" + socketException.getMessage(); //$NON-NLS-1$ + showErrorMessage(strMsg); + + Logger.logException(socketException); + + disconnectTerminal(); + } catch (IOException ioException) { + showErrorMessage(TerminalMessages.IOError + "!\n" + ioException.getMessage());//$NON-NLS-1$ + + Logger.logException(ioException); + + disconnectTerminal(); + } + } + + @Override + public Shell getShell() { + return getCtlText().getShell(); + } + + protected void sendChar(char chKey, boolean altKeyPressed) { + try { + int byteToSend = chKey; + OutputStream os = getOutputStream(); + if (os==null) { + // 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$ + } else { + if (altKeyPressed) { + // When the ALT key is pressed at the same time that a character is + // typed, translate it into an ESCAPE followed by the character. The + // alternative in this case is to set the high bit of the character + // being transmitted, but that will cause input such as ALT-f to be + // seen as the ISO Latin-1 character '�', which can be confusing to + // European users running Emacs, for whom Alt-f should move forward a + // word instead of inserting the '�' character. + // + // TODO: Make the ESCAPE-vs-highbit behavior user configurable. + + byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding); + StringBuilder b = new StringBuilder("sending ESC"); //$NON-NLS-1$ + for (int i = 0; i < bytesToSend.length; i++) { + if (i != 0) b.append(" +"); //$NON-NLS-1$ + b.append(" '" + bytesToSend[i] + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + } + Logger.log(b.toString()); + os.write('\u001b'); + os.write(bytesToSend); + } else { + byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding); + StringBuilder b = new StringBuilder("sending"); //$NON-NLS-1$ + for (int i = 0; i < bytesToSend.length; i++) { + if (i != 0) b.append(" +"); //$NON-NLS-1$ + b.append(" '" + bytesToSend[i] + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + } + Logger.log(b.toString()); + os.write(bytesToSend); + } + os.flush(); + } + } catch (SocketException socketException) { + Logger.logException(socketException); + + displayTextInTerminal(socketException.getMessage()); + + String strMsg = TerminalMessages.SocketError + + "!\n" + socketException.getMessage(); //$NON-NLS-1$ + + showErrorMessage(strMsg); + Logger.logException(socketException); + + disconnectTerminal(); + } catch (IOException ioException) { + Logger.logException(ioException); + + displayTextInTerminal(ioException.getMessage()); + + String strMsg = TerminalMessages.IOError + "!\n" + ioException.getMessage(); //$NON-NLS-1$ + + showErrorMessage(strMsg); + Logger.logException(ioException); + + disconnectTerminal(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setupTerminal(org.eclipse.swt.widgets.Composite) + */ + @Override + public void setupTerminal(Composite parent) { + Assert.isNotNull(parent); + boolean wasDisposed = true; + TerminalState oldState = fState; + fState = TerminalState.CLOSED; + if (fClipboard != null && !fClipboard.isDisposed()) { + // terminal was not disposed (DnD) + wasDisposed = false; + fClipboard.dispose(); + fPollingTextCanvasModel.stopPolling(); + } + if (fWndParent != null && !fWndParent.isDisposed()) { + // terminal widget gets a new parent (DnD) + fWndParent.dispose(); + } + setupControls(parent); + setCommandInputField(fCommandInputField); + setupListeners(); + if (fUseCommonPrefs && wasDisposed) { + updatePreferences(); + onTerminalFontChanged(); + TerminalPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); + JFaceResources.getFontRegistry().addListener(fFontListener); + } + setupHelp(fWndParent, TerminalPlugin.HELP_VIEW); + + if (!wasDisposed) { + fState = oldState; + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#updatePreferences() + */ + private void updatePreferences() { + int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_BUFFERLINES, 0, null); + boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_INVERT_COLORS, false, null); + setBufferLineLimit(bufferLineLimit); + setInvertedColors(invert); + } + + private void onTerminalFontChanged() { + // set the font for all + setFont(ITerminalConstants.FONT_DEFINITION); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String) + */ + @Override + public void setFont(String fontName) { + Font font=JFaceResources.getFont(fontName); + getCtlText().setFont(font); + if(fCommandInputField!=null) { + fCommandInputField.setFont(font); + } + // Tell the TerminalControl singleton that the font has changed. + fCtlText.updateFont(fontName); + getTerminalText().fontChanged(); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(org.eclipse.swt.graphics.Font) + */ + @Override + @Deprecated + public void setFont(Font font) { + getCtlText().setFont(font); + if(fCommandInputField!=null) { + fCommandInputField.setFont(font); + } + + // Tell the TerminalControl singleton that the font has changed. + fCtlText.onFontChange(); + getTerminalText().fontChanged(); + } + @Override + public Font getFont() { + return getCtlText().getFont(); + } + @Override + public Control getControl() { + return fCtlText; + } + @Override + public Control getRootControl() { + return fWndParent; + } + protected void setupControls(Composite parent) { + fWndParent=new Composite(parent,SWT.NONE); + GridLayout layout=new GridLayout(); + layout.marginWidth=0; layout.marginHeight=0; layout.verticalSpacing=0; + fWndParent.setLayout(layout); + + ITerminalTextDataSnapshot snapshot=fTerminalModel.makeSnapshot(); + // TODO how to get the initial size correctly! + snapshot.updateSnapshot(false); + fPollingTextCanvasModel=new PollingTextCanvasModel(snapshot); + fCtlText=new TextCanvas(fWndParent,fPollingTextCanvasModel,SWT.NONE,new TextLineRenderer(fCtlText,fPollingTextCanvasModel)); + + fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + fCtlText.addResizeHandler(new TextCanvas.ResizeListener() { + @Override + public void sizeChanged(int lines, int columns) { + fTerminalText.setDimensions(lines, columns); + } + }); + fCtlText.addMouseListener(new MouseAdapter() { + @Override + public void mouseUp(MouseEvent e) { + // update selection used by middle mouse button paste + if (e.button == 1 && getSelection().length() > 0) { + copy(DND.SELECTION_CLIPBOARD); + } + } + }); + + fDisplay = getCtlText().getDisplay(); + fClipboard = new Clipboard(fDisplay); + } + + protected void setupListeners() { + fKeyHandler = new TerminalKeyHandler(); + fFocusListener = new TerminalFocusListener(); + + getCtlText().addKeyListener(fKeyHandler); + getCtlText().addFocusListener(fFocusListener); + + } + + /** + * Setup all the help contexts for the controls. + */ + protected void setupHelp(Composite parent, String id) { + Control[] children = parent.getChildren(); + + for (int nIndex = 0; nIndex < children.length; nIndex++) { + if (children[nIndex] instanceof Composite) { + setupHelp((Composite) children[nIndex], id); + } + } + + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, id); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#displayTextInTerminal(java.lang.String) + */ + @Override + public void displayTextInTerminal(String text) { + writeToTerminal("\r\n"+text+"\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ + } + private void writeToTerminal(String text) { + try { + getRemoteToTerminalOutputStream().write(text.getBytes(fEncoding)); + } catch (UnsupportedEncodingException e) { + // should never happen! + e.printStackTrace(); + } catch (IOException e) { + // should never happen! + e.printStackTrace(); + } + } + + @Override + public OutputStream getRemoteToTerminalOutputStream() { + if(Logger.isLogEnabled()) { + return new LoggingOutputStream(fInputStream.getOutputStream()); + } else { + return fInputStream.getOutputStream(); + } + } + protected boolean isLogCharEnabled() { + return TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_CHAR); + } + + @Override + public OutputStream getOutputStream() { + if(getTerminalConnector()!=null) + return getTerminalConnector().getTerminalToRemoteStream(); + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setMsg(java.lang.String) + */ + @Override + public void setMsg(String msg) { + fMsg = msg; + } + + public String getMsg() { + return fMsg; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getCtlText() + */ + protected TextCanvas getCtlText() { + return fCtlText; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getTerminalText() + */ + public VT100Emulator getTerminalText() { + return fTerminalText; + } + protected class TerminalFocusListener implements FocusListener { + private IContextActivation terminalContextActivation = null; + private IContextActivation editContextActivation = null; + + protected TerminalFocusListener() { + super(); + } + + @Override + @SuppressWarnings("cast") + public void focusGained(FocusEvent event) { + // Disable all keyboard accelerators (e.g., Control-B) so the Terminal view + // can see every keystroke. Without this, Emacs, vi, and Bash are unusable + // in the Terminal view. + if (getState() == TerminalState.CONNECTED) + captureKeyEvents(true); + + IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class); + editContextActivation = contextService.activateContext("org.eclipse.tm.terminal.EditContext"); //$NON-NLS-1$ + } + + @Override + @SuppressWarnings("cast") + public void focusLost(FocusEvent event) { + // Enable all keybindings. + captureKeyEvents(false); + + // Restore the command context to its previous value. + + IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class); + contextService.deactivateContext(editContextActivation); + } + + @SuppressWarnings("cast") + protected void captureKeyEvents(boolean capture) { + IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); + IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class); + + boolean enableKeyFilter = !capture; + if (bindingService.isKeyFilterEnabled() != enableKeyFilter) + bindingService.setKeyFilterEnabled(enableKeyFilter); + + if (capture && terminalContextActivation == null) { + // The above code fails to cause Eclipse to disable menu-activation + // accelerators (e.g., Alt-F for the File menu), so we set the command + // context to be the Terminal view's command context. This enables us to + // override menu-activation accelerators with no-op commands in our + // plugin.xml file, which enables the Terminal view to see absolutely _all_ + // key-presses. + terminalContextActivation = contextService.activateContext("org.eclipse.tm.terminal.TerminalContext"); //$NON-NLS-1$ + + } else if (!capture && terminalContextActivation != null) { + contextService.deactivateContext(terminalContextActivation); + terminalContextActivation = null; + } + } + } + + protected class TerminalKeyHandler extends KeyAdapter { + @Override + public void keyPressed(KeyEvent event) { + //TODO next 2 lines are probably obsolete now + if (getState()==TerminalState.CONNECTING) + return; + + //TODO we should no longer handle copy & paste specially. + //Instead, we should have Ctrl+Shift always go to local since there is no escape sequence for this. + //On Mac, Command+Anything already goes always to local. + //Note that this decision means that Command will NOT be Meta in Emacs on a Remote. + int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); + if (editActionAccelerators.isCopyAction(accelerator)) { + copy(); + return; + } + if (editActionAccelerators.isPasteAction(accelerator)) { + paste(); + return; + } + + // We set the event.doit to false to prevent any further processing of this + // key event. The only reason this is here is because I was seeing the F10 + // key both send an escape sequence (due to this method) and switch focus + // to the Workbench File menu (forcing the user to click in the Terminal + // view again to continue entering text). This fixes that. + + event.doit = false; + + char character = event.character; + int modifierKeys = event.stateMask & SWT.MODIFIER_MASK; + boolean ctrlKeyPressed = (event.stateMask & SWT.CTRL) != 0; + boolean onlyCtrlKeyPressed = modifierKeys == SWT.CTRL; + boolean macCmdKeyPressed = (event.stateMask & SWT.COMMAND) != 0; + + // To fix SPR 110341, we consider the Alt key to be pressed only when the + // Control key is _not_ also pressed. This works around a bug in SWT where, + // on European keyboards, the AltGr key being pressed appears to us as Control + // + Alt being pressed simultaneously. + boolean altKeyPressed = (event.stateMask & SWT.ALT) != 0 && !ctrlKeyPressed; + + //if (!isConnected()) { + if (fState==TerminalState.CLOSED) { + // Pressing ENTER while not connected causes us to connect. + if (character == '\r' && isConnectOnEnterIfClosed()) { + connectTerminal(); + return; + } + + // Ignore all other keyboard input when not connected. + // Allow other key handlers (such as Ctrl+F1) do their work + event.doit = true; + return; + } + + // Manage the Del key + if (event.keyCode == 0x000007f) { + sendString("\u001b[3~"); //$NON-NLS-1$ + return; + } + + // TODO Linux tty is usually expecting a DEL (^?) character + // but this causes issues with some telnet servers and + // serial connections. Workaround: stty erase ^H + //if (event.keyCode == SWT.BS) { + // sendChar(SWT.DEL, altKeyPressed); + // return; + //} + + // If the event character is NUL ('\u0000'), then a special key was pressed + // (e.g., PageUp, PageDown, an arrow key, a function key, Shift, Alt, + // Control, etc.). The one exception is when the user presses Control-@, + // which sends a NUL character, in which case we must send the NUL to the + // remote endpoint. This is necessary so that Emacs will work correctly, + // because Control-@ (i.e., NUL) invokes Emacs' set-mark-command when Emacs + // is running on a terminal. When the user presses Control-@, the keyCode + // is 50. + // On a Mac, the Cmd key is always used for local commands. + + if (macCmdKeyPressed || (character == '\u0000' && event.keyCode != 50)) { + // A special key was pressed. Figure out which one it was and send the + // appropriate ANSI escape sequence. + // + // IMPORTANT: Control will not enter this method for these special keys + // unless certain tags are present in the plugin.xml file + // for the Terminal view. Do not delete those tags. + + String escSeq = null; + boolean anyModifierPressed = modifierKeys != 0; + boolean onlyMacCmdKeyPressed = modifierKeys == SWT.COMMAND; + + switch (event.keyCode) { + case 0x1000001: // Up arrow. + if (!anyModifierPressed) + escSeq = fApplicationCursorKeys ? "\u001bOA" : "\u001b[A"; //$NON-NLS-1$ //$NON-NLS-2$ + break; + + case 0x1000002: // Down arrow. + if (!anyModifierPressed) + escSeq = fApplicationCursorKeys ? "\u001bOB" : "\u001b[B"; //$NON-NLS-1$ //$NON-NLS-2$ + break; + + case 0x1000003: // Left arrow. + if (onlyCtrlKeyPressed) { + escSeq = "\u001b[1;5D"; //$NON-NLS-1$ + } else if (!anyModifierPressed) { + escSeq = fApplicationCursorKeys ? "\u001bOD" : "\u001b[D"; //$NON-NLS-1$ //$NON-NLS-2$ + } else if (onlyMacCmdKeyPressed) { + // Cmd-Left is "Home" on the Mac + escSeq = fApplicationCursorKeys ? "\u001bOH" : "\u001b[H"; //$NON-NLS-1$ //$NON-NLS-2$ + } + break; + + case 0x1000004: // Right arrow. + if (onlyCtrlKeyPressed) { + escSeq = "\u001b[1;5C"; //$NON-NLS-1$ + } else if (!anyModifierPressed) { + escSeq = fApplicationCursorKeys ? "\u001bOC" : "\u001b[C"; //$NON-NLS-1$ //$NON-NLS-2$ + } else if (onlyMacCmdKeyPressed) { + // Cmd-Right is "End" on the Mac + escSeq = fApplicationCursorKeys ? "\u001bOF" : "\u001b[F"; //$NON-NLS-1$ //$NON-NLS-2$ + } + break; + + case 0x1000005: // PgUp key. + if (!anyModifierPressed) + escSeq = "\u001b[5~"; //$NON-NLS-1$ + break; + + case 0x1000006: // PgDn key. + if (!anyModifierPressed) + escSeq = "\u001b[6~"; //$NON-NLS-1$ + break; + + case 0x1000007: // Home key. + if (!anyModifierPressed) + escSeq = fApplicationCursorKeys ? "\u001bOH" : "\u001b[H"; //$NON-NLS-1$ //$NON-NLS-2$ + break; + + case 0x1000008: // End key. + if (!anyModifierPressed) + escSeq = fApplicationCursorKeys ? "\u001bOF" : "\u001b[F"; //$NON-NLS-1$ //$NON-NLS-2$ + break; + + case 0x1000009: // Insert. + if (!anyModifierPressed) + escSeq = "\u001b[2~"; //$NON-NLS-1$ + break; + + case 0x100000a: // F1 key. + if (!anyModifierPressed) + escSeq = "\u001bOP"; //$NON-NLS-1$ + break; + + case 0x100000b: // F2 key. + if (!anyModifierPressed) + escSeq = "\u001bOQ"; //$NON-NLS-1$ + break; + + case 0x100000c: // F3 key. + if (!anyModifierPressed) + escSeq = "\u001bOR"; //$NON-NLS-1$ + break; + + case 0x100000d: // F4 key. + if (!anyModifierPressed) + escSeq = "\u001bOS"; //$NON-NLS-1$ + break; + + case 0x100000e: // F5 key. + if (!anyModifierPressed) + escSeq = "\u001b[15~"; //$NON-NLS-1$ + break; + + case 0x100000f: // F6 key. + if (!anyModifierPressed) + escSeq = "\u001b[17~"; //$NON-NLS-1$ + break; + + case 0x1000010: // F7 key. + if (!anyModifierPressed) + escSeq = "\u001b[18~"; //$NON-NLS-1$ + break; + + case 0x1000011: // F8 key. + if (!anyModifierPressed) + escSeq = "\u001b[19~"; //$NON-NLS-1$ + break; + + case 0x1000012: // F9 key. + if (!anyModifierPressed) + escSeq = "\u001b[20~"; //$NON-NLS-1$ + break; + + case 0x1000013: // F10 key. + if (!anyModifierPressed) + escSeq = "\u001b[21~"; //$NON-NLS-1$ + break; + + case 0x1000014: // F11 key. + if (!anyModifierPressed) + escSeq = "\u001b[23~"; //$NON-NLS-1$ + break; + + case 0x1000015: // F12 key. + if (!anyModifierPressed) + escSeq = "\u001b[24~"; //$NON-NLS-1$ + break; + + default: + // Ignore other special keys. Control flows through this case when + // the user presses SHIFT, CONTROL, ALT, and any other key not + // handled by the above cases. + break; + } + + if (escSeq == null) { + // Any unmapped key should be handled locally by Eclipse + event.doit = true; + processKeyBinding(event, accelerator); + } else + sendString(escSeq); + + // It's ok to return here, because we never locally echo special keys. + + return; + } + + Logger.log("stateMask = " + event.stateMask); //$NON-NLS-1$ + + if (onlyCtrlKeyPressed) { + switch (character) { + case ' ': + // Send a NUL character -- many terminal emulators send NUL when + // Control-Space is pressed. This is used to set the mark in Emacs. + character = '\u0000'; + break; + case '/': + // Ctrl+/ is undo in emacs + character = '\u001f'; + break; + } + } + + //TODO: At this point, Ctrl+M sends the same as Ctrl+Shift+M . + //This is undesired. Fixing this here might make the special Ctrl+Shift+C + //handling unnecessary further up. + sendChar(character, altKeyPressed); + + // Now decide if we should locally echo the character we just sent. We do + // _not_ locally echo the character if any of these conditions are true: + // + // o This is a serial connection. + // + // o This is a TCP connection (i.e., m_telnetConnection is not null) and + // the remote endpoint is not a TELNET server. + // + // o The ALT (or META) key is pressed. + // + // o The character is any of the first 32 ISO Latin-1 characters except + // Control-I or Control-M. + // + // o The character is the DELETE character. + + if (getTerminalConnector() == null + || getTerminalConnector().isLocalEcho() == false || altKeyPressed + || (character >= '\u0001' && character < '\t') + || (character > '\t' && character < '\r') + || (character > '\r' && character <= '\u001f') + || character == '\u007f') { + // No local echoing. + return; + } + + // Locally echo the character. + + StringBuffer charBuffer = new StringBuffer(); + charBuffer.append(character); + + // If the character is a carriage return, we locally echo it as a CR + LF + // combination. + + if (character == '\r') + charBuffer.append('\n'); + + writeToTerminal(charBuffer.toString()); + } + + /* + * Process given event as Eclipse key binding. + */ + @SuppressWarnings("cast") + private void processKeyBinding(KeyEvent event, int accelerator) { + IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); + KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator); + Binding binding = bindingService.getPerfectMatch(KeySequence.getInstance(keyStroke)); + if (binding != null) { + ParameterizedCommand cmd = binding.getParameterizedCommand(); + if (cmd != null) { + IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class); + Event cmdEvent = new Event(); + cmdEvent.type = SWT.KeyDown; + cmdEvent.display = event.display; + cmdEvent.widget = event.widget; + cmdEvent.character = event.character; + cmdEvent.keyCode = event.keyCode; + ////Bug - KeyEvent.keyLocation was introduced in Eclipse 3.6 + ////Use reflection for now to remain backward compatible down to Eclipse 3.4 + //cmdEvent.keyLocation = event.keyLocation; + try { + Field f1 = event.getClass().getField("keyLocation"); //$NON-NLS-1$ + Field f2 = cmdEvent.getClass().getField("keyLocation"); //$NON-NLS-1$ + f2.set(cmdEvent, f1.get(event)); + } catch(NoSuchFieldException nsfe) { + /* ignore, this is Eclipse 3.5 or earlier */ + } catch(Throwable t) { + t.printStackTrace(); + } + cmdEvent.stateMask = event.stateMask; + event.doit = false; + try { + handlerService.executeCommand(cmd, cmdEvent); + } catch (ExecutionException e) { + TerminalPlugin.getDefault().getLog().log( + new Status(IStatus.ERROR,TerminalPlugin.PLUGIN_ID,e.getLocalizedMessage(),e)); + } catch (Exception e) { + // ignore other exceptions from cmd execution + } + } + } + } + + } + + @Override + public void setTerminalTitle(String title) { + fTerminalListener.setTerminalTitle(title); + } + + + @Override + public TerminalState getState() { + return fState; + } + + + @Override + public void setState(TerminalState state) { + fState=state; + fTerminalListener.setState(state); + // enable the (blinking) cursor if the terminal is connected + runAsyncInDisplayThread(new Runnable() { + @Override + public void run() { + if(fCtlText!=null && !fCtlText.isDisposed()) { + if (isConnected()) { + fCtlText.setCursorEnabled(true); + } else { + fCtlText.setCursorEnabled(false); + // Stop capturing all key events + fFocusListener.captureKeyEvents(false); + } + } + } + }); + } + /** + * @param runnable run in display thread + */ + private void runAsyncInDisplayThread(Runnable runnable) { + if(Display.findDisplay(Thread.currentThread())!=null) + runnable.run(); + else if(PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getDisplay() != null && !PlatformUI.getWorkbench().getDisplay().isDisposed()) + PlatformUI.getWorkbench().getDisplay().asyncExec(runnable); + // else should not happen and we ignore it... + } + + @Override + public String getSettingsSummary() { + if(getTerminalConnector()!=null) + return getTerminalConnector().getSettingsSummary(); + return ""; //$NON-NLS-1$ + } + + @Override + public void setConnector(ITerminalConnector connector) { + fConnector=connector; + + } + @Override + public ICommandInputField getCommandInputField() { + return fCommandInputField; + } + + @Override + public void setCommandInputField(ICommandInputField inputField) { + if(fCommandInputField!=null) + fCommandInputField.dispose(); + fCommandInputField=inputField; + if(fCommandInputField!=null) + fCommandInputField.createControl(fWndParent, this); + if(fWndParent.isVisible()) + fWndParent.layout(true); + } + + @Override + public int getBufferLineLimit() { + return fTerminalModel.getMaxHeight(); + } + + @Override + public void setBufferLineLimit(int bufferLineLimit) { + if(bufferLineLimit<=0) + return; + synchronized (fTerminalModel) { + if(fTerminalModel.getHeight()>bufferLineLimit) + fTerminalModel.setDimensions(bufferLineLimit, fTerminalModel.getWidth()); + fTerminalModel.setMaxHeight(bufferLineLimit); + } + } + + @Override + public boolean isScrollLock() { + return fCtlText.isScrollLock(); + } + + @Override + public void setScrollLock(boolean on) { + fCtlText.setScrollLock(on); + } + + @Override + public void setInvertedColors(boolean invert) { + fCtlText.setInvertedColors(invert); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setConnectOnEnterIfClosed(boolean) + */ + @Override + public final void setConnectOnEnterIfClosed(boolean on) { + connectOnEnterIfClosed = on; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnectOnEnterIfClosed() + */ + @Override + public final boolean isConnectOnEnterIfClosed() { + return connectOnEnterIfClosed; + } + + @Override + public void setVT100LineWrapping(boolean enable) { + getTerminalText().setVT100LineWrapping(enable); + } + + @Override + public boolean isVT100LineWrapping() { + return getTerminalText().isVT100LineWrapping(); + } + + @Override + public void enableApplicationCursorKeys(boolean enable) { + fApplicationCursorKeys = enable; + } + + @Override + public void addMouseListener(ITerminalMouseListener listener) { + getCtlText().addTerminalMouseListener(listener); + } + + @Override + public void removeMouseListener(ITerminalMouseListener listener) { + getCtlText().removeTerminalMouseListener(listener); + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java new file mode 100644 index 00000000000..184b63b4e14 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.model; + +import org.eclipse.tm.terminal.model.ITerminalTextData; + +public interface ISnapshotChanges { + + /** + * @param line might bigger than the number of lines.... + */ + void markLineChanged(int line); + + /** + * Marks all lines in the range as changed + * @param line >=0 + * @param n might be out of range + */ + void markLinesChanged(int line, int n); + + /** + * Marks all lines within the scrolling region + * changed and resets the scrolling information + */ + void convertScrollingIntoChanges(); + + /** + * @return true if something has changed + */ + boolean hasChanged(); + + /** + * @param startLine + * @param size + * @param shift + */ + void scroll(int startLine, int size, int shift); + + /** + * Mark all lines changed + * @param height if no window is set this is the number of + * lines that are marked as changed + */ + void setAllChanged(int height); + + int getFirstChangedLine(); + + int getLastChangedLine(); + + int getScrollWindowStartLine(); + + int getScrollWindowSize(); + + int getScrollWindowShift(); + + boolean hasLineChanged(int line); + + void markDimensionsChanged(); + boolean hasDimensionsChanged(); + void markCursorChanged(); + + /** + * @return true if the terminal data has changed + */ + boolean hasTerminalChanged(); + /** + * mark the terminal as changed + */ + void setTerminalChanged(); + + + void copyChangedLines(ITerminalTextData dest, ITerminalTextData source); + + /** + * @param startLine -1 means follow the end of the data + * @param size number of lines to follow + */ + void setInterestWindow(int startLine, int size); + int getInterestWindowStartLine(); + int getInterestWindowSize(); + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java new file mode 100644 index 00000000000..222cc8858cf --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java @@ -0,0 +1,408 @@ +/******************************************************************************* + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.model; + +import org.eclipse.tm.terminal.model.ITerminalTextData; + + +/** + * Collects the changes of the {@link ITerminalTextData} + * + * @noextend This class is not intended to be subclassed by clients. + * @noreference This class is not intended to be referenced by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * This class used to be package-protected. It is public only for access by the Unit Tests. + */ +public class SnapshotChanges implements ISnapshotChanges { + /** + * The first line changed + */ + private int fFirstChangedLine; + /** + * The last line changed + */ + private int fLastChangedLine; + private int fScrollWindowStartLine; + private int fScrollWindowSize; + private int fScrollWindowShift; + /** + * true, if scrolling should not tracked anymore + */ + private boolean fScrollDontTrack; + /** + * The lines that need to be copied + * into the snapshot (lines that have + * not changed don't have to be copied) + */ + private boolean[] fChangedLines; + + private int fInterestWindowSize; + private int fInterestWindowStartLine; + private boolean fDimensionsChanged; + private boolean fTerminalHasChanged; + private boolean fCursorHasChanged; + + public SnapshotChanges(int nLines) { + setChangedLinesLength(nLines); + fFirstChangedLine=Integer.MAX_VALUE; + fLastChangedLine=-1; + } + public SnapshotChanges(int windowStart, int windowSize) { + setChangedLinesLength(windowStart+windowSize); + fFirstChangedLine=Integer.MAX_VALUE; + fLastChangedLine=-1; + fInterestWindowStartLine=windowStart; + fInterestWindowSize=windowSize; + + } + /** + * This is used in asserts to throw an {@link RuntimeException}. + * This is useful for tests. + * @return never -- throws an exception + */ + private boolean throwRuntimeException() { + throw new RuntimeException(); + } + /** + * @param line + * @param size + * @return true if the range overlaps with the interest window + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + * It used to be package protected, and it is public only for Unit Tests. + */ + public boolean isInInterestWindow(int line, int size) { + if(fInterestWindowSize<=0) + return true; + if(line+size<=fInterestWindowStartLine || line>=fInterestWindowStartLine+fInterestWindowSize) + return false; + return true; + } + /** + * @param line + * @return true if the line is within the interest window + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + * It used to be package protected, and it is public only for Unit Tests. + */ + public boolean isInInterestWindow(int line) { + if(fInterestWindowSize<=0) + return true; + if(line=fInterestWindowStartLine+fInterestWindowSize) + return false; + return true; + } + /** + * @param line + * @return the line within the window + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + * It used to be package protected, and it is public only for Unit Tests. + */ + public int fitLineToWindow(int line) { + if(fInterestWindowSize<=0) + return line; + if(linebefore {@link #fitLineToWindow(int)} has been called! + * @param size + * @return the adjusted size. + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + * It used to be package protected, and it is public only for Unit Tests. + * + *

            Note:

            {@link #fitLineToWindow(int)} has to be called on the line to + * move the window correctly! + */ + public int fitSizeToWindow(int line, int size) { + if(fInterestWindowSize<=0) + return size; + if(linefInterestWindowStartLine+fInterestWindowSize) + size=fInterestWindowStartLine+fInterestWindowSize-line; + return size; + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLineChanged(int) + */ + public void markLineChanged(int line) { + if(!isInInterestWindow(line)) + return; + line=fitLineToWindow(line); + if(linefLastChangedLine) + fLastChangedLine=line; + // in case the terminal got resized we expand + // don't remember the changed line because + // there is nothing to copy + if(line0 || fScrollWindowShift!=0 ||fDimensionsChanged || fCursorHasChanged) + return true; + return false; + } + public void markDimensionsChanged() { + fDimensionsChanged=true; + } + public boolean hasDimensionsChanged() { + return fDimensionsChanged; + } + public boolean hasTerminalChanged() { + return fTerminalHasChanged; + } + public void setTerminalChanged() { + fTerminalHasChanged=true; + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#scroll(int, int, int) + */ + public void scroll(int startLine, int size, int shift) { + size=fitSizeToWindow(startLine, size); + startLine=fitLineToWindow(startLine); + // let's track only negative shifts + if(fScrollDontTrack) { + // we are in a state where we cannot track scrolling + // so let's simply mark the scrolled lines as changed + markLinesChanged(startLine, size); + } else if(shift>=0) { + // we cannot handle positive scroll + // forget about clever caching of scroll events + doNotTrackScrollingAnymore(); + // mark all lines inside the scroll region as changed + markLinesChanged(startLine, size); + } else { + // we have already scrolled + if(fScrollWindowShift<0) { + // we have already scrolled + if(fScrollWindowStartLine==startLine && fScrollWindowSize==size) { + // we are scrolling the same region again? + fScrollWindowShift+=shift; + scrollChangesLinesWithNegativeShift(startLine,size,shift); + } else { + // mark all lines in the old scroll region as changed + doNotTrackScrollingAnymore(); + // mark all lines changed, because + markLinesChanged(startLine, size); + } + } else { + // first scroll in this change -- we just notify it + fScrollWindowStartLine=startLine; + fScrollWindowSize=size; + fScrollWindowShift=shift; + scrollChangesLinesWithNegativeShift(startLine,size,shift); + } + } + } + /** + * Some incompatible scrolling occurred. We cannot do the + * scroll optimization anymore... + */ + private void doNotTrackScrollingAnymore() { + if(fScrollWindowSize>0) { + // convert the current scrolling into changes + markLinesChanged(fScrollWindowStartLine, fScrollWindowSize); + fScrollWindowStartLine=0; + fScrollWindowSize=0; + fScrollWindowShift=0; + } + // don't be clever on scrolling anymore + fScrollDontTrack=true; + } + /** + * Scrolls the changed lines data + * + * @param line + * @param n + * @param shift must be negative! + */ + private void scrollChangesLinesWithNegativeShift(int line, int n, int shift) { + assert shift <0 || throwRuntimeException(); + // scroll the region + // don't run out of bounds! + int m=Math.min(line+n+shift,getChangedLineLength()+shift); + for (int i = line; i < m; i++) { + setChangedLine(i, hasLineChanged(i-shift)); + // move the first changed line up. + // We don't have to move the maximum down, + // because with a shift scroll, the max is moved + // my the next loop in this method + if(i0) { + int shift=oldStartLine-startLine; + if(shift==0) { + if(size>oldSize) { + // add lines to the end + markLinesChanged(oldStartLine+oldSize, size-oldSize); + } + // else no lines within the window have changed + + } else if(Math.abs(shift)TerminalTextData.toMultiLineText(this,0,200)) + * @param term the terminal + * @param start start line to show + * @param len number of lines to show -- negative numbers means show all + * @return a string representation of the content + */ + static public String toMultiLineText(ITerminalTextDataReadOnly term, int start, int len) { + if(len<0) + len=term.getHeight(); + StringBuffer buff=new StringBuffer(); + int width=term.getWidth(); + int n=Math.min(len,term.getHeight()-start); + for (int line = start; line < n; line++) { + if(line>0) + buff.append("\n"); //$NON-NLS-1$ + for (int column = 0; column < width; column++) { + buff.append(term.getChar(line, column)); + } + } + // get rid of the empty space at the end of the lines + //return buff.toString().replaceAll("\000+", ""); //$NON-NLS-1$//$NON-NLS-2$ + // + int i = buff.length() - 1; + while (i >= 0 && buff.charAt(i) == '\000') { + i--; + } + buff.setLength(i + 1); + return buff.toString(); + // + } + + /** + * Show the first 100 lines + * see {@link #toMultiLineText(ITerminalTextDataReadOnly, int, int)} + * @param term A read-only terminal model + * @return a string representation of the terminal + */ + static public String toMultiLineText(ITerminalTextDataReadOnly term) { + return toMultiLineText(term, 0, 100); + } + + public TerminalTextData() { + this(new TerminalTextDataFastScroll()); + +// this(new TerminalTextDataStore()); + } + public TerminalTextData(ITerminalTextData data) { + fData=data; + } + public int getWidth() { + return fData.getWidth(); + } + public int getHeight() { + // no need for an extra variable + return fData.getHeight(); + } + public void setDimensions(int height, int width) { + int h=getHeight(); + int w=getWidth(); + if(w==width && h==height) + return; + fData.setDimensions(height, width); + sendDimensionsChanged(h, w, height, width); + } + private void sendDimensionsChanged(int oldHeight, int oldWidth, int newHeight, int newWidth) { + // determine what has changed + if(oldWidth==newWidth) { + if(oldHeight list=new ArrayList(); + list.addAll(Arrays.asList(fSnapshots)); + list.remove(snapshot); + fSnapshots=list.toArray(new TerminalTextDataSnapshot[list.size()]); + } + + public ITerminalTextDataSnapshot makeSnapshot() { + // poor mans approach to modify the array + TerminalTextDataSnapshot snapshot=new TerminalTextDataSnapshot(this); + snapshot.markDimensionsChanged(); + List list=new ArrayList(); + list.addAll(Arrays.asList(fSnapshots)); + list.add(snapshot); + fSnapshots=list.toArray(new TerminalTextDataSnapshot[list.size()]); + return snapshot; + } + public void addLine() { + int oldHeight=getHeight(); + fData.addLine(); + // was is an append or a scroll? + int newHeight=getHeight(); + if(newHeight>oldHeight) { + //the line was appended + sendLinesChangedToSnapshot(oldHeight, 1); + int width=getWidth(); + sendDimensionsChanged(oldHeight, width, newHeight, width); + + } else { + // the line was scrolled + sendScrolledToSnapshots(0, oldHeight, -1); + } + + } + + public void copy(ITerminalTextData source) { + fData.copy(source); + fCursorLine=source.getCursorLine(); + fCursorColumn=source.getCursorColumn(); + } + + public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { + fData.copyLine(source, sourceLine, destLine); + } + public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { + fData.copyRange(source, sourceStartLine, destStartLine, length); + } + public char[] getChars(int line) { + return fData.getChars(line); + } + public Style[] getStyles(int line) { + return fData.getStyles(line); + } + public int getMaxHeight() { + return fData.getMaxHeight(); + } + public void setMaxHeight(int height) { + fData.setMaxHeight(height); + } + public void cleanLine(int line) { + fData.cleanLine(line); + sendLineChangedToSnapshots(line); + } + public int getCursorColumn() { + return fCursorColumn; + } + public int getCursorLine() { + return fCursorLine; + } + public void setCursorColumn(int column) { + fCursorColumn=column; + sendCursorChanged(); + } + public void setCursorLine(int line) { + fCursorLine=line; + sendCursorChanged(); + } + + public boolean isWrappedLine(int line) { + return fData.isWrappedLine(line); + } + + public void setWrappedLine(int line) { + fData.setWrappedLine(line); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java new file mode 100644 index 00000000000..92021783376 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java @@ -0,0 +1,259 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.model; + +import org.eclipse.tm.terminal.model.ITerminalTextData; +import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; +import org.eclipse.tm.terminal.model.LineSegment; +import org.eclipse.tm.terminal.model.Style; + +/** + * This class is optimized for scrolling the entire {@link #getHeight()}. + * The scrolling is done by moving an offset into the data and using + * the modulo operator. + * + */ +public class TerminalTextDataFastScroll implements ITerminalTextData { + + final ITerminalTextData fData; + private int fHeight; + private int fMaxHeight; + /** + * The offset into the array. + */ + int fOffset; + public TerminalTextDataFastScroll(ITerminalTextData data,int maxHeight) { + fMaxHeight=maxHeight; + fData=data; + fData.setDimensions(maxHeight, fData.getWidth()); + if(maxHeight>2) + assert shiftOffset(-2) || throwRuntimeException(); + } + public TerminalTextDataFastScroll(int maxHeight) { + this(new TerminalTextDataStore(),maxHeight); + } + public TerminalTextDataFastScroll() { + this(new TerminalTextDataStore(),1); + } + /** + * This is used in asserts to throw an {@link RuntimeException}. + * This is useful for tests. + * @return never -- throws an exception + */ + private boolean throwRuntimeException() { + throw new RuntimeException(); + } + /** + * + * @param line + * @return the actual line number in {@link #fData} + */ + int getPositionOfLine(int line) { + return (line+fOffset)%fMaxHeight; + } + /** + * Moves offset by delta. This does not move the data! + * @param delta + */ + void moveOffset(int delta) { + assert Math.abs(delta)=0 && destStartLine+length<=fHeight) || throwRuntimeException(); + for (int i = 0; i < length; i++) { + fData.copyLine(source, i+sourceStartLine, getPositionOfLine(i+destStartLine)); + } + } + + public char getChar(int line, int column) { + assert (line>=0 && line=0 && line=0 && line=0 && line=0 && line=0 && startLine+size<=fHeight) || throwRuntimeException(); + if(shift>=fMaxHeight || -shift>=fMaxHeight) { + cleanLines(startLine, fMaxHeight-startLine); + return; + } + if(size==fHeight) { + // This is the case this class is optimized for! + moveOffset(-shift); + // we only have to clean the lines that appear by the move + if(shift<0) { + cleanLines(Math.max(startLine, startLine+size+shift),Math.min(-shift, getHeight()-startLine)); + } else { + cleanLines(startLine, Math.min(shift, getHeight()-startLine)); + } + } else { + // we have to copy the lines. + if(shift<0) { + // move the region up + // shift is negative!! + for (int i = startLine; i < startLine+size+shift; i++) { + fData.copyLine(fData, getPositionOfLine(i-shift), getPositionOfLine(i)); + } + // then clean the opened lines + cleanLines(Math.max(0, startLine+size+shift),Math.min(-shift, getHeight()-startLine)); + } else { + for (int i = startLine+size-1; i >=startLine && i-shift>=0; i--) { + fData.copyLine(fData, getPositionOfLine(i-shift), getPositionOfLine(i)); + } + cleanLines(startLine, Math.min(shift, getHeight()-startLine)); + } + } + } + + public void setChar(int line, int column, char c, Style style) { + assert (line>=0 && line=0 && line=0 && line=0 || throwRuntimeException(); + assert width>=0 || throwRuntimeException(); + if(height > fMaxHeight) + setMaxHeight(height); + fHeight=height; + if(width!=fData.getWidth()) + fData.setDimensions(fMaxHeight, width); + } + + public void setMaxHeight(int maxHeight) { + assert maxHeight>=fHeight || throwRuntimeException(); + // move everything to offset0 + int start=getPositionOfLine(0); + if(start!=0) { + // invent a more efficient algorithm.... + ITerminalTextData buffer=new TerminalTextDataStore(); + // create a buffer with the expected height + buffer.setDimensions(maxHeight, getWidth()); + int n=Math.min(fMaxHeight-start,maxHeight); + // copy the first part + buffer.copyRange(fData, start, 0, n); + // copy the second part + if(n=0 && line=0 && linenot threadsafe! + */ +class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot { + /** + * The changes of the current snapshot relative to the + * previous snapshot + */ + volatile ISnapshotChanges fCurrentChanges; + /** + * Keeps track of changes that happened since the current + * snapshot has been made. + */ + ISnapshotChanges fFutureChanges; + /** + * Is used as lock and is the reference to the terminal we take snapshots from. + */ + final TerminalTextData fTerminal; + /** + * A snapshot copy of of fTerminal + */ + // snapshot does not need internal synchronisation + final TerminalTextDataWindow fSnapshot; + // this variable is synchronized on fTerminal! + private SnapshotOutOfDateListener[] fListener=new SnapshotOutOfDateListener[0]; + // this variable is synchronized on fTerminal! + private boolean fListenersNeedNotify; + private int fInterestWindowSize; + private int fInterestWindowStartLine; + + TerminalTextDataSnapshot(TerminalTextData terminal) { + fSnapshot = new TerminalTextDataWindow(); + fTerminal = terminal; + fCurrentChanges = new SnapshotChanges(fTerminal.getHeight()); + fCurrentChanges.setTerminalChanged(); + fFutureChanges = new SnapshotChanges(fTerminal.getHeight()); + fFutureChanges.markLinesChanged(0, fTerminal.getHeight()); + fListenersNeedNotify=true; + fInterestWindowSize=-1; + } + /** + * This is used in asserts to throw an {@link RuntimeException}. + * This is useful for tests. + * @return never -- throws an exception + */ + private boolean throwRuntimeException() { + throw new RuntimeException(); + } + + public void detach() { + fTerminal.removeSnapshot(this); + } + + public boolean isOutOfDate() { + // this is called from fTerminal, therefore we lock on fTerminal + synchronized (fTerminal) { + return fFutureChanges.hasChanged(); + } + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#snapshot() + */ + public void updateSnapshot(boolean detectScrolling) { + // make sure terminal does not change while we make the snapshot + synchronized (fTerminal) { + // let's make the future changes current + fCurrentChanges=fFutureChanges; + fFutureChanges=new SnapshotChanges(fTerminal.getHeight()); + fFutureChanges.setInterestWindow(fInterestWindowStartLine, fInterestWindowSize); + // and update the snapshot + if(fSnapshot.getHeight()!=fTerminal.getHeight()||fSnapshot.getWidth()!=fTerminal.getWidth()) { + if(fInterestWindowSize==-1) + fSnapshot.setWindow(0, fTerminal.getHeight()); + // if the dimensions have changed, we need a full copy + fSnapshot.copy(fTerminal); + // and we mark all lines as changed + fCurrentChanges.setAllChanged(fTerminal.getHeight()); + } else { + // first we do the scroll on the copy + int start=fCurrentChanges.getScrollWindowStartLine(); + int lines=Math.min(fCurrentChanges.getScrollWindowSize(), fSnapshot.getHeight()-start); + fSnapshot.scroll(start, lines, fCurrentChanges.getScrollWindowShift()); + // and then create the snapshot of the changed lines + fCurrentChanges.copyChangedLines(fSnapshot, fTerminal); + } + fListenersNeedNotify=true; + fSnapshot.setCursorLine(fTerminal.getCursorLine()); + fSnapshot.setCursorColumn(fTerminal.getCursorColumn()); + } + if(!detectScrolling) { + // let's pretend there was no scrolling and + // convert the scrolling into line changes + fCurrentChanges.convertScrollingIntoChanges(); + } + } + + public char getChar(int line, int column) { + return fSnapshot.getChar(line, column); + } + + public int getHeight() { + return fSnapshot.getHeight(); + } + + public LineSegment[] getLineSegments(int line, int column, int len) { + return fSnapshot.getLineSegments(line, column, len); + } + + public Style getStyle(int line, int column) { + return fSnapshot.getStyle(line, column); + } + + public int getWidth() { + return fSnapshot.getWidth(); + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getFirstChangedLine() + */ + public int getFirstChangedLine() { + return fCurrentChanges.getFirstChangedLine(); + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getLastChangedLine() + */ + public int getLastChangedLine() { + return fCurrentChanges.getLastChangedLine(); + } + + public boolean hasLineChanged(int line) { + return fCurrentChanges.hasLineChanged(line); + } + public boolean hasDimensionsChanged() { + return fCurrentChanges.hasDimensionsChanged(); + } + public boolean hasTerminalChanged() { + return fCurrentChanges.hasTerminalChanged(); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeY() + */ + public int getScrollWindowStartLine() { + return fCurrentChanges.getScrollWindowStartLine(); + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeN() + */ + public int getScrollWindowSize() { + return fCurrentChanges.getScrollWindowSize(); + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeShift() + */ + public int getScrollWindowShift() { + return fCurrentChanges.getScrollWindowShift(); + } + + /** + * Announces a change in line line + * @param line + */ + void markLineChanged(int line) { + // threading + fFutureChanges.markLineChanged(line); + fFutureChanges.setTerminalChanged(); + notifyListers(); + } + /** + * Announces a change of n lines beginning with line line + * @param line + * @param n + */ + void markLinesChanged(int line,int n) { + fFutureChanges.markLinesChanged(line,n); + fFutureChanges.setTerminalChanged(); + notifyListers(); + } + + void markDimensionsChanged() { + fFutureChanges.markDimensionsChanged(); + fFutureChanges.setTerminalChanged(); + notifyListers(); + } + void markCursorChanged() { + fFutureChanges.markCursorChanged(); + fFutureChanges.setTerminalChanged(); + notifyListers(); + } + + /** + * @param startLine + * @param size + * @param shift + */ + void scroll(int startLine, int size, int shift) { + fFutureChanges.scroll(startLine,size,shift); + fFutureChanges.setTerminalChanged(); + notifyListers(); + } + /** + * Notifies listeners about the change + */ + private void notifyListers() { + // this code has to be called from a block synchronized on fTerminal + synchronized (fTerminal) { + if(fListenersNeedNotify) { + for (int i = 0; i < fListener.length; i++) { + fListener[i].snapshotOutOfDate(this); + } + fListenersNeedNotify=false; + } + } + } + public ITerminalTextDataSnapshot makeSnapshot() { + return fSnapshot.makeSnapshot(); + } + + synchronized public void addListener(SnapshotOutOfDateListener listener) { + List list=new ArrayList(); + list.addAll(Arrays.asList(fListener)); + list.add(listener); + fListener=list.toArray(new SnapshotOutOfDateListener[list.size()]); + } + + synchronized public void removeListener(SnapshotOutOfDateListener listener) { + List list=new ArrayList(); + list.addAll(Arrays.asList(fListener)); + list.remove(listener); + fListener=list.toArray(new SnapshotOutOfDateListener[list.size()]); + } + public String toString() { + return fSnapshot.toString(); + } + + + public int getInterestWindowSize() { + return fInterestWindowSize; + } + + + public int getInterestWindowStartLine() { + return fInterestWindowStartLine; + } + + public void setInterestWindow(int startLine, int size) { + assert startLine>=0 || throwRuntimeException(); + assert size>=0 || throwRuntimeException(); + fInterestWindowStartLine=startLine; + fInterestWindowSize=size; + fSnapshot.setWindow(startLine, size); + fFutureChanges.setInterestWindow(startLine, size); + notifyListers(); + } + + + public char[] getChars(int line) { + return fSnapshot.getChars(line); + } + + + public Style[] getStyles(int line) { + return fSnapshot.getStyles(line); + } + public int getCursorColumn() { + return fSnapshot.getCursorColumn(); + } + public int getCursorLine() { + return fSnapshot.getCursorLine(); + } + public ITerminalTextData getTerminalTextData() { + return fTerminal; + } + public boolean isWrappedLine(int line) { + return fSnapshot.isWrappedLine(line); + } +} + + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java new file mode 100644 index 00000000000..9817087942b --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java @@ -0,0 +1,344 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.model; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; + +import org.eclipse.tm.terminal.model.ITerminalTextData; +import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; +import org.eclipse.tm.terminal.model.LineSegment; +import org.eclipse.tm.terminal.model.Style; + +/** + * This class is thread safe. + * + */ +public class TerminalTextDataStore implements ITerminalTextData { + private char[][] fChars; + private Style[][] fStyle; + private int fWidth; + private int fHeight; + private int fMaxHeight; + private int fCursorColumn; + private int fCursorLine; + final private BitSet fWrappedLines = new BitSet(); + + public TerminalTextDataStore() { + fChars=new char[0][]; + fStyle=new Style[0][]; + fWidth=0; + } + /** + * This is used in asserts to throw an {@link RuntimeException}. + * This is useful for tests. + * @return never -- throws an exception + */ + private boolean throwRuntimeException() { + throw new RuntimeException(); + } + + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getWidth() + */ + public int getWidth() { + return fWidth; + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getHeight() + */ + public int getHeight() { + return fHeight; + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setDimensions(int, int) + */ + public void setDimensions(int height, int width) { + assert height>=0 || throwRuntimeException(); + assert width>=0 || throwRuntimeException(); + // just extend the region + if(height>fChars.length) { + int h=4*height/3; + if(fMaxHeight>0 && h>fMaxHeight) + h=fMaxHeight; + fStyle=(Style[][]) resizeArray(fStyle, height); + fChars=(char[][]) resizeArray(fChars, height); + } + // clean the new lines + if(height>fHeight) { + for (int i = fHeight; i < height; i++) { + cleanLine(i); + } + } + // set dimensions after successful resize! + fWidth=width; + fHeight=height; + } + /** + * Reallocates an array with a new size, and copies the contents of the old + * array to the new array. + * + * @param origArray the old array, to be reallocated. + * @param newSize the new array size. + * @return A new array with the same contents (chopped off if needed or filled with 0 or null). + */ + private Object resizeArray(Object origArray, int newSize) { + int oldSize = Array.getLength(origArray); + if(oldSize==newSize) + return origArray; + Class elementType = origArray.getClass().getComponentType(); + Object newArray = Array.newInstance(elementType, newSize); + int preserveLength = Math.min(oldSize, newSize); + if (preserveLength > 0) + System.arraycopy(origArray, 0, newArray, 0, preserveLength); + return newArray; + } + + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getLineSegments(int, int, int) + */ + public LineSegment[] getLineSegments(int line, int column, int len) { + // get the styles and chars for this line + Style[] styles=fStyle[line]; + char[] chars=fChars[line]; + int col=column; + int n=column+len; + + // expand the line if needed.... + if(styles==null) + styles=new Style[n]; + else if(styles.length segments=new ArrayList(); + for (int i = column; i < n; i++) { + if(styles[i]!=style) { + segments.add(new LineSegment(col,new String(chars,col,i-col),style)); + style=styles[i]; + col=i; + } + } + if(col < n) { + segments.add(new LineSegment(col,new String(chars,col,n-col),style)); + } + return segments.toArray(new LineSegment[segments.size()]); + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getChar(int, int) + */ + public char getChar(int line, int column) { + assert column=fChars[line].length) + return 0; + return fChars[line][column]; + } + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getStyle(int, int) + */ + public Style getStyle(int line, int column) { + assert column=fStyle[line].length) + return null; + return fStyle[line][column]; + } + + void ensureLineLength(int iLine, int length) { + if(length>fWidth) + throw new RuntimeException(); + if(fChars[iLine]==null) { + fChars[iLine]=new char[length]; + } else if(fChars[iLine].length=startLine && i-shift>=0; i--) { + fChars[i]=fChars[i-shift]; + fStyle[i]=fStyle[i-shift]; + fWrappedLines.set(i, fWrappedLines.get(i-shift)); + } + cleanLines(startLine, Math.min(shift, getHeight()-startLine)); + } + } + /** + * Replaces the lines with new empty data + * @param line + * @param len + */ + private void cleanLines(int line, int len) { + for (int i = line; i < line+len; i++) { + cleanLine(i); + } + } + + /* + * @return a text representation of the object. + * Lines are separated by '\n'. No style information is returned. + */ + public String toString() { + StringBuffer buff=new StringBuffer(); + for (int line = 0; line < getHeight(); line++) { + if(line>0) + buff.append("\n"); //$NON-NLS-1$ + for (int column = 0; column < fWidth; column++) { + buff.append(getChar(line, column)); + } + } + return buff.toString(); + } + + + public ITerminalTextDataSnapshot makeSnapshot() { + throw new UnsupportedOperationException(); + } + + public void addLine() { + if(fMaxHeight>0 && getHeight()char=='\000' and style=null. + * + */ +public class TerminalTextDataWindow implements ITerminalTextData { + final ITerminalTextData fData; + int fWindowStartLine; + int fWindowSize; + int fHeight; + int fMaxHeight; + public TerminalTextDataWindow(ITerminalTextData data) { + fData=data; + } + public TerminalTextDataWindow() { + this(new TerminalTextDataStore()); + } + /** + * This is used in asserts to throw an {@link RuntimeException}. + * This is useful for tests. + * @return never -- throws an exception + */ + private boolean throwRuntimeException() { + throw new RuntimeException(); + } + /** + * @param line + * @return true if the line is within the window + */ + boolean isInWindow(int line) { + return line>=fWindowStartLine && line0 && getHeight()0) + fData.copyRange(source, fWindowStartLine, 0, n); + } + public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { + int n=length; + int dStart=destStartLine-fWindowStartLine; + int sStart=sourceStartLine; + // if start outside our range, cut the length to copy + if(dStart<0) { + n+=dStart; + sStart-=dStart; + dStart=0; + } + // do not exceed the window size + n=Math.min(n,fWindowSize); + if(n>0) + fData.copyRange(source, sStart, dStart, n); + + } + public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { + if(isInWindow(destLine)) + fData.copyLine(source, sourceLine, destLine-fWindowStartLine); + } + public void scroll(int startLine, int size, int shift) { + assert (startLine>=0 && startLine+size<=fHeight) || throwRuntimeException(); + int n=size; + int start=startLine-fWindowStartLine; + // if start outside our range, cut the length to copy + if(start<0) { + n+=start; + start=0; + } + n=Math.min(n,fWindowSize-start); + // do not exceed the window size + if(n>0) + fData.scroll(start, n, shift); + } + public void setChar(int line, int column, char c, Style style) { + if(!isInWindow(line)) + return; + fData.setChar(line-fWindowStartLine, column, c, style); + } + public void setChars(int line, int column, char[] chars, int start, int len, Style style) { + if(!isInWindow(line)) + return; + fData.setChars(line-fWindowStartLine, column, chars, start, len, style); + } + public void setChars(int line, int column, char[] chars, Style style) { + if(!isInWindow(line)) + return; + fData.setChars(line-fWindowStartLine, column, chars, style); + } + public void setDimensions(int height, int width) { + assert height>=0 || throwRuntimeException(); + fData.setDimensions(fWindowSize, width); + fHeight=height; + } + public void setMaxHeight(int height) { + fMaxHeight=height; + } + public void setWindow(int startLine, int size) { + fWindowStartLine=startLine; + fWindowSize=size; + fData.setDimensions(fWindowSize, getWidth()); + } + public int getWindowStartLine() { + return fWindowStartLine; + } + public int getWindowSize() { + return fWindowSize; + } + public void setHeight(int height) { + fHeight = height; + } + public void cleanLine(int line) { + if(isInWindow(line)) + fData.cleanLine(line-fWindowStartLine); + } + public int getCursorColumn() { + return fData.getCursorColumn(); + } + public int getCursorLine() { + return fData.getCursorLine(); + } + public void setCursorColumn(int column) { + fData.setCursorColumn(column); + } + public void setCursorLine(int line) { + fData.setCursorLine(line); + } + public boolean isWrappedLine(int line) { + if(isInWindow(line)) + return fData.isWrappedLine(line - fWindowStartLine); + return false; + } + public void setWrappedLine(int line) { + if(isInWindow(line)) + fData.setWrappedLine(line - fWindowStartLine); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java new file mode 100644 index 00000000000..907c79d095f --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +/** + * Constants for Terminal Preferences. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ITerminalConstants { + + 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_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$ + public static final int DEFAULT_BUFFERLINES = 1000; + public static final boolean DEFAULT_INVERT_COLORS = false; + + public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$ + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java new file mode 100644 index 00000000000..920d5e4cf6e --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + * Martin Oberhuber (Wind River) - [436612] Restore Eclipse 3.4 compatibility + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; + +/** + * Terminal Preference Initializer. + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * @noreference This class is not intended to be referenced by clients. + */ +public class TerminalPreferenceInitializer extends AbstractPreferenceInitializer { + + public TerminalPreferenceInitializer() { + } + + public void initializeDefaultPreferences() { + //DefaultScope.INSTANCE was added in Eclipse 3.7 + IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); + defaultPrefs.putBoolean(ITerminalConstants.PREF_INVERT_COLORS, ITerminalConstants.DEFAULT_INVERT_COLORS); + defaultPrefs.putInt(ITerminalConstants.PREF_BUFFERLINES, ITerminalConstants.DEFAULT_BUFFERLINES); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java new file mode 100644 index 00000000000..89a2c8f8df1 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * Terminal Preference Page. + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * @noreference This class is not intended to be referenced by clients. + */ +public class TerminalPreferencePage extends FieldEditorPreferencePage implements + IWorkbenchPreferencePage { + protected BooleanFieldEditor fInvertColors; + + protected IntegerFieldEditor fEditorBufferSize; + + public TerminalPreferencePage() { + super(GRID); + } + protected void createFieldEditors() { + setupPage(); + } + public void init(IWorkbench workbench) { + // do nothing + } + protected void setupPage() { + setupData(); + setupEditors(); + } + protected void setupData() { + TerminalPlugin plugin; + IPreferenceStore preferenceStore; + + plugin = TerminalPlugin.getDefault(); + preferenceStore = plugin.getPreferenceStore(); + setPreferenceStore(preferenceStore); + } + protected void setupEditors() { + fInvertColors = new BooleanFieldEditor( + ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS, + getFieldEditorParent()); + fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, + TerminalMessages.BUFFERLINES, getFieldEditorParent()); + + fEditorBufferSize.setValidRange(0, Integer.MAX_VALUE); + + addField(fInvertColors); + addField(fEditorBufferSize); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java new file mode 100644 index 00000000000..501f45fb430 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2013, 2015 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Control; + +/** + * Abstract settings page providing a common implementation of the listener handling. + */ +public abstract class AbstractSettingsPage implements ISettingsPage, IMessageProvider { + // A message associated with the control. + private String message = null; + + // The message type of the associated message. + private int messageType = IMessageProvider.NONE; + + // Reference to the listener + private final ListenerList listeners = new ListenerList(); + + // Flag to control the control decorations + private boolean hasDecoration = false; + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#addListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener) + */ + public void addListener(Listener listener) { + Assert.isNotNull(listener); + listeners.add(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#removeListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener) + */ + public void removeListener(Listener listener) { + Assert.isNotNull(listener); + listeners.remove(listener); + } + + /** + * Fire the listeners for the given control. + * + * @param control The control or null. + */ + public void fireListeners(Control control) { + Object[] list = listeners.getListeners(); + for (int i = 0; i < list.length; i++) { + Object l = list[i]; + if (!(l instanceof Listener)) continue; + ((Listener)l).onSettingsPageChanged(control); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IMessageProvider#getMessage() + */ + public final String getMessage() { + return message; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IMessageProvider#getMessageType() + */ + public final int getMessageType() { + return messageType; + } + + /** + * Set the message and the message type. + * + * @param message The message or null. + * @param messageType The type of the message (NONE, INFORMATION, WARNING, ERROR). + */ + public final void setMessage(String message, int messageType) { + this.message = message; + this.messageType = messageType; + } + + /** + * Sets if or if not the settings panel widgets will have control decorations + * or not. The method has effect only if called before {@link #createControl(org.eclipse.swt.widgets.Composite)}. + * + * @param value True if the panel widgets have control decorations, false otherwise. + */ + public final void setHasControlDecoration(boolean value) { + this.hasDecoration = value; + } + + /** + * Returns if or if not the settings panel widgets will have control + * decorations or not. + * + * @return True if the panel widgets have control decorations, false otherwise. + */ + protected final boolean hasControlDecoration() { + return hasDecoration; + } + + /** + * Creates a new instance of a {@link ControlDecoration} object associated with + * the given control. The method is called after the control has been created. + * + * @param control The control. Must not be null. + * @return The control decoration object instance. + */ + protected final ControlDecoration createControlDecoration(Control control) { + Assert.isNotNull(control); + if (!hasDecoration) return null; + ControlDecoration controlDecoration = new ControlDecoration(control, getControlDecorationPosition()); + controlDecoration.setShowOnlyOnFocus(false); + control.setData("controlDecoration", controlDecoration); //$NON-NLS-1$ + return controlDecoration; + } + + /** + * Returns the control decoration position. The default is + * {@link SWT#TOP} | {@link SWT#LEFT}. + * + * @return The control position. + */ + protected int getControlDecorationPosition() { + return SWT.TOP | SWT.LEFT; + } + + /** + * Updates the control decoration of the given control to represent the given message + * and message type. If the message is null or the message type is + * {@link IMessageProvider#NONE} no decoration will be shown. + * + * @param control The control. Must not be null. + * @param message The message. + * @param messageType The message type. + */ + protected final void updateControlDecoration(Control control, String message, int messageType) { + Assert.isNotNull(control); + + ControlDecoration controlDecoration = (ControlDecoration)control.getData("controlDecoration"); //$NON-NLS-1$ + if (controlDecoration != null) { + // The description is the same as the message + controlDecoration.setDescriptionText(message); + + // The icon depends on the message type + FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); + + // Determine the id of the decoration to show + String decorationId = FieldDecorationRegistry.DEC_INFORMATION; + if (messageType == IMessageProvider.ERROR) { + decorationId = FieldDecorationRegistry.DEC_ERROR; + } else if (messageType == IMessageProvider.WARNING) { + decorationId = FieldDecorationRegistry.DEC_WARNING; + } + + // Get the field decoration + FieldDecoration fieldDeco = registry.getFieldDecoration(decorationId); + if (fieldDeco != null) { + controlDecoration.setImage(fieldDeco.getImage()); + } + + if (message == null || messageType == IMessageProvider.NONE) { + controlDecoration.hide(); + } + else { + controlDecoration.show(); + } + } + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java new file mode 100644 index 00000000000..a00d71d24d1 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * @author Michael Scharf + * + * TODO: Michael Scharf: provide a long description of a wizard + * TODO: Michael Scharf: allow multiple pages to be generated + *

            + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will + * work or that it will remain the same. Please do not use this API without + * consulting with the Target Management team. + *

            + */ +public interface ISettingsPage { + + public interface Listener { + + /** + * Invoked by settings page controls to signal that the settings page + * changed and page container may update their state. + * + * @param control The control which triggered the event or null + */ + public void onSettingsPageChanged(Control control); + } + + /** + * Create a page to be shown in a dialog or wizard to setup the connection. + * @param parent + */ + void createControl(Composite parent); + + /** + * Called before the page is shown. Loads the state from the {@link ITerminalConnector}. + */ + void loadSettings(); + + /** + * Called when the OK button is pressed. + */ + void saveSettings(); + + /** + * @return true if the + */ + boolean validateSettings(); + + /** + * Adds the given listener. + *

            + * Has not effect if the same listener is already registered. + * + * @param listener The listener. Must not be null. + */ + public void addListener(Listener listener); + + /** + * Removes the given listener. + *

            + * Has no effect if the same listener was not registered. + * + * @param listener The listener. Must not be null. + */ + public void removeListener(Listener listener); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java new file mode 100644 index 00000000000..b7dd8592922 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +/** + * A simple interface to a store to persist the state of a connection. + * + * @author Michael Scharf + *

            + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will + * work or that it will remain the same. Please do not use this API without + * consulting with the Target Management team. + *

            + */ +public interface ISettingsStore { + /** + * @param key alpha numeric key, may contain dots (.) + * @return value + */ + String get(String key); + + /** + * @param key alpha numeric key, may contain dots (.) + * @param defaultValue + * @return the value or the default + */ + String get(String key, String defaultValue); + + /** + * Save a string value + * @param key alpha numeric key, may contain dots (.) + * @param value + */ + void put(String key, String value); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java new file mode 100644 index 00000000000..242726e785e --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend + * Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +import java.io.OutputStream; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl; + +/** + * A contributed connection type to manage a single connection. + * + * Implementations of this class are contributed through the + * org.eclipse.tm.terminal.control.connectors extension point. This + * class gives access to the static markup of a terminal connector extension as + * well as providing the lifecycle management for the dynamically loaded + * {@link TerminalConnectorImpl} instance, which performs the actual + * communications. This pattern allows for lazy initialization, bundle + * activation and class loading of the actual {@link TerminalConnectorImpl} + * instance. + * + * Clients can get terminal connector instances from the + * {@link TerminalConnectorExtension} class, or from + * {@link ITerminalViewControl#getTerminalConnector()} when running inside an + * active terminal widget. + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + * + * @author Michael Scharf + *

            + * EXPERIMENTAL. This class or interface has been added + * as part of a work in progress. There is no guarantee that this API + * will work or that it will remain the same. Please do not use this API + * without consulting with the Target Management team. + *

            + */ +public interface ITerminalConnector extends IAdaptable { + /** + * @return an ID of this connector. The id from the plugin.xml. + * @since org.eclipse.tm.terminal 2.0 + */ + String getId(); + + /** + * @return null the name (as specified in the plugin.xml) + * @since org.eclipse.tm.terminal 2.0 + */ + String getName(); + + /** + * @return True if the connector is not visible in user + * selections. + * @since org.eclipse.tm.terminal 3.0.1 + */ + boolean isHidden(); + + /** + * @return true if the {@link TerminalConnectorImpl} has been initialized. + * If there was an initialization error, {@link #getInitializationErrorMessage()} + * returns the error message. + * @since org.eclipse.tm.terminal 2.0 + */ + boolean isInitialized(); + + /** + * This method initializes the connector if it is not initialized! + * If the connector was initialized successfully, null is + * returned. Otherwise an error message describing the problem is returned. + * @return null or a localized error message. + * @since org.eclipse.tm.terminal 2.0 + */ + String getInitializationErrorMessage(); + + /** + * Connect using the current state of the settings. + * @param control Used to inform the UI about state changes and messages from the connection. + */ + void connect(ITerminalControl control); + + /** + * Disconnect if connected. Else do nothing. + */ + void disconnect(); + + /** + * @return true if a local echo is needed. + * TODO:Michael Scharf: this should be handed within the connection.... + */ + boolean isLocalEcho(); + + /** + * Notify the remote site that the size of the terminal has changed. + * @param newWidth + * @param newHeight + */ + void setTerminalSize(int newWidth, int newHeight); + + /** + * @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 + * terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()} + * @since org.eclipse.tm.terminal 2.0 + */ + OutputStream getTerminalToRemoteStream(); + + /** + * Load the state of this connection. Is typically called before + * {@link #connect(ITerminalControl)}. + * + * @param store a string based data store. Short keys like "foo" can be used to + * store the state of the connection. + */ + void load(ISettingsStore store); + + /** + * When the view or dialog containing the terminal is closed, + * the state of the connection is saved into the settings store store + * @param store + */ + void save(ISettingsStore store); + + /** + * Set or reset the settings store to the default values. + */ + void setDefaultSettings(); + + /** + * @return A string that represents the settings of the connection. This representation + * may be shown in the status line of the terminal view. + */ + String getSettingsSummary(); + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java new file mode 100644 index 00000000000..79b3cb829e5 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use + * Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend + * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +/** + * Represents the terminal view as seen by a terminal connection. + *

            + * EXPERIMENTAL. This class or interface has been added as part + * of a work in progress. There is no guarantee that this API will work or that + * it will remain the same. Please do not use this API without consulting with + * the Target Management team. + *

            + * + * @author Michael Scharf + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface ITerminalControl { + + /** + * @return the current state of the connection + */ + TerminalState getState(); + + /** + * @param state + */ + void setState(TerminalState state); + + /** + * Setup the terminal control within the given parent composite. + * + * @param parent The parent composite. Must not be null. + */ + void setupTerminal(Composite parent); + + /** + * A shell to show dialogs. + * @return the shell in which the terminal is shown. + */ + Shell getShell(); + + /** + * Set the encoding that the Terminal uses to decode bytes from the + * Terminal-to-remote-Stream into Unicode Characters used in Java; or, to + * encode Characters typed by the user into bytes sent over the wire to the + * remote. + * + * By default, the local Platform Default Encoding is used. Also note that + * the encoding must not be applied in case the terminal stream is processed + * by some data transfer protocol which requires binary data. + * + * Validity of the encoding set here is not checked. Since some encodings do + * not cover the entire range of Unicode characters, it can happen that a + * particular Unicode String typed in by the user can not be encoded into a + * byte Stream with the encoding specified. and UnsupportedEncodingException + * will be thrown in this case at the time the String is about to be + * processed. + * + * The concrete encoding to use can either be specified manually by a user, + * by means of a dialog, or a connector can try to obtain it automatically + * from the remote side e.g. by evaluating an environment variable such as + * LANG on UNIX systems. + * + * @since org.eclipse.tm.terminal 2.0 + */ + void setEncoding(String encoding) throws UnsupportedEncodingException; + + /** + * Return the current encoding. That's interesting when the previous + * setEncoding() call failed and the fallback default encoding should be + * queried, such that e.g. a combobox with encodings to choose can be + * properly initialized. + * + * @return the current Encoding of the Terminal. + * @since org.eclipse.tm.terminal 2.0 + */ + String getEncoding(); + + /** + * Show a text in the terminal. If puts newlines at the beginning and the + * end. + * + * @param text TODO: Michael Scharf: Is this really needed? + */ + void displayTextInTerminal(String text); + + /** + * @return a stream used to write to the terminal. Any bytes written to this + * stream appear in the terminal or are interpreted by the emulator as + * control sequences. The stream in the opposite direction, terminal + * to remote is in {@link ITerminalConnector#getTerminalToRemoteStream()}. + */ + OutputStream getRemoteToTerminalOutputStream(); + + /** + * Set the title of the terminal view. + * @param title + */ + void setTerminalTitle(String title); + + /** + * Show an error message during connect. + * @param msg + * TODO: Michael Scharf: Should be replaced by a better error notification mechanism! + */ + void setMsg(String msg); + + /** + * Sets if or if not the terminal view control should try to reconnect + * the terminal connection if the user hits ENTER in a closed terminal. + *

            + * Reconnect on ENTER if terminal is closed is enabled by default. + * + * @param on True to enable the reconnect, false to disable it. + */ + void setConnectOnEnterIfClosed(boolean on); + + /** + * Returns if or if not the terminal view control should try to reconnect + * the terminal connection if the user hits ENTER in a closed terminal. + * + * @return True the reconnect is enabled, false if disabled. + */ + boolean isConnectOnEnterIfClosed(); + + /** + * Enables VT100 line wrapping mode (default is off). + * This corresponds to the VT100 'eat_newline_glitch' terminal capability. + * If enabled, writing to the rightmost column does not cause + * an immediate wrap to the next line. Instead the line wrap occurs on the + * next output character. + * + * @param enable whether to enable or disable VT100 line wrapping mode + */ + void setVT100LineWrapping(boolean enable); + + /** + * @return whether VT100 line wrapping mode is enabled + */ + boolean isVT100LineWrapping(); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java new file mode 100644 index 00000000000..437935f3959 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2005, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Fran Litterio (Wind River) - initial API and implementation + * Ted Williams (Wind River) - refactored into org.eclipse namespace + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +import java.io.FileOutputStream; +import java.io.PrintStream; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; + +/** + * A simple logger class. Every method in this class is static, so they can be + * called from both class and instance methods. To use this class, write code + * like this: + *

            + * + *

            + * Logger.log("something has happened");
            + * Logger.log("counter is " + counter);
            + * 
            + * + * @author Fran Litterio + *

            + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will + * work or that it will remain the same. Please do not use this API without + * consulting with the Target Management team. + *

            + */ +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_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$ + + private static PrintStream logStream; + + static { + // Any of the three known debugging options turns on the creation of the log file + boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG) + || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR) + || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND); + + // Log only if tracing is enabled + if (createLogFile && TerminalPlugin.getDefault() != null) { + IPath logFile = Platform.getStateLocation(TerminalPlugin.getDefault().getBundle()); + if (logFile != null && logFile.toFile().isDirectory()) { + logFile = logFile.append("tmterminal.log"); //$NON-NLS-1$ + try { + logStream = new PrintStream(new FileOutputStream(logFile.toFile(), true)); + } catch (Exception ex) { + logStream = System.err; + logStream.println("Exception when opening log file -- logging to stderr!"); //$NON-NLS-1$ + ex.printStackTrace(logStream); + } + } + } + } + + /** + * Encodes a String such that non-printable control characters are + * converted into user-readable escape sequences for logging. + * @param message String to encode + * @return encoded String + */ + public static final String encode(String message) { + boolean encoded = false; + StringBuffer buf = new StringBuffer(message.length()+32); + for (int i=0; i=' ' && 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) { + return buf.toString(); + } + return message; + } + + /** + * Checks if logging is enabled. + * @return true if logging is enabled. + */ + public static final boolean isLogEnabled() { + return (logStream!=null); + } + + /** + * Logs the specified message. Do not append a newline to parameter + * message. This method does that for you. + * + * @param message A String containing the message to log. + */ + public static final void log(String message) { + if (logStream != null) { + // Read my own stack to get the class name, method name, and line + // number of + // where this method was called. + + StackTraceElement caller = new Throwable().getStackTrace()[1]; + int lineNumber = caller.getLineNumber(); + String className = caller.getClassName(); + String methodName = caller.getMethodName(); + className = className.substring(className.lastIndexOf('.') + 1); + + logStream.println(className + "." + methodName + ":" + lineNumber + ": " + message); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + logStream.flush(); + } + } + + /** + * Writes a stack trace for an exception to both Standard Error and to the + * log file. + */ + public static final void logException(Exception ex) { + // log in eclipse error log + if (TerminalPlugin.getDefault() != null) { + TerminalPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex)); + } else { + ex.printStackTrace(); + } + // Additional Tracing for debug purposes: + // Read my own stack to get the class name, method name, and line number + // of where this method was called + if(logStream!=null) { + StackTraceElement caller = new Throwable().getStackTrace()[1]; + int lineNumber = caller.getLineNumber(); + String className = caller.getClassName(); + String methodName = caller.getMethodName(); + className = className.substring(className.lastIndexOf('.') + 1); + + PrintStream tmpStream = System.err; + + if (logStream != null) { + tmpStream = logStream; + } + + tmpStream.println(className + + "." + methodName + ":" + lineNumber + ": " + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + "Caught exception: " + ex); //$NON-NLS-1$ + ex.printStackTrace(tmpStream); + } + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java new file mode 100644 index 00000000000..e86f157f6c1 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +/** + * A settings store implementation doing nothing. + */ +public class NullSettingsStore implements ISettingsStore { + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String) + */ + @Override + public String get(String key) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String, java.lang.String) + */ + @Override + public String get(String key, String defaultValue) { + return defaultValue; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#put(java.lang.String, java.lang.String) + */ + @Override + public void put(String key, String value) { + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java new file mode 100644 index 00000000000..fe494bc0da7 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.RegistryFactory; +import org.eclipse.tm.internal.terminal.connector.TerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl; + +/** + * A factory to get {@link ITerminalConnector} instances. + * + * @author Michael Scharf + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * + *

            + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the Target Management + * team. + *

            + */ +public class TerminalConnectorExtension { + static private ITerminalConnector makeConnector(final IConfigurationElement config) { + String id = config.getAttribute("id"); //$NON-NLS-1$ + if(id==null || id.length()==0) + id=config.getAttribute("class"); //$NON-NLS-1$ + String name= config.getAttribute("name"); //$NON-NLS-1$ + if(name==null || name.length()==0) { + name=id; + } + String hidden = config.getAttribute("hidden"); //$NON-NLS-1$ + boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false; + TerminalConnector.Factory factory=new TerminalConnector.Factory(){ + public TerminalConnectorImpl makeConnector() throws Exception { + return (TerminalConnectorImpl)config.createExecutableExtension("class"); //$NON-NLS-1$ + }}; + return new TerminalConnector(factory,id,name, isHidden); + } + + /** + * Return a specific terminal connector for a given connector id. The + * terminal connector is not yet instantiated to any real connection. + * + * @param id the id of the terminal connector in the + * org.eclipse.tm.terminal.control.connectors + * extension point + * @return a new ITerminalConnector with id or null if there + * is no extension with that id. + * @since org.eclipse.tm.terminal 2.0 + */ + public static ITerminalConnector makeTerminalConnector(String id) { + IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$ + for (int i = 0; i < config.length; i++) { + if(id.equals(config[i].getAttribute("id"))) { //$NON-NLS-1$ + return makeConnector(config[i]); + } + } + return null; + } + /** + * Return a list of available terminal connectors (connection types). + * + * The terminal connectors returned are not yet instantiated to any real + * connection. Each terminal connector can connect to one remote system at a + * time. + * + * @return a new list of {@link ITerminalConnector} instances defined in the + * org.eclipse.tm.terminal.control.connectors + * extension point + * @since org.eclipse.tm.terminal 2.0 return value is ITerminalConnector[] + */ + public static ITerminalConnector[] makeTerminalConnectors() { + IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$ + List result=new ArrayList(); + for (int i = 0; i < config.length; i++) { + result.add(makeConnector(config[i])); + } + return result.toArray(new ITerminalConnector[result.size()]); + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java new file mode 100644 index 00000000000..14051ae2114 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Michael Scharf (Wind River) - [262996] get rid of TerminalState.OPENED + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api; + +/** + * Represent the sate of a terminal connection. + * In java 1.5 this would be an enum. + * @author Michael Scharf + * + *

            + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will + * work or that it will remain the same. Please do not use this API without + * consulting with the Target Management team. + *

            + */ +public class TerminalState { + /** + * The terminal is not connected. + */ + public final static TerminalState CLOSED=new TerminalState("CLOSED"); //$NON-NLS-1$ + + /** + * The terminal is about to connect. + */ + public final static TerminalState CONNECTING=new TerminalState("CONNECTING..."); //$NON-NLS-1$ + + /** + * The terminal is connected. + */ + public final static TerminalState CONNECTED=new TerminalState("CONNECTED"); //$NON-NLS-1$ + + private final String fState; + + public TerminalState(String state) { + fState = state; + } + + public String toString() { + return fState; + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java new file mode 100644 index 00000000000..a358335508e --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2008, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.provisional.api.provider; + +import java.io.OutputStream; + +import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; + +/** + * Abstract base class for all terminal connector implementations to be + * registered via the org.eclipse.tm.terminal.control.connectors + * extension point. + * + * @since org.eclipse.tm.terminal 2.0 + */ +public abstract class TerminalConnectorImpl { + + /** + * The TerminalControl associated with this connector. + * Required for advertising state changes when needed. + */ + protected ITerminalControl fControl; + + /** + * Initialize this connector. This is called once after the constructor, in + * order to perform any required initializations such as loading required + * native libraries. Any work that may lead to runtime exceptions should be + * done in this method rather than in the constructor. + * + * @throws Exception when the connector fails to initialize (due to missing + * required libraries, for instance). + */ + public void initialize() throws Exception { + } + + /** + * Connect using the current state of the settings. + * + * This method is designed to be overridden by actual implementations, in + * order to open the streams required for communicating with the remote + * side. Extenders must call super.connect(control) as the + * first thing they are doing. + * + * @param control Used to inform the UI about state changes and messages + * from the connection. + */ + public void connect(ITerminalControl control) { + Logger.log("entered."); //$NON-NLS-1$ + fControl = control; + } + + /** + * Disconnect if connected. Else do nothing. Has to set the state of the + * {@link ITerminalControl} when finished disconnecting. + */ + public final void disconnect() { + Logger.log("entered."); //$NON-NLS-1$ + doDisconnect(); + fControl.setState(TerminalState.CLOSED); + } + + /** + * Disconnect if connected. Else do nothing. Clients should override to + * perform any extra work needed for disconnecting. + */ + protected void doDisconnect() { + // Do nothing by default + } + + /** + * @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 + * terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()} + */ + abstract public OutputStream getTerminalToRemoteStream(); + + /** + * @return A string that represents the settings of the connection. This representation + * may be shown in the status line of the terminal view. + */ + abstract public String getSettingsSummary(); + + /** + * Test if local echo is needed. The default implementation returns + * false. Override to modify this behavior. + * + * @return true if a local echo is needed. TODO:Michael Scharf: this should + * be handed within the connection.... + */ + public boolean isLocalEcho() { + return false; + } + + /** + * Set or reset the settings store to the default values. + */ + public void setDefaultSettings() { + // do nothing by default + } + + /** + * Load the state or settings of this connection. Is typically called before + * {@link #connect(ITerminalControl)}. + * + * Connectors that have nothing to configure do not need to implement this. + * Those terminals that do have configuration need to override this method + * to load settings. + * + * @param store a string based data store. Short keys like "foo" can be used + * to store the state of the connection. + */ + public void load(ISettingsStore store) { + // do nothing by default + } + + /** + * When the view or dialog containing the terminal is closed, the state of + * the connection is saved into the settings store store. + * + * Connectors that have no state or settings to persist do not need to + * override this. Others should override to persist their settings. + * + * @param store the store for persisting settings. + */ + public void save(ISettingsStore store) { + // do nothing by default + } + + /** + * Notify the remote site that the size of the terminal has changed. + * + * Concrete connectors should override this if they have the possibility to + * inform the remote about changed terminal size. + * + * @param newWidth the new width in characters. + * @param newHeight the new height in characters. + */ + public void setTerminalSize(int newWidth, int newHeight) { + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java new file mode 100644 index 00000000000..f57b8277b8d --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java @@ -0,0 +1,380 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1 + * Anton Leherbauer (Wind River) - [219589] Copy an entire line selection + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; +import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; + +abstract public class AbstractTextCanvasModel implements ITextCanvasModel { + protected List fListeners = new ArrayList(); + private int fCursorLine; + private int fCursorColumn; + private boolean fShowCursor; + private long fCursorTime; + private boolean fCursorIsEnabled; + private final ITerminalTextDataSnapshot fSnapshot; + private int fLines; + + private int fSelectionStartLine=-1; + private int fSeletionEndLine; + private int fSelectionStartCoumn; + private int fSelectionEndColumn; + private ITerminalTextDataSnapshot fSelectionSnapshot; + private String fCurrentSelection=""; //$NON-NLS-1$ + private final Point fSelectionAnchor=new Point(0,0); + /** + * do not update while update is running + */ + boolean fInUpdate; + private int fCols; + + public AbstractTextCanvasModel(ITerminalTextDataSnapshot snapshot) { + fSnapshot=snapshot; + fLines=fSnapshot.getHeight(); + } + public void addCellCanvasModelListener(ITextCanvasModelListener listener) { + fListeners.add(listener); + } + + public void removeCellCanvasModelListener(ITextCanvasModelListener listener) { + fListeners.remove(listener); + } + + protected void fireCellRangeChanged(int x, int y, int width, int height) { + for (Iterator iter = fListeners.iterator(); iter.hasNext();) { + ITextCanvasModelListener listener = iter.next(); + listener.rangeChanged(x, y, width, height); + } + } + protected void fireDimensionsChanged( int width,int height) { + for (Iterator iter = fListeners.iterator(); iter.hasNext();) { + ITextCanvasModelListener listener = iter.next(); + listener.dimensionsChanged(width,height); + } + + } + protected void fireTerminalDataChanged() { + for (Iterator iter = fListeners.iterator(); iter.hasNext();) { + ITextCanvasModelListener listener = iter.next(); + listener.terminalDataChanged(); + } + + } + + public ITerminalTextDataReadOnly getTerminalText() { + return fSnapshot; + } + protected ITerminalTextDataSnapshot getSnapshot() { + return fSnapshot; + } + protected void updateSnapshot() { + if(!fInUpdate && fSnapshot.isOutOfDate()) { + fInUpdate=true; + try { + fSnapshot.updateSnapshot(false); + if(fSnapshot.hasTerminalChanged()) + fireTerminalDataChanged(); + // TODO why does hasDimensionsChanged not work?????? + // if(fSnapshot.hasDimensionsChanged()) + // fireDimensionsChanged(); + if(fLines!=fSnapshot.getHeight() || fCols!=fSnapshot.getWidth()) { + fireDimensionsChanged(fSnapshot.getWidth(),fSnapshot.getHeight()); + fLines=fSnapshot.getHeight(); + fCols=fSnapshot.getWidth(); + } + int y=fSnapshot.getFirstChangedLine(); + // has any line changed? + if(y=getSnapshot().getHeight()) { + cursorLine=getSnapshot().getHeight()-1; + cursorColumn=getSnapshot().getWidth()-1; + } + // has the cursor moved? + if(fCursorLine!=cursorLine || fCursorColumn!=cursorColumn) { + // hide the old cursor! + fShowCursor=false; + // clean the previous cursor + // bug 206363: paint also the char to the left and right of the cursor - see also below + int col=fCursorColumn; + int width=2; + if(col>0) { + col--; + width++; + } + fireCellRangeChanged(col, fCursorLine, width, 1); + // the cursor is shown when it moves! + fShowCursor=true; + fCursorTime=System.currentTimeMillis(); + fCursorLine=cursorLine; + fCursorColumn=cursorColumn; + // and draw the new cursor + fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1); + } else { + long t=System.currentTimeMillis(); + // TODO make the cursor blink time customisable + if(t-fCursorTime>500) { + fShowCursor=!fShowCursor; + fCursorTime=t; + // on some windows machines, there is some left + // over when updating the cursor . + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=206363 + int col=fCursorColumn; + int width=2; + if(col>0) { + col--; + width++; + } + fireCellRangeChanged(col, fCursorLine, width, 1); + } + } + } + public void setVisibleRectangle(int startLine, int startCol, int height, int width) { + fSnapshot.setInterestWindow(Math.max(0,startLine), Math.max(1,height)); + update(); + } + protected void showCursor(boolean show) { + fShowCursor=true; + } + public void setCursorEnabled(boolean visible) { + fCursorTime=System.currentTimeMillis(); + fShowCursor=visible; + fCursorIsEnabled=visible; + fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1); + } + public boolean isCursorEnabled() { + return fCursorIsEnabled; + } + + public Point getSelectionEnd() { + if(fSelectionStartLine<0) + return null; + else + return new Point(fSelectionEndColumn, fSeletionEndLine); + } + + public Point getSelectionStart() { + if (fSelectionStartLine < 0) + return null; + else + return new Point(fSelectionStartCoumn,fSelectionStartLine); + } + public Point getSelectionAnchor() { + if(fSelectionStartLine<0) + return null; + return new Point(fSelectionAnchor.x,fSelectionAnchor.y); + } + public void setSelectionAnchor(Point anchor) { + fSelectionAnchor.x=anchor.x; + fSelectionAnchor.y=anchor.y; + } + + public void setSelection(int startLine, int endLine, int startColumn, int endColumn) { +// System.err.println(startLine+","+endLine+","+startColumn+","+endColumn); + doSetSelection(startLine, endLine, startColumn, endColumn); + fCurrentSelection=extractSelectedText(); + } + private void doSetSelection(int startLine, int endLine, int startColumn, int endColumn) { + assert(startLine<0 || startLine<=endLine); + if(startLine>=0) { + if(fSelectionSnapshot==null) { + fSelectionSnapshot=fSnapshot.getTerminalTextData().makeSnapshot(); + fSelectionSnapshot.updateSnapshot(true); + } + } else if(fSelectionSnapshot!=null) { + fSelectionSnapshot.detach(); + fSelectionSnapshot=null; + } + int oldStart=fSelectionStartLine; + int oldEnd=fSeletionEndLine; + fSelectionStartLine = startLine; + fSeletionEndLine = endLine; + fSelectionStartCoumn = startColumn; + fSelectionEndColumn = endColumn; + if(fSelectionSnapshot!=null) { + fSelectionSnapshot.setInterestWindow(0, fSelectionSnapshot.getHeight()); + } + int changedStart; + int changedEnd; + if(oldStart<0) { + changedStart=fSelectionStartLine; + changedEnd=fSeletionEndLine; + } else if(fSelectionStartLine<0) { + changedStart=oldStart; + changedEnd=oldEnd; + } else { + changedStart=Math.min(oldStart, fSelectionStartLine); + changedEnd=Math.max(oldEnd, fSeletionEndLine); + } + if(changedStart>=0) { + fireCellRangeChanged(0, changedStart, fSnapshot.getWidth(), changedEnd-changedStart+1); + } + } + + public boolean hasLineSelection(int line) { + if (fSelectionStartLine < 0) + return false; + else + return line >= fSelectionStartLine && line <= fSeletionEndLine; + } + + public String getSelectedText() { + return fCurrentSelection; + } + + // helper to sanitize text copied out of a snapshot + private static String scrubLine(String text) { + // get rid of the empty space at the end of the lines + // text=text.replaceAll("\000+$",""); //$NON-NLS-1$//$NON-NLS-2$ + // + int i = text.length() - 1; + while (i >= 0 && text.charAt(i) == '\000') { + i--; + } + text = text.substring(0, i + 1); + // + // null means space + return text.replace('\000', ' '); + } + + /** + * Calculates the currently selected text + * @return the currently selected text + */ + private String extractSelectedText() { + if(fSelectionStartLine<0 || fSelectionStartCoumn<0 || fSelectionSnapshot==null) + return ""; //$NON-NLS-1$ + StringBuffer buffer=new StringBuffer(); + for (int line = fSelectionStartLine; line <= fSeletionEndLine; line++) { + String text; + char[] chars=fSelectionSnapshot.getChars(line); + if(chars!=null) { + text=new String(chars); + if(line==fSeletionEndLine && fSelectionEndColumn >= 0) + text=text.substring(0, Math.min(fSelectionEndColumn+1,text.length())); + if(line==fSelectionStartLine) + text=text.substring(Math.min(fSelectionStartCoumn,text.length())); + text=scrubLine(text); + } else { + text=""; //$NON-NLS-1$ + } + buffer.append(text); + if(line < fSeletionEndLine && !fSelectionSnapshot.isWrappedLine(line)) + buffer.append('\n'); + } + return buffer.toString(); + } + private void updateSelection() { + if (fSelectionSnapshot != null && fSelectionSnapshot.isOutOfDate()) { + fSelectionSnapshot.updateSnapshot(true); + // has the selection moved? + if (fSelectionSnapshot != null && fSelectionStartLine >= 0 && fSelectionSnapshot.getScrollWindowSize() > 0) { + int start = fSelectionStartLine + fSelectionSnapshot.getScrollWindowShift(); + int end = fSeletionEndLine + fSelectionSnapshot.getScrollWindowShift(); + if (start < 0) + if (end >= 0) + start = 0; + else + start = -1; + doSetSelection(start, end, fSelectionStartCoumn, fSelectionEndColumn); + } + // check if the content of the selection has changed. If the content has + // changed, clear the selection + if (fCurrentSelection.length()>0 && fSelectionSnapshot != null + && fSelectionSnapshot.getFirstChangedLine() <= fSeletionEndLine + && fSelectionSnapshot.getLastChangedLine() >= fSelectionStartLine) { + // has the selected text changed? + if (!fCurrentSelection.equals(extractSelectedText())) { + setSelection(-1, -1, -1, -1); + } + } + // update the observed window... + if (fSelectionSnapshot != null) + // todo make -1 to work! + fSelectionSnapshot.setInterestWindow(0, fSelectionSnapshot.getHeight()); + } + } + + @Override + public String getAllText() { + + // Make a snapshot of the whole text data + ITerminalTextDataSnapshot snapshot = fSnapshot.getTerminalTextData().makeSnapshot(); + snapshot.updateSnapshot(true); + snapshot.detach(); + + // Extract the data + StringBuffer sb = new StringBuffer(); + for (int line = 0; line < snapshot.getHeight(); line++) { + char[] chars = snapshot.getChars(line); + String text; + if (chars != null) { + text = scrubLine(new String(chars)); // take care of NULs + } else { + text = ""; //$NON-NLS-1$ null arrays represent empty lines + } + sb.append(text); + // terminate lines except (1) the last one and (2) wrapped lines + if ((line < snapshot.getHeight() - 1) && !snapshot.isWrappedLine(line)) { + sb.append('\n'); + } + } + return sb.toString(); + } +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java new file mode 100644 index 00000000000..40ab4bf1ca4 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java @@ -0,0 +1,232 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.ScrollBar; + +/** + * A Grid based Canvas. The canvas has rows and columns. + * CellPainting is done with the abstract method drawCell + */ +abstract public class GridCanvas extends VirtualCanvas { + /** width of a cell */ + private int fCellWidth; + /** height of a cell */ + private int fCellHeight; + + public GridCanvas(Composite parent, int style) { + super(parent, style); + addListener(SWT.MouseWheel, new Listener() { + public void handleEvent(Event event) { + if(getVerticalBar().isVisible()) { + int delta=-fCellHeight; + if(event.count<0) + delta=-delta; + scrollYDelta(delta); + } + event.doit=false; + } + }); + + } + + /** template method paint. + * iterates over all cells in the clipping rectangle and paints them. + */ + protected void paint(GC gc) { + Rectangle clipping=gc.getClipping(); + if(clipping.width==0 || clipping.height==0) + return; + Rectangle clientArea= getScreenRectInVirtualSpace(); + // Beginning coordinates + int xOffset=clientArea.x; + int yOffset=clientArea.y; + int colFirst=virtualXToCell(xOffset+clipping.x); + if(colFirst>getCols()) + colFirst=getCols(); + else if (colFirst < 0) { + colFirst = 0; + } + int rowFirst=virtualYToCell(yOffset+clipping.y); + // End coordinates + int colLast=virtualXToCell(xOffset+clipping.x+clipping.width+fCellWidth); + if(colLast>getCols()) + colLast=getCols(); + int rowLast=virtualYToCell(yOffset+clipping.y+clipping.height+fCellHeight); + if(rowLast>getRows()) + rowLast=getRows(); + // System.out.println(rowFirst+"->"+rowLast+" "+System.currentTimeMillis()); + // draw the cells + for(int row=rowFirst;row<=rowLast;row++) { + int cx=colFirst*fCellWidth-xOffset; + int cy=row*fCellHeight-yOffset; + drawLine(gc,row,cx,cy,colFirst,colLast); + } + paintUnoccupiedSpace(gc,clipping); + } + /** + * @param gc + * @param row the line to draw + * @param x coordinate on screen + * @param y coordinate on screen + * @param colFirst first column to draw + * @param colLast last column to draw + */ + abstract void drawLine(GC gc, int row, int x, int y, int colFirst, int colLast); + + abstract protected int getRows(); + abstract protected int getCols(); + + protected void setCellWidth(int cellWidth) { + fCellWidth = cellWidth; + getHorizontalBar().setIncrement(fCellWidth); + } + + public int getCellWidth() { + return fCellWidth; + } + + protected void setCellHeight(int cellHeight) { + fCellHeight = cellHeight; + getVerticalBar().setIncrement(fCellHeight); + } + + public int getCellHeight() { + return fCellHeight; + } + + int virtualXToCell(int x) { + return x/fCellWidth; + } + + int virtualYToCell(int y) { + return y/fCellHeight; + } + + protected Point screenPointToCell(int x, int y) { + x=screenXtoVirtual(x)/fCellWidth; + y=screenYtoVirtual(y)/fCellHeight; + return new Point(x,y); + } + + Point screenPointToCell(Point point) { + return screenPointToCell(point.x,point.y); + } + + protected Point cellToOriginOnScreen(int x, int y) { + x=virtualXtoScreen(fCellWidth*x); + y=virtualYtoScreen(fCellHeight*y); + return new Point(x,y); + } + + Point cellToOriginOnScreen(Point cell) { + return cellToOriginOnScreen(cell.x,cell.y); + } + + Rectangle getCellScreenRect(Point cell) { + return getCellScreenRect(cell.x,cell.y); + } + + Rectangle getCellScreenRect(int x, int y) { + x=fCellWidth*virtualXtoScreen(x); + y=fCellHeight*virtualYtoScreen(y); + return new Rectangle(x,y,fCellWidth,fCellHeight); + } + + protected Rectangle getCellVirtualRect(Point cell) { + return getCellVirtualRect(cell.x,cell.y); + } + + Rectangle getCellVirtualRect(int x, int y) { + x=fCellWidth*x; + y=fCellHeight*y; + return new Rectangle(x,y,fCellWidth,fCellHeight); + } + protected void viewRectangleChanged(int x, int y, int width, int height) { + int cellX=virtualXToCell(x); + int cellY=virtualYToCell(y); + // End coordinates + int xE=virtualXToCell(x+width); +// if(xE>getCols()) +// xE=getCols(); + int yE=virtualYToCell(y+height); +// if(yE>getRows()) +// yE=getRows(); + visibleCellRectangleChanged(cellX,cellY,xE-cellX,yE-cellY); + } + + /** + * Called when the viewed part has changed. + * Override when you need this information.... + * Is only called if the values change (well, almost) + * @param x origin of visible cells + * @param y origin of visible cells + * @param width number of cells visible in x direction + * @param height number of cells visible in y direction + */ + protected void visibleCellRectangleChanged(int x, int y, int width, int height) { + } + + protected void setVirtualExtend(int width, int height) { + int cellHeight = getCellHeight(); + if (cellHeight > 0) { + height -= height % cellHeight; + } + super.setVirtualExtend(width, height); + } + + protected void setVirtualOrigin(int x, int y) { + int cellHeight = getCellHeight(); + if (cellHeight > 0) { + int remainder = y % cellHeight; + if (remainder < 0) { + y -= (cellHeight + remainder); + } else { + y -= remainder; + } + } + super.setVirtualOrigin(x, y); + } + + protected void scrollY(ScrollBar vBar) { + int vSelection = vBar.getSelection (); + Rectangle bounds = getVirtualBounds(); + int y = -vSelection; + int cellHeight = getCellHeight(); + if (cellHeight > 0) { + int remainder = y % cellHeight; + if (remainder < 0) { + y -= (cellHeight + remainder); + } else { + y -= remainder; + } + } + int deltaY = y - bounds.y; + if(deltaY!=0) { + scrollSmart(0,deltaY); + setVirtualOrigin(bounds.x, bounds.y += deltaY); + } + if (-bounds.y + getRows() * getCellHeight() >= bounds.height) { + // scrolled to bottom - need to redraw bottom area + Rectangle clientRect = getClientArea(); + redraw(0, clientRect.height - fCellHeight, clientRect.width, fCellHeight, false); + } + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java new file mode 100644 index 00000000000..e03946b79b5 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering + * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; + +/** + * + */ +public interface ILinelRenderer { + int getCellWidth(); + int getCellHeight(); + 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. + */ + void onFontChange(); + /** + * Set a new font + * @param fontName Jface name of the new font + * @since 3.2 + */ + void updateFont(String fontName); + void setInvertedColors(boolean invert); + Color getDefaultBackgroundColor(); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java new file mode 100644 index 00000000000..e56b51aa88d --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; + +public interface ITextCanvasModel { + void addCellCanvasModelListener(ITextCanvasModelListener listener); + void removeCellCanvasModelListener(ITextCanvasModelListener listener); + + ITerminalTextDataReadOnly getTerminalText(); + /** + * This is is + * @param startLine + * @param startCol + * @param height + * @param width + */ + void setVisibleRectangle(int startLine, int startCol, int height, int width); + + /** + * @return true when the cursor is shown (used for blinking cursors) + */ + boolean isCursorOn(); + /** + * Show/Hide the cursor. + * @param visible + */ + void setCursorEnabled(boolean visible); + + /** + * @return true if the cursor is shown. + */ + boolean isCursorEnabled(); + + /** + * @return the line of the cursor + */ + int getCursorLine(); + /** + * @return the column of the cursor + */ + int getCursorColumn(); + + /** + * @return the start of the selection or null if nothing is selected + * {@link Point#x} is the column and {@link Point#y} is the line. + */ + Point getSelectionStart(); + /** + * @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. + */ + Point getSelectionEnd(); + + Point getSelectionAnchor(); + + void setSelectionAnchor(Point anchor); + /** + * Sets the selection. A negative startLine clears the selection. + * @param startLine + * @param endLine + * @param startColumn + * @param endColumn + */ + void setSelection(int startLine, int endLine, int startColumn, int endColumn); + + /** + * @param line + * @return true if line is part of the selection + */ + boolean hasLineSelection(int line); + + String getSelectedText(); + + /** + * Collect and return all text present in the model. + * + *

            Individual lines of the returned text are separated by '\n'. + * + *

            The method is primarily designed for test automation. + * + * @since 4.4 + */ + String getAllText(); +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java new file mode 100644 index 00000000000..4e09027ac48 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + +/** + */ +public interface ITextCanvasModelListener { + void rangeChanged(int col, int line, int width, int height); + void dimensionsChanged(int cols, int rows); + /** + * Called when any text change happened. Used to scroll to the + * end of text in auto scroll mode. This does not get fired + * when the window of interest has changed! + */ + void terminalDataChanged(); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java new file mode 100644 index 00000000000..f0e11324a2d --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java @@ -0,0 +1,312 @@ +/******************************************************************************* + * Copyright (c) 1996, 2011 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Douglas Lea (Addison Wesley) - [cq:1552] BoundedBufferWithStateTracking adapted to BoundedByteBuffer + * Martin Oberhuber (Wind River) - the waitForAvailable method + * Martin Oberhuber (Wind River) - [208166] Avoid unnecessary arraycopy in BoundedByteBuffer + * Pawel Piech (Wind River) - [333613] "Job found still running" after shutdown + *******************************************************************************/ + +package org.eclipse.tm.internal.terminal.textcanvas; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * The main purpose of this class is to start a runnable in the + * display thread when data is available and to pretend no data + * is available after a given amount of time the runnable is running. + * + */ +public class PipedInputStream extends InputStream { + /** + * The output stream used by the terminal backend to write to the terminal + */ + protected final OutputStream fOutputStream; + /** + * A blocking byte queue. + */ + private final BoundedByteBuffer fQueue; + + /** + * A byte bounded buffer used to synchronize the input and the output stream. + *

            + * Adapted from BoundedBufferWithStateTracking + * http://gee.cs.oswego.edu/dl/cpj/allcode.java + * http://gee.cs.oswego.edu/dl/cpj/ + *

            + * BoundedBufferWithStateTracking is part of the examples for the book + * Concurrent Programming in Java: Design Principles and Patterns by + * Doug Lea (ISBN 0-201-31009-0). Second edition published by + * Addison-Wesley, November 1999. The code is + * Copyright(c) Douglas Lea 1996, 1999 and released to the public domain + * and may be used for any purposes whatsoever. + *

            + * For some reasons a solution based on + * PipedOutputStream/PipedIntputStream + * does work *very* slowly: + * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4404700 + *

            + * + */ + private class BoundedByteBuffer { + protected final byte[] fBuffer; // the elements + protected int fPutPos = 0; // circular indices + protected int fTakePos = 0; + protected int fUsedSlots = 0; // the count + private boolean fClosed; + public BoundedByteBuffer(int capacity) throws IllegalArgumentException { + // make sure we don't deadlock on too small capacity + if (capacity <= 0) + throw new IllegalArgumentException(); + fBuffer = new byte[capacity]; + } + /** + * @return the bytes available for {@link #read()} + * Must be called with a lock on this! + */ + public int available() { + return fUsedSlots; + } + /** + * Writes a single byte to the buffer. Blocks if the buffer is full. + * @param b byte to write to the buffer + * @throws InterruptedException when the thread is interrupted while waiting + * for the buffer to become ready + * Must be called with a lock on this! + */ + public void write(byte b) throws InterruptedException { + while (fUsedSlots == fBuffer.length) + // wait until not full + wait(); + + fBuffer[fPutPos] = b; + fPutPos = (fPutPos + 1) % fBuffer.length; // cyclically increment + + if (fUsedSlots++ == 0) // signal if was empty + notifyAll(); + } + public int getFreeSlots() { + return fBuffer.length - fUsedSlots; + } + public void write(byte[] b, int off, int len) throws InterruptedException { + assert len<=getFreeSlots(); + while (fUsedSlots == fBuffer.length) + // wait until not full + wait(); + int n = Math.min(len, fBuffer.length - fPutPos); + System.arraycopy(b, off, fBuffer, fPutPos, n); + if (fPutPos + len > fBuffer.length) + System.arraycopy(b, off + n, fBuffer, 0, len - n); + fPutPos = (fPutPos + len) % fBuffer.length; // cyclically increment + boolean wasEmpty = fUsedSlots == 0; + fUsedSlots += len; + if (wasEmpty) // signal if was empty + notifyAll(); + } + /** + * Read a single byte. Blocks until a byte is available. + * @return a byte from the buffer + * @throws InterruptedException when the thread is interrupted while waiting + * for the buffer to become ready + * Must be called with a lock on this! + */ + public int read() throws InterruptedException { + while (fUsedSlots == 0) { + if(fClosed) + return -1; + // wait until not empty + wait(); + } + byte b = fBuffer[fTakePos]; + fTakePos = (fTakePos + 1) % fBuffer.length; + + if (fUsedSlots-- == fBuffer.length) // signal if was full + notifyAll(); + return b; + } + public int read(byte[] cbuf, int off, int len) throws InterruptedException { + assert len<=available(); + while (fUsedSlots == 0) { + if(fClosed) + return 0; + // wait until not empty + wait(); + } + int n = Math.min(len, fBuffer.length - fTakePos); + System.arraycopy(fBuffer, fTakePos, cbuf, off, n); + if (fTakePos + len > n) + System.arraycopy(fBuffer, 0, cbuf, off + n, len - n); + fTakePos = (fTakePos + len) % fBuffer.length; + boolean wasFull = fUsedSlots == fBuffer.length; + fUsedSlots -= len; + if(wasFull) + notifyAll(); + + return len; + } + public void close() { + fClosed=true; + notifyAll(); + } + public boolean isClosed() { + return fClosed; + } + } + + /** + * An output stream that calls {@link PipedInputStream#textAvailable} + * every time data is written to the stream. The data is written to + * {@link PipedInputStream#fQueue}. + * + */ + class PipedOutputStream extends OutputStream { + public void write(byte[] b, int off, int len) throws IOException { + try { + synchronized (fQueue) { + if(fQueue.isClosed()) + throw new IOException("Stream is closed!"); //$NON-NLS-1$ + int written=0; + while(writtenPipedInputStream is the same as closing the output stream. + * The stream will allow reading data that's still in the pipe after which it will + * throw an IOException. + */ + public void close() throws IOException { + synchronized(fQueue) { + fQueue.close(); + } + } + + public int read(byte[] cbuf, int off, int len) throws IOException { + int n=0; + if(len==0) + return 0; + // read as much as we can using a single synchronized statement + try { + synchronized (fQueue) { + // if nothing available, block and read one byte + if (fQueue.available() == 0) { + // block now until at least one byte is available + int c = fQueue.read(); + // are we at the end of stream + if (c == -1) + return -1; + cbuf[off] = (byte) c; + n++; + } + // is there more data available? + if (n < len && fQueue.available() > 0) { + // read at most available() + int nn = Math.min(fQueue.available(), len - n); + // are we at the end of the stream? + if (nn == 0 && fQueue.isClosed()) { + // if no byte was read, return -1 to indicate end of stream + // else return the bytes we read up to now + if (n == 0) + n = -1; + return n; + } + fQueue.read(cbuf, off + n, nn); + n += nn; + } + + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + return n; + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java new file mode 100644 index 00000000000..b54fdf643f8 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [420928] Terminal widget leaks memory + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; + +/** + * @author Michael.Scharf@scharf-software.com + * + */ +public class PollingTextCanvasModel extends AbstractTextCanvasModel { + private static final int DEFAULT_POLL_INTERVAL = 50; + int fPollInterval = -1; + + /** + * + */ + public PollingTextCanvasModel(ITerminalTextDataSnapshot snapshot) { + super(snapshot); + startPolling(); + } + public void setUpdateInterval(int t) { + fPollInterval = t; + } + public void stopPolling() { + // timerExec only dispatches if the delay is >=0 + fPollInterval = -1; + } + public void startPolling() { + if (fPollInterval < 0) { + fPollInterval = DEFAULT_POLL_INTERVAL; + Display.getDefault().timerExec(fPollInterval, new Runnable(){ + public void run() { + update(); + Display.getDefault().timerExec(fPollInterval, this); + } + }); + } + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java new file mode 100644 index 00000000000..81e63e27ed5 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -0,0 +1,296 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Michael Scharf (Wind River) - [205260] Terminal does not take the font from the preferences + * Michael Scharf (Wind River) - [209746] There are cases where some colors not displayed correctly + * Michael Scharf (Wind River) - [206328] Terminal does not draw correctly with proportional fonts + * Martin Oberhuber (Wind River) - [247700] Terminal uses ugly fonts in JEE package + * Martin Oberhuber (Wind River) - [335358] Fix Terminal color definition + * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + * Martin Oberhuber (Wind River) - [475422] Fix display on MacOSX Retina + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; +import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.StyleColor; + +public class StyleMap { + private static final String BLACK = "black"; //$NON-NLS-1$ + private static final String WHITE = "white"; //$NON-NLS-1$ + private static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$ + private static final String GRAY = "gray"; //$NON-NLS-1$ + private static final String MAGENTA = "magenta"; //$NON-NLS-1$ + private static final String CYAN = "cyan"; //$NON-NLS-1$ + private static final String YELLOW = "yellow"; //$NON-NLS-1$ + private static final String BLUE = "blue"; //$NON-NLS-1$ + private static final String GREEN = "green"; //$NON-NLS-1$ + private static final String RED = "red"; //$NON-NLS-1$ + + private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$ + String fFontName=ITerminalConstants.FONT_DEFINITION; + Map fColorMapForeground=new HashMap(); + Map fColorMapBackground=new HashMap(); + Map fColorMapIntense=new HashMap(); + private Point fCharSize; + private final Style fDefaultStyle; + private boolean fInvertColors; + private boolean fProportional; + private final int[] fOffsets=new int[256]; + StyleMap() { + initColors(); + fDefaultStyle=Style.getStyle(StyleColor.getStyleColor(BLACK),StyleColor.getStyleColor(WHITE)); + updateFont(); + } + private void initColors() { + initForegroundColors(); + initBackgroundColors(); + initIntenseColors(); + } + private void initForegroundColors() { + if(fInvertColors) { + setColor(fColorMapForeground, WHITE, 0, 0, 0); + setColor(fColorMapForeground, WHITE_FOREGROUND, 50, 50, 50); + setColor(fColorMapForeground, BLACK, 229, 229, 229); + } else { + setColor(fColorMapForeground, WHITE, 255, 255, 255); + setColor(fColorMapForeground, WHITE_FOREGROUND, 229, 229, 229); + setColor(fColorMapForeground, BLACK, 50, 50, 50); + } + setColor(fColorMapForeground, RED, 205, 0, 0); + setColor(fColorMapForeground, GREEN, 0, 205, 0); + setColor(fColorMapForeground, BLUE, 0, 0, 238); + setColor(fColorMapForeground, YELLOW, 205, 205, 0); + setColor(fColorMapForeground, CYAN, 0, 205, 205); + setColor(fColorMapForeground, MAGENTA, 205, 0, 205); + setColor(fColorMapForeground, GRAY, 229, 229, 229); + } + + private void initBackgroundColors() { + if(fInvertColors) { + setColor(fColorMapBackground, WHITE, 0, 0, 0); + setColor(fColorMapBackground, WHITE_FOREGROUND, 50, 50, 50); // only used when colors are inverse + setColor(fColorMapBackground, BLACK, 255, 255, 255); + } else { + setColor(fColorMapBackground, WHITE, 255, 255, 255); + setColor(fColorMapBackground, WHITE_FOREGROUND, 229, 229, 229); + setColor(fColorMapBackground, BLACK, 0, 0, 0); + } + setColor(fColorMapBackground, RED, 205, 0, 0); + setColor(fColorMapBackground, GREEN, 0, 205, 0); + setColor(fColorMapBackground, BLUE, 0, 0, 238); + setColor(fColorMapBackground, YELLOW, 205, 205, 0); + setColor(fColorMapBackground, CYAN, 0, 205, 205); + setColor(fColorMapBackground, MAGENTA, 205, 0, 205); + setColor(fColorMapBackground, GRAY, 229, 229, 229); + } + + private void initIntenseColors() { + if(fInvertColors) { + setColor(fColorMapIntense, WHITE, 127, 127, 127); + setColor(fColorMapIntense, WHITE_FOREGROUND, 0, 0, 0); // only used when colors are inverse + setColor(fColorMapIntense, BLACK, 255, 255, 255); + } else { + setColor(fColorMapIntense, WHITE, 255, 255, 255); + setColor(fColorMapIntense, WHITE_FOREGROUND, 255, 255, 255); + setColor(fColorMapIntense, BLACK, 0, 0, 0); + } + setColor(fColorMapIntense, RED, 255, 0, 0); + setColor(fColorMapIntense, GREEN, 0, 255, 0); + setColor(fColorMapIntense, BLUE, 92, 92, 255); + setColor(fColorMapIntense, YELLOW, 255, 255, 0); + setColor(fColorMapIntense, CYAN, 0, 255, 255); + setColor(fColorMapIntense, MAGENTA, 255, 0, 255); + setColor(fColorMapIntense, GRAY, 255, 255, 255); + } + + private void setColor(Map colorMap, String name, int r, int g, int b) { + String colorName=PREFIX+r+"-"+g+"-"+b; //$NON-NLS-1$//$NON-NLS-2$ + Color color=JFaceResources.getColorRegistry().get(colorName); + if(color==null) { + JFaceResources.getColorRegistry().put(colorName, new RGB(r,g,b)); + color=JFaceResources.getColorRegistry().get(colorName); + } + colorMap.put(StyleColor.getStyleColor(name), color); + colorMap.put(StyleColor.getStyleColor(name.toUpperCase()), color); + } + + public Color getForegrondColor(Style style) { + style = defaultIfNull(style); + Map map = style.isBold() ? fColorMapIntense : fColorMapForeground; + //Map map = fColorMapForeground; + if(style.isReverse()) + return getColor(map ,style.getBackground()); + else + return getColor(map ,style.getForground()); + } + public Color getBackgroundColor(Style style) { + style = defaultIfNull(style); + if(style.isReverse()) + return getColor(fColorMapBackground,style.getForground()); + else + return getColor(fColorMapBackground,style.getBackground()); + } + Color getColor(Map map,StyleColor color) { + Color c=map.get(color); + if(c==null) { + c=Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); + } + return c; + } + private Style defaultIfNull(Style style) { + if(style==null) + style=fDefaultStyle; + return style; + } + public void setInvertedColors(boolean invert) { + if(invert==fInvertColors) + return; + fInvertColors=invert; + initColors(); + } +// static Font getBoldFont(Font font) { +// FontData fontDatas[] = font.getFontData(); +// FontData data = fontDatas[0]; +// return new Font(Display.getCurrent(), data.getName(), data.getHeight(), data.getStyle()|SWT.BOLD); +// } + + public Font getFont(Style style) { + style = defaultIfNull(style); + if(style.isBold()) { + return JFaceResources.getFontRegistry().getBold(fFontName); + } else if(style.isUnderline()) { + return JFaceResources.getFontRegistry().getItalic(fFontName); + + } + return JFaceResources.getFontRegistry().get(fFontName); + } + + public Font getFont() { + return JFaceResources.getFontRegistry().get(fFontName); + + } + public int getFontWidth() { + return fCharSize.x; + } + public int getFontHeight() { + return fCharSize.y; + } + public void updateFont() { + updateFont(ITerminalConstants.FONT_DEFINITION); + } + /** + * Update the StyleMap for a new font name. + * The font name must be a valid name in the Jface font registry. + * @param fontName Jface name of the new font to use. + * @since 3.2 + */ + public void updateFont(String fontName) { + Display display=Display.getCurrent(); + GC gc = new GC (display); + if (JFaceResources.getFontRegistry().hasValueFor(fontName)) { + fFontName = fontName; + } else { + //fall back to "basic jface text font" + fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$ + } + gc.setFont(getFont()); + fCharSize = gc.textExtent ("W"); //$NON-NLS-1$ + fProportional=false; + + for (char c = ' '; c <= '~'; c++) { + // consider only the first 128 chars for deciding if a font + // is proportional. Collect char width as a side-effect. + if(measureChar(gc, c, true)) + fProportional=true; + } + if(fProportional) { + // Widest char minus the padding on the left and right: + // Looks much better for small fonts + fCharSize.x-=2; + // Collect width of the upper characters (for offset calculation) + for (char c = '~'+1; c < fOffsets.length; c++) { + measureChar(gc, c,false); + } + // Calculate offsets based on each character's width and the bounding box + for (int i = ' '; i < fOffsets.length; i++) { + fOffsets[i]=(fCharSize.x-fOffsets[i])/2; + } + } else { + // Non-Proportional: Reset all offsets (eg after font change) + for (int i = 0; i < fOffsets.length; i++) { + fOffsets[i]=0; + } + String t = "The quick brown Fox jumps over the Lazy Dog."; //$NON-NLS-1$ + Point ext=gc.textExtent(t); + if(ext.x != fCharSize.x * t.length()) { + //Bug 475422: On OSX with Retina display and due to scaling, + //a text many be shorter than the sum of its bounding boxes. + //Because even with fixed width font, bounding box size + //may not be an integer but a fraction eg 6.75 pixels. + // + //Painting in proportional mode ensures that each character + //is painted individually into its proper bounding box, rather + //than using an optimization where Strings would be drawn as + //a whole. This fixes the "fractional bounding box" problem. + fProportional=true; + } + //measure font in boldface, too, and if wider then treat like proportional + gc.setFont(getFont(fDefaultStyle.setBold(true))); + Point charSizeBold = gc.textExtent("W"); //$NON-NLS-1$ + if (fCharSize.x != charSizeBold.x) { + fProportional=true; + } + } + gc.dispose (); + } + /** + * @param gc + * @param c + * @param updateMax + * @return true if the the font is proportional + */ + private boolean measureChar(GC gc, char c, boolean updateMax) { + boolean proportional=false; + Point ext=gc.textExtent(String.valueOf(c)); + if(ext.x>0 && ext.y>0 && (fCharSize.x!=ext.x || fCharSize.y!=ext.y)) { + proportional=true; + if(updateMax) { + fCharSize.x=Math.max(fCharSize.x, ext.x); + fCharSize.y=Math.max(fCharSize.y, ext.y); + } + } + fOffsets[c]=ext.x; + return proportional; + } + public boolean isFontProportional() { + return fProportional; + } + /** + * Return the offset in pixels required to center a given character + * @param c the character to measure + * @return the offset in x direction to center this character + */ + public int getCharOffset(char c) { + if(c>=fOffsets.length) + return 0; + return fOffsets[c]; + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java new file mode 100644 index 00000000000..a98fc50cad2 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -0,0 +1,486 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Michael Scharf (Wind River) - [240098] The cursor should not blink when the terminal is disconnected + * Uwe Stieber (Wind River) - [281328] The very first few characters might be missing in the terminal control if opened and connected programmatically + * Martin Oberhuber (Wind River) - [294327] After logging in, the remote prompt is hidden + * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering + * Uwe Stieber (Wind River) - [205486] Fix ScrollLock always moving to line 1 + * Anton Leherbauer (Wind River) - [219589] Copy an entire line selection + * Anton Leherbauer (Wind River) - [196465] Resizing Terminal changes Scroller location + * Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour + * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + * Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty + * Davy Landman (CWI) - [475267][api] Allow custom mouse listeners + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener; + +/** + * A cell oriented Canvas. Maintains a list of "cells". + * It can either be vertically or horizontally scrolled. + * The CellRenderer is responsible for painting the cell. + */ +public class TextCanvas extends GridCanvas { + protected final ITextCanvasModel fCellCanvasModel; + /** Renders the cells */ + private final ILinelRenderer fCellRenderer; + private boolean fScrollLock; + private Point fDraggingStart; + private Point fDraggingEnd; + private boolean fHasSelection; + private ResizeListener fResizeListener; + private final List fMouseListeners; + + // The minSize is meant to determine the minimum size of the backing store + // (grid) into which remote data is rendered. If the viewport is smaller + // than that minimum size, the backing store size remains at the minSize, + // and a scrollbar is shown instead. In reality, this has the following + // issues or effects today: + // (a) Bug 281328: For very early data coming in before the widget is + // realized, the minSize determines into what initial grid that is + // rendered. See also @link{#addResizeHandler(ResizeListener)}. + // (b) Bug 294468: Since we have redraw and size computation problems + // with horizontal scrollers, for now the minColumns must be small + // enough to avoid a horizontal scroller appearing in most cases. + // (b) Bug 294327: since we have problems with the vertical scroller + // showing the correct location, minLines must be small enough + // to avoid a vertical scroller or new data may be rendered off-screen. + // As a compromise, we have been working with a 20x4 since the Terminal + // inception, though many users would want a 80x24 minSize and backing + // store. Pros and cons of the small minsize: + // + consistent "remote size==viewport size", vi works as expected + // - dumb terminals which expect 80x24 render garbled on small viewport. + // If bug 294468 were resolved, an 80 wide minSize would be preferrable + // since it allows switching the terminal viewport small/large as needed, + // without destroying the backing store. For a complete solution, + // Bug 196462 tracks the request for a user-defined fixed-widow-size-mode. + private int fMinColumns=80; + private int fMinLines=4; + private boolean fCursorEnabled; + private boolean fResizing; + + /** + * Create a new CellCanvas with the given SWT style bits. + * (SWT.H_SCROLL and SWT.V_SCROLL are automatically added). + */ + public TextCanvas(Composite parent, ITextCanvasModel model, int style,ILinelRenderer cellRenderer) { + super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL); + fCellRenderer=cellRenderer; + setCellWidth(fCellRenderer.getCellWidth()); + setCellHeight(fCellRenderer.getCellHeight()); + fCellCanvasModel=model; + fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener(){ + public void rangeChanged(int col, int line, int width, int height) { + if(isDisposed()) return; + repaintRange(col,line,width,height); + } + public void dimensionsChanged(int cols, int rows) { + if(isDisposed()) return; + calculateGrid(); + } + public void terminalDataChanged() { + if(isDisposed()) return; + + // scroll to end (unless scroll lock is active) + if (!fResizing) { + calculateGrid(); + scrollToEnd(); + } + } + }); + // let the cursor blink if the text canvas gets the focus... + addFocusListener(new FocusListener(){ + public void focusGained(FocusEvent e) { + fCellCanvasModel.setCursorEnabled(fCursorEnabled); + } + public void focusLost(FocusEvent e) { + fCellCanvasModel.setCursorEnabled(false); + }}); + fMouseListeners = new ArrayList(); + addMouseListener(new MouseListener(){ + public void mouseDoubleClick(MouseEvent e) { + if (fMouseListeners.size() > 0) { + Point pt = screenPointToCell(e.x, e.y); + if (pt != null) { + for (ITerminalMouseListener l : fMouseListeners) { + l.mouseDoubleClick(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + } + } + } + } + public void mouseDown(MouseEvent e) { + if(e.button==1) { // left button + fDraggingStart=screenPointToCell(e.x, e.y); + fHasSelection=false; + if((e.stateMask&SWT.SHIFT)!=0) { + Point anchor=fCellCanvasModel.getSelectionAnchor(); + if(anchor!=null) + fDraggingStart=anchor; + } else { + fCellCanvasModel.setSelectionAnchor(fDraggingStart); + } + fDraggingEnd=null; + } + if (fMouseListeners.size() > 0) { + Point pt = screenPointToCell(e.x, e.y); + if (pt != null) { + for (ITerminalMouseListener l : fMouseListeners) { + l.mouseDown(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + } + } + } + } + public void mouseUp(MouseEvent e) { + if(e.button==1) { // left button + updateHasSelection(e); + if(fHasSelection) + setSelection(screenPointToCell(e.x, e.y)); + else + fCellCanvasModel.setSelection(-1,-1,-1,-1); + fDraggingStart=null; + } + if (fMouseListeners.size() > 0) { + Point pt = screenPointToCell(e.x, e.y); + if (pt != null) { + for (ITerminalMouseListener l : fMouseListeners) { + l.mouseUp(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + } + } + } + } + }); + addMouseMoveListener(new MouseMoveListener() { + + public void mouseMove(MouseEvent e) { + if (fDraggingStart != null) { + updateHasSelection(e); + setSelection(screenPointToCell(e.x, e.y)); + } + } + }); + serVerticalBarVisible(true); + setHorizontalBarVisible(false); + } + + /** + * The user has to drag the mouse to at least one character to make a selection. + * Once this is done, even a one char selection is OK. + * + * @param e + */ + private void updateHasSelection(MouseEvent e) { + if(fDraggingStart!=null) { + Point p=screenPointToCell(e.x, e.y); + if(fDraggingStart.x!=p.x||fDraggingStart.y!=p.y) + fHasSelection=true; + } + } + + void setSelection(Point p) { + if (fDraggingStart !=null && !p.equals(fDraggingEnd)) { + fDraggingEnd = p; + if (compare(p, fDraggingStart) < 0) { + // bug 219589 - make sure selection start coordinates are non-negative + int startColumn = Math.max(0, p.x); + int startRow = Math.max(p.y, 0); + fCellCanvasModel.setSelection(startRow, fDraggingStart.y, startColumn, fDraggingStart.x); + } else { + fCellCanvasModel.setSelection(fDraggingStart.y, p.y, fDraggingStart.x, p.x); + + } + } + } + + int compare(Point p1, Point p2) { + if (p1.equals(p2)) + return 0; + if (p1.y == p2.y) { + if (p1.x > p2.x) + return 1; + else + return -1; + } + if (p1.y > p2.y) { + return 1; + } else { + return -1; + } + } + public ILinelRenderer getCellRenderer() { + return fCellRenderer; + } + + public int getMinColumns() { + return fMinColumns; + } + + public void setMinColumns(int minColumns) { + fMinColumns = minColumns; + } + + public int getMinLines() { + return fMinLines; + } + + public void setMinLines(int minLines) { + fMinLines = minLines; + } + + protected void onResize(boolean init) { + if(fResizeListener!=null) { + Rectangle bonds=getClientArea(); + int cellHeight = getCellHeight(); + int cellWidth = getCellWidth(); + int lines=bonds.height/cellHeight; + int columns=bonds.width/cellWidth; + // when the view is minimised, its size is set to 0 + // we don't sent this to the terminal! + if((lines>0 && columns>0) || init) { + if(columns=fMinColumns && isHorizontalBarVisble()) { + setHorizontalBarVisible(false); + bonds=getClientArea(); + lines=bonds.height/cellHeight; + columns=bonds.width/cellWidth; + } + if(lines 0) { + y = 0; + } + Rectangle v=getViewRectangle(); + if(v.y!=-y) { + setVirtualOrigin(v.x,y); + } + // make sure the scroll area is correct: + scrollY(getVerticalBar()); + scrollX(getHorizontalBar()); + } + } + /** + * + * @return true if the cursor should be shown on output.... + */ + public boolean isScrollLock() { + return fScrollLock; + } + /** + * If set then if the size changes + */ + public void setScrollLock(boolean scrollLock) { + fScrollLock=scrollLock; + } + protected void repaintRange(int col, int line, int width, int height) { + Point origin=cellToOriginOnScreen(col,line); + Rectangle r=new Rectangle(origin.x,origin.y,width*getCellWidth(),height*getCellHeight()); + repaint(r); + } + protected void drawLine(GC gc, int line, int x, int y, int colFirst, int colLast) { + fCellRenderer.drawLine(fCellCanvasModel, gc,line,x,y,colFirst, colLast); + } + protected Color getTerminalBackgroundColor() { + return fCellRenderer.getDefaultBackgroundColor(); + } + protected void visibleCellRectangleChanged(int x, int y, int width, int height) { + fCellCanvasModel.setVisibleRectangle(y,x,height,width); + update(); + } + protected int getCols() { + return fCellCanvasModel.getTerminalText().getWidth(); + } + protected int getRows() { + return fCellCanvasModel.getTerminalText().getHeight(); + } + public String getSelectionText() { + // TODO -- create a hasSelectionMethod! + return fCellCanvasModel.getSelectedText(); + } + public void copy() { + String selectionText = getSelectionText(); + if (selectionText != null && selectionText.length() > 0) { + Clipboard clipboard = new Clipboard(getDisplay()); + clipboard.setContents(new Object[] { selectionText }, new Transfer[] { TextTransfer.getInstance() }); + clipboard.dispose(); + } + } + public void selectAll() { + fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth()); + fCellCanvasModel.setSelectionAnchor(new Point(0,0)); + } + + /** + * @since 4.1 + */ + public void clearSelection() { + fCellCanvasModel.setSelection(-1,-1,-1,-1); + } + + /** + * Collect and return all text present in the widget. + * + *

            Individual lines of the returned text are separated by '\n'. + * + *

            The method is primarily designed for test automation. Tests need + * to check what happens in a terminal (e.g. if and how a CDT Debugger + * Console reacts in a GDB session) and this method allows to read the + * text present in the terminal. + * + * @since 4.4 + */ + public String getAllText() { + return fCellCanvasModel.getAllText(); + } + + public boolean isEmpty() { + return false; + } + /** + * Gets notified when the visible size of the terminal changes. + * This should update the model! + * + */ + public interface ResizeListener { + void sizeChanged(int lines, int columns); + } + /** + * @param listener this listener gets notified, when the size of + * the widget changed. It should change the dimensions of the underlying + * terminaldata + */ + public void addResizeHandler(ResizeListener listener) { + if(fResizeListener!=null) + throw new IllegalArgumentException("There can be at most one listener at the moment!"); //$NON-NLS-1$ + fResizeListener=listener; + + // Bug 281328: [terminal] The very first few characters might be missing in + // the terminal control if opened and connected programmatically + // + // 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. + Rectangle bonds=getClientArea(); + if (bonds.height=getTerminalText().getHeight() || colFirst>=getTerminalText().getWidth() || colFirst-colLast==0) { + fillBackground(gc, x, y, getCellWidth()*(colLast-colFirst), getCellHeight()); + } else { + colLast=Math.min(colLast, getTerminalText().getWidth()); + LineSegment[] segments=getTerminalText().getLineSegments(line, colFirst, colLast-colFirst); + for (int i = 0; i < segments.length; i++) { + LineSegment segment=segments[i]; + Style style=segment.getStyle(); + setupGC(gc, style); + String text=segment.getText(); + drawText(gc, x, y, colFirst, segment.getColumn(), text); + drawCursor(model, gc, line, x, y, colFirst); + } + if(fModel.hasLineSelection(line)) { + gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); + gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); + Point start=model.getSelectionStart(); + Point end=model.getSelectionEnd(); + char[] chars=model.getTerminalText().getChars(line); + if(chars==null) + return; + int offset=0; + if(start.y==line) + offset=start.x; + offset=Math.max(offset, colFirst); + int len; + if(end.y==line) + len=end.x-offset+1; + else + len=chars.length-offset+1; + len=Math.min(len,chars.length-offset); + if(len>0) { + String text=new String(chars,offset,len); + drawText(gc, x, y, colFirst, offset, text); + } + } + } + } + + private void fillBackground(GC gc, int x, int y, int width, int height) { + Color bg=gc.getBackground(); + gc.setBackground(getDefaultBackgroundColor()); + gc.fillRectangle (x,y,width,height); + gc.setBackground(bg); + + } + + public Color getDefaultBackgroundColor() { + // null == default style + return fStyleMap.getBackgroundColor(null); + } + + private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) { + if(!model.isCursorOn()) + return; + int cursorLine=model.getCursorLine(); + + if(row==cursorLine) { + int cursorColumn=model.getCursorColumn(); + if(cursorColumnCanvas showing a virtual object. + * Virtual: the extent of the total canvas. + * Screen: the visible client area in the screen. + */ +public abstract class VirtualCanvas extends Canvas { + + private final Rectangle fVirtualBounds = new Rectangle(0,0,0,0); + private Rectangle fClientArea; + /** + * prevent infinite loop in {@link #updateScrollbars()} + */ + private boolean fInUpdateScrollbars; + private static boolean fInUpdateScrollbarsLogged; + + public VirtualCanvas(Composite parent, int style) { + super(parent, style|SWT.NO_BACKGROUND|SWT.NO_REDRAW_RESIZE); + fClientArea=getClientArea(); + addListener(SWT.Paint, new Listener() { + public void handleEvent(Event event) { + paint(event.gc); + } + }); + addListener(SWT.Resize, new Listener() { + public void handleEvent(Event event) { + fClientArea=getClientArea(); + onResize(); + } + }); + getVerticalBar().addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + scrollY((ScrollBar)e.widget); + + } + + }); + getHorizontalBar().addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + scrollX((ScrollBar)e.widget); + + } + }); + } + protected void onResize() { + updateViewRectangle(); + } + protected void scrollX(ScrollBar hBar) { + int hSelection = hBar.getSelection (); + int destX = -hSelection - fVirtualBounds.x; + fVirtualBounds.x = -hSelection; + scrollSmart(destX, 0); + updateViewRectangle(); + } + protected void scrollXDelta(int delta) { + getHorizontalBar().setSelection(-fVirtualBounds.x+delta); + scrollX(getHorizontalBar()); + } + + protected void scrollY(ScrollBar vBar) { + int vSelection = vBar.getSelection (); + int destY = -vSelection - fVirtualBounds.y; + if(destY!=0) { + fVirtualBounds.y = -vSelection; + scrollSmart(0,destY); + updateViewRectangle(); + } + + } + protected void scrollYDelta(int delta) { + getVerticalBar().setSelection(-fVirtualBounds.y+delta); + scrollY(getVerticalBar()); + } + + + protected void scrollSmart(int deltaX, int deltaY) { + if (deltaX != 0 || deltaY != 0) { + Rectangle rect = getBounds(); + scroll (deltaX, deltaY, 0, 0, rect.width, rect.height, false); + } + } + + /** + * @param rect in virtual space + */ + protected void revealRect(Rectangle rect) { + Rectangle visibleRect=getScreenRectInVirtualSpace(); + // scroll the X part + int deltaX=0; + if(rect.x0||marginHeight>0){ + Color bg=getBackground(); + gc.setBackground(getTerminalBackgroundColor()); + if (marginWidth > 0) { + gc.fillRectangle (width, clipping.y, marginWidth, clipping.height); + } + if (marginHeight > 0) { + gc.fillRectangle (clipping.x, height, clipping.width, marginHeight); + } + gc.setBackground(bg); + } + } + /** + * @private + */ + protected boolean inClipping(Rectangle clipping, Rectangle r) { + // TODO check if this is OK in all cases (the <=!) + // + if(r.x+r.width<=clipping.x) + return false; + if(clipping.x+clipping.width<=r.x) + return false; + if(r.y+r.height<=clipping.y) + return false; + if(clipping.y+clipping.height<=r.y) + return false; + + return true; + } + /** + * @return the screen rect in virtual space (starting with (0,0)) + * of the visible screen. (x,y>=0) + */ + protected Rectangle getScreenRectInVirtualSpace() { + Rectangle r= new Rectangle(fClientArea.x-fVirtualBounds.x,fClientArea.y-fVirtualBounds.y,fClientArea.width,fClientArea.height); + return r; + } + /** + * @return the rect in virtual space (starting with (0,0)) + * of the visible screen. (x,y>=0) + */ + protected Rectangle getRectInVirtualSpace(Rectangle r) { + return new Rectangle(r.x-fVirtualBounds.x,r.y-fVirtualBounds.y,r.width,r.height); + } + + /** + * Sets the extent of the virtual display area + * @param width width of the display area + * @param height height of the display area + */ + protected void setVirtualExtend(int width, int height) { + fVirtualBounds.width=width; + fVirtualBounds.height=height; + updateScrollbars(); + updateViewRectangle(); + } + /** + * sets the scrolling origin. Also sets the scrollbars. + * Does NOT redraw! + * Use negative values (move the virtual origin to the top left + * to see something in the screen (which is located at (0,0)) + * @param x + * @param y + */ + protected void setVirtualOrigin(int x, int y) { + if (fVirtualBounds.x != x || fVirtualBounds.y != y) { + fVirtualBounds.x=x; + fVirtualBounds.y=y; + getHorizontalBar().setSelection(-x); + getVerticalBar().setSelection(-y); + updateViewRectangle(); + } + } + protected Rectangle getVirtualBounds() { + return cloneRectangle(fVirtualBounds); + } + /** + * @param x + * @return the virtual coordinate in screen space + */ + protected int virtualXtoScreen(int x) { + return x+fVirtualBounds.x; + } + protected int virtualYtoScreen(int y) { + return y+fVirtualBounds.y; + } + protected int screenXtoVirtual(int x) { + return x-fVirtualBounds.x; + } + protected int screenYtoVirtual(int y) { + return y-fVirtualBounds.y; + } + /** called when the viewed part is changing */ + private final Rectangle fViewRectangle=new Rectangle(0,0,0,0); + protected void updateViewRectangle() { + if( + fViewRectangle.x==-fVirtualBounds.x + && fViewRectangle.y==-fVirtualBounds.y + && fViewRectangle.width==fClientArea.width + && fViewRectangle.height==fClientArea.height + ) + return; + fViewRectangle.x=-fVirtualBounds.x; + fViewRectangle.y=-fVirtualBounds.y; + fViewRectangle.width=fClientArea.width; + fViewRectangle.height=fClientArea.height; + viewRectangleChanged(fViewRectangle.x,fViewRectangle.y,fViewRectangle.width,fViewRectangle.height); + } + protected Rectangle getViewRectangle() { + return cloneRectangle(fViewRectangle); + } + private Rectangle cloneRectangle(Rectangle r) { + return new Rectangle(r.x,r.y,r.width,r.height); + } + /** + * Called when the viewed part has changed. + * Override when you need this information.... + * Is only called if the values change! + * @param x visible in virtual space + * @param y visible in virtual space + * @param width + * @param height + */ + protected void viewRectangleChanged(int x, int y, int width, int height) { + } + /** + * @private + */ + private void updateScrollbars() { + // don't get into infinite loops.... + if(!fInUpdateScrollbars) { + fInUpdateScrollbars=true; + try { + doUpdateScrollbar(); + } finally { + fInUpdateScrollbars=false; + } + } else { + if(!fInUpdateScrollbarsLogged) { + fInUpdateScrollbarsLogged=true; + TerminalPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, + TerminalPlugin.PLUGIN_ID, IStatus.OK, "Unexpected Recursion in terminal", //$NON-NLS-1$ + new RuntimeException())); + } + } + } + private void doUpdateScrollbar() { + Rectangle clientArea= getClientArea(); + ScrollBar horizontal= getHorizontalBar(); + // even if setVisible was called on the scrollbar, isVisible + // returns false if its parent is not visible. + if(!isVisible() || horizontal.isVisible()) { + horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement()); + int max= fVirtualBounds.width; + horizontal.setMaximum(max); + horizontal.setThumb(clientArea.width); + } + ScrollBar vertical= getVerticalBar(); + // even if setVisible was called on the scrollbar, isVisible + // returns false if its parent is not visible. + if(!isVisible() || vertical.isVisible()) { + vertical.setPageIncrement(clientArea.height - vertical.getIncrement()); + int max= fVirtualBounds.height; + vertical.setMaximum(max); + vertical.setThumb(clientArea.height); + } + } + protected boolean isVertialBarVisible() { + return getVerticalBar().isVisible(); + } + protected void serVerticalBarVisible(boolean showVScrollBar) { + ScrollBar vertical= getVerticalBar(); + vertical.setVisible(showVScrollBar); + vertical.setSelection(0); + } + protected boolean isHorizontalBarVisble() { + return getHorizontalBar().isVisible(); + } + protected void setHorizontalBarVisible(boolean showHScrollBar) { + ScrollBar horizontal= getHorizontalBar(); + horizontal.setVisible(showHScrollBar); + horizontal.setSelection(0); + } +} + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java new file mode 100644 index 00000000000..5ce26eec893 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + +/** + * A writable matrix of characters and {@link Style}. This is intended to be the + * low level representation of the text of a Terminal. Higher layers are + * responsible to fill the text and styles into this representation. + *

            + * Note: Implementations of this interface has to be thread safe. + *

            + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface ITerminalTextData extends ITerminalTextDataReadOnly { + + /** + * Sets the dimensions of the data. If the dimensions are smaller than the current + * dimensions, the lines will be chopped. If the dimensions are bigger, then + * the new elements will be filled with 0 chars and null Style. + * @param height + * @param width + */ + void setDimensions(int height, int width); + + void setMaxHeight(int height); + int getMaxHeight(); + + /** + * Set a single character and the associated {@link Style}. + * @param line line must be >=0 and < height + * @param column column must be >=0 and < width + * @param c the new character at this position + * @param style the style or null + */ + void setChar(int line, int column, char c, Style style); + + /** + * Set an array of characters showing in the same {@link Style}. + * @param line line must be >=0 and < height + * @param column column must be >=0 and < width + * @param chars the new characters at this position + * @param style the style or null + */ + void setChars(int line, int column, char[] chars, Style style); + + /** + * Set a subrange of an array of characters showing in the same {@link Style}. + * @param line line must be >=0 and < height + * @param column column must be >=0 and < width + * @param chars the new characters at this position + * @param start the start index in the chars array + * @param len the number of characters to insert. Characters beyond width are not inserted. + * @param style the style or null + */ + void setChars(int line, int column, char[] chars, int start, int len, Style style); + + + /** + * Cleans the entire line. + * @param line + */ + void cleanLine(int line); + + /** + * Shifts some lines up or down. The "empty" space is filled with '\000' chars + * and null {@link Style} + *

            To illustrate shift, here is some sample data: + *

            +	 * 0 aaaa
            +	 * 1 bbbb
            +	 * 2 cccc
            +	 * 3 dddd
            +	 * 4 eeee
            +	 * 
            + * + * Shift a region of 3 lines up by one line shift(1,3,-1) + *
            +	 * 0 aaaa
            +	 * 1 cccc
            +	 * 2 dddd
            +	 * 3
            +	 * 4 eeee
            +	 * 
            + * + * + * Shift a region of 3 lines down by one line shift(1,3,1) + *
            +	 * 0 aaaa
            +	 * 1
            +	 * 2 bbbb
            +	 * 3 cccc
            +	 * 4 eeee
            +	 * 
            + * @param startLine the start line of the shift + * @param size the number of lines to shift + * @param shift how much scrolling is done. New scrolled area is filled with '\000'. + * Negative number means scroll down, positive scroll up (see example above). + */ + void scroll(int startLine, int size, int shift); + + /**Adds a new line to the terminal. If maxHeigth is reached, the entire terminal + * will be scrolled. Else a line will be added. + */ + void addLine(); + /** + * Copies the entire source into this and changes the size accordingly + * @param source + */ + void copy(ITerminalTextData source); + /** + * Copy a sourceLine from source to this at destLine. + * @param source + * @param sourceLine + * @param destLine + */ + void copyLine(ITerminalTextData source,int sourceLine, int destLine); + /** + * Copy length lines from source starting at sourceLine into this starting at + * destLine. + * @param source + * @param sourceStartLine + * @param destStartLine + * @param length + */ + void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine,int length); + + void setCursorLine(int line); + void setCursorColumn(int column); + + /** + * Makes this line a wrapped line which logically continues on next line. + * + * @param line + * @since 3.3 + */ + void setWrappedLine(int line); + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java new file mode 100644 index 00000000000..d7a63ae7e2a --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + +/** + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface ITerminalTextDataReadOnly { + + /** + * @return the width of the terminal + */ + int getWidth(); + + /** + * @return the height of the terminal + */ + int getHeight(); + + /** + * @param line be >=0 and < height + * @param startCol must be >=0 and < width + * @param numberOfCols must be > 0 + * @return a the line segments of the specified range + */ + LineSegment[] getLineSegments(int line, int startCol, int numberOfCols); + + /** + * @param line must be >=0 and < height + * @param column must be >=0 and < width + * @return the character at column,line + */ + char getChar(int line, int column); + + /** + * @param line must be >=0 and < height + * @param column must be >=0 and < width + * @return style at column,line or null + */ + Style getStyle(int line, int column); + + /** + * Creates a new instance of {@link ITerminalTextDataSnapshot} that + * can be used to track changes. Make sure to call {@link ITerminalTextDataSnapshot#detach()} + * if you don't need the snapshots anymore. + *

            Note: A new snapshot is empty and needs a call to {@link ITerminalTextDataSnapshot#updateSnapshot(boolean)} to + * get its initial values. You might want to setup the snapshot to your needs by calling + * {@link ITerminalTextDataSnapshot#setInterestWindow(int, int)}. + *

            + * @return a new instance of {@link ITerminalTextDataSnapshot} that "listens" to changes of + * this. + */ + public ITerminalTextDataSnapshot makeSnapshot(); + + char[] getChars(int line); + Style[] getStyles(int line); + + /** + * @return the line in which the cursor is at the moment + */ + int getCursorLine(); + /** + * @return the column at which the cursor is at the moment + */ + int getCursorColumn(); + + /** + * @param line + * @return true if this line got wrapped, ie. logically continues on next line + * @since 3.3 + */ + boolean isWrappedLine(int line); + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java new file mode 100644 index 00000000000..0d5960a37a9 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java @@ -0,0 +1,226 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + +/** + * This class maintains a snapshot of an instance of {@link ITerminalTextData}. + * While the {@link ITerminalTextData} continues changing, the snapshot remains + * unchanged until the next snapshot is taken by calling + * {@link #updateSnapshot(boolean)}. This is important, because the + * {@link ITerminalTextData} might get modified by another thread. Suppose you + * would want to draw the content of the {@link ITerminalTextData} using the + * following loop: + * + *
            + * for (int line = 0; line < term.getHeight(); line++)
            + * 	for (int column = 0; column < term.getWidth(); column++)
            + * 		drawCharacter(column, line, term.getChar(column, line), term.getStyle(column, line));
            + * 
            + * + * This might fail because the background thread could change the dimensions of + * the {@link ITerminalTextData} while you iterate the loop. One solution would + * be to put a synchronized(term){} statement around the code. This + * has two problems: 1. you would have to know about the internals of the + * synchronisation of {@link ITerminalTextData}. 2. The other thread that + * changes {@link ITerminalTextData} is blocked while the potentially slow + * drawing is done. + *

            + * Solution: Take a snapshot of the terminal and use the snapshot to draw + * the content. There is no danger that the data structure get changed while you + * draw. There are also methods to find out what has changed to minimize the + * number of lines that get redrawn. + *

            + * + *

            + * Drawing optimization: To optimize redrawing of changed lines, this + * class keeps track of lines that have changed since the previous snapshot. + *

            + * + *
            + * // iterate over the potentially changed lines
            + * for (int line = snap.getFirstChangedLine(); line <= snap.getLastChangedLine(); line++)
            + * 	// redraw only if the line has changed
            + * 	if (snap.hasLineChanged(line))
            + * 		for (int column = 0; column < snap.getWidth(); column++)
            + * 			drawCharacter(column, line, snap.getChar(column, line), snap.getStyle(column, line));
            + * 
            + * + *

            + * Scroll optimization: Often new lines are appended at the bottom of the + * terminal and the rest of the lines are scrolled up. In this case all lines + * would be marked as changed. To optimize for this case, + * {@link #updateSnapshot(boolean)} can be called with true for the + * detectScrolling parameter. The object will keep track of + * scrolling. The UI must first handle the scrolling and then use the + * {@link #hasLineChanged(int)} method to determine scrolling: + * + *

            + * // scroll the visible region of the UI <b>before</b> drawing the changed lines.
            + * doUIScrolling(snap.getScrollChangeY(), snap.getScrollChangeN(), snap.getScrollChangeShift());
            + * // iterate over the potentially changed lines
            + * for (int line = snap.getFirstChangedLine(); line <= snap.getFirstChangedLine(); line++)
            + * 	// redraw only if the line has changed
            + * 	if (snap.hasLineChanged(line))
            + * 		for (int column = 0; column < snap.getWidth(); column++)
            + * 			drawCharacter(column, line, snap.getChar(column, line), snap.getStyle(column, line));
            + * 
            + * + *

            + *

            + * Threading Note: This class is not thread safe! All methods have to be + * called by the a same thread, that created the instance by calling + * {@link ITerminalTextDataReadOnly#makeSnapshot()}. + *

            + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly { + /** + * This listener gets called when the current snapshot + * is out of date. Calling {@link ITerminalTextDataSnapshot#updateSnapshot(boolean)} + * will have an effect. Once the {@link #snapshotOutOfDate(ITerminalTextDataSnapshot)} method is called, + * it will not be called until {@link ITerminalTextDataSnapshot#updateSnapshot(boolean)} + * is called and a new snapshot needs to be updated again. + *

            + * A typical terminal view would not update the snapshot immediately + * after the {@link #snapshotOutOfDate(ITerminalTextDataSnapshot)} has been called. It would introduce a + * delay to update the UI (and the snapshot} 10 or 20 times per second. + * + *

            Make sure you don't spend too much time in this method. + */ + interface SnapshotOutOfDateListener { + /** + * Gets called when the snapshot is out of date. To get the snapshot up to date, + * call {@link ITerminalTextDataSnapshot#updateSnapshot(boolean)}. + * @param snapshot The snapshot that is out of date + */ + void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot); + } + void addListener(SnapshotOutOfDateListener listener); + void removeListener(SnapshotOutOfDateListener listener); + + /** + * Ends the listening to the {@link ITerminalTextData}. After this + * has been called no new snapshot data is collected. + */ + void detach(); + /** + * @return true if the data has changed since the previous snapshot. + */ + boolean isOutOfDate(); + + /** + * The window of interest is the region the snapshot should track. + * Changes outside this region are ignored. The change takes effect after + * an update! + * @param startLine -1 means track the end of the data + * @param size number of lines to track. A size of -1 means track all. + */ + void setInterestWindow(int startLine, int size); + int getInterestWindowStartLine(); + int getInterestWindowSize(); + + /** + * Create a new snapshot of the {@link ITerminalTextData}. It will efficiently + * copy the data of the {@link ITerminalTextData} into an internal representation. + * The snapshot also keeps track of the changes since the previous snapshot. + *

            With the methods {@link #getFirstChangedLine()}, {@link #getLastChangedLine()} and + * {@link #hasLineChanged(int)} + * you can find out what has changed in the current snapshot since the previous snapshot. + * @param detectScrolling if true the snapshot tries to identify scroll + * changes since the last snapshot. In this case the information about scrolling + * can be retrieved using the following methods: + * {@link #getScrollWindowStartLine()}, {@link #getScrollWindowSize()} and {@link #getScrollWindowShift()} + *
            Note: The method {@link #hasLineChanged(int)} returns changes after the + * scrolling has been applied. + */ + void updateSnapshot(boolean detectScrolling); + + /** + * @return The first line changed in this snapshot compared + * to the previous snapshot. + * + *

            Note: If no line has changed, this + * returns {@link Integer#MAX_VALUE} + * + *

            Note: if {@link #updateSnapshot(boolean)} has been called with true, + * then this does not include lines that only have been scrolled. This is the + * first line that has changed after the scroll has been applied. + */ + int getFirstChangedLine(); + + /** + * @return The last line changed in this snapshot compared + * to the previous snapshot. If the height has changed since the + * last update of the snapshot, then the returned value is within + * the new dimensions. + * + *

            Note: If no line has changed, this returns -1 + * + *

            Note: if {@link #updateSnapshot(boolean)} has been called with true, + * then this does not include lines that only have been scrolled. This is the + * last line that has changed after the scroll has been applied. + * + *

            A typical for loop using this method would look like this (note the <= in the for loop): + *

            +	 * for(int line=snap.{@link #getFirstChangedLine()}; line <= snap.getLastChangedLine(); line++)
            +	 *    if(snap.{@link #hasLineChanged(int) hasLineChanged(line)})
            +	 *       doSomething(line);
            +	 * 
            + */ + int getLastChangedLine(); + + /** + * @param line + * @return true if the line has changed since the previous snapshot + */ + boolean hasLineChanged(int line); + + boolean hasDimensionsChanged(); + + /** + * @return true if the terminal has changed (and not just the + * window of interest) + */ + boolean hasTerminalChanged(); + /** + * If {@link #updateSnapshot(boolean)} was called with true, then this method + * returns the top of the scroll region. + * @return The first line scrolled in this snapshot compared + * to the previous snapshot. See also {@link ITerminalTextData#scroll(int, int, int)}. + */ + int getScrollWindowStartLine(); + + /** + * If {@link #updateSnapshot(boolean)} was called with true, then this method + * returns the size of the scroll region. + * @return The number of lines scrolled in this snapshot compared + * to the previous snapshot. See also {@link ITerminalTextData#scroll(int, int, int)} + * If nothing has changed, 0 is returned. + */ + int getScrollWindowSize(); + + /** + * If {@link #updateSnapshot(boolean)} was called with true, then this method + * returns number of lines moved by the scroll region. + * @return The the scroll shift of this snapshot compared + * to the previous snapshot. See also {@link ITerminalTextData#scroll(int, int, int)} + */ + int getScrollWindowShift(); + + /** + * @return The {@link ITerminalTextData} on that this instance is observing. + */ + ITerminalTextData getTerminalTextData(); + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java new file mode 100644 index 00000000000..3f153dd97fe --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + + +public class LineSegment { + private final String fText; + private final int fCol; + private final Style fStyle; + public LineSegment(int col, String text, Style style) { + fCol = col; + fText = text; + fStyle = style; + } + public Style getStyle() { + return fStyle; + } + public String getText() { + return fText; + } + public int getColumn() { + return fCol; + } + public String toString() { + return "LineSegment("+fCol+", \""+fText+"\","+fStyle+")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + } +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java new file mode 100644 index 00000000000..001ad6896f1 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author scharf + * Flyweight + * Threadsafe. + * + */ +// TODO add an Object for user data, use weak map to keep track of styles with associated +// user data +public class Style { + private final StyleColor fForground; + private final StyleColor fBackground; + private final boolean fBold; + private final boolean fBlink; + private final boolean fUnderline; + private final boolean fReverse; + private final static Map fgStyles=new HashMap(); + private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, boolean reverse) { + fForground = forground; + fBackground = background; + fBold = bold; + fBlink = blink; + fUnderline = underline; + 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); + Style cached; + synchronized (fgStyles) { + cached=fgStyles.get(style); + if(cached==null) { + cached=style; + fgStyles.put(cached, cached); + } + } + return cached; + } + public static Style getStyle(String forground, String background) { + return getStyle(StyleColor.getStyleColor(forground), StyleColor.getStyleColor(background),false,false,false,false); + } + public static Style getStyle(StyleColor forground, StyleColor background) { + return getStyle(forground, background,false,false,false,false); + } + public Style setForground(StyleColor forground) { + return getStyle(forground,fBackground,fBold,fBlink,fUnderline,fReverse); + } + public Style setBackground(StyleColor background) { + return getStyle(fForground,background,fBold,fBlink,fUnderline,fReverse); + } + public Style setForground(String colorName) { + return getStyle(StyleColor.getStyleColor(colorName),fBackground,fBold,fBlink,fUnderline,fReverse); + } + public Style setBackground(String colorName) { + return getStyle(fForground,StyleColor.getStyleColor(colorName),fBold,fBlink,fUnderline,fReverse); + } + public Style setBold(boolean bold) { + return getStyle(fForground,fBackground,bold,fBlink,fUnderline,fReverse); + } + public Style setBlink(boolean blink) { + return getStyle(fForground,fBackground,fBold,blink,fUnderline,fReverse); + } + public Style setUnderline(boolean underline) { + return getStyle(fForground,fBackground,fBold,fBlink,underline,fReverse); + } + public Style setReverse(boolean reverse) { + return getStyle(fForground,fBackground,fBold,fBlink,fUnderline,reverse); + } + public StyleColor getBackground() { + return fBackground; + } + public boolean isBlink() { + return fBlink; + } + public boolean isBold() { + return fBold; + } + public StyleColor getForground() { + return fForground; + } + public boolean isReverse() { + return fReverse; + } + public boolean isUnderline() { + return fUnderline; + } + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fBackground == null) ? 0 : fBackground.hashCode()); + result = prime * result + (fBlink ? 1231 : 1237); + result = prime * result + (fBold ? 1231 : 1237); + result = prime * result + ((fForground == null) ? 0 : fForground.hashCode()); + result = prime * result + (fReverse ? 1231 : 1237); + result = prime * result + (fUnderline ? 1231 : 1237); + return result; + } + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Style other = (Style) obj; + // background == is the same as equals + if (fBackground != other.fBackground) + return false; + if (fBlink != other.fBlink) + return false; + if (fBold != other.fBold) + return false; + if (fForground != other.fForground) + return false; + if (fReverse != other.fReverse) + return false; + if (fUnderline != other.fUnderline) + return false; + return true; + } + public String toString() { + StringBuffer result=new StringBuffer(); + result.append("Style(foreground="); //$NON-NLS-1$ + result.append(fForground); + result.append(", background="); //$NON-NLS-1$ + result.append(fBackground); + if(fBlink) + result.append(", blink"); //$NON-NLS-1$ + if(fBold) + result.append(", bold"); //$NON-NLS-1$ + if(fBlink) + result.append(", blink"); //$NON-NLS-1$ + if(fReverse) + result.append(", reverse"); //$NON-NLS-1$ + if(fUnderline) + result.append(", underline"); //$NON-NLS-1$ + result.append(")"); //$NON-NLS-1$ + return result.toString(); + } + +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java new file mode 100644 index 00000000000..98b19ad02ad --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + +import java.util.HashMap; +import java.util.Map; + +/** + * + * Flyweight + * Threadsafe. + */ +public class StyleColor { + private final static Map fgStyleColors=new HashMap(); + final String fName; + + /** + * @param name the name of the color. It is up to the UI to associate a + * named color with a visual representation + * @return a StyleColor + */ + public static StyleColor getStyleColor(String name) { + StyleColor result; + synchronized (fgStyleColors) { + result=fgStyleColors.get(name); + if(result==null) { + result=new StyleColor(name); + fgStyleColors.put(name, result); + } + } + return result; + } + // nobody except the factory method is allowed to instantiate this class! + private StyleColor(String name) { + fName = name; + } + + public String getName() { + return fName; + } + + public String toString() { + return fName; + } + // no need to override equals and hashCode, because Object uses object identity +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java new file mode 100644 index 00000000000..364f810e2cb --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michael Scharf (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.terminal.model; + +import org.eclipse.tm.internal.terminal.model.SynchronizedTerminalTextData; +import org.eclipse.tm.internal.terminal.model.TerminalTextData; + +public class TerminalTextDataFactory { + static public ITerminalTextData makeTerminalTextData() { + return new SynchronizedTerminalTextData(new TerminalTextData()); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/tm32.png b/terminal/plugins/org.eclipse.tm.terminal.control/tm32.png new file mode 100644 index 0000000000000000000000000000000000000000..668b05b79135152cc0d518da0873c4426bed32e6 GIT binary patch literal 1349 zcmV-L1-kl)P)`(46b=_T=mH%KWS%@{pgd=vJ7=FgXrav5 z=lZ;J_mm#YqHa@FRS^##9T+$&AW$qKRV!Vab%B_9g`0SUnsR`cGGd?n*Q)BKRdH=* zCm%~IT%2)zmCx<_bAOlHt8g|qJ0Kc8EnuW(bB>3Xz zvVIpB8zmh^E+bepDP=h=Z!cu3U~h|JagFM&V=yLOJTP@cHia-}uv=<}c8IrXe5_t^ zp+;JaUTlf~`0;UUWgr?pH!EsFG=MT|wpC?>SZ9X5pnDP!AUG^+Kr(wYZoE`vgHlvg zC?HKWDP=w|b~bRnPiBlzWs6T|jX-$7+_8Qb6fG_!SUfIrJT7rJY`HgXx;JgOHf^{z zXt9Qnq58IEmy3dRa)r&x*6{E1{rvs>{QUFs^|P?RNk~;&Tw{-mpvJ?|%E;Bt%Gt}v z*2u-vsinFzGC=vSRzE*TEhASjC0t=)ZJL&@wzI{G&DYm zgn@i`jnmQGwX?!YOI6#pi!CWbO+;{7QF>ifeO^|6Usrx#SASnteqL66TvU8uSAShp zd|Fa^Qc83?HCL6Dn)#?mKtV?-AWt70FYfN{zNU#46Dc7ZKY@aSBO5~|C@k;q?Ec=+fsy0l=Qitw%5m#wuR!2QnMD=6}uDk^^0FPmr~fg4sg5%S6^Di_aR)j|a( z*RCMTUvk&N0GFXE41wmK$0Dz#C3yiPA1R_DoPGwIyq4zKa}WzooYcY&PMroCprUg4 z$Wa^$w2mDI`Eb+bEnBy3+rDGRj-5Mp?cTO$&z@~N_U_%Wd*A*82M;k+tEjA9w_XZ6 zXxgxm0qDf#D^{-RzzSBaUc;cG(zh6B*^;H0U;oVoKFu-Y(x!NNsA1}^zkQMzvqb6ixf{8%!LXaa{+uA!iIx#_4M|V#z$eT5_b@f;s(b&}7 z0t%>tLZDei#b8iUQc^4>RayoFV|Oag^_ zatahkrKXufK|(4dx}%~&Dq>XY+8lDKGY;4W#>>V7PoTXfBpvh81 z#mHD4mh7cW&0r>2n8GrSvWkeRn!1K2Sb?^Vt{w#F8zAzQkg$lTn79Nm=SfM+$jZqp zD9FpnDJmi7FE(}#PDtkE;^yJy Date: Tue, 28 Aug 2018 20:48:51 -0400 Subject: [PATCH 02/76] add intermediate poms in terminal/plugins and terminal/features; upversion everything to 4.5.0 and fix plugin deps to use new version; fix versions of dstore plugins Change-Id: Ic5dd336a22e822e848b9fe63f02029c24bd0bf08 Signed-off-by: nickboldt --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- terminal/plugins/org.eclipse.tm.terminal.control/pom.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index c1d11b97017..cb0771d4146 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.4.0.qualifier +Bundle-Version: 4.5.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml index 566656faba0..4acc845b9a7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml @@ -7,11 +7,10 @@ org.eclipse.tm.terminal org.eclipse.tm.terminal.maven-build - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../admin/pom-build.xml - 4.4.0-SNAPSHOT org.eclipse.tm.terminal.control eclipse-plugin From 55f7e14cf90a72ee8128f11f50de92e076a2f204 Mon Sep 17 00:00:00 2001 From: nickboldt Date: Tue, 25 Sep 2018 14:01:32 -0400 Subject: [PATCH 03/76] bump up to 4.5.1 since we no longer support 32-bit (breaking change) part 2 Change-Id: Ifa14f8b829bf1859e36ffce719e6cfac14012236 Signed-off-by: nickboldt --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- terminal/plugins/org.eclipse.tm.terminal.control/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index cb0771d4146..921c9290268 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.5.0.qualifier +Bundle-Version: 4.5.1.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml index 4acc845b9a7..5594ac0a8d2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml @@ -7,7 +7,7 @@ org.eclipse.tm.terminal org.eclipse.tm.terminal.maven-build - 4.5.0-SNAPSHOT + 4.5.1-SNAPSHOT ../../admin/pom-build.xml From 6c2b2e9c26f747ff9b02eec45a842bedf9071808 Mon Sep 17 00:00:00 2001 From: nickboldt Date: Thu, 1 Nov 2018 12:21:58 -0400 Subject: [PATCH 04/76] Bug 538094 - update to EPL 2.0 (leave EDL 1.0 unchanged) Change-Id: I5ef20c1c81c17896e3c73ae0aa8c6cf47a708016 Signed-off-by: nickboldt --- .../org.eclipse.tm.terminal.control/HelpContexts.xml | 6 +++--- .../plugins/org.eclipse.tm.terminal.control/about.html | 4 ++-- .../org.eclipse.tm.terminal.control/about.properties | 4 ++-- .../org.eclipse.tm.terminal.control/build.properties | 8 +++++--- .../css/org.eclipse.tm.terminal.stylesheet.dark.css | 4 ++-- .../org.eclipse.tm.terminal.control/plugin.properties | 8 +++++--- .../plugins/org.eclipse.tm.terminal.control/plugin.xml | 8 +++++--- .../plugins/org.eclipse.tm.terminal.control/pom.xml | 10 ++++++++++ .../schema/connectors.exsd | 6 +++--- .../internal/terminal/connector/TerminalConnector.java | 8 +++++--- .../TerminalToRemoteInjectionOutputStream.java | 8 +++++--- .../terminal/control/CommandInputFieldWithHistory.java | 8 +++++--- .../internal/terminal/control/ICommandInputField.java | 6 +++--- .../internal/terminal/control/ITerminalListener.java | 8 +++++--- .../internal/terminal/control/ITerminalListener2.java | 8 +++++--- .../terminal/control/ITerminalMouseListener.java | 8 +++++--- .../terminal/control/ITerminalViewControl.java | 8 +++++--- .../terminal/control/TerminalViewControlFactory.java | 6 +++--- .../control/actions/AbstractTerminalAction.java | 8 +++++--- .../terminal/control/actions/ActionMessages.java | 8 +++++--- .../terminal/control/actions/ActionMessages.properties | 8 +++++--- .../internal/terminal/control/actions/ImageConsts.java | 8 +++++--- .../control/actions/TerminalActionClearAll.java | 8 +++++--- .../terminal/control/actions/TerminalActionCopy.java | 8 +++++--- .../terminal/control/actions/TerminalActionCut.java | 8 +++++--- .../terminal/control/actions/TerminalActionPaste.java | 8 +++++--- .../control/actions/TerminalActionSelectAll.java | 8 +++++--- .../terminal/control/impl/ITerminalControlForText.java | 6 +++--- .../terminal/control/impl/TerminalMessages.java | 6 +++--- .../terminal/control/impl/TerminalMessages.properties | 8 +++++--- .../internal/terminal/control/impl/TerminalPlugin.java | 8 +++++--- .../terminal/emulator/EditActionAccelerators.java | 8 +++++--- .../terminal/emulator/IVT100EmulatorBackend.java | 6 +++--- .../terminal/emulator/LoggingOutputStream.java | 6 +++--- .../terminal/emulator/VT100BackendTraceDecorator.java | 6 +++--- .../tm/internal/terminal/emulator/VT100Emulator.java | 8 +++++--- .../terminal/emulator/VT100EmulatorBackend.java | 6 +++--- .../terminal/emulator/VT100TerminalControl.java | 8 +++++--- .../tm/internal/terminal/model/ISnapshotChanges.java | 8 +++++--- .../tm/internal/terminal/model/SnapshotChanges.java | 8 +++++--- .../terminal/model/SynchronizedTerminalTextData.java | 6 +++--- .../tm/internal/terminal/model/TerminalTextData.java | 8 +++++--- .../terminal/model/TerminalTextDataFastScroll.java | 6 +++--- .../terminal/model/TerminalTextDataSnapshot.java | 6 +++--- .../internal/terminal/model/TerminalTextDataStore.java | 6 +++--- .../terminal/model/TerminalTextDataWindow.java | 6 +++--- .../terminal/preferences/ITerminalConstants.java | 8 +++++--- .../preferences/TerminalPreferenceInitializer.java | 8 +++++--- .../terminal/preferences/TerminalPreferencePage.java | 8 +++++--- .../terminal/provisional/api/AbstractSettingsPage.java | 8 +++++--- .../terminal/provisional/api/ISettingsPage.java | 8 +++++--- .../terminal/provisional/api/ISettingsStore.java | 6 +++--- .../terminal/provisional/api/ITerminalConnector.java | 8 +++++--- .../terminal/provisional/api/ITerminalControl.java | 8 +++++--- .../tm/internal/terminal/provisional/api/Logger.java | 8 +++++--- .../terminal/provisional/api/NullSettingsStore.java | 8 +++++--- .../provisional/api/TerminalConnectorExtension.java | 8 +++++--- .../terminal/provisional/api/TerminalState.java | 8 +++++--- .../api/provider/TerminalConnectorImpl.java | 8 +++++--- .../terminal/textcanvas/AbstractTextCanvasModel.java | 8 +++++--- .../tm/internal/terminal/textcanvas/GridCanvas.java | 6 +++--- .../internal/terminal/textcanvas/ILinelRenderer.java | 8 +++++--- .../internal/terminal/textcanvas/ITextCanvasModel.java | 8 +++++--- .../terminal/textcanvas/ITextCanvasModelListener.java | 8 +++++--- .../internal/terminal/textcanvas/PipedInputStream.java | 4 ++-- .../terminal/textcanvas/PollingTextCanvasModel.java | 6 +++--- .../tm/internal/terminal/textcanvas/StyleMap.java | 8 +++++--- .../tm/internal/terminal/textcanvas/TextCanvas.java | 8 +++++--- .../internal/terminal/textcanvas/TextLineRenderer.java | 8 +++++--- .../tm/internal/terminal/textcanvas/VirtualCanvas.java | 6 +++--- .../eclipse/tm/terminal/model/ITerminalTextData.java | 8 +++++--- .../tm/terminal/model/ITerminalTextDataReadOnly.java | 8 +++++--- .../tm/terminal/model/ITerminalTextDataSnapshot.java | 8 +++++--- .../src/org/eclipse/tm/terminal/model/LineSegment.java | 6 +++--- .../src/org/eclipse/tm/terminal/model/Style.java | 6 +++--- .../src/org/eclipse/tm/terminal/model/StyleColor.java | 6 +++--- .../tm/terminal/model/TerminalTextDataFactory.java | 6 +++--- 77 files changed, 332 insertions(+), 224 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml b/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml index 761da672632..2bde74230c5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/HelpContexts.xml @@ -1,11 +1,11 @@ + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd b/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd index 58681ba9028..8a0862cf413 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd +++ b/terminal/plugins/org.eclipse.tm.terminal.control/schema/connectors.exsd @@ -95,11 +95,11 @@ - Copyright (c) 2006 - 2015 Wind River Systems, Inc. and others. + Copyright (c) 2006 - 2018 Wind River Systems, Inc. and others. All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 +are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at -http://www.eclipse.org/legal/epl-v10.html +https://www.eclipse.org/legal/epl-2.0/ Contributors: Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java index cfbdabe8c88..dfa2f8faf91 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java index 7db522edc4c..362306a4fb1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2008, 2017 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java index ffcdc4a4934..0034ea648ba 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java index a65a61c5170..2e31750195f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java index 587abfd8162..62d548c29a0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java index 76bc56d1cf4..1166a99c929 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java @@ -1,8 +1,10 @@ /******************************************************************************* - * Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015, 2018 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html + * of the Eclipse Public License 2.0 which accompanies this distribution, and is + * available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Wind River Systems - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java index d72c26c9a84..1e07fb20069 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java @@ -1,8 +1,10 @@ /******************************************************************************* - * Copyright (c) 2015 CWI. All rights reserved. + * Copyright (c) 2015, 2018 CWI. All rights reserved. * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html + * of the Eclipse Public License 2.0 which accompanies this distribution, and is + * available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Davy Landman (CWI) - [475267][api] Initial definition of interface diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index 904897c3df9..08706167229 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java index 9ccbdaa37eb..42717a45731 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java index 08561b872eb..218044a07aa 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java index ddcc65bbfb3..80baa8a81fe 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties index 558ab80213d..ffc7d452c3a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties @@ -1,9 +1,11 @@ ############################################################################### -# Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. # All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 +# are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 # # Initial Contributors: # The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java index eda9eff1f19..e44e7dfaa27 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java index 85650f6e504..eb0e91ce181 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java index 49260c160c3..375accd6c0b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java index 63532bdeb1e..d35479dd174 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java index ca1011c3be2..af13acb3964 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java index a91ec1cb9b0..b2f0057e3d3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java index f15468023e7..0bbd0096fbb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java index 137d67acee6..56b3d1b3511 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties index dd249e27d29..93ee9767472 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties @@ -1,9 +1,11 @@ ############################################################################### -# Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. # All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 +# are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 # # Initial Contributors: # The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java index de791f818d1..c566aaf61c6 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java index e95d69e86e2..6f5f5f2966f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2013, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java index aff90891b6a..b47b8edd5af 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java index 20c176f30a0..e291b9e5345 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java index 78531437ee6..92d357f80d2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 5e6817a0979..cc3b76424c9 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index a6ea4e5d23b..0332edacc01 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index b5d62b5ded9..366a9963e7d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java index 184b63b4e14..b7c71eb9efa 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java index 222cc8858cf..0c62f59f091 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java index dedac098a39..8c3eee1708e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse synchronized public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java index a361d0adef5..89a5dc578d8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java index 92021783376..e175cd7182c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java index 9d9924b533b..1f64cc7cafb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java index 9817087942b..280a28d7cdf 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java index 52f351a7252..0e7eba4b4f2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java index 907c79d095f..b9980eec90b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java index 920d5e4cf6e..431dd902d3b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java index 89a2c8f8df1..7bb452c5855 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Initial Contributors: * The following Wind River employees contributed to the Terminal component diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java index 501f45fb430..673716e8267 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java @@ -1,8 +1,10 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2018 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html + * of the Eclipse Public License 2.0 which accompanies this distribution, and is + * available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Wind River Systems - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java index a00d71d24d1..33e895a0578 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsPage.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java index b7dd8592922..7346453b4cc 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java index 242726e785e..244fb9ab7fb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java index 79b3cb829e5..ac133ffdb5c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index 437935f3959..25f3c6649ac 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2005, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Fran Litterio (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java index e86f157f6c1..16e6432f826 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java @@ -1,8 +1,10 @@ /******************************************************************************* - * Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015, 2018 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html + * of the Eclipse Public License 2.0 which accompanies this distribution, and is + * available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Wind River Systems - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java index fe494bc0da7..6eea871b388 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java index 14051ae2114..9425cbf7eaf 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java index a358335508e..7b22cc3cdb7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java index f57b8277b8d..c6035b38eb4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java index 40ab4bf1ca4..dc5d4c56993 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java index e03946b79b5..9666fd9a910 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java index e56b51aa88d..0fbba76959c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java index 4e09027ac48..bc942890baa 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java index f0e11324a2d..4c00d995454 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java @@ -1,9 +1,9 @@ /******************************************************************************* * Copyright (c) 1996, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java index b54fdf643f8..4d0a6581cc3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index 81e63e27ed5..5d4e91a7a0f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index a98fc50cad2..2161798bf26 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 46497f42ede..134db6d92a5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java index 9d479c72954..c307ee184e2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java index 5ce26eec893..83e5e9568e1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java index d7a63ae7e2a..21a4870caaf 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java index 0d5960a37a9..47c7ee4cb57 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java @@ -1,9 +1,11 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java index 3f153dd97fe..7381d0e6439 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java index 001ad6896f1..fa7be137653 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java index 98b19ad02ad..10e1ed55096 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java index 364f810e2cb..2877c4d0631 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation From a0141537696908120b765337cc7b9aedc4cacf4c Mon Sep 17 00:00:00 2001 From: nickboldt Date: Thu, 31 Jan 2019 18:04:08 -0500 Subject: [PATCH 05/76] upversion to .100 as now based on Eclipse 4.11 Change-Id: I99acb204f490355d91a4de3f4233329246a0b9d0 Signed-off-by: nickboldt --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- terminal/plugins/org.eclipse.tm.terminal.control/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 921c9290268..3b24cbe1d7a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.5.1.qualifier +Bundle-Version: 4.5.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml index bb852596b7d..826e4b51bf4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml @@ -17,7 +17,7 @@ org.eclipse.tm.terminal org.eclipse.tm.terminal.maven-build - 4.5.1-SNAPSHOT + 4.5.100-SNAPSHOT ../../admin/pom-build.xml From 3aa1b023ebc3f276ea25a6a227fcaab2bc86a65b Mon Sep 17 00:00:00 2001 From: Julien Dehaudt Date: Wed, 17 Jul 2019 11:21:08 +0200 Subject: [PATCH 06/76] Bug 549013 - Eclipse menu won't display on Ubuntu 16.04 LTS when SSH/Serial command shells are opened Buglink: https://bugs.eclipse.org/bugs/show_bug.cgi?id=549013 Signed-off-by: Julien Dehaudt --- .../emulator/VT100TerminalControl.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 366a9963e7d..9f07dc37036 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -74,13 +74,12 @@ import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -143,7 +142,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private KeyListener fKeyHandler; private final ITerminalListener fTerminalListener; private String fMsg = ""; //$NON-NLS-1$ - private TerminalFocusListener fFocusListener; + private TerminalMouseTrackListener fFocusListener; private ITerminalConnector fConnector; private final ITerminalConnector[] fConnectors; private final boolean fUseCommonPrefs; @@ -793,10 +792,10 @@ public void mouseUp(MouseEvent e) { protected void setupListeners() { fKeyHandler = new TerminalKeyHandler(); - fFocusListener = new TerminalFocusListener(); + fFocusListener = new TerminalMouseTrackListener(); getCtlText().addKeyListener(fKeyHandler); - getCtlText().addFocusListener(fFocusListener); + getCtlText().addMouseTrackListener(fFocusListener); } @@ -878,17 +877,21 @@ protected TextCanvas getCtlText() { public VT100Emulator getTerminalText() { return fTerminalText; } - protected class TerminalFocusListener implements FocusListener { + protected class TerminalMouseTrackListener implements MouseTrackListener { private IContextActivation terminalContextActivation = null; private IContextActivation editContextActivation = null; - protected TerminalFocusListener() { + protected TerminalMouseTrackListener() { super(); } @Override - @SuppressWarnings("cast") - public void focusGained(FocusEvent event) { + public void mouseHover(MouseEvent e) { + } + + @Override + @SuppressWarnings("cast") + public void mouseEnter(MouseEvent e) { // Disable all keyboard accelerators (e.g., Control-B) so the Terminal view // can see every keystroke. Without this, Emacs, vi, and Bash are unusable // in the Terminal view. @@ -900,8 +903,8 @@ public void focusGained(FocusEvent event) { } @Override - @SuppressWarnings("cast") - public void focusLost(FocusEvent event) { + @SuppressWarnings("cast") + public void mouseExit(MouseEvent e) { // Enable all keybindings. captureKeyEvents(false); From 07d012485c34b96db1417e8ee1444cb6ba1fee38 Mon Sep 17 00:00:00 2001 From: nickboldt Date: Wed, 17 Jul 2019 07:53:45 -0400 Subject: [PATCH 07/76] bump to 4.5.102-SNAPSHOT Change-Id: I12c461c9d05241629442ae84ea1c2f439a23039d Signed-off-by: nickboldt --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- terminal/plugins/org.eclipse.tm.terminal.control/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 3b24cbe1d7a..5150cac4ff8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.5.100.qualifier +Bundle-Version: 4.5.102.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml index 826e4b51bf4..b0e7c9b32ee 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml @@ -17,7 +17,7 @@ org.eclipse.tm.terminal org.eclipse.tm.terminal.maven-build - 4.5.100-SNAPSHOT + 4.5.102-SNAPSHOT ../../admin/pom-build.xml From 7dd52f08b16573ba11e53e25978c911641b1c983 Mon Sep 17 00:00:00 2001 From: nickboldt Date: Wed, 17 Jul 2019 08:09:50 -0400 Subject: [PATCH 08/76] bump to 4.5.102-SNAPSHOT Change-Id: I1481ac53d6bd5a0c66eced40acfa77a51c3c73f4 Signed-off-by: nickboldt --- terminal/plugins/org.eclipse.tm.terminal.control/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml index b0e7c9b32ee..a0de87da146 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml @@ -17,9 +17,10 @@ org.eclipse.tm.terminal org.eclipse.tm.terminal.maven-build - 4.5.102-SNAPSHOT + 4.5.100-SNAPSHOT ../../admin/pom-build.xml + 4.5.102-SNAPSHOT org.eclipse.tm.terminal.control eclipse-plugin From 3922a55cc1449e7c4b0c6a96ab3e5a28c0f172aa Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 31 Jan 2020 10:29:05 -0500 Subject: [PATCH 09/76] Bug 559474: Integrate tm.terminal into CDT's releng Change-Id: I46db42560ec0b93bb265f45920d78c97a32338c3 --- .../org.eclipse.tm.terminal.control/pom.xml | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/pom.xml diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml deleted file mode 100644 index a0de87da146..00000000000 --- a/terminal/plugins/org.eclipse.tm.terminal.control/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - 4.0.0 - - - org.eclipse.tm.terminal - org.eclipse.tm.terminal.maven-build - 4.5.100-SNAPSHOT - ../../admin/pom-build.xml - - 4.5.102-SNAPSHOT - - org.eclipse.tm.terminal.control - eclipse-plugin - From 7bfeb96298949711f71ddd74ab73646327dafc70 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 31 Jan 2020 10:38:39 -0500 Subject: [PATCH 10/76] Bug 559474: Normalize features to match requirements of CDT Change-Id: I274a6e5f985d60d1ae6fc929af3eb0fdcea868ba --- .../org.eclipse.tm.terminal.control/about.ini | 9 ++--- .../about.mappings | 9 +++++ .../about.properties | 38 +++++++++++------- .../build.properties | 5 ++- .../cdt_logo_icon32.png | Bin 0 -> 1885 bytes .../org.eclipse.tm.terminal.control/tm32.png | Bin 1349 -> 0 bytes 6 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/about.mappings create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/cdt_logo_icon32.png delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/tm32.png diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.ini b/terminal/plugins/org.eclipse.tm.terminal.control/about.ini index 3adc27ab587..e07a7bb377e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.ini +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.ini @@ -11,17 +11,14 @@ aboutText=%blurb # needed for primary features only # Property "featureImage" contains path to feature image (32x32) -featureImage=tm32.png +featureImage=cdt_logo_icon32.png # Property "aboutImage" contains path to product image (500x330 or 115x164) # needed for primary features only -# Property "appName" contains name of the application (not translated) +# Property "appName" contains name of the application (translated) # needed for primary features only -# Property "welcomePage" contains path to welcome page (special XML-based format) -# optional - # Property "welcomePerspective" contains the id of the perspective in which the # welcome page is to be opened. -# optional \ No newline at end of file +# optional diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.mappings b/terminal/plugins/org.eclipse.tm.terminal.control/about.mappings new file mode 100644 index 00000000000..936a8039c3e --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.mappings @@ -0,0 +1,9 @@ +# about.mappings +# contains fill-ins for about.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. + +# The following should contain the build version. +# e.g. "0=20200106-1728" +# This value will be added automatically via the build scripts +0=${buildId} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties index 55d889e964e..e6e6518939a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -1,24 +1,32 @@ -################################################################################ -# Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 2.0 -# which accompanies this distribution, and is available at -# https://www.eclipse.org/legal/epl-2.0/ -# -# Contributors: -# Martin Oberhuber - initial API and implementation -################################################################################ +############################################################################### +# Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### # about.properties # contains externalized strings for about.ini # java.io.Properties file (ISO 8859-1 with "\" escapes) # fill-ins are supplied by about.mappings # This file should be translated. -# -# Do not translate any values surrounded by {} +# NOTE TO TRANSLATOR: Please do not translate the featureVersion variable. -blurb=Target Management Terminal Widget\n\ + +blurb=TM Terminal Control\n\ \n\ Version: {featureVersion}\n\ +Build id: {0}\n\ +\n\ +Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation +\n\ +See the NOTICE file(s) distributed with this work for additional\n\ +information regarding copyright ownership.\n\ \n\ -(c) Copyright Wind River Systems, Inc. and others 2003, 2018. All rights reserved.\n\ -Visit http://www.eclipse.org/tm +Visit http://www.eclipse.org/cdt diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties index ff0b66ba638..33c3ee02e8d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties @@ -26,10 +26,11 @@ bin.includes = .,\ about.html,\ about.ini,\ about.properties,\ - tm32.png,\ icons/,\ HelpContexts.xml,\ - css/ + css/,\ + about.mappings,\ + cdt_logo_icon32.png source.. = src/ output.. = bin/ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/cdt_logo_icon32.png b/terminal/plugins/org.eclipse.tm.terminal.control/cdt_logo_icon32.png new file mode 100644 index 0000000000000000000000000000000000000000..470ca81b327234a519c2a443515e85727409b5f4 GIT binary patch literal 1885 zcmV-j2cr0iP)!H^1ntgMx$mQ^a+I-;$Ws3z8GYqX(iXst@JwrY8nR6N2$5hQdjkl4<{u^qpz z?d$vAABiL5I?h--Z9nP$^PTUU@Ao_B+;hGI{Evg&ZU?&_cApis05Hm7G%X$~QC}(f-LgFHq8$YV5GWUfO@Y&&e z=IeO2a}heb&KSCn2bXwkmWC&EjL}=EpQ_6Fbawo$X!6<%g2er^5|^HZlrrGdhzkH3D^y=pV@;xrv=WnFMDJJ zD2gd2D~gm!W&&?Sl0*9xMZBew*#QY*9F~UdHLg3mXj*3};HgaL$aw714n-B?#r#=; zAGG6#ZPjRfx|e>Q=-Pf(DlRKxYGUe>U8zj)F92XRRNZGY`@XMdZ7T?&SV_u_WcbPV zQ`z9*1UGyrmyexk@UA^Z2xW*QhMtS3ZyYR}FaTIsSpKmG12z+E?Jw8tb~!uWEG3Rd z2X@A}o4;phgV*a>dC+EBxT)O6%!}!3p~$&M1TlS8ud}ugLL2j9a-f_z08jvMcP&;m zyRfu(5WN&r_h2b0ot^mmw79;iuDYYgZuUJi*I!{^Z7qwv_x0%*<03)gu2m8TW|m-m z6V^imj`^9h7E|?0rKDK$(-#4t%F*(?$>3@);F6q=WckQ3Rg-fTQ_TY`WAaIIJ~|n{ zvR9J%P$l785@`3L9V&1+Y#1X3!YGQw0h%@~!UuE0)LEKh-F9>B7DW-$03m{u9t=*N z-7G8laR4BMVmv|4@YeP7u>q z6Ws7?voqk-!^!dB2+@0NX5Ygz;u-*C_{ecd&IMSVrP*roZUg{Dm6DYbplQ9wWo_JL zWSy&6#-{|RppGP zDcPCX$^w9<%Gn|;Q{XZHkjNoX??k;Mr>@4+H(o6stZ;tk^07Wi&IKz87edpNd@SWZ zz%WK%@e<5nwZ%(70N{hI`0$&JxPQg#j_(oEy1y0=CdquzA9`;wO|kCgx^IOjLg@iO z5V@g1xNn1`@M8c#Q>@G5Xx^LTg58BpNC<5JG_`mWmSQvjEO%o?XDvEU2l8))rKWGt zl+HwEf~HwVCO7$kC};dS+Tb-A++QPv5QZ@C8>ZOyEzseDtK*SiM2V z7#9KnMJSz~wKf}AduzcbOk?)D(%I1?sw$`FTP_L!P6ct&AIE1~?!XpR3cgcHvKSZK z>#{ZOR5gVk34gRM!3F-TY18LKY2@q-szfT82&I z>CCw+@oJlnG1V3m&Bp2t(zNI6=W^q3XZY~DiYg@(MM{ctE|BFTC!)zu_fICS?3EQE zY}7mNuB+~N$8BqRO4C#^Cro`@E`izeoFz?CW|;Z$wSgv}7jG zJsH39w5$lxvK3J}hr`;ieSu^7FN?2ZE<5q=XtaM@>2-X|h0<1qJI_Cc^Ctp0@#OKA zi*p$gMV0w!LlQkDO1WV`l^NPlW7NCuv6+1j7xqYLR5T=oc%%he4u1!S_w`}lA3s~Q z^vkkjypR|e3HPlpwPc@j#e*>nj-(LiT8FN@F!A2$AbrlLcXxadQ<~u;r$duxHz{S7 zt*kA-9Kq#}Msa5UTD*9NJ(4`?PaR-%RcmO9G2f1`tcb~2%HK5}8~E{DzhuR#9C|pO zS&e5mFT>`S&NHv}1eO@>)}~$aJxpXdA4})P-;SmH2Sh33uf+YgrqyGFXX|o2+Uh~; zScZfzOuG2XQ*Ns8G$SCiqDqCQS${SkIq{`D&B_H$K-b!^$gG1oltzdXG4E;je;xk< X7GP-TgL9xq00000NkvXXu0mjf1*xYU literal 0 HcmV?d00001 diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/tm32.png b/terminal/plugins/org.eclipse.tm.terminal.control/tm32.png deleted file mode 100644 index 668b05b79135152cc0d518da0873c4426bed32e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1349 zcmV-L1-kl)P)`(46b=_T=mH%KWS%@{pgd=vJ7=FgXrav5 z=lZ;J_mm#YqHa@FRS^##9T+$&AW$qKRV!Vab%B_9g`0SUnsR`cGGd?n*Q)BKRdH=* zCm%~IT%2)zmCx<_bAOlHt8g|qJ0Kc8EnuW(bB>3Xz zvVIpB8zmh^E+bepDP=h=Z!cu3U~h|JagFM&V=yLOJTP@cHia-}uv=<}c8IrXe5_t^ zp+;JaUTlf~`0;UUWgr?pH!EsFG=MT|wpC?>SZ9X5pnDP!AUG^+Kr(wYZoE`vgHlvg zC?HKWDP=w|b~bRnPiBlzWs6T|jX-$7+_8Qb6fG_!SUfIrJT7rJY`HgXx;JgOHf^{z zXt9Qnq58IEmy3dRa)r&x*6{E1{rvs>{QUFs^|P?RNk~;&Tw{-mpvJ?|%E;Bt%Gt}v z*2u-vsinFzGC=vSRzE*TEhASjC0t=)ZJL&@wzI{G&DYm zgn@i`jnmQGwX?!YOI6#pi!CWbO+;{7QF>ifeO^|6Usrx#SASnteqL66TvU8uSAShp zd|Fa^Qc83?HCL6Dn)#?mKtV?-AWt70FYfN{zNU#46Dc7ZKY@aSBO5~|C@k;q?Ec=+fsy0l=Qitw%5m#wuR!2QnMD=6}uDk^^0FPmr~fg4sg5%S6^Di_aR)j|a( z*RCMTUvk&N0GFXE41wmK$0Dz#C3yiPA1R_DoPGwIyq4zKa}WzooYcY&PMroCprUg4 z$Wa^$w2mDI`Eb+bEnBy3+rDGRj-5Mp?cTO$&z@~N_U_%Wd*A*82M;k+tEjA9w_XZ6 zXxgxm0qDf#D^{-RzzSBaUc;cG(zh6B*^;H0U;oVoKFu-Y(x!NNsA1}^zkQMzvqb6ixf{8%!LXaa{+uA!iIx#_4M|V#z$eT5_b@f;s(b&}7 z0t%>tLZDei#b8iUQc^4>RayoFV|Oag^_ zatahkrKXufK|(4dx}%~&Dq>XY+8lDKGY;4W#>>V7PoTXfBpvh81 z#mHD4mh7cW&0r>2n8GrSvWkeRn!1K2Sb?^Vt{w#F8zAzQkg$lTn79Nm=SfM+$jZqp zD9FpnDJmi7FE(}#PDtkE;^yJy Date: Fri, 31 Jan 2020 10:56:37 -0500 Subject: [PATCH 11/76] Bug 559474: Add all file types to .gitattributes Change-Id: Ib63f010cf5e741beb6a77096e958ab5478133635 --- terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore b/terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore deleted file mode 100644 index ba077a4031a..00000000000 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin From 62fb37230546db32609b0b27ded98ea58c58abaa Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 31 Jan 2020 10:59:16 -0500 Subject: [PATCH 12/76] Bug 559474: Normalize .settings Change-Id: I4b8ca8341a3f479a74a06621f68534732cff6957 --- .../.settings/org.eclipse.jdt.core.prefs | 398 +++++++++++++++++- .../.settings/org.eclipse.jdt.launching.prefs | 3 + .../.settings/org.eclipse.jdt.ui.prefs | 133 ++++++ .../.settings/org.eclipse.pde.api.tools.prefs | 184 ++++++++ .../.settings/org.eclipse.pde.prefs | 35 ++ 5 files changed, 736 insertions(+), 17 deletions(-) create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.launching.prefs create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.api.tools.prefs create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs index eb9982c343a..2b6ecff8a01 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs @@ -1,32 +1,58 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch, *.xtend +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning @@ -35,35 +61,50 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullReference=error org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled @@ -72,19 +113,25 @@ org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning @@ -97,4 +144,321 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=false +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.launching.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 00000000000..f8a131b56e0 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning +org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..e44576346c4 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,133 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=false +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_modifiers=false +cleanup.remove_redundant_semicolons=true +cleanup.remove_redundant_type_arguments=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=false +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=false +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_CDT +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_CDT +formatter_settings_version=14 +internal.default.compliance=user +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=1000 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=1000 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.api.tools.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 00000000000..ec9fbf321d0 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,184 @@ +ANNOTATION_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +ANNOTATION_ELEMENT_TYPE_ADDED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error +ANNOTATION_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_INTERFACE_BOUNDS=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TO_CLASS=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TO_ENUM=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITH_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +API_USE_SCAN_FIELD_SEVERITY=Error +API_USE_SCAN_METHOD_SEVERITY=Error +API_USE_SCAN_TYPE_SEVERITY=Error +CLASS_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +CLASS_ELEMENT_TYPE_ADDED_FIELD=Error +CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERCLASS_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_CHANGED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error +CLASS_ELEMENT_TYPE_CHANGED_TO_ENUM=Error +CLASS_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +ENUM_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error +ENUM_ELEMENT_TYPE_CHANGED_TO_CLASS=Error +ENUM_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENTS=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +INTERFACE_ELEMENT_TYPE_ADDED_DEFAULT_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error +INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETERS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +INTERFACE_ELEMENT_TYPE_CHANGED_INTERFACE_BOUNDS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TO_CLASS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TO_ENUM=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_ANNOTATION=Ignore +INVALID_JAVADOC_TAG=Error +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Warning +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +MISSING_EE_DESCRIPTIONS=Warning +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Warning +automatically_removed_unused_problem_filters=false +changed_execution_env=Error +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +incompatible_api_component_version_report_major_without_breaking_change=Warning +incompatible_api_component_version_report_minor_without_api_change=Warning +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Error +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs new file mode 100644 index 00000000000..d2dc703ba9e --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs @@ -0,0 +1,35 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=2 +compilers.p.build.java.compiler=2 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=2 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=2 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.no.automatic.module=1 +compilers.p.not-externalized-att=1 +compilers.p.service.component.without.lazyactivation=1 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +compilers.use-project=true +eclipse.preferences.version=1 From 618422999955ff4471a626e69bbb9979a5daa69c Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 31 Jan 2020 11:02:25 -0500 Subject: [PATCH 13/76] 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 --- .../build.properties | 6 +- .../plugin.properties | 2 +- .../terminal/connector/TerminalConnector.java | 71 ++-- ...TerminalToRemoteInjectionOutputStream.java | 137 +++--- .../control/CommandInputFieldWithHistory.java | 171 ++++---- .../terminal/control/ICommandInputField.java | 15 +- .../terminal/control/ITerminalListener2.java | 2 +- .../control/ITerminalMouseListener.java | 4 +- .../control/ITerminalViewControl.java | 100 +++-- .../control/TerminalViewControlFactory.java | 20 +- .../actions/AbstractTerminalAction.java | 35 +- .../control/actions/ActionMessages.java | 3 +- .../control/actions/ActionMessages.properties | 2 +- .../terminal/control/actions/ImageConsts.java | 2 +- .../actions/TerminalActionClearAll.java | 12 +- .../control/actions/TerminalActionCopy.java | 14 +- .../control/actions/TerminalActionCut.java | 14 +- .../control/actions/TerminalActionPaste.java | 19 +- .../actions/TerminalActionSelectAll.java | 6 +- .../control/impl/ITerminalControlForText.java | 22 +- .../control/impl/TerminalMessages.java | 28 +- .../control/impl/TerminalMessages.properties | 2 +- .../terminal/control/impl/TerminalPlugin.java | 23 +- .../emulator/EditActionAccelerators.java | 2 +- .../emulator/IVT100EmulatorBackend.java | 44 +- .../emulator/LoggingOutputStream.java | 26 +- .../emulator/VT100BackendTraceDecorator.java | 47 +- .../terminal/emulator/VT100Emulator.java | 148 +++---- .../emulator/VT100EmulatorBackend.java | 203 +++++---- .../emulator/VT100TerminalControl.java | 400 +++++++++--------- .../terminal/model/ISnapshotChanges.java | 8 +- .../terminal/model/SnapshotChanges.java | 225 +++++----- .../model/SynchronizedTerminalTextData.java | 41 +- .../terminal/model/TerminalTextData.java | 92 ++-- .../model/TerminalTextDataFastScroll.java | 147 ++++--- .../model/TerminalTextDataSnapshot.java | 91 ++-- .../terminal/model/TerminalTextDataStore.java | 236 ++++++----- .../model/TerminalTextDataWindow.java | 148 ++++--- .../preferences/ITerminalConstants.java | 14 +- .../TerminalPreferenceInitializer.java | 2 +- .../preferences/TerminalPreferencePage.java | 19 +- .../provisional/api/AbstractSettingsPage.java | 21 +- .../provisional/api/ISettingsStore.java | 16 +- .../provisional/api/ITerminalConnector.java | 28 +- .../provisional/api/ITerminalControl.java | 12 +- .../terminal/provisional/api/Logger.java | 126 +++--- .../api/TerminalConnectorExtension.java | 30 +- .../provisional/api/TerminalState.java | 6 +- .../api/provider/TerminalConnectorImpl.java | 20 +- .../textcanvas/AbstractTextCanvasModel.java | 189 +++++---- .../terminal/textcanvas/GridCanvas.java | 136 +++--- .../terminal/textcanvas/ILinelRenderer.java | 6 + .../terminal/textcanvas/ITextCanvasModel.java | 6 + .../textcanvas/ITextCanvasModelListener.java | 2 + .../terminal/textcanvas/PipedInputStream.java | 112 ++--- .../textcanvas/PollingTextCanvasModel.java | 20 +- .../terminal/textcanvas/StyleMap.java | 152 ++++--- .../terminal/textcanvas/TextCanvas.java | 171 ++++---- .../terminal/textcanvas/TextLineRenderer.java | 119 +++--- .../terminal/textcanvas/VirtualCanvas.java | 223 +++++----- .../tm/terminal/model/ITerminalTextData.java | 12 +- .../model/ITerminalTextDataReadOnly.java | 2 + .../model/ITerminalTextDataSnapshot.java | 6 + .../tm/terminal/model/LineSegment.java | 20 +- .../org/eclipse/tm/terminal/model/Style.java | 86 ++-- .../eclipse/tm/terminal/model/StyleColor.java | 27 +- .../model/TerminalTextDataFactory.java | 12 +- 67 files changed, 2311 insertions(+), 1852 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties index 33c3ee02e8d..4e1b392a770 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties @@ -13,7 +13,7 @@ # Helmut Haigermoser and Ted Williams. # # Contributors: -# Michael Scharf (Wind River) - split into core, view and connector plugins +# Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Anna Dushistova (MontaVista) - added icons ############################################################################### @@ -31,9 +31,9 @@ bin.includes = .,\ css/,\ about.mappings,\ cdt_logo_icon32.png - + source.. = src/ output.. = bin/ src.includes = schema/,\ about.html - + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties index daad8a7fc59..033ccc4ec69 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties @@ -13,7 +13,7 @@ # Helmut Haigermoser and Ted Williams. # # Contributors: -# Michael Scharf (Wind River) - split into core, view and connector plugins +# Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget ############################################################################### diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java index dfa2f8faf91..99cb5472d72 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java @@ -10,7 +10,7 @@ * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Michael Scharf (Wind River) - [200541] Extract from TerminalConnectorExtension.TerminalConnectorProxy - * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl + * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl * Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point *******************************************************************************/ package org.eclipse.tm.internal.terminal.connector; @@ -65,6 +65,7 @@ public interface Factory { */ TerminalConnectorImpl makeConnector() throws Exception; } + /** * The factory for creating impl instances. */ @@ -95,6 +96,7 @@ public interface Factory { * This keeps the value until the connector is created. */ private ISettingsStore fStore; + /** * Constructor for the terminal connector. * @@ -104,119 +106,138 @@ public interface Factory { * this ID. * @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; fId = id; fName = name; fHidden = hidden; } + public String getInitializationErrorMessage() { getConnectorImpl(); - if(fException!=null) + if (fException != null) return fException.getLocalizedMessage(); return null; } + public String getId() { return fId; } + public String getName() { return fName; } + public boolean isHidden() { return fHidden; } + private TerminalConnectorImpl getConnectorImpl() { - if(!isInitialized()) { + if (!isInitialized()) { try { - fConnector=fTerminalConnectorFactory.makeConnector(); + fConnector = fTerminalConnectorFactory.makeConnector(); fConnector.initialize(); } catch (Exception e) { - fException=e; - fConnector=new TerminalConnectorImpl(){ + fException = e; + fConnector = new TerminalConnectorImpl() { public void connect(ITerminalControl control) { // super.connect(control); control.setState(TerminalState.CLOSED); control.setMsg(getInitializationErrorMessage()); } + public OutputStream getTerminalToRemoteStream() { return null; } + public String getSettingsSummary() { return null; - }}; + } + }; // that's the place where we log the exception Logger.logException(e); } - if(fConnector!=null && fStore!=null) + if (fConnector != null && fStore != null) fConnector.load(fStore); } return fConnector; } public boolean isInitialized() { - return fConnector!=null || fException!=null; + return fConnector != null || fException != null; } + public void connect(ITerminalControl control) { getConnectorImpl().connect(control); } + public void disconnect() { getConnectorImpl().disconnect(); } + public OutputStream getTerminalToRemoteStream() { return getConnectorImpl().getTerminalToRemoteStream(); } + public String getSettingsSummary() { - if(fConnector!=null) + if (fConnector != null) return getConnectorImpl().getSettingsSummary(); else return TerminalMessages.NotInitialized; } + public boolean isLocalEcho() { return getConnectorImpl().isLocalEcho(); } + public void load(ISettingsStore store) { - if(fConnector==null) { - fStore=store; + if (fConnector == null) { + fStore = store; } else { getConnectorImpl().load(store); } } + @Override public void setDefaultSettings() { getConnectorImpl().setDefaultSettings(); } + public void save(ISettingsStore store) { // no need to save the settings: it cannot have changed // because we are not initialized.... - if(fConnector!=null) + if (fConnector != null) getConnectorImpl().save(store); } + public void setTerminalSize(int newWidth, int newHeight) { // we assume that setTerminalSize is called also after // the terminal has been initialized. Else we would have to cache // the values.... - if(fConnector!=null) { + if (fConnector != null) { fConnector.setTerminalSize(newWidth, newHeight); } } + public Object getAdapter(Class adapter) { - TerminalConnectorImpl connector=null; - if(isInitialized()) - connector=getConnectorImpl(); + TerminalConnectorImpl connector = null; + if (isInitialized()) + connector = getConnectorImpl(); // if we cannot create the connector then we cannot adapt... - if(connector!=null) { + if (connector != null) { // maybe the connector is adaptable - if(connector instanceof IAdaptable) { - Object result =((IAdaptable)connector).getAdapter(adapter); + if (connector instanceof IAdaptable) { + Object result = ((IAdaptable) connector).getAdapter(adapter); // Not sure if the next block is needed.... - if(result==null) + if (result == null) //defer to the platform - result= Platform.getAdapterManager().getAdapter(connector, adapter); - if(result!=null) + result = Platform.getAdapterManager().getAdapter(connector, adapter); + if (result != null) return result; } // maybe the real adapter is what we need.... - if(adapter.isInstance(connector)) + if (adapter.isInstance(connector)) return connector; } // maybe we have to be adapted.... diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java index 362306a4fb1..5dc1173c5bb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java @@ -29,19 +29,22 @@ public class TerminalToRemoteInjectionOutputStream extends FilterOutputStream { */ static abstract public class Interceptor { protected OutputStream fOriginal; + /** * @param original the injection into the original stream begins * @throws IOException */ public void begin(OutputStream original) throws IOException { - fOriginal=original; + fOriginal = original; } + /** * @param b a byte was written to the {@link TerminalToRemoteInjectionOutputStream}. * @throws IOException */ public void write(int b) throws IOException { } + /** * @param b bytes written to the {@link TerminalToRemoteInjectionOutputStream}. * @param off the start offset in the data. @@ -50,122 +53,144 @@ public void write(int b) throws IOException { */ public void write(byte[] b, int off, int len) throws IOException { } + /** * The injection into the normal stream ends. * @throws IOException */ public void close() throws IOException { } + public void flush() { } } + static public class BufferInterceptor extends Interceptor { - private final ByteArrayOutputStream fBuffer=new ByteArrayOutputStream(); - public void close() throws IOException { - fOriginal.write(fBuffer.toByteArray()); + private final ByteArrayOutputStream fBuffer = new ByteArrayOutputStream(); + + public void close() throws IOException { + fOriginal.write(fBuffer.toByteArray()); } + public void write(byte[] b, int off, int len) throws IOException { fBuffer.write(b, off, len); } + public void write(int b) throws IOException { fBuffer.write(b); } } + private class TerminalFilterOutputStream extends OutputStream { - final private Object fLock=TerminalToRemoteInjectionOutputStream.this; + final private Object fLock = TerminalToRemoteInjectionOutputStream.this; + public void close() throws IOException { - synchronized(fLock) { - if(fInjection==this) { + synchronized (fLock) { + if (fInjection == this) { flush(); ungrabOutput(); } } } + public void write(byte[] b, int off, int len) throws IOException { - synchronized(fLock) { + synchronized (fLock) { checkStream(); out.write(b, off, len); } } + public void write(byte[] b) throws IOException { - synchronized(fLock) { + synchronized (fLock) { checkStream(); out.write(b); } } + public void flush() throws IOException { - synchronized(fLock) { + synchronized (fLock) { checkStream(); out.flush(); } } + public void write(int b) throws IOException { - synchronized(fLock) { + synchronized (fLock) { checkStream(); out.write(b); } } + private void checkStream() throws IOException { - if(fInjection!=this) + if (fInjection != this) 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) { super(out); } + synchronized protected void ungrabOutput() throws IOException { - if(fInterceptor!=null) { + if (fInterceptor != null) { fInterceptor.close(); - fInterceptor=null; - fInjection=null; + fInterceptor = 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. - * @param interceptor This is used handle bytes sent while the injection stream is active. - * @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) { - throw new IOException("Buffer in use"); //$NON-NLS-1$ - } - fInterceptor=interceptor; - fInterceptor.begin(out); - fInjection=new TerminalFilterOutputStream(); - return fInjection; - } - /** See {@link #grabOutput(TerminalToRemoteInjectionOutputStream.Interceptor)}. - * @return injection output stream - * @throws IOException - */ - public synchronized OutputStream grabOutput() throws IOException { + + /** + * There can only be one injection stream active at a time. You must call close on the + * returned output stream to end the injection. + * @param interceptor This is used handle bytes sent while the injection stream is active. + * @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) { + throw new IOException("Buffer in use"); //$NON-NLS-1$ + } + fInterceptor = interceptor; + fInterceptor.begin(out); + 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(); } + + synchronized public void close() throws IOException { + if (fInjection != null) { + fInjection.close(); + } + super.close(); + } + synchronized public void flush() throws IOException { - if(fInterceptor!=null) - fInterceptor.flush(); + if (fInterceptor != null) + fInterceptor.flush(); out.flush(); } - synchronized public void write(byte[] b, int off, int len) throws IOException { - if(fInterceptor!=null) - fInterceptor.write(b, off, len); - else - out.write(b, off, len); + + synchronized public void write(byte[] b, int off, int len) throws IOException { + if (fInterceptor != null) + fInterceptor.write(b, off, len); + else + out.write(b, off, len); } + synchronized public void write(int b) throws IOException { - if(fInterceptor!=null) - fInterceptor.write(b); - else - out.write(b); - } + if (fInterceptor != null) + fInterceptor.write(b); + else + out.write(b); + } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java index 0034ea648ba..92f3a89c549 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -41,8 +41,6 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; - - /** * Manages the Command History for the command line input * of the terminal control. @@ -60,16 +58,16 @@ public class CommandInputFieldWithHistory implements ICommandInputField { private class FieldAssist implements IContentProposalProvider { public IContentProposal[] getProposals(String contents, int position) { - String prefix=contents.substring(0, position); - List result=new ArrayList(); + String prefix = contents.substring(0, position); + List result = new ArrayList(); // show an entry only once - Set seen=new HashSet(); + Set seen = new HashSet(); for (Iterator iterator = fHistory.iterator(); iterator.hasNext();) { 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 - String content=history.substring(prefix.length()); - result.add(new Proposal(content,history)); + String content = history.substring(prefix.length()); + result.add(new Proposal(content, history)); // don't add this proposal again seen.add(history); } @@ -78,14 +76,17 @@ public IContentProposal[] getProposals(String contents, int position) { } } + private static class Proposal implements IContentProposal { private final String fContent; private final String fLabel; + Proposal(String content, String label) { - fContent= content; - fLabel= label; + fContent = content; + fLabel = label; } + public String getContent() { return fContent; } @@ -103,7 +104,7 @@ public int getCursorPosition() { } } - final List fHistory=new ArrayList(); + final List fHistory = new ArrayList(); /** * Keeps a modifiable history while in history editing mode */ @@ -111,7 +112,7 @@ public int getCursorPosition() { /** * The current position in the edit history */ - private int fEditHistoryPos=0; + private int fEditHistoryPos = 0; /** * The limit of the history. */ @@ -122,9 +123,11 @@ public int getCursorPosition() { private Text fInputField; private Sash fSash; private Composite fPanel; + public CommandInputFieldWithHistory(int maxHistorySize) { - fMaxSize=maxHistorySize; + fMaxSize = maxHistorySize; } + /** * Add a line to the history. * @param line The line to be added to the history. @@ -132,16 +135,17 @@ public CommandInputFieldWithHistory(int maxHistorySize) { protected void pushLine(String line) { endHistoryMode(); // anything to remember? - if(line==null || line.trim().length()==0) + if (line == null || line.trim().length() == 0) return; - fHistory.add(0,line); + fHistory.add(0, line); // 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); // limit the history size. - if(fHistory.size()>=fMaxSize) - fHistory.remove(fHistory.size()-1); + if (fHistory.size() >= fMaxSize) + fHistory.remove(fHistory.size() - 1); } + /** * Sets the history * @param history or null @@ -149,34 +153,36 @@ protected void pushLine(String line) { public void setHistory(String history) { endHistoryMode(); fHistory.clear(); - if(history==null) + if (history == null) return; // add history entries separated by '\n' // fHistory.addAll(Arrays.asList(history.split("\n"))); //$NON-NLS-1$ // - StringTokenizer tok=new StringTokenizer(history,"\n"); //$NON-NLS-1$ - while(tok.hasMoreElements()) + StringTokenizer tok = new StringTokenizer(history, "\n"); //$NON-NLS-1$ + while (tok.hasMoreElements()) fHistory.add((String) tok.nextElement()); // } + /** * @return the current content of the history buffer and new line separated list */ public String getHistory() { - StringBuffer buff=new StringBuffer(); - boolean sep=false; + StringBuffer buff = new StringBuffer(); + boolean sep = false; for (Iterator iterator = fHistory.iterator(); iterator.hasNext();) { - String line=iterator.next(); - if(line.length()>0) { - if(sep) + String line = iterator.next(); + if (line.length() > 0) { + if (sep) buff.append("\n"); //$NON-NLS-1$ else - sep=true; + sep = true; buff.append(line); } } return buff.toString(); } + /** * @param currLine Line of text to be moved in history * @param count (+1 or -1) for forward and backward movement. -1 goes back @@ -184,22 +190,23 @@ public String getHistory() { * if the limit is reached. */ public String move(String currLine, int count) { - if(!inHistoryMode()) { - fEditedHistory=new ArrayList(fHistory.size()+1); + if (!inHistoryMode()) { + fEditedHistory = new ArrayList(fHistory.size() + 1); fEditedHistory.add(currLine); fEditedHistory.addAll(fHistory); - fEditHistoryPos=0; + fEditHistoryPos = 0; } - fEditedHistory.set(fEditHistoryPos,currLine); - if(fEditHistoryPos+count>=fEditedHistory.size()) + fEditedHistory.set(fEditHistoryPos, currLine); + if (fEditHistoryPos + count >= fEditedHistory.size()) return null; - if(fEditHistoryPos+count<0) + if (fEditHistoryPos + count < 0) return null; - fEditHistoryPos+=count; + fEditHistoryPos += count; return (String) fEditedHistory.get(fEditHistoryPos); } + private boolean inHistoryMode() { - return fEditedHistory!=null; + return fEditedHistory != null; } /** @@ -207,41 +214,43 @@ private boolean inHistoryMode() { * @return the string to be shown in the command line */ protected String escape() { - if(!inHistoryMode()) + if (!inHistoryMode()) return null; - String line= (String) fEditedHistory.get(0); + String line = (String) fEditedHistory.get(0); endHistoryMode(); return line; } + /** * End history editing */ private void endHistoryMode() { - fEditedHistory=null; - fEditHistoryPos=0; + fEditedHistory = null; + fEditHistoryPos = 0; } - public void createControl(final Composite parent,final ITerminalViewControl terminal) { -// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH); - fSash = new Sash(parent,SWT.HORIZONTAL); + + public void createControl(final Composite parent, final ITerminalViewControl terminal) { + // 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); - gd_sash.heightHint=5; + gd_sash.heightHint = 5; fSash.setLayoutData(gd_sash); - fSash.addListener (SWT.Selection, new Listener () { - public void handleEvent (Event e) { + fSash.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { if (e.detail == SWT.DRAG) { // don't redraw during drag, it causes paint errors - bug 220971 return; } // no idea why this is needed GridData gdata = (GridData) fInputField.getLayoutData(); - Rectangle sashRect = fSash.getBounds (); - Rectangle containerRect = parent.getClientArea (); + Rectangle sashRect = fSash.getBounds(); + 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 - 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 - e.y=Math.min(e.y,containerRect.height-h); + e.y = Math.min(e.y, containerRect.height - h); fInputField.setLayoutData(gdata); parent.layout(); // else the content assist icon will be replicated @@ -250,17 +259,20 @@ public void handleEvent (Event e) { }); fPanel = new Composite(parent, SWT.NONE); 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.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - fInputField=new Text(fPanel, SWT.MULTI|SWT.BORDER|SWT.WRAP|SWT.V_SCROLL); - GridData data=new GridData(SWT.FILL, SWT.FILL, true, false); - boolean installDecoration=true; - if(installDecoration) { + fInputField = new Text(fPanel, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); + boolean installDecoration = true; + if (installDecoration) { // The ContentAssistCommandAdapter says: "The client is responsible for // ensuring that adequate space is reserved for the decoration." // TODO: what is the "adequate space"??? - data.horizontalIndent=6; + data.horizontalIndent = 6; } fInputField.setLayoutData(data); fInputField.setFont(terminal.getFont()); @@ -268,57 +280,56 @@ public void handleEvent (Event e) { // Else the ENTER key is sent *first* to the input field // and then to the field assist popup. // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659) - new ContentAssistCommandAdapter( - fInputField, - new TextContentAdapter(), - new FieldAssist(), - null, - null, + new ContentAssistCommandAdapter(fInputField, new TextContentAdapter(), new FieldAssist(), null, null, installDecoration); - fInputField.addKeyListener(new KeyListener(){ + fInputField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { // if the field assist has handled the key already then // ignore it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659) - if(!e.doit) + if (!e.doit) return; - if(e.character==SWT.CR || e.character==SWT.LF) { - e.doit=false; - String line=fInputField.getText(); - if(!terminal.pasteString(line+'\r')) + if (e.character == SWT.CR || e.character == SWT.LF) { + e.doit = false; + String line = fInputField.getText(); + if (!terminal.pasteString(line + '\r')) return; pushLine(line); setCommand("");//$NON-NLS-1$ - } else if(e.keyCode==SWT.ARROW_UP || e.keyCode==SWT.PAGE_UP) { - e.doit=false; - setCommand(move(fInputField.getText(),1)); - } else if(e.keyCode==SWT.ARROW_DOWN || e.keyCode==SWT.PAGE_DOWN) { - e.doit=false; - setCommand(move(fInputField.getText(),-1)); - } else if(e.keyCode==SWT.ESC) { - e.doit=false; + } else if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.PAGE_UP) { + e.doit = false; + setCommand(move(fInputField.getText(), 1)); + } else if (e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.PAGE_DOWN) { + e.doit = false; + setCommand(move(fInputField.getText(), -1)); + } else if (e.keyCode == SWT.ESC) { + e.doit = false; setCommand(escape()); } } + private void setCommand(String line) { - if(line==null) + if (line == null) return; fInputField.setText(line); fInputField.setSelection(fInputField.getCharCount()); } + public void keyReleased(KeyEvent e) { } }); } + public void setFont(Font font) { fInputField.setFont(font); fInputField.getParent().layout(true); } + public void dispose() { fSash.dispose(); - fSash=null; + fSash = null; fPanel.dispose(); - fPanel=null; + fPanel = null; fInputField.dispose(); - fInputField=null; + fInputField = null; } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java index 2e31750195f..8e314acd78b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial implementation *******************************************************************************/ package org.eclipse.tm.internal.terminal.control; @@ -23,8 +23,9 @@ public interface ICommandInputField { * @param terminal */ void createControl(Composite parent, ITerminalViewControl terminal); - + void dispose(); + /** * Sets the font of a control created with {@link #createControl(Composite, ITerminalViewControl)} * @param control diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java index 1166a99c929..30f22f82ba0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener2.java @@ -13,7 +13,7 @@ /** * Terminal listener allowing to listen to terminal selection changes. - * + * * @since 4.1 */ public interface ITerminalListener2 extends ITerminalListener { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java index 1e07fb20069..d926433c83b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java @@ -17,7 +17,7 @@ * Terminal specific version of {@link org.eclipse.swt.events.MouseListener} * @since 4.1 */ -public interface ITerminalMouseListener { +public interface ITerminalMouseListener { /** * Invoked when a double-click has happend inside the terminal control.
            *
            @@ -26,6 +26,7 @@ public interface ITerminalMouseListener { * @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values */ void mouseDoubleClick(ITerminalTextDataReadOnly terminalText, int line, int column, int button); + /** * Invoked when a mouse button is pushed down inside the terminal control.
            *
            @@ -34,6 +35,7 @@ public interface ITerminalMouseListener { * @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); + /** * Invoked when a mouse button is released inside the terminal control.
            *
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index 08706167229..ef309cafc19 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -50,13 +50,15 @@ public interface ITerminalViewControl { */ String getEncoding(); - boolean isEmpty(); - /** - * Sets the Terminal font - * @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font - * @param font - */ + boolean isEmpty(); + + /** + * Sets the Terminal font + * @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font + * @param font + */ void setFont(Font font); + /** * Sets the font for the Terminal, using a JFace symbolic font name, such * that bold and italic variants can be leveraged. @@ -64,51 +66,74 @@ public interface ITerminalViewControl { * @param fontName */ void setFont(String fontName); + void setInvertedColors(boolean invert); + Font getFont(); + /** * @return the text control */ Control getControl(); + /** * @return the root of all controls */ Control getRootControl(); - boolean isDisposed(); - void selectAll(); - void clearTerminal(); - void copy(); - void paste(); - String getSelection(); - TerminalState getState(); - Clipboard getClipboard(); - void disconnectTerminal(); - 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); + + boolean isDisposed(); + + void selectAll(); + + void clearTerminal(); + + void copy(); + + void paste(); + + String getSelection(); + + TerminalState getState(); + + Clipboard getClipboard(); + + void disconnectTerminal(); + + 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 */ public boolean pasteString(String string); - boolean isConnected(); + boolean isConnected(); - /** - * @param inputField null means no input field is shown - */ - void setCommandInputField(ICommandInputField inputField); - /** - * @return null or the current input field - */ - ICommandInputField getCommandInputField(); + /** + * @param inputField null means no input field is shown + */ + void setCommandInputField(ICommandInputField inputField); + + /** + * @return null or the current input field + */ + ICommandInputField getCommandInputField(); /** * @return the maximum number of lines to display @@ -121,13 +146,16 @@ public interface ITerminalViewControl { * in the terminal view. -1 means unlimited. */ public void setBufferLineLimit(int bufferLineLimit); + boolean isScrollLock(); + void setScrollLock(boolean on); - + /** * @since 4.1 */ void addMouseListener(ITerminalMouseListener listener); + /** * @since 4.1 */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java index 42717a45731..b04fb597701 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget @@ -23,7 +23,8 @@ public class TerminalViewControlFactory { * @param wndParent The Window parent to embed the Terminal in. * @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); } @@ -32,12 +33,13 @@ public static ITerminalViewControl makeControl(ITerminalListener target, Composi * @param target Callback for notifying the owner of Terminal state changes. * @param wndParent The Window parent to embed the Terminal in. * @param connectors Provided connectors. - * @param useCommonPrefs If true, the Terminal widget will pick up settings + * @param useCommonPrefs If true, the Terminal widget will pick up settings * from the org.eclipse.tm.terminal.TerminalPreferencePage Preference page. * Otherwise, clients need to maintain settings themselves. * @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); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java index 218044a07aa..9745792e7af 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java @@ -32,13 +32,11 @@ public AbstractTerminalAction(String strId) { this(null, strId, 0); } - public AbstractTerminalAction(ITerminalViewControl target, - String strId) { + public AbstractTerminalAction(ITerminalViewControl target, String strId) { this(target, strId, 0); } - public AbstractTerminalAction(ITerminalViewControl target, - String strId, int style) { + public AbstractTerminalAction(ITerminalViewControl target, String strId, int style) { super("", style); //$NON-NLS-1$ fTarget = target; @@ -48,27 +46,20 @@ public AbstractTerminalAction(ITerminalViewControl target, abstract public void run(); - protected void setupAction(String strText, String strToolTip, - String strImage, String strEnabledImage, String strDisabledImage, - boolean bEnabled) { - setupAction(strText, strToolTip, strImage, strEnabledImage, - strDisabledImage, bEnabled, TerminalPlugin.getDefault() - .getImageRegistry()); + protected void setupAction(String strText, String strToolTip, String strImage, String strEnabledImage, + String strDisabledImage, boolean bEnabled) { + setupAction(strText, strToolTip, strImage, strEnabledImage, strDisabledImage, bEnabled, + TerminalPlugin.getDefault().getImageRegistry()); } - protected void setupAction(String strText, String strToolTip, - String strHoverImage, String strEnabledImage, - String strDisabledImage, boolean bEnabled, - ImageRegistry imageRegistry) { - setupAction(strText, strToolTip, imageRegistry - .getDescriptor(strHoverImage), imageRegistry - .getDescriptor(strEnabledImage), imageRegistry - .getDescriptor(strDisabledImage), bEnabled); + protected void setupAction(String strText, String strToolTip, String strHoverImage, String strEnabledImage, + String strDisabledImage, boolean bEnabled, ImageRegistry imageRegistry) { + setupAction(strText, strToolTip, imageRegistry.getDescriptor(strHoverImage), + imageRegistry.getDescriptor(strEnabledImage), imageRegistry.getDescriptor(strDisabledImage), bEnabled); } - protected void setupAction(String strText, String strToolTip, - ImageDescriptor hoverImage, ImageDescriptor enabledImage, - ImageDescriptor disabledImage, boolean bEnabled) { + protected void setupAction(String strText, String strToolTip, ImageDescriptor hoverImage, + ImageDescriptor enabledImage, ImageDescriptor disabledImage, boolean bEnabled) { setText(strText); setToolTipText(strToolTip); setEnabled(bEnabled); @@ -85,7 +76,7 @@ protected void setupAction(String strText, String strToolTip, /** * Return the terminal instance on which the action should operate. - * + * * @return the terminal instance on which the action should operate. */ protected ITerminalViewControl getTarget() { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java index 80baa8a81fe..b613258f390 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java @@ -23,8 +23,7 @@ public class ActionMessages extends NLS { static { - NLS.initializeMessages(ActionMessages.class.getName(), - ActionMessages.class); + NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class); } public static String COPY; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties index ffc7d452c3a..e6302102f4d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties @@ -13,7 +13,7 @@ # Helmut Haigermoser and Ted Williams. # # Contributors: -# Michael Scharf (Wind River) - split into core, view and connector plugins +# Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin ############################################################################### diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java index e44e7dfaa27..5d3852f41b7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java @@ -23,7 +23,7 @@ public interface ImageConsts { 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_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$ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java index eb0e91ce181..928465e6728 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java @@ -26,19 +26,15 @@ public class TerminalActionClearAll extends AbstractTerminalAction { public TerminalActionClearAll() { super(TerminalActionClearAll.class.getName()); - setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, - ImageConsts.IMAGE_CLCL_CLEAR_ALL, - ImageConsts.IMAGE_ELCL_CLEAR_ALL, - ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); + setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, ImageConsts.IMAGE_CLCL_CLEAR_ALL, + ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); } public TerminalActionClearAll(ITerminalViewControl target) { super(target, TerminalActionClearAll.class.getName()); - setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, - ImageConsts.IMAGE_CLCL_CLEAR_ALL, - ImageConsts.IMAGE_ELCL_CLEAR_ALL, - ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); + setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, ImageConsts.IMAGE_CLCL_CLEAR_ALL, + ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); } public void run() { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java index 375accd6c0b..55cc03a3b08 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java @@ -29,20 +29,18 @@ public TerminalActionCopy() { super(TerminalActionCopy.class.getName()); setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$ ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); - setupAction(ActionMessages.COPY, ActionMessages.COPY, si - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); + setupAction(ActionMessages.COPY, ActionMessages.COPY, si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), + si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), + si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); } public TerminalActionCopy(ITerminalViewControl target) { super(target, TerminalActionCopy.class.getName()); setActionDefinitionId("org.eclipse.tm.terminal.copy"); //$NON-NLS-1$ ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); - setupAction(ActionMessages.COPY, ActionMessages.COPY, si - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); + setupAction(ActionMessages.COPY, ActionMessages.COPY, si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), + si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), + si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); } public void run() { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java index d35479dd174..4b07afd75a1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java @@ -27,19 +27,17 @@ public class TerminalActionCut extends AbstractTerminalAction { public TerminalActionCut() { super(TerminalActionCut.class.getName()); ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); - setupAction(ActionMessages.CUT, ActionMessages.CUT, si - .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si - .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si - .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); + setupAction(ActionMessages.CUT, ActionMessages.CUT, si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), + si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), + si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); } public TerminalActionCut(ITerminalViewControl target) { super(target, TerminalActionCut.class.getName()); ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); - setupAction(ActionMessages.CUT, ActionMessages.CUT, si - .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si - .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si - .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); + setupAction(ActionMessages.CUT, ActionMessages.CUT, si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), + si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), + si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); } public void run() { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java index af13acb3964..1fb92daa66b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java @@ -33,22 +33,18 @@ public TerminalActionPaste() { super(TerminalActionPaste.class.getName()); setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$ ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); - setupAction(ActionMessages.PASTE, ActionMessages.PASTE, - si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), - si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), - si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), - false); + setupAction(ActionMessages.PASTE, ActionMessages.PASTE, si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), false); } public TerminalActionPaste(ITerminalViewControl target) { super(target, TerminalActionPaste.class.getName()); setActionDefinitionId("org.eclipse.tm.terminal.paste"); //$NON-NLS-1$ ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); - setupAction(ActionMessages.PASTE, ActionMessages.PASTE, - si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), - si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), - si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), - false); + setupAction(ActionMessages.PASTE, ActionMessages.PASTE, si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), + si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), false); } public void run() { @@ -62,8 +58,7 @@ public void updateAction(boolean aboutToShow) { ITerminalViewControl target = getTarget(); boolean bEnabled = target != null && target.getClipboard() != null && !target.getClipboard().isDisposed(); if (bEnabled) { - String strText = (String) target.getClipboard().getContents( - TextTransfer.getInstance()); + String strText = (String) target.getClipboard().getContents(TextTransfer.getInstance()); bEnabled = ((strText != null) && (!strText.equals("")) && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$ } setEnabled(bEnabled); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java index b2f0057e3d3..f194c97de06 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java @@ -27,15 +27,13 @@ public class TerminalActionSelectAll extends AbstractTerminalAction { public TerminalActionSelectAll() { super(TerminalActionSelectAll.class.getName()); - setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, - (ImageDescriptor) null, null, null, false); + setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, (ImageDescriptor) null, null, null, false); } public TerminalActionSelectAll(ITerminalViewControl target) { super(target, TerminalActionSelectAll.class.getName()); - setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, - (ImageDescriptor) null, null, null, false); + setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, (ImageDescriptor) null, null, null, false); } public void run() { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java index 0bbd0096fbb..7fa736975e5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Anton Leherbauer (Wind River) - [458398] Add support for normal/application cursor keys mode @@ -23,19 +23,21 @@ * */ public interface ITerminalControlForText { - + TerminalState getState(); + void setState(TerminalState state); + void setTerminalTitle(String title); - + ITerminalConnector getTerminalConnector(); OutputStream getOutputStream(); - + /** * Enable/disable Application Cursor Keys mode (DECCKM) * @param enable */ void enableApplicationCursorKeys(boolean enable); - + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java index 56b3d1b3511..cf95067c05c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget @@ -19,14 +19,14 @@ public class TerminalMessages extends NLS { NLS.initializeMessages(TerminalMessages.class.getName(), TerminalMessages.class); } - public static String TerminalError; - public static String SocketError; - public static String IOError; - public static String CannotConnectTo; - public static String NotInitialized; + public static String TerminalError; + public static String SocketError; + public static String IOError; + public static String CannotConnectTo; + public static String NotInitialized; - //Preference Page - public static String INVERT_COLORS; - public static String BUFFERLINES; + //Preference Page + public static String INVERT_COLORS; + public static String BUFFERLINES; } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties index 93ee9767472..34492a197cb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties @@ -13,7 +13,7 @@ # Helmut Haigermoser and Ted Williams. # # Contributors: -# Michael Scharf (Wind River) - split into core, view and connector plugins +# Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget ############################################################################### diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java index c566aaf61c6..9f96e7b28c4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java @@ -31,14 +31,15 @@ public class TerminalPlugin extends AbstractUIPlugin { private static TerminalPlugin plugin; - 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 PLUGIN_ID = "org.eclipse.tm.terminal.control"; //$NON-NLS-1$ + public static final String HELP_VIEW = PLUGIN_ID + ".terminal_view"; //$NON-NLS-1$ /** * The constructor. */ public TerminalPlugin() { } + /** * Returns the shared instance. */ @@ -50,7 +51,7 @@ public static TerminalPlugin getDefault() { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ @Override - public void start(BundleContext context) throws Exception { + public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } @@ -59,7 +60,7 @@ public void start(BundleContext context) throws Exception { * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } @@ -73,20 +74,24 @@ public static boolean isOptionEnabled(String strOption) { } @Override - protected void initializeImageRegistry(ImageRegistry imageRegistry) { + protected void initializeImageRegistry(ImageRegistry imageRegistry) { try { // 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 - 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 - 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) { 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); ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); imageRegistry.put(strKey, imageDescriptor); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java index 6f5f5f2966f..9f8b06f57ed 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -33,7 +33,7 @@ private void load() { private void addAccelerator(String commandId) { TriggerSequence[] bindings = bindingsFor(commandId); - for (int i=0; i - * + * * There are never any ANSI control characters or escape sequences in the * text being displayed by this method (this includes newlines, carriage * returns, and tabs). @@ -134,7 +134,7 @@ public interface IVT100EmulatorBackend { * first column of the next line, as if a carriage return (CR) and a NL were * written. *

            - * + * * UNIX terminals typically display a NL character as a CR followed by a NL * because the terminal device typically has the ONLCR attribute bit set * (see the termios(4) man page for details), which causes the terminal @@ -151,7 +151,7 @@ public interface IVT100EmulatorBackend { * This method returns the relative line number of the line containing the * cursor. The returned line number is relative to the topmost visible line, * which has relative line number 0. - * + * * @return The relative line number of the line containing the cursor. */ int getCursorLine(); @@ -181,7 +181,7 @@ public interface IVT100EmulatorBackend { * If enabled, writing to the rightmost column does not cause * an immediate wrap to the next line. Instead the line wrap occurs on the * next output character. - * + * * @param enable whether to enable or disable VT100 line wrapping mode */ void setVT100LineWrapping(boolean enable); @@ -193,14 +193,14 @@ public interface IVT100EmulatorBackend { /** * Enables/disables insert mode (IRM). - * + * * @param enable whether to enable insert mode */ void setInsertMode(boolean enable); /** * Set scrolling region. Negative values reset the scroll region. - * + * * @param top top line of scroll region * @param bottom bottom line of scroll region */ @@ -208,14 +208,14 @@ public interface IVT100EmulatorBackend { /** * Scroll text upwards. - * + * * @param lines number of lines to scroll */ void scrollUp(int lines); /** * Scroll text downwards. - * + * * @param lines number of lines to scroll */ void scrollDown(int lines); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java index e291b9e5345..c365c87043b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -23,25 +23,25 @@ public LoggingOutputStream(OutputStream out) { } 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.encode(new String(b, 0, len)) + "'"); //$NON-NLS-1$ - + // we cannot call super.write, because this would call our write // which logs character by character..... //super.write(b, off, len); if ((off | len | (b.length - (len + off)) | (off + len)) < 0) - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException(); - for (int i = 0 ; i < len ; i++) { - super.write(b[off + i]); + for (int i = 0; i < len; i++) { + super.write(b[off + i]); } } 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.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); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java index 92d357f80d2..0f5f4ad1dbf 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode * Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode @@ -20,13 +20,14 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend { final IVT100EmulatorBackend fBackend; final PrintStream fWriter; + public VT100BackendTraceDecorator(IVT100EmulatorBackend backend, PrintStream out) { fBackend = backend; - fWriter=out; + fWriter = out; } 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); } @@ -36,12 +37,12 @@ public void clearAll() { } 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); } 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); } @@ -100,12 +101,12 @@ public Style getStyle() { } 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); } 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); } @@ -115,37 +116,37 @@ public void processNewline() { } 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); } 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); } 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); } 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); } 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); } 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); } 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); } @@ -154,22 +155,22 @@ public boolean isVT100LineWrapping() { } 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); } 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); } 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); } 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); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index cc3b76424c9..92159e8702b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -84,7 +84,6 @@ public class VT100Emulator implements ControlListener { * character. Expecting a character set designation character. */ private static final int ANSISTATE_EXPECTING_CHARSET_DESIGNATION = 5; - /** * This field holds the current state of the Finite TerminalState Automaton (FSA) @@ -140,6 +139,7 @@ public class VT100Emulator implements ControlListener { Reader fReader; boolean fCrAfterNewLine; + /** * The constructor. */ @@ -154,13 +154,13 @@ public VT100Emulator(ITerminalTextData data, ITerminalControlForText terminal, R ansiParameters[i] = new StringBuffer(); } setInputStreamReader(reader); - if(TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) - text=new VT100BackendTraceDecorator(new VT100EmulatorBackend(data),System.out); + if (TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) + text = new VT100BackendTraceDecorator(new VT100EmulatorBackend(data), System.out); else - text=new VT100EmulatorBackend(data); + text = new VT100EmulatorBackend(data); -// text.setDimensions(24, 80); - Style style=Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$ //$NON-NLS-2$ + // text.setDimensions(24, 80); + Style style = Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$ //$NON-NLS-2$ text.setDefaultStyle(style); text.setStyle(style); } @@ -182,7 +182,7 @@ public void setInputStreamReader(Reader reader) { fReader = reader; } - public void setDimensions(int lines,int cols) { + public void setDimensions(int lines, int cols) { text.setDimensions(lines, cols); ITerminalConnector telnetConnection = getConnector(); if (telnetConnection != null) { @@ -236,22 +236,23 @@ public void fontChanged() { if (text != null) 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 -// * other implementors of {@link ITerminalConnector}, like the -// * SerialPortHandler. -// *

            -// * These connectors write text to the terminal's buffer through -// * {@link TerminalControl#writeToTerminal(String)} and then have -// * this run method executed in the display thread. This method -// * must not execute at the same time as methods -// * {@link #setNewText(StringBuffer)} and {@link #clearTerminal()}. -// *

            -// * IMPORTANT: This method must be called in strict alternation with method -// * {@link #setNewText(StringBuffer)}. -// *

            -// */ + + // /** + // * 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 + // * other implementors of {@link ITerminalConnector}, like the + // * SerialPortHandler. + // *

            + // * These connectors write text to the terminal's buffer through + // * {@link TerminalControl#writeToTerminal(String)} and then have + // * this run method executed in the display thread. This method + // * must not execute at the same time as methods + // * {@link #setNewText(StringBuffer)} and {@link #clearTerminal()}. + // *

            + // * IMPORTANT: This method must be called in strict alternation with method + // * {@link #setNewText(StringBuffer)}. + // *

            + // */ public void processText() { try { // Find the width and height of the terminal, and resize it to display an @@ -275,6 +276,7 @@ public void processText() { Logger.logException(ex); } } + /** * This method scans the newly received text, processing ANSI control * characters and escape sequences and displaying normal text. @@ -283,7 +285,6 @@ public void processText() { private void processNewText() throws IOException { Logger.log("entered"); //$NON-NLS-1$ - // Scan the newly received text. while (hasNextChar()) { @@ -309,7 +310,7 @@ private void processNewText() throws IOException { case '\n': processNewline(); // Newline (Control-J) - if(fCrAfterNewLine) + if (fCrAfterNewLine) processCarriageReturn(); // Carriage Return (Control-M) break; @@ -382,8 +383,7 @@ private void processNewText() throws IOException { break; default: - Logger - .log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + Logger.log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$ ansiState = ANSISTATE_INITIAL; break; } @@ -448,6 +448,7 @@ private void processNewText() throws IOException { } } } + private void resetTerminal() { text.eraseAll(); text.setCursor(0, 0); @@ -456,6 +457,7 @@ private void resetTerminal() { text.setInsertMode(false); terminal.enableApplicationCursorKeys(false); } + /** * 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 @@ -463,8 +465,7 @@ private void resetTerminal() { */ private void processAnsiOsCommand() { if (ansiOsCommand.charAt(0) != '0' || ansiOsCommand.charAt(1) != ';') { - Logger - .log("Ignoring unsupported ANSI OSC sequence: '" + ansiOsCommand + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + Logger.log("Ignoring unsupported ANSI OSC sequence: '" + ansiOsCommand + "'"); //$NON-NLS-1$ //$NON-NLS-2$ return; } terminal.setTerminalTitle(ansiOsCommand.substring(2)); @@ -514,7 +515,7 @@ private void processAnsiCommandCharacter(char ansiCommandCharacter) { // Line Position Absolute [row] (default = [1,column]) (VPA). processAnsiCommand_d(); break; - + case 'E': // Move cursor to first column of Nth next line (default 1). processAnsiCommand_E(); @@ -559,7 +560,7 @@ private void processAnsiCommandCharacter(char ansiCommandCharacter) { // Set Mode. processAnsiCommand_l(); break; - + case 'M': // Delete line(s). processAnsiCommand_M(); @@ -688,7 +689,7 @@ private void processAnsiCommand_d() { // Line Position Absolute [row] (default = [1,column]) (VPA). text.setCursorLine(getAnsiParameter(0) - 1); } - + /** * This method moves the cursor to the first column of the Nth next line, * where N is specified by the ANSI parameter (default 1). @@ -838,15 +839,14 @@ private void processAnsiCommand_m() { 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 // order. int totalParameters = ansiParameters.length; int parameterIndex = 0; - while (parameterIndex < totalParameters - && ansiParameters[parameterIndex].length() > 0) { + while (parameterIndex < totalParameters && ansiParameters[parameterIndex].length() > 0) { int ansiParameter = getAnsiParameter(parameterIndex); switch (ansiParameter) { @@ -896,15 +896,15 @@ private void processAnsiCommand_m() { break; case 31: - style = style.setForground("RED"); //$NON-NLS-1$ + style = style.setForground("RED"); //$NON-NLS-1$ break; case 32: - style = style.setForground("GREEN"); //$NON-NLS-1$ + style = style.setForground("GREEN"); //$NON-NLS-1$ break; case 33: - style = style.setForground("YELLOW"); //$NON-NLS-1$ + style = style.setForground("YELLOW"); //$NON-NLS-1$ break; case 34: @@ -912,7 +912,7 @@ private void processAnsiCommand_m() { break; case 35: - style = style.setForground("MAGENTA"); //$NON-NLS-1$ + style = style.setForground("MAGENTA"); //$NON-NLS-1$ break; case 36: @@ -964,8 +964,7 @@ private void processAnsiCommand_m() { break; default: - Logger - .log("Unsupported graphics rendition parameter: " + ansiParameter); //$NON-NLS-1$ + Logger.log("Unsupported graphics rendition parameter: " + ansiParameter); //$NON-NLS-1$ break; } @@ -1025,23 +1024,23 @@ private void processAnsiCommand_r() { top = getAnsiParameter(0); bottom = getAnsiParameter(1); } - text.setScrollRegion(top-1, bottom-1); + text.setScrollRegion(top - 1, bottom - 1); } - + /** * Scroll up n lines (default = 1 line). */ private void processAnsiCommand_S() { text.scrollUp(getAnsiParameter(0)); } - + /** * Scroll down n lines (default = 1 line). */ private void processAnsiCommand_T() { text.scrollDown(getAnsiParameter(0)); } - + private void processDecPrivateCommand_h() { int param = getAnsiParameter(0); switch (param) { @@ -1080,7 +1079,7 @@ private void processDecPrivateCommand_l() { break; } } - + /** * This method returns one of the numeric ANSI parameters received in the * most recent escape sequence. @@ -1128,6 +1127,7 @@ private void processAnsiParameterCharacter(char ch) { ansiParameters[nextAnsiParameter].append(ch); } } + /** * This method processes a contiguous sequence of non-control characters. * This is a performance optimization, so that we don't have to insert or @@ -1137,15 +1137,14 @@ private void processAnsiParameterCharacter(char ch) { * @throws IOException */ private void processNonControlCharacters(char character) throws IOException { - StringBuffer buffer=new StringBuffer(); + StringBuffer buffer = new StringBuffer(); buffer.append(character); // Identify a contiguous sequence of non-control characters, starting at // firstNonControlCharacterIndex in newText. - while(hasNextChar()) { - character=getNextChar(); - if(character == '\u0000' || character == '\b' || character == '\t' - || character == '\u0007' || character == '\n' - || character == '\r' || character == '\u001b') { + while (hasNextChar()) { + character = getNextChar(); + if (character == '\u0000' || character == '\b' || character == '\t' || character == '\u0007' + || character == '\n' || character == '\r' || character == '\u001b') { pushBackChar(character); break; } @@ -1173,7 +1172,6 @@ private void displayNewText(String buffer) { text.appendString(buffer); } - /** * Process a BEL (Control-G) character. */ @@ -1251,8 +1249,8 @@ private void adjustTerminalDimensions() { // to make it display an integral number of lines of text. // TODO -// if(text.getColumns()!=80 && text.getLines()!=80) -// text.setDimensions(24, 80); + // if(text.getColumns()!=80 && text.getLines()!=80) + // text.setDimensions(24, 80); // 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 // communicate it to the TELNET server. If we are in a serial connection, @@ -1267,7 +1265,7 @@ private void adjustTerminalDimensions() { } private ITerminalConnector getConnector() { - if(terminal.getTerminalConnector()!=null) + if (terminal.getTerminalConnector() != null) return terminal.getTerminalConnector(); return null; } @@ -1291,7 +1289,7 @@ private int relativeCursorLine() { * contain any text to move the cursor to any column in that line. */ private void moveCursor(int targetLine, int targetColumn) { - text.setCursor(targetLine,targetColumn); + text.setCursor(targetLine, targetColumn); } /** @@ -1330,42 +1328,43 @@ private void moveCursorForward(int columnsToMove) { private void moveCursorBackward(int columnsToMove) { moveCursor(relativeCursorLine(), getCursorColumn() - columnsToMove); } + /** * 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. */ public void resetState() { - ansiState=ANSISTATE_INITIAL; + ansiState = ANSISTATE_INITIAL; text.setStyle(text.getDefaultStyle()); text.setScrollRegion(-1, -1); text.setInsertMode(false); } -// public OutputStream getOutputStream() { -// return fTerminalInputStream.getOutputStream(); -// } + // public OutputStream getOutputStream() { + // return fTerminalInputStream.getOutputStream(); + // } /** * Buffer for {@link #pushBackChar(char)}. */ - private int fNextChar=-1; + private int fNextChar = -1; private char getNextChar() throws IOException { - int c=-1; - if(fNextChar!=-1) { - c= fNextChar; - fNextChar=-1; + int c = -1; + if (fNextChar != -1) { + c = fNextChar; + fNextChar = -1; } else { c = fReader.read(); } // TODO: better end of file handling - if(c==-1) - c=0; - return (char)c; + if (c == -1) + c = 0; + return (char) c; } - private boolean hasNextChar() throws IOException { - if(fNextChar>=0) + private boolean hasNextChar() throws IOException { + if (fNextChar >= 0) return true; return fReader.ready(); } @@ -1378,20 +1377,25 @@ private boolean hasNextChar() throws IOException { */ void pushBackChar(char c) { //assert fNextChar!=-1: "Already a character waiting:"+fNextChar; //$NON-NLS-1$ - fNextChar=c; + fNextChar = c; } + private int getCursorColumn() { return text.getCursorColumn(); } + public boolean isCrAfterNewLine() { return fCrAfterNewLine; } + public void setCrAfterNewLine(boolean crAfterNewLine) { fCrAfterNewLine = crAfterNewLine; } + void setVT100LineWrapping(boolean enable) { text.setVT100LineWrapping(enable); } + boolean isVT100LineWrapping() { return text.isVT100LineWrapping(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index 0332edacc01..22afb9ac7e8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [206329] Changing terminal size right after connect does not scroll properly * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode @@ -26,22 +26,27 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend { 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 fBottom; + ScrollRegion(int top, int bottom) { fTop = top; fBottom = bottom; } + boolean contains(int line) { return line >= fTop && line <= fBottom; } + int getTopLine() { return fTop; } + int getBottomLine() { return fBottom; } + int getHeight() { return fBottom - fTop + 1; } @@ -54,7 +59,7 @@ int getHeight() { * {@link #widthInColumns} - 1. We track the cursor column using this field * to avoid having to recompute it repeatly using StyledText method calls. *

            - * + * * The StyledText widget that displays text has a vertical bar (called the * "caret") that appears _between_ character cells, but ANSI terminals have * the concept of a cursor that appears _in_ a character cell, so we need a @@ -63,13 +68,13 @@ int getHeight() { * class is that the cursor is logically in column N when the caret is * physically positioned immediately to the _left_ of column N. *

            - * + * * When fCursorColumn is N, the next character output to the terminal appears * in column N. When a character is output to the rightmost column on a * given line (column widthInColumns - 1), the cursor moves to column 0 on * the next line after the character is drawn (this is the default line wrapping * mode). If VT100 line wrapping mode is enabled, the cursor does not move - * to the next line until the next character is printed (this is known as + * to the next line until the next character is printed (this is known as * the VT100 'eat_newline_glitch'). * If the cursor is in the bottommost line when line wrapping * occurs, the topmost visible line is scrolled off the top edge of the @@ -78,7 +83,7 @@ int getHeight() { */ private int fCursorColumn; private int fCursorLine; - /* true if last output occurred on rightmost column + /* true if last output occurred on rightmost column * and next output requires line wrap */ private boolean fWrapPending; private boolean fInsertMode; @@ -91,16 +96,16 @@ int getHeight() { private ScrollRegion fScrollRegion = ScrollRegion.FULL_WINDOW; public VT100EmulatorBackend(ITerminalTextData terminal) { - fTerminal=terminal; + fTerminal = terminal; } - + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#clearAll() */ public void clearAll() { synchronized (fTerminal) { // clear the history - int n=fTerminal.getHeight(); + int n = fTerminal.getHeight(); for (int line = 0; line < n; line++) { fTerminal.cleanLine(line); } @@ -109,34 +114,35 @@ public void clearAll() { setCursor(0, 0); } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDimensions(int, int) */ public void setDimensions(int lines, int cols) { synchronized (fTerminal) { - if(lines==fLines && cols==fColumns) + if (lines == fLines && cols == fColumns) return; // nothing to do // relative cursor line - int cl=getCursorLine(); - int cc=getCursorColumn(); - int height=fTerminal.getHeight(); + int cl = getCursorLine(); + int cc = getCursorColumn(); + int height = fTerminal.getHeight(); // absolute cursor line - int acl=cl+height-fLines; - int newLines=Math.max(lines,height); - if(lines=fCursorColumn+n; col--) { - char c=fTerminal.getChar(line, col-n); - Style style=fTerminal.getStyle(line, col-n); - fTerminal.setChar(line, col,c, style); + int line = toAbsoluteLine(fCursorLine); + int n = charactersToInsert; + for (int col = fColumns - 1; col >= fCursorColumn + n; col--) { + char c = fTerminal.getChar(line, col - n); + Style style = fTerminal.getStyle(line, col - n); + fTerminal.setChar(line, col, c, style); } - int last=Math.min(fCursorColumn+n, fColumns); - for (int col = fCursorColumn; col 0; - int line=toAbsoluteLine(fCursorLine); - int nLines=Math.min(fTerminal.getHeight()-line, fScrollRegion.getBottomLine()-fCursorLine+1); + assert n > 0; + int line = toAbsoluteLine(fCursorLine); + int nLines = Math.min(fTerminal.getHeight() - line, fScrollRegion.getBottomLine() - fCursorLine + 1); fTerminal.scroll(line, nLines, n); } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteCharacters(int) */ public void deleteCharacters(int n) { synchronized (fTerminal) { - int line=toAbsoluteLine(fCursorLine); - for (int col = fCursorColumn+n; col < fColumns; col++) { - char c=fTerminal.getChar(line, col); - Style style=fTerminal.getStyle(line, col); - fTerminal.setChar(line, col-n,c, style); + int line = toAbsoluteLine(fCursorLine); + for (int col = fCursorColumn + n; col < fColumns; col++) { + char c = fTerminal.getChar(line, col); + Style style = fTerminal.getStyle(line, col); + fTerminal.setChar(line, col - n, c, style); } - int first=Math.max(fCursorColumn, fColumns-n); - for (int col = first; col 0; - int line=toAbsoluteLine(fCursorLine); - int nLines=Math.min(fTerminal.getHeight()-line, fScrollRegion.getBottomLine()-fCursorLine+1); + assert n > 0; + int line = toAbsoluteLine(fCursorLine); + int nLines = Math.min(fTerminal.getHeight() - line, fScrollRegion.getBottomLine() - fCursorLine + 1); fTerminal.scroll(line, nLines, -n); } } + private boolean isCusorInScrollingRegion() { return fScrollRegion.contains(fCursorLine); } @@ -304,39 +319,41 @@ public void setDefaultStyle(Style defaultStyle) { */ public Style getStyle() { synchronized (fTerminal) { - if(fStyle==null) + if (fStyle == null) return fDefaultStyle; return fStyle; } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setStyle(org.eclipse.tm.terminal.model.Style) */ public void setStyle(Style style) { synchronized (fTerminal) { - fStyle=style; + fStyle = style; } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#appendString(java.lang.String) */ public void appendString(String buffer) { synchronized (fTerminal) { - char[] chars=buffer.toCharArray(); + char[] chars = buffer.toCharArray(); if (fInsertMode) insertCharacters(chars.length); - int line=toAbsoluteLine(fCursorLine); - int i=0; + int line = toAbsoluteLine(fCursorLine); + int i = 0; while (i < chars.length) { - if(fWrapPending) { + if (fWrapPending) { 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); - int col=fCursorColumn+n; - i+=n; + int col = fCursorColumn + n; + i += n; // wrap needed? - if(col == fColumns) { + if (col == fColumns) { if (fVT100LineWrapping) { // deferred line wrapping (eat_newline_glitch) setCursorColumn(col - 1); @@ -353,10 +370,10 @@ public void appendString(String buffer) { private int doLineWrap() { int line; - line=toAbsoluteLine(fCursorLine); + line = toAbsoluteLine(fCursorLine); fTerminal.setWrappedLine(line); doNewline(); - line=toAbsoluteLine(fCursorLine); + line = toAbsoluteLine(fCursorLine); setCursorColumn(0); return line; } @@ -367,15 +384,16 @@ private int doLineWrap() { private void doNewline() { if (fCursorLine == fScrollRegion.getBottomLine()) scrollUp(1); - else if (fCursorLine+1>=fLines) { - int h=fTerminal.getHeight(); + else if (fCursorLine + 1 >= fLines) { + int h = fTerminal.getHeight(); fTerminal.addLine(); - if(h!=fTerminal.getHeight()) - setCursorLine(fCursorLine+1); + if (h != fTerminal.getHeight()) + setCursorLine(fCursorLine + 1); } else { - setCursorLine(fCursorLine+1); + setCursorLine(fCursorLine + 1); } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#processNewline() */ @@ -384,6 +402,7 @@ public void processNewline() { doNewline(); } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorLine() */ @@ -392,6 +411,7 @@ public int getCursorLine() { return fCursorLine; } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorColumn() */ @@ -400,6 +420,7 @@ public int getCursorColumn() { return fCursorColumn; } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursor(int, int) */ @@ -415,11 +436,11 @@ public void setCursor(int targetLine, int targetColumn) { */ public void setCursorColumn(int targetColumn) { synchronized (fTerminal) { - if(targetColumn<0) - targetColumn=0; - else if(targetColumn>=fColumns) - targetColumn=fColumns-1; - fCursorColumn=targetColumn; + if (targetColumn < 0) + targetColumn = 0; + else if (targetColumn >= fColumns) + targetColumn = fColumns - 1; + fCursorColumn = targetColumn; fWrapPending = false; // We make the assumption that nobody is changing the // terminal cursor except this class! @@ -433,11 +454,11 @@ else if(targetColumn>=fColumns) */ public void setCursorLine(int targetLine) { synchronized (fTerminal) { - if(targetLine<0) - targetLine=0; - else if(targetLine>=fLines) - targetLine=fLines-1; - fCursorLine=targetLine; + if (targetLine < 0) + targetLine = 0; + else if (targetLine >= fLines) + targetLine = fLines - 1; + fCursorLine = targetLine; // We make the assumption that nobody is changing the // terminal cursor except this class! // This assumption gives a huge performance improvement @@ -470,32 +491,32 @@ public void setVT100LineWrapping(boolean enable) { public boolean isVT100LineWrapping() { return fVT100LineWrapping; } - + public void setInsertMode(boolean enable) { fInsertMode = enable; } public void setScrollRegion(int top, int bottom) { if (top < 0 || bottom < 0) - fScrollRegion = ScrollRegion.FULL_WINDOW; + fScrollRegion = ScrollRegion.FULL_WINDOW; else if (top < bottom) fScrollRegion = new ScrollRegion(top, bottom); } public void scrollUp(int n) { - assert n>0; + assert n > 0; synchronized (fTerminal) { 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); } } public void scrollDown(int n) { - assert n>0; + assert n > 0; synchronized (fTerminal) { 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); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 9f07dc37036..cd325c25874 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -125,30 +125,29 @@ * * @author Chris Thew */ -public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl -{ - protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$ - - /** - * 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 - * displayed using the view's StyledText widget. - */ - private final VT100Emulator fTerminalText; - private Display fDisplay; - private TextCanvas fCtlText; - private Composite fWndParent; - private Clipboard fClipboard; - private KeyListener fKeyHandler; - private final ITerminalListener fTerminalListener; - private String fMsg = ""; //$NON-NLS-1$ - private TerminalMouseTrackListener fFocusListener; - private ITerminalConnector fConnector; - private final ITerminalConnector[] fConnectors; +public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl { + protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$ + + /** + * 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 + * displayed using the view's StyledText widget. + */ + private final VT100Emulator fTerminalText; + private Display fDisplay; + private TextCanvas fCtlText; + private Composite fWndParent; + private Clipboard fClipboard; + private KeyListener fKeyHandler; + private final ITerminalListener fTerminalListener; + private String fMsg = ""; //$NON-NLS-1$ + private TerminalMouseTrackListener fFocusListener; + private ITerminalConnector fConnector; + private final ITerminalConnector[] fConnectors; 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 String fEncoding = defaultEncoding; private InputStreamReader fInputStreamReader; @@ -166,10 +165,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC /** * Listens to changes in the preferences */ - private final IPropertyChangeListener fPreferenceListener=new IPropertyChangeListener() { + private final IPropertyChangeListener fPreferenceListener = new IPropertyChangeListener() { @Override - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) || event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) { updatePreferences(); } @@ -177,7 +176,7 @@ public void propertyChange(PropertyChangeEvent event) { }; private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() { @Override - public void propertyChange(PropertyChangeEvent event) { + public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) { onTerminalFontChanged(); } @@ -205,13 +204,14 @@ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerm * Otherwise, clients need to maintain settings themselves. * @since 3.2 */ - public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) { - fConnectors=connectors; + public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, + boolean useCommonPrefs) { + fConnectors = connectors; fUseCommonPrefs = useCommonPrefs; - fTerminalListener=target; - fTerminalModel=TerminalTextDataFactory.makeTerminalTextData(); + fTerminalListener = target; + fTerminalModel = TerminalTextDataFactory.makeTerminalTextData(); fTerminalModel.setMaxHeight(1000); - fInputStream=new PipedInputStream(8*1024); + fInputStream = new PipedInputStream(8 * 1024); fTerminalText = new VT100Emulator(fTerminalModel, this, null); try { // Use Default Encoding as start, until setEncoding() is called @@ -229,7 +229,7 @@ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerm } @Override - public void setEncoding(String encoding) throws UnsupportedEncodingException { + public void setEncoding(String encoding) throws UnsupportedEncodingException { if (encoding == null) { // TODO better use a standard remote-to-local encoding? encoding = "ISO-8859-1"; //$NON-NLS-1$ @@ -243,12 +243,12 @@ public void setEncoding(String encoding) throws UnsupportedEncodingException { } @Override - public String getEncoding() { + public String getEncoding() { return fEncoding; } @Override - public ITerminalConnector[] getConnectors() { + public ITerminalConnector[] getConnectors() { return fConnectors; } @@ -256,7 +256,7 @@ public ITerminalConnector[] getConnectors() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#copy() */ @Override - public void copy() { + public void copy() { copy(DND.CLIPBOARD); } @@ -273,17 +273,17 @@ private void copy(int clipboardType) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste() */ @Override - public void paste() { + public void paste() { paste(DND.CLIPBOARD); -// TODO paste in another thread.... to avoid blocking -// new Thread() { -// public void run() { -// for (int i = 0; i < strText.length(); i++) { -// sendChar(strText.charAt(i), false); -// } -// -// } -// }.start(); + // TODO paste in another thread.... to avoid blocking + // new Thread() { + // public void run() { + // for (int i = 0; i < strText.length(); i++) { + // sendChar(strText.charAt(i), false); + // } + // + // } + // }.start(); } private void paste(int clipboardType) { @@ -296,8 +296,8 @@ private void paste(int clipboardType) { * @param strText the text to paste */ @Override - public boolean pasteString(String strText) { - if(!isConnected()) + public boolean pasteString(String strText) { + if (!isConnected()) return false; if (strText == null) return false; @@ -316,10 +316,10 @@ public boolean pasteString(String strText) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#selectAll() */ @Override - public void selectAll() { + public void selectAll() { getCtlText().selectAll(); if (fTerminalListener instanceof ITerminalListener2) { - ((ITerminalListener2)fTerminalListener).setTerminalSelectionChanged(); + ((ITerminalListener2) fTerminalListener).setTerminalSelectionChanged(); } } @@ -327,7 +327,7 @@ public void selectAll() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#sendKey(char) */ @Override - public void sendKey(char character) { + public void sendKey(char character) { Event event; KeyEvent keyEvent; @@ -346,12 +346,12 @@ public void sendKey(char character) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#clearTerminal() */ @Override - public void clearTerminal() { + public void clearTerminal() { // The TerminalText object does all text manipulation. getTerminalText().clearTerminal(); getCtlText().clearSelection(); if (fTerminalListener instanceof ITerminalListener2) { - ((ITerminalListener2)fTerminalListener).setTerminalSelectionChanged(); + ((ITerminalListener2) fTerminalListener).setTerminalSelectionChanged(); } } @@ -359,7 +359,7 @@ public void clearTerminal() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getClipboard() */ @Override - public Clipboard getClipboard() { + public Clipboard getClipboard() { return fClipboard; } @@ -367,10 +367,10 @@ public Clipboard getClipboard() { * @return non null selection */ @Override - public String getSelection() { - String txt= fCtlText.getSelectionText(); - if(txt==null) - txt=""; //$NON-NLS-1$ + public String getSelection() { + String txt = fCtlText.getSelectionText(); + if (txt == null) + txt = ""; //$NON-NLS-1$ return txt; } @@ -378,7 +378,7 @@ public String getSelection() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setFocus() */ @Override - public void setFocus() { + public void setFocus() { getCtlText().setFocus(); } @@ -386,7 +386,7 @@ public void setFocus() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isEmpty() */ @Override - public boolean isEmpty() { + public boolean isEmpty() { return getCtlText().isEmpty(); } @@ -394,7 +394,7 @@ public boolean isEmpty() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isDisposed() */ @Override - public boolean isDisposed() { + public boolean isDisposed() { return getCtlText().isDisposed(); } @@ -402,17 +402,17 @@ public boolean isDisposed() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnected() */ @Override - public boolean isConnected() { - return fState==TerminalState.CONNECTED; + public boolean isConnected() { + return fState == TerminalState.CONNECTED; } /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disposeTerminal() */ @Override - public void disposeTerminal() { + public void disposeTerminal() { Logger.log("entered."); //$NON-NLS-1$ - if(fUseCommonPrefs) { + if (fUseCommonPrefs) { TerminalPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); JFaceResources.getFontRegistry().removeListener(fFontListener); } @@ -422,16 +422,14 @@ public void disposeTerminal() { } @Override - public void connectTerminal() { + public void connectTerminal() { Logger.log("entered."); //$NON-NLS-1$ - if(getTerminalConnector()==null) + if (getTerminalConnector() == null) return; fTerminalText.resetState(); fApplicationCursorKeys = false; - if(fConnector.getInitializationErrorMessage()!=null) { - showErrorMessage(NLS.bind( - TerminalMessages.CannotConnectTo, - fConnector.getName(), + if (fConnector.getInitializationErrorMessage() != null) { + showErrorMessage(NLS.bind(TerminalMessages.CannotConnectTo, fConnector.getName(), fConnector.getInitializationErrorMessage())); // we cannot connect because the connector was not initialized return; @@ -443,39 +441,42 @@ public void connectTerminal() { } @Override - public ITerminalConnector getTerminalConnector() { + public ITerminalConnector getTerminalConnector() { return fConnector; } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disconnectTerminal() */ @Override - public void disconnectTerminal() { + public void disconnectTerminal() { Logger.log("entered."); //$NON-NLS-1$ //Disconnect the remote side first - if (getState()!=TerminalState.CLOSED) { - if(getTerminalConnector()!=null) { + if (getState() != TerminalState.CLOSED) { + if (getTerminalConnector() != null) { getTerminalConnector().disconnect(); } } - //Ensure that a new Job can be started; then clean up old Job. - Job job; - synchronized(this) { - job = fJob; - fJob = null; - } - if (job!=null) { - job.cancel(); - // 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). - Thread t = job.getThread(); - if(t!=null) t.interrupt(); - try { - job.join(); - } catch (InterruptedException e) {} - } + //Ensure that a new Job can be started; then clean up old Job. + Job job; + synchronized (this) { + job = fJob; + fJob = null; + } + if (job != null) { + job.cancel(); + // 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). + Thread t = job.getThread(); + if (t != null) + t.interrupt(); + try { + job.join(); + } catch (InterruptedException e) { + } + } fPollingTextCanvasModel.stopPolling(); } @@ -486,7 +487,7 @@ private void waitForConnect() { do { if (!fDisplay.readAndDispatch()) fDisplay.sleep(); - } while (getState()==TerminalState.CONNECTING); + } while (getState() == TerminalState.CONNECTING); if (getCtlText().isDisposed()) { disconnectTerminal(); @@ -506,23 +507,23 @@ private void waitForConnect() { } private synchronized void startReaderJob() { - if(fJob==null) { - fJob=new Job("Terminal data reader") { //$NON-NLS-1$ + if (fJob == null) { + fJob = new Job("Terminal data reader") { //$NON-NLS-1$ @Override - protected IStatus run(IProgressMonitor monitor) { - IStatus status=Status.OK_STATUS; + protected IStatus run(IProgressMonitor monitor) { + IStatus status = Status.OK_STATUS; try { - while(true) { - while(fInputStream.available()==0 && !monitor.isCanceled()) { + while (true) { + while (fInputStream.available() == 0 && !monitor.isCanceled()) { try { fInputStream.waitForAvailable(500); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } - if(monitor.isCanceled()) { + if (monitor.isCanceled()) { //Do not disconnect terminal here because another reader job may already be running - status=Status.CANCEL_STATUS; + status = Status.CANCEL_STATUS; break; } try { @@ -530,7 +531,8 @@ protected IStatus run(IProgressMonitor monitor) { fTerminalText.processText(); } catch (Exception e) { disconnectTerminal(); - status=new Status(IStatus.ERROR,TerminalPlugin.PLUGIN_ID,e.getLocalizedMessage(),e); + status = new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, e.getLocalizedMessage(), + e); break; } } @@ -538,8 +540,8 @@ protected IStatus run(IProgressMonitor monitor) { // 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) synchronized (VT100TerminalControl.this) { - if (fJob==this) { - fJob=null; + if (fJob == this) { + fJob = null; } } } @@ -576,8 +578,7 @@ protected void sendString(String string) { } catch (SocketException socketException) { displayTextInTerminal(socketException.getMessage()); - String strMsg = TerminalMessages.SocketError - + "!\n" + socketException.getMessage(); //$NON-NLS-1$ + String strMsg = TerminalMessages.SocketError + "!\n" + socketException.getMessage(); //$NON-NLS-1$ showErrorMessage(strMsg); Logger.logException(socketException); @@ -593,7 +594,7 @@ protected void sendString(String string) { } @Override - public Shell getShell() { + public Shell getShell() { return getCtlText().getShell(); } @@ -601,7 +602,7 @@ protected void sendChar(char chKey, boolean altKeyPressed) { try { int byteToSend = chKey; OutputStream os = getOutputStream(); - if (os==null) { + if (os == null) { // 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$ } else { @@ -619,7 +620,8 @@ protected void sendChar(char chKey, boolean altKeyPressed) { byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding); StringBuilder b = new StringBuilder("sending ESC"); //$NON-NLS-1$ 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$ } Logger.log(b.toString()); @@ -629,7 +631,8 @@ protected void sendChar(char chKey, boolean altKeyPressed) { byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding); StringBuilder b = new StringBuilder("sending"); //$NON-NLS-1$ 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$ } Logger.log(b.toString()); @@ -642,8 +645,7 @@ protected void sendChar(char chKey, boolean altKeyPressed) { displayTextInTerminal(socketException.getMessage()); - String strMsg = TerminalMessages.SocketError - + "!\n" + socketException.getMessage(); //$NON-NLS-1$ + String strMsg = TerminalMessages.SocketError + "!\n" + socketException.getMessage(); //$NON-NLS-1$ showErrorMessage(strMsg); Logger.logException(socketException); @@ -667,7 +669,7 @@ protected void sendChar(char chKey, boolean altKeyPressed) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setupTerminal(org.eclipse.swt.widgets.Composite) */ @Override - public void setupTerminal(Composite parent) { + public void setupTerminal(Composite parent) { Assert.isNotNull(parent); boolean wasDisposed = true; TerminalState oldState = fState; @@ -703,8 +705,10 @@ public void setupTerminal(Composite parent) { * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#updatePreferences() */ private void updatePreferences() { - int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_BUFFERLINES, 0, null); - boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_INVERT_COLORS, false, null); + int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, + ITerminalConstants.PREF_BUFFERLINES, 0, null); + boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID, + ITerminalConstants.PREF_INVERT_COLORS, false, null); setBufferLineLimit(bufferLineLimit); setInvertedColors(invert); } @@ -719,10 +723,10 @@ private void onTerminalFontChanged() { * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String) */ @Override - public void setFont(String fontName) { - Font font=JFaceResources.getFont(fontName); + public void setFont(String fontName) { + Font font = JFaceResources.getFont(fontName); getCtlText().setFont(font); - if(fCommandInputField!=null) { + if (fCommandInputField != null) { fCommandInputField.setFont(font); } // Tell the TerminalControl singleton that the font has changed. @@ -734,10 +738,10 @@ public void setFont(String fontName) { * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(org.eclipse.swt.graphics.Font) */ @Override - @Deprecated + @Deprecated public void setFont(Font font) { getCtlText().setFont(font); - if(fCommandInputField!=null) { + if (fCommandInputField != null) { fCommandInputField.setFont(font); } @@ -745,40 +749,47 @@ public void setFont(Font font) { fCtlText.onFontChange(); getTerminalText().fontChanged(); } + @Override - public Font getFont() { + public Font getFont() { return getCtlText().getFont(); } + @Override - public Control getControl() { + public Control getControl() { return fCtlText; } + @Override - public Control getRootControl() { + public Control getRootControl() { return fWndParent; } + protected void setupControls(Composite parent) { - fWndParent=new Composite(parent,SWT.NONE); - GridLayout layout=new GridLayout(); - layout.marginWidth=0; layout.marginHeight=0; layout.verticalSpacing=0; + fWndParent = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.verticalSpacing = 0; fWndParent.setLayout(layout); - ITerminalTextDataSnapshot snapshot=fTerminalModel.makeSnapshot(); + ITerminalTextDataSnapshot snapshot = fTerminalModel.makeSnapshot(); // TODO how to get the initial size correctly! snapshot.updateSnapshot(false); - fPollingTextCanvasModel=new PollingTextCanvasModel(snapshot); - fCtlText=new TextCanvas(fWndParent,fPollingTextCanvasModel,SWT.NONE,new TextLineRenderer(fCtlText,fPollingTextCanvasModel)); + fPollingTextCanvasModel = new PollingTextCanvasModel(snapshot); + fCtlText = new TextCanvas(fWndParent, fPollingTextCanvasModel, SWT.NONE, + new TextLineRenderer(fCtlText, fPollingTextCanvasModel)); fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); fCtlText.addResizeHandler(new TextCanvas.ResizeListener() { @Override - public void sizeChanged(int lines, int columns) { + public void sizeChanged(int lines, int columns) { fTerminalText.setDimensions(lines, columns); } }); fCtlText.addMouseListener(new MouseAdapter() { @Override - public void mouseUp(MouseEvent e) { + public void mouseUp(MouseEvent e) { // update selection used by middle mouse button paste if (e.button == 1 && getSelection().length() > 0) { copy(DND.SELECTION_CLIPBOARD); @@ -818,9 +829,10 @@ protected void setupHelp(Composite parent, String id) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#displayTextInTerminal(java.lang.String) */ @Override - public void displayTextInTerminal(String text) { - writeToTerminal("\r\n"+text+"\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ + public void displayTextInTerminal(String text) { + writeToTerminal("\r\n" + text + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ } + private void writeToTerminal(String text) { try { getRemoteToTerminalOutputStream().write(text.getBytes(fEncoding)); @@ -834,20 +846,21 @@ private void writeToTerminal(String text) { } @Override - public OutputStream getRemoteToTerminalOutputStream() { - if(Logger.isLogEnabled()) { + public OutputStream getRemoteToTerminalOutputStream() { + if (Logger.isLogEnabled()) { return new LoggingOutputStream(fInputStream.getOutputStream()); } else { return fInputStream.getOutputStream(); } } + protected boolean isLogCharEnabled() { return TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_CHAR); } @Override - public OutputStream getOutputStream() { - if(getTerminalConnector()!=null) + public OutputStream getOutputStream() { + if (getTerminalConnector() != null) return getTerminalConnector().getTerminalToRemoteStream(); return null; } @@ -856,7 +869,7 @@ public OutputStream getOutputStream() { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setMsg(java.lang.String) */ @Override - public void setMsg(String msg) { + public void setMsg(String msg) { fMsg = msg; } @@ -877,6 +890,7 @@ protected TextCanvas getCtlText() { public VT100Emulator getTerminalText() { return fTerminalText; } + protected class TerminalMouseTrackListener implements MouseTrackListener { private IContextActivation terminalContextActivation = null; private IContextActivation editContextActivation = null; @@ -898,7 +912,8 @@ public void mouseEnter(MouseEvent e) { if (getState() == TerminalState.CONNECTED) 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$ } @@ -910,14 +925,17 @@ public void mouseExit(MouseEvent e) { // 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); } @SuppressWarnings("cast") protected void captureKeyEvents(boolean capture) { - IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); - IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class); + IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench() + .getAdapter(IBindingService.class); + IContextService contextService = (IContextService) PlatformUI.getWorkbench() + .getAdapter(IContextService.class); boolean enableKeyFilter = !capture; if (bindingService.isKeyFilterEnabled() != enableKeyFilter) @@ -941,9 +959,9 @@ protected void captureKeyEvents(boolean capture) { protected class TerminalKeyHandler extends KeyAdapter { @Override - public void keyPressed(KeyEvent event) { + public void keyPressed(KeyEvent event) { //TODO next 2 lines are probably obsolete now - if (getState()==TerminalState.CONNECTING) + if (getState() == TerminalState.CONNECTING) return; //TODO we should no longer handle copy & paste specially. @@ -981,7 +999,7 @@ public void keyPressed(KeyEvent event) { boolean altKeyPressed = (event.stateMask & SWT.ALT) != 0 && !ctrlKeyPressed; //if (!isConnected()) { - if (fState==TerminalState.CLOSED) { + if (fState == TerminalState.CLOSED) { // Pressing ENTER while not connected causes us to connect. if (character == '\r' && isConnectOnEnterIfClosed()) { connectTerminal(); @@ -1203,12 +1221,9 @@ public void keyPressed(KeyEvent event) { // // o The character is the DELETE character. - if (getTerminalConnector() == null - || getTerminalConnector().isLocalEcho() == false || altKeyPressed - || (character >= '\u0001' && character < '\t') - || (character > '\t' && character < '\r') - || (character > '\r' && character <= '\u001f') - || character == '\u007f') { + if (getTerminalConnector() == null || getTerminalConnector().isLocalEcho() == false || altKeyPressed + || (character >= '\u0001' && character < '\t') || (character > '\t' && character < '\r') + || (character > '\r' && character <= '\u001f') || character == '\u007f') { // No local echoing. return; } @@ -1232,13 +1247,15 @@ public void keyPressed(KeyEvent event) { */ @SuppressWarnings("cast") 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); Binding binding = bindingService.getPerfectMatch(KeySequence.getInstance(keyStroke)); if (binding != null) { ParameterizedCommand cmd = binding.getParameterizedCommand(); if (cmd != null) { - IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class); + IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() + .getAdapter(IHandlerService.class); Event cmdEvent = new Event(); cmdEvent.type = SWT.KeyDown; cmdEvent.display = event.display; @@ -1252,9 +1269,9 @@ private void processKeyBinding(KeyEvent event, int accelerator) { Field f1 = event.getClass().getField("keyLocation"); //$NON-NLS-1$ Field f2 = cmdEvent.getClass().getField("keyLocation"); //$NON-NLS-1$ f2.set(cmdEvent, f1.get(event)); - } catch(NoSuchFieldException nsfe) { + } catch (NoSuchFieldException nsfe) { /* ignore, this is Eclipse 3.5 or earlier */ - } catch(Throwable t) { + } catch (Throwable t) { t.printStackTrace(); } cmdEvent.stateMask = event.stateMask; @@ -1262,8 +1279,8 @@ private void processKeyBinding(KeyEvent event, int accelerator) { try { handlerService.executeCommand(cmd, cmdEvent); } catch (ExecutionException e) { - TerminalPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR,TerminalPlugin.PLUGIN_ID,e.getLocalizedMessage(),e)); + TerminalPlugin.getDefault().getLog() + .log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, e.getLocalizedMessage(), e)); } catch (Exception e) { // ignore other exceptions from cmd execution } @@ -1274,26 +1291,24 @@ private void processKeyBinding(KeyEvent event, int accelerator) { } @Override - public void setTerminalTitle(String title) { + public void setTerminalTitle(String title) { fTerminalListener.setTerminalTitle(title); } - @Override - public TerminalState getState() { + public TerminalState getState() { return fState; } - @Override - public void setState(TerminalState state) { - fState=state; + public void setState(TerminalState state) { + fState = state; fTerminalListener.setState(state); // enable the (blinking) cursor if the terminal is connected runAsyncInDisplayThread(new Runnable() { @Override - public void run() { - if(fCtlText!=null && !fCtlText.isDisposed()) { + public void run() { + if (fCtlText != null && !fCtlText.isDisposed()) { if (isConnected()) { fCtlText.setCursorEnabled(true); } else { @@ -1305,73 +1320,76 @@ public void run() { } }); } + /** * @param runnable run in display thread */ private void runAsyncInDisplayThread(Runnable runnable) { - if(Display.findDisplay(Thread.currentThread())!=null) + if (Display.findDisplay(Thread.currentThread()) != null) 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); // else should not happen and we ignore it... } @Override - public String getSettingsSummary() { - if(getTerminalConnector()!=null) + public String getSettingsSummary() { + if (getTerminalConnector() != null) return getTerminalConnector().getSettingsSummary(); return ""; //$NON-NLS-1$ } @Override - public void setConnector(ITerminalConnector connector) { - fConnector=connector; + public void setConnector(ITerminalConnector connector) { + fConnector = connector; } + @Override - public ICommandInputField getCommandInputField() { + public ICommandInputField getCommandInputField() { return fCommandInputField; } @Override - public void setCommandInputField(ICommandInputField inputField) { - if(fCommandInputField!=null) + public void setCommandInputField(ICommandInputField inputField) { + if (fCommandInputField != null) fCommandInputField.dispose(); - fCommandInputField=inputField; - if(fCommandInputField!=null) + fCommandInputField = inputField; + if (fCommandInputField != null) fCommandInputField.createControl(fWndParent, this); - if(fWndParent.isVisible()) + if (fWndParent.isVisible()) fWndParent.layout(true); } @Override - public int getBufferLineLimit() { + public int getBufferLineLimit() { return fTerminalModel.getMaxHeight(); } @Override - public void setBufferLineLimit(int bufferLineLimit) { - if(bufferLineLimit<=0) + public void setBufferLineLimit(int bufferLineLimit) { + if (bufferLineLimit <= 0) return; synchronized (fTerminalModel) { - if(fTerminalModel.getHeight()>bufferLineLimit) + if (fTerminalModel.getHeight() > bufferLineLimit) fTerminalModel.setDimensions(bufferLineLimit, fTerminalModel.getWidth()); fTerminalModel.setMaxHeight(bufferLineLimit); } } @Override - public boolean isScrollLock() { + public boolean isScrollLock() { return fCtlText.isScrollLock(); } @Override - public void setScrollLock(boolean on) { + public void setScrollLock(boolean on) { fCtlText.setScrollLock(on); } @Override - public void setInvertedColors(boolean invert) { + public void setInvertedColors(boolean invert) { fCtlText.setInvertedColors(invert); } @@ -1379,7 +1397,7 @@ public void setInvertedColors(boolean invert) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setConnectOnEnterIfClosed(boolean) */ @Override - public final void setConnectOnEnterIfClosed(boolean on) { + public final void setConnectOnEnterIfClosed(boolean on) { connectOnEnterIfClosed = on; } @@ -1387,33 +1405,33 @@ public final void setConnectOnEnterIfClosed(boolean on) { * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnectOnEnterIfClosed() */ @Override - public final boolean isConnectOnEnterIfClosed() { + public final boolean isConnectOnEnterIfClosed() { return connectOnEnterIfClosed; } @Override - public void setVT100LineWrapping(boolean enable) { + public void setVT100LineWrapping(boolean enable) { getTerminalText().setVT100LineWrapping(enable); } @Override - public boolean isVT100LineWrapping() { + public boolean isVT100LineWrapping() { return getTerminalText().isVT100LineWrapping(); } @Override - public void enableApplicationCursorKeys(boolean enable) { + public void enableApplicationCursorKeys(boolean enable) { fApplicationCursorKeys = enable; } - + @Override public void addMouseListener(ITerminalMouseListener listener) { - getCtlText().addTerminalMouseListener(listener); + getCtlText().addTerminalMouseListener(listener); } - + @Override public void removeMouseListener(ITerminalMouseListener listener) { - getCtlText().removeTerminalMouseListener(listener); + getCtlText().removeTerminalMouseListener(listener); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java index b7c71eb9efa..9f51f2150ac 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/ISnapshotChanges.java @@ -48,7 +48,7 @@ public interface ISnapshotChanges { /** * Mark all lines changed - * @param height if no window is set this is the number of + * @param height if no window is set this is the number of * lines that are marked as changed */ void setAllChanged(int height); @@ -66,19 +66,21 @@ public interface ISnapshotChanges { boolean hasLineChanged(int line); void markDimensionsChanged(); + boolean hasDimensionsChanged(); + void markCursorChanged(); /** * @return true if the terminal data has changed */ boolean hasTerminalChanged(); + /** * mark the terminal as changed */ void setTerminalChanged(); - void copyChangedLines(ITerminalTextData dest, ITerminalTextData source); /** @@ -86,7 +88,9 @@ public interface ISnapshotChanges { * @param size number of lines to follow */ void setInterestWindow(int startLine, int size); + int getInterestWindowStartLine(); + int getInterestWindowSize(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java index 0c62f59f091..a4975cfac66 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java @@ -14,7 +14,6 @@ import org.eclipse.tm.terminal.model.ITerminalTextData; - /** * Collects the changes of the {@link ITerminalTextData} * @@ -45,26 +44,28 @@ public class SnapshotChanges implements ISnapshotChanges { * not changed don't have to be copied) */ private boolean[] fChangedLines; - + private int fInterestWindowSize; private int fInterestWindowStartLine; private boolean fDimensionsChanged; private boolean fTerminalHasChanged; private boolean fCursorHasChanged; - + public SnapshotChanges(int nLines) { setChangedLinesLength(nLines); - fFirstChangedLine=Integer.MAX_VALUE; - fLastChangedLine=-1; + fFirstChangedLine = Integer.MAX_VALUE; + fLastChangedLine = -1; } + public SnapshotChanges(int windowStart, int windowSize) { - setChangedLinesLength(windowStart+windowSize); - fFirstChangedLine=Integer.MAX_VALUE; - fLastChangedLine=-1; - fInterestWindowStartLine=windowStart; - fInterestWindowSize=windowSize; + setChangedLinesLength(windowStart + windowSize); + fFirstChangedLine = Integer.MAX_VALUE; + fLastChangedLine = -1; + fInterestWindowStartLine = windowStart; + fInterestWindowSize = windowSize; } + /** * This is used in asserts to throw an {@link RuntimeException}. * This is useful for tests. @@ -73,6 +74,7 @@ public SnapshotChanges(int windowStart, int windowSize) { private boolean throwRuntimeException() { throw new RuntimeException(); } + /** * @param line * @param size @@ -82,12 +84,13 @@ private boolean throwRuntimeException() { * It used to be package protected, and it is public only for Unit Tests. */ public boolean isInInterestWindow(int line, int size) { - if(fInterestWindowSize<=0) + if (fInterestWindowSize <= 0) return true; - if(line+size<=fInterestWindowStartLine || line>=fInterestWindowStartLine+fInterestWindowSize) + if (line + size <= fInterestWindowStartLine || line >= fInterestWindowStartLine + fInterestWindowSize) return false; return true; } + /** * @param line * @return true if the line is within the interest window @@ -96,12 +99,13 @@ public boolean isInInterestWindow(int line, int size) { * It used to be package protected, and it is public only for Unit Tests. */ public boolean isInInterestWindow(int line) { - if(fInterestWindowSize<=0) + if (fInterestWindowSize <= 0) return true; - if(line=fInterestWindowStartLine+fInterestWindowSize) + if (line < fInterestWindowStartLine || line >= fInterestWindowStartLine + fInterestWindowSize) return false; return true; } + /** * @param line * @return the line within the window @@ -110,17 +114,18 @@ public boolean isInInterestWindow(int line) { * It used to be package protected, and it is public only for Unit Tests. */ public int fitLineToWindow(int line) { - if(fInterestWindowSize<=0) + if (fInterestWindowSize <= 0) return line; - if(linebefore {@link #fitLineToWindow(int)} has been called! * @param size - * @return the adjusted size. + * @return the adjusted size. * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. * It used to be package protected, and it is public only for Unit Tests. @@ -129,99 +134,110 @@ public int fitLineToWindow(int line) { * move the window correctly! */ public int fitSizeToWindow(int line, int size) { - if(fInterestWindowSize<=0) + if (fInterestWindowSize <= 0) return size; - if(linefInterestWindowStartLine+fInterestWindowSize) - size=fInterestWindowStartLine+fInterestWindowSize-line; + if (line + size > fInterestWindowStartLine + fInterestWindowSize) + size = fInterestWindowStartLine + fInterestWindowSize - line; return size; } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLineChanged(int) */ public void markLineChanged(int line) { - if(!isInInterestWindow(line)) + if (!isInInterestWindow(line)) return; - line=fitLineToWindow(line); - if(linefLastChangedLine) - fLastChangedLine=line; - // in case the terminal got resized we expand + line = fitLineToWindow(line); + if (line < fFirstChangedLine) + fFirstChangedLine = line; + if (line > fLastChangedLine) + fLastChangedLine = line; + // in case the terminal got resized we expand // don't remember the changed line because // there is nothing to copy - if(line0 || fScrollWindowShift!=0 ||fDimensionsChanged || fCursorHasChanged) + if (fFirstChangedLine != Integer.MAX_VALUE || fLastChangedLine > 0 || fScrollWindowShift != 0 + || fDimensionsChanged || fCursorHasChanged) return true; return false; } + public void markDimensionsChanged() { - fDimensionsChanged=true; + fDimensionsChanged = true; } + public boolean hasDimensionsChanged() { return fDimensionsChanged; } + public boolean hasTerminalChanged() { return fTerminalHasChanged; } + public void setTerminalChanged() { - fTerminalHasChanged=true; + fTerminalHasChanged = true; } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#scroll(int, int, int) */ public void scroll(int startLine, int size, int shift) { - size=fitSizeToWindow(startLine, size); - startLine=fitLineToWindow(startLine); + size = fitSizeToWindow(startLine, size); + startLine = fitLineToWindow(startLine); // let's track only negative shifts - if(fScrollDontTrack) { + if (fScrollDontTrack) { // we are in a state where we cannot track scrolling // so let's simply mark the scrolled lines as changed markLinesChanged(startLine, size); - } else if(shift>=0) { + } else if (shift >= 0) { // we cannot handle positive scroll // forget about clever caching of scroll events doNotTrackScrollingAnymore(); @@ -229,12 +245,12 @@ public void scroll(int startLine, int size, int shift) { markLinesChanged(startLine, size); } else { // we have already scrolled - if(fScrollWindowShift<0) { + if (fScrollWindowShift < 0) { // we have already scrolled - if(fScrollWindowStartLine==startLine && fScrollWindowSize==size) { + if (fScrollWindowStartLine == startLine && fScrollWindowSize == size) { // we are scrolling the same region again? - fScrollWindowShift+=shift; - scrollChangesLinesWithNegativeShift(startLine,size,shift); + fScrollWindowShift += shift; + scrollChangesLinesWithNegativeShift(startLine, size, shift); } else { // mark all lines in the old scroll region as changed doNotTrackScrollingAnymore(); @@ -243,28 +259,30 @@ public void scroll(int startLine, int size, int shift) { } } else { // first scroll in this change -- we just notify it - fScrollWindowStartLine=startLine; - fScrollWindowSize=size; - fScrollWindowShift=shift; - scrollChangesLinesWithNegativeShift(startLine,size,shift); + fScrollWindowStartLine = startLine; + fScrollWindowSize = size; + fScrollWindowShift = shift; + scrollChangesLinesWithNegativeShift(startLine, size, shift); } } } + /** * Some incompatible scrolling occurred. We cannot do the * scroll optimization anymore... */ private void doNotTrackScrollingAnymore() { - if(fScrollWindowSize>0) { + if (fScrollWindowSize > 0) { // convert the current scrolling into changes markLinesChanged(fScrollWindowStartLine, fScrollWindowSize); - fScrollWindowStartLine=0; - fScrollWindowSize=0; - fScrollWindowShift=0; + fScrollWindowStartLine = 0; + fScrollWindowSize = 0; + fScrollWindowShift = 0; } // don't be clever on scrolling anymore - fScrollDontTrack=true; + fScrollDontTrack = true; } + /** * Scrolls the changed lines data * @@ -273,78 +291,85 @@ private void doNotTrackScrollingAnymore() { * @param shift must be negative! */ private void scrollChangesLinesWithNegativeShift(int line, int n, int shift) { - assert shift <0 || throwRuntimeException(); + assert shift < 0 || throwRuntimeException(); // scroll the region // 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++) { - setChangedLine(i, hasLineChanged(i-shift)); + setChangedLine(i, hasLineChanged(i - shift)); // move the first changed line up. // We don't have to move the maximum down, // because with a shift scroll, the max is moved // my the next loop in this method - if(i0) { - int shift=oldStartLine-startLine; - if(shift==0) { - if(size>oldSize) { + int oldStartLine = fInterestWindowStartLine; + int oldSize = fInterestWindowSize; + fInterestWindowStartLine = startLine; + fInterestWindowSize = size; + if (oldSize > 0) { + int shift = oldStartLine - startLine; + if (shift == 0) { + if (size > oldSize) { // add lines to the end - markLinesChanged(oldStartLine+oldSize, size-oldSize); + markLinesChanged(oldStartLine + oldSize, size - oldSize); } // else no lines within the window have changed - - } else if(Math.abs(shift)0) + if (line > 0) buff.append("\n"); //$NON-NLS-1$ for (int column = 0; column < width; column++) { buff.append(term.getChar(line, column)); @@ -83,71 +84,86 @@ static public String toMultiLineText(ITerminalTextDataReadOnly term) { public TerminalTextData() { this(new TerminalTextDataFastScroll()); -// this(new TerminalTextDataStore()); + // this(new TerminalTextDataStore()); } + public TerminalTextData(ITerminalTextData data) { - fData=data; + fData = data; } + public int getWidth() { return fData.getWidth(); } + public int getHeight() { // no need for an extra variable return fData.getHeight(); } + public void setDimensions(int height, int width) { - int h=getHeight(); - int w=getWidth(); - if(w==width && h==height) + int h = getHeight(); + int w = getWidth(); + if (w == width && h == height) return; fData.setDimensions(height, width); sendDimensionsChanged(h, w, height, width); } + private void sendDimensionsChanged(int oldHeight, int oldWidth, int newHeight, int newWidth) { // determine what has changed - if(oldWidth==newWidth) { - if(oldHeight list=new ArrayList(); + List list = new ArrayList(); list.addAll(Arrays.asList(fSnapshots)); list.remove(snapshot); - fSnapshots=list.toArray(new TerminalTextDataSnapshot[list.size()]); + fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]); } public ITerminalTextDataSnapshot makeSnapshot() { // poor mans approach to modify the array - TerminalTextDataSnapshot snapshot=new TerminalTextDataSnapshot(this); + TerminalTextDataSnapshot snapshot = new TerminalTextDataSnapshot(this); snapshot.markDimensionsChanged(); - List list=new ArrayList(); + List list = new ArrayList(); list.addAll(Arrays.asList(fSnapshots)); list.add(snapshot); - fSnapshots=list.toArray(new TerminalTextDataSnapshot[list.size()]); + fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]); return snapshot; } + public void addLine() { - int oldHeight=getHeight(); + int oldHeight = getHeight(); fData.addLine(); // was is an append or a scroll? - int newHeight=getHeight(); - if(newHeight>oldHeight) { + int newHeight = getHeight(); + if (newHeight > oldHeight) { //the line was appended sendLinesChangedToSnapshot(oldHeight, 1); - int width=getWidth(); + int width = getWidth(); sendDimensionsChanged(oldHeight, width, newHeight, width); } else { @@ -225,44 +245,54 @@ public void addLine() { public void copy(ITerminalTextData source) { fData.copy(source); - fCursorLine=source.getCursorLine(); - fCursorColumn=source.getCursorColumn(); + fCursorLine = source.getCursorLine(); + fCursorColumn = source.getCursorColumn(); } public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { fData.copyLine(source, sourceLine, destLine); } + public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { fData.copyRange(source, sourceStartLine, destStartLine, length); } + public char[] getChars(int line) { return fData.getChars(line); } + public Style[] getStyles(int line) { return fData.getStyles(line); } + public int getMaxHeight() { return fData.getMaxHeight(); } + public void setMaxHeight(int height) { fData.setMaxHeight(height); } + public void cleanLine(int line) { fData.cleanLine(line); sendLineChangedToSnapshots(line); } + public int getCursorColumn() { return fCursorColumn; } + public int getCursorLine() { return fCursorLine; } + public void setCursorColumn(int column) { - fCursorColumn=column; + fCursorColumn = column; sendCursorChanged(); } + public void setCursorLine(int line) { - fCursorLine=line; + fCursorLine = line; sendCursorChanged(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java index e175cd7182c..14dbbaef115 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ @@ -23,27 +23,31 @@ * */ public class TerminalTextDataFastScroll implements ITerminalTextData { - + final ITerminalTextData fData; private int fHeight; private int fMaxHeight; /** - * The offset into the array. + * The offset into the array. */ int fOffset; - public TerminalTextDataFastScroll(ITerminalTextData data,int maxHeight) { - fMaxHeight=maxHeight; - fData=data; + + public TerminalTextDataFastScroll(ITerminalTextData data, int maxHeight) { + fMaxHeight = maxHeight; + fData = data; fData.setDimensions(maxHeight, fData.getWidth()); - if(maxHeight>2) + if (maxHeight > 2) assert shiftOffset(-2) || throwRuntimeException(); } + public TerminalTextDataFastScroll(int maxHeight) { - this(new TerminalTextDataStore(),maxHeight); + this(new TerminalTextDataStore(), maxHeight); } + public TerminalTextDataFastScroll() { - this(new TerminalTextDataStore(),1); + this(new TerminalTextDataStore(), 1); } + /** * This is used in asserts to throw an {@link RuntimeException}. * This is useful for tests. @@ -52,23 +56,26 @@ public TerminalTextDataFastScroll() { private boolean throwRuntimeException() { throw new RuntimeException(); } + /** - * + * * @param line * @return the actual line number in {@link #fData} */ int getPositionOfLine(int line) { - return (line+fOffset)%fMaxHeight; + return (line + fOffset) % fMaxHeight; } + /** * Moves offset by delta. This does not move the data! * @param delta */ void moveOffset(int delta) { - assert Math.abs(delta)=0 && destStartLine+length<=fHeight) || throwRuntimeException(); + assert (destStartLine >= 0 && destStartLine + length <= fHeight) || throwRuntimeException(); 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) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); return fData.getChar(getPositionOfLine(line), column); } public char[] getChars(int line) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); return fData.getChars(getPositionOfLine(line)); } @@ -123,7 +132,7 @@ public int getHeight() { } public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); return fData.getLineSegments(getPositionOfLine(line), startCol, numberOfCols); } @@ -132,12 +141,12 @@ public int getMaxHeight() { } public Style getStyle(int line, int column) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); return fData.getStyle(getPositionOfLine(line), column); } public Style[] getStyles(int line) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); return fData.getStyles(getPositionOfLine(line)); } @@ -148,111 +157,119 @@ public int getWidth() { public ITerminalTextDataSnapshot makeSnapshot() { return fData.makeSnapshot(); } + 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)); } } + public void scroll(int startLine, int size, int shift) { - assert (startLine>=0 && startLine+size<=fHeight) || throwRuntimeException(); - if(shift>=fMaxHeight || -shift>=fMaxHeight) { - cleanLines(startLine, fMaxHeight-startLine); + assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException(); + if (shift >= fMaxHeight || -shift >= fMaxHeight) { + cleanLines(startLine, fMaxHeight - startLine); return; } - if(size==fHeight) { + if (size == fHeight) { // This is the case this class is optimized for! moveOffset(-shift); - // we only have to clean the lines that appear by the move - if(shift<0) { - cleanLines(Math.max(startLine, startLine+size+shift),Math.min(-shift, getHeight()-startLine)); + // we only have to clean the lines that appear by the move + if (shift < 0) { + cleanLines(Math.max(startLine, startLine + size + shift), Math.min(-shift, getHeight() - startLine)); } else { - cleanLines(startLine, Math.min(shift, getHeight()-startLine)); + cleanLines(startLine, Math.min(shift, getHeight() - startLine)); } } else { // we have to copy the lines. - if(shift<0) { + if (shift < 0) { // move the region up // shift is negative!! - for (int i = startLine; i < startLine+size+shift; i++) { - fData.copyLine(fData, getPositionOfLine(i-shift), getPositionOfLine(i)); + for (int i = startLine; i < startLine + size + shift; i++) { + fData.copyLine(fData, getPositionOfLine(i - shift), getPositionOfLine(i)); } // 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 { - for (int i = startLine+size-1; i >=startLine && i-shift>=0; i--) { - fData.copyLine(fData, getPositionOfLine(i-shift), getPositionOfLine(i)); + for (int i = startLine + size - 1; i >= startLine && i - shift >= 0; 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) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); fData.setChar(getPositionOfLine(line), column, c, style); } public void setChars(int line, int column, char[] chars, int start, int len, Style style) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); fData.setChars(getPositionOfLine(line), column, chars, start, len, style); } public void setChars(int line, int column, char[] chars, Style style) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); fData.setChars(getPositionOfLine(line), column, chars, style); } public void setDimensions(int height, int width) { - assert height>=0 || throwRuntimeException(); - assert width>=0 || throwRuntimeException(); - if(height > fMaxHeight) + assert height >= 0 || throwRuntimeException(); + assert width >= 0 || throwRuntimeException(); + if (height > fMaxHeight) setMaxHeight(height); - fHeight=height; - if(width!=fData.getWidth()) + fHeight = height; + if (width != fData.getWidth()) fData.setDimensions(fMaxHeight, width); } public void setMaxHeight(int maxHeight) { - assert maxHeight>=fHeight || throwRuntimeException(); + assert maxHeight >= fHeight || throwRuntimeException(); // move everything to offset0 - int start=getPositionOfLine(0); - if(start!=0) { + int start = getPositionOfLine(0); + if (start != 0) { // invent a more efficient algorithm.... - ITerminalTextData buffer=new TerminalTextDataStore(); + ITerminalTextData buffer = new TerminalTextDataStore(); // create a buffer with the expected height buffer.setDimensions(maxHeight, getWidth()); - int n=Math.min(fMaxHeight-start,maxHeight); + int n = Math.min(fMaxHeight - start, maxHeight); // copy the first part buffer.copyRange(fData, start, 0, n); // copy the second part - if(n=0 && line= 0 && line < fHeight) || throwRuntimeException(); return fData.isWrappedLine(getPositionOfLine(line)); } + public void setWrappedLine(int line) { - assert (line>=0 && line= 0 && line < fHeight) || throwRuntimeException(); fData.setWrappedLine(getPositionOfLine(line)); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java index 1f64cc7cafb..6dad9798f93 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ @@ -21,7 +21,7 @@ import org.eclipse.tm.terminal.model.Style; /** - * The public methods of this class have to be called from one thread! + * The public methods of this class have to be called from one thread! * * Threading considerations: * This class is not threadsafe! @@ -47,7 +47,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot { // snapshot does not need internal synchronisation final TerminalTextDataWindow fSnapshot; // this variable is synchronized on fTerminal! - private SnapshotOutOfDateListener[] fListener=new SnapshotOutOfDateListener[0]; + private SnapshotOutOfDateListener[] fListener = new SnapshotOutOfDateListener[0]; // this variable is synchronized on fTerminal! private boolean fListenersNeedNotify; private int fInterestWindowSize; @@ -60,9 +60,10 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot { fCurrentChanges.setTerminalChanged(); fFutureChanges = new SnapshotChanges(fTerminal.getHeight()); fFutureChanges.markLinesChanged(0, fTerminal.getHeight()); - fListenersNeedNotify=true; - fInterestWindowSize=-1; + fListenersNeedNotify = true; + fInterestWindowSize = -1; } + /** * This is used in asserts to throw an {@link RuntimeException}. * This is useful for tests. @@ -71,7 +72,7 @@ class TerminalTextDataSnapshot implements ITerminalTextDataSnapshot { private boolean throwRuntimeException() { throw new RuntimeException(); } - + public void detach() { fTerminal.removeSnapshot(this); } @@ -82,6 +83,7 @@ public boolean isOutOfDate() { return fFutureChanges.hasChanged(); } } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#snapshot() */ @@ -89,12 +91,12 @@ public void updateSnapshot(boolean detectScrolling) { // make sure terminal does not change while we make the snapshot synchronized (fTerminal) { // let's make the future changes current - fCurrentChanges=fFutureChanges; - fFutureChanges=new SnapshotChanges(fTerminal.getHeight()); + fCurrentChanges = fFutureChanges; + fFutureChanges = new SnapshotChanges(fTerminal.getHeight()); fFutureChanges.setInterestWindow(fInterestWindowStartLine, fInterestWindowSize); // and update the snapshot - if(fSnapshot.getHeight()!=fTerminal.getHeight()||fSnapshot.getWidth()!=fTerminal.getWidth()) { - if(fInterestWindowSize==-1) + if (fSnapshot.getHeight() != fTerminal.getHeight() || fSnapshot.getWidth() != fTerminal.getWidth()) { + if (fInterestWindowSize == -1) fSnapshot.setWindow(0, fTerminal.getHeight()); // if the dimensions have changed, we need a full copy fSnapshot.copy(fTerminal); @@ -102,17 +104,17 @@ public void updateSnapshot(boolean detectScrolling) { fCurrentChanges.setAllChanged(fTerminal.getHeight()); } else { // first we do the scroll on the copy - int start=fCurrentChanges.getScrollWindowStartLine(); - int lines=Math.min(fCurrentChanges.getScrollWindowSize(), fSnapshot.getHeight()-start); + int start = fCurrentChanges.getScrollWindowStartLine(); + int lines = Math.min(fCurrentChanges.getScrollWindowSize(), fSnapshot.getHeight() - start); fSnapshot.scroll(start, lines, fCurrentChanges.getScrollWindowShift()); // and then create the snapshot of the changed lines fCurrentChanges.copyChangedLines(fSnapshot, fTerminal); } - fListenersNeedNotify=true; + fListenersNeedNotify = true; fSnapshot.setCursorLine(fTerminal.getCursorLine()); fSnapshot.setCursorColumn(fTerminal.getCursorColumn()); } - if(!detectScrolling) { + if (!detectScrolling) { // let's pretend there was no scrolling and // convert the scrolling into line changes fCurrentChanges.convertScrollingIntoChanges(); @@ -138,12 +140,14 @@ public Style getStyle(int line, int column) { public int getWidth() { return fSnapshot.getWidth(); } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getFirstChangedLine() */ public int getFirstChangedLine() { return fCurrentChanges.getFirstChangedLine(); } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getLastChangedLine() */ @@ -154,9 +158,11 @@ public int getLastChangedLine() { public boolean hasLineChanged(int line) { return fCurrentChanges.hasLineChanged(line); } + public boolean hasDimensionsChanged() { return fCurrentChanges.hasDimensionsChanged(); } + public boolean hasTerminalChanged() { return fCurrentChanges.hasTerminalChanged(); } @@ -167,19 +173,21 @@ public boolean hasTerminalChanged() { public int getScrollWindowStartLine() { return fCurrentChanges.getScrollWindowStartLine(); } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeN() */ public int getScrollWindowSize() { return fCurrentChanges.getScrollWindowSize(); } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeShift() */ public int getScrollWindowShift() { return fCurrentChanges.getScrollWindowShift(); } - + /** * Announces a change in line line * @param line @@ -190,22 +198,24 @@ void markLineChanged(int line) { fFutureChanges.setTerminalChanged(); notifyListers(); } + /** * Announces a change of n lines beginning with line line * @param line * @param n */ - void markLinesChanged(int line,int n) { - fFutureChanges.markLinesChanged(line,n); + void markLinesChanged(int line, int n) { + fFutureChanges.markLinesChanged(line, n); fFutureChanges.setTerminalChanged(); notifyListers(); } - + void markDimensionsChanged() { fFutureChanges.markDimensionsChanged(); fFutureChanges.setTerminalChanged(); notifyListers(); } + void markCursorChanged() { fFutureChanges.markCursorChanged(); fFutureChanges.setTerminalChanged(); @@ -218,86 +228,87 @@ void markCursorChanged() { * @param shift */ void scroll(int startLine, int size, int shift) { - fFutureChanges.scroll(startLine,size,shift); + fFutureChanges.scroll(startLine, size, shift); fFutureChanges.setTerminalChanged(); notifyListers(); } + /** * Notifies listeners about the change */ private void notifyListers() { // this code has to be called from a block synchronized on fTerminal synchronized (fTerminal) { - if(fListenersNeedNotify) { + if (fListenersNeedNotify) { for (int i = 0; i < fListener.length; i++) { fListener[i].snapshotOutOfDate(this); } - fListenersNeedNotify=false; + fListenersNeedNotify = false; } } } + public ITerminalTextDataSnapshot makeSnapshot() { return fSnapshot.makeSnapshot(); } synchronized public void addListener(SnapshotOutOfDateListener listener) { - List list=new ArrayList(); + List list = new ArrayList(); list.addAll(Arrays.asList(fListener)); list.add(listener); - fListener=list.toArray(new SnapshotOutOfDateListener[list.size()]); + fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]); } synchronized public void removeListener(SnapshotOutOfDateListener listener) { - List list=new ArrayList(); + List list = new ArrayList(); list.addAll(Arrays.asList(fListener)); list.remove(listener); - fListener=list.toArray(new SnapshotOutOfDateListener[list.size()]); + fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]); } + public String toString() { return fSnapshot.toString(); } - public int getInterestWindowSize() { return fInterestWindowSize; } - public int getInterestWindowStartLine() { return fInterestWindowStartLine; } public void setInterestWindow(int startLine, int size) { - assert startLine>=0 || throwRuntimeException(); - assert size>=0 || throwRuntimeException(); - fInterestWindowStartLine=startLine; - fInterestWindowSize=size; + assert startLine >= 0 || throwRuntimeException(); + assert size >= 0 || throwRuntimeException(); + fInterestWindowStartLine = startLine; + fInterestWindowSize = size; fSnapshot.setWindow(startLine, size); fFutureChanges.setInterestWindow(startLine, size); notifyListers(); } - public char[] getChars(int line) { return fSnapshot.getChars(line); } - public Style[] getStyles(int line) { return fSnapshot.getStyles(line); } + public int getCursorColumn() { return fSnapshot.getCursorColumn(); } + public int getCursorLine() { return fSnapshot.getCursorLine(); } + public ITerminalTextData getTerminalTextData() { return fTerminal; } + public boolean isWrappedLine(int line) { return fSnapshot.isWrappedLine(line); } } - - diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java index 280a28d7cdf..83a9ca0dd35 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ @@ -36,10 +36,11 @@ public class TerminalTextDataStore implements ITerminalTextData { final private BitSet fWrappedLines = new BitSet(); public TerminalTextDataStore() { - fChars=new char[0][]; - fStyle=new Style[0][]; - fWidth=0; + fChars = new char[0][]; + fStyle = new Style[0][]; + fWidth = 0; } + /** * This is used in asserts to throw an {@link RuntimeException}. * This is useful for tests. @@ -48,7 +49,6 @@ public TerminalTextDataStore() { private boolean throwRuntimeException() { throw new RuntimeException(); } - /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getWidth() @@ -56,47 +56,50 @@ private boolean throwRuntimeException() { public int getWidth() { return fWidth; } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getHeight() */ public int getHeight() { return fHeight; } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setDimensions(int, int) */ public void setDimensions(int height, int width) { - assert height>=0 || throwRuntimeException(); - assert width>=0 || throwRuntimeException(); + assert height >= 0 || throwRuntimeException(); + assert width >= 0 || throwRuntimeException(); // just extend the region - if(height>fChars.length) { - int h=4*height/3; - if(fMaxHeight>0 && h>fMaxHeight) - h=fMaxHeight; - fStyle=(Style[][]) resizeArray(fStyle, height); - fChars=(char[][]) resizeArray(fChars, height); + if (height > fChars.length) { + int h = 4 * height / 3; + if (fMaxHeight > 0 && h > fMaxHeight) + h = fMaxHeight; + fStyle = (Style[][]) resizeArray(fStyle, height); + fChars = (char[][]) resizeArray(fChars, height); } // clean the new lines - if(height>fHeight) { + if (height > fHeight) { for (int i = fHeight; i < height; i++) { cleanLine(i); } } // set dimensions after successful resize! - fWidth=width; - fHeight=height; + fWidth = width; + fHeight = height; } + /** * Reallocates an array with a new size, and copies the contents of the old * array to the new array. - * + * * @param origArray the old array, to be reallocated. * @param newSize the new array size. * @return A new array with the same contents (chopped off if needed or filled with 0 or null). */ private Object resizeArray(Object origArray, int newSize) { int oldSize = Array.getLength(origArray); - if(oldSize==newSize) + if (oldSize == newSize) return origArray; Class elementType = origArray.getClass().getComponentType(); Object newArray = Array.newInstance(elementType, newSize); @@ -106,145 +109,150 @@ private Object resizeArray(Object origArray, int newSize) { return newArray; } - /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getLineSegments(int, int, int) */ public LineSegment[] getLineSegments(int line, int column, int len) { // get the styles and chars for this line - Style[] styles=fStyle[line]; - char[] chars=fChars[line]; - int col=column; - int n=column+len; - + Style[] styles = fStyle[line]; + char[] chars = fChars[line]; + int col = column; + int n = column + len; + // expand the line if needed.... - if(styles==null) - styles=new Style[n]; - else if(styles.length segments=new ArrayList(); + Style style = styles[column]; + List segments = new ArrayList(); for (int i = column; i < n; i++) { - if(styles[i]!=style) { - segments.add(new LineSegment(col,new String(chars,col,i-col),style)); - style=styles[i]; - col=i; + if (styles[i] != style) { + segments.add(new LineSegment(col, new String(chars, col, i - col), style)); + style = styles[i]; + col = i; } } - if(col < n) { - segments.add(new LineSegment(col,new String(chars,col,n-col),style)); + if (col < n) { + segments.add(new LineSegment(col, new String(chars, col, n - col), style)); } return segments.toArray(new LineSegment[segments.size()]); } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getChar(int, int) */ public char getChar(int line, int column) { - assert column=fChars[line].length) + assert column < fWidth || throwRuntimeException(); + if (fChars[line] == null || column >= fChars[line].length) return 0; return fChars[line][column]; } + /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getStyle(int, int) */ public Style getStyle(int line, int column) { - assert column=fStyle[line].length) + assert column < fWidth || throwRuntimeException(); + if (fStyle[line] == null || column >= fStyle[line].length) return null; return fStyle[line][column]; } - + void ensureLineLength(int iLine, int length) { - if(length>fWidth) + if (length > fWidth) throw new RuntimeException(); - if(fChars[iLine]==null) { - fChars[iLine]=new char[length]; - } else if(fChars[iLine].length=startLine && i-shift>=0; i--) { - fChars[i]=fChars[i-shift]; - fStyle[i]=fStyle[i-shift]; - fWrappedLines.set(i, fWrappedLines.get(i-shift)); + for (int i = startLine + size - 1; i >= startLine && i - shift >= 0; i--) { + fChars[i] = fChars[i - shift]; + fStyle[i] = fStyle[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 * @param line * @param 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); } } - + /* * @return a text representation of the object. * Lines are separated by '\n'. No style information is returned. */ public String toString() { - StringBuffer buff=new StringBuffer(); + StringBuffer buff = new StringBuffer(); for (int line = 0; line < getHeight(); line++) { - if(line>0) + if (line > 0) buff.append("\n"); //$NON-NLS-1$ for (int column = 0; column < fWidth; column++) { buff.append(getChar(line, column)); @@ -253,65 +261,65 @@ public String toString() { return buff.toString(); } - public ITerminalTextDataSnapshot makeSnapshot() { throw new UnsupportedOperationException(); } public void addLine() { - if(fMaxHeight>0 && getHeight() 0 && getHeight() < fMaxHeight) { + setDimensions(getHeight() + 1, getWidth()); } else { - scroll(0,getHeight(),-1); + scroll(0, getHeight(), -1); } } public void copy(ITerminalTextData source) { - fWidth=source.getWidth(); - int n=source.getHeight(); - if(getHeight()!=n) { - fChars=new char[n][]; - fStyle=new Style[n][]; + fWidth = source.getWidth(); + int n = source.getHeight(); + if (getHeight() != n) { + fChars = new char[n][]; + fStyle = new Style[n][]; } for (int i = 0; i < n; i++) { copyLine(source, i, i); } - fHeight=n; - fCursorLine=source.getCursorLine(); - fCursorColumn=source.getCursorColumn(); + fHeight = n; + fCursorLine = source.getCursorLine(); + 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++) { - copyLine(source, i+sourceStartLine, i+destStartLine); + copyLine(source, i + sourceStartLine, i + destStartLine); } } public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { - fChars[destLine]=source.getChars(sourceLine); - fStyle[destLine]=source.getStyles(sourceLine); + fChars[destLine] = source.getChars(sourceLine); + fStyle[destLine] = source.getStyles(sourceLine); fWrappedLines.set(destLine, source.isWrappedLine(sourceLine)); } public char[] getChars(int line) { - if(fChars[line]==null) + if (fChars[line] == null) return null; return fChars[line].clone(); } public Style[] getStyles(int line) { - if(fStyle[line]==null) + if (fStyle[line] == null) return null; return fStyle[line].clone(); } public void setLine(int line, char[] chars, Style[] styles) { - fChars[line]=chars.clone(); - fStyle[line]=styles.clone(); + fChars[line] = chars.clone(); + fStyle[line] = styles.clone(); fWrappedLines.clear(line); } public void setMaxHeight(int height) { - fMaxHeight=height; + fMaxHeight = height; } public int getMaxHeight() { @@ -319,25 +327,31 @@ public int getMaxHeight() { } public void cleanLine(int line) { - fChars[line]=null; - fStyle[line]=null; + fChars[line] = null; + fStyle[line] = null; fWrappedLines.clear(line); } + public int getCursorColumn() { return fCursorColumn; } + public int getCursorLine() { return fCursorLine; } + public void setCursorColumn(int column) { - fCursorColumn=column; + fCursorColumn = column; } + public void setCursorLine(int line) { - fCursorLine=line; + fCursorLine = line; } + public boolean isWrappedLine(int line) { return fWrappedLines.get(line); } + public void setWrappedLine(int line) { fWrappedLines.set(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java index 0e7eba4b4f2..57321df54f7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ @@ -17,8 +17,8 @@ import org.eclipse.tm.terminal.model.Style; /** - * This class stores the data only within a window {@link #setWindow(int, int)} and - * {@link #getWindowStartLine()} and {@link #getWindowSize()}. Everything outside + * This class stores the data only within a window {@link #setWindow(int, int)} and + * {@link #getWindowStartLine()} and {@link #getWindowSize()}. Everything outside * the is char=='\000' and style=null. * */ @@ -28,12 +28,15 @@ public class TerminalTextDataWindow implements ITerminalTextData { int fWindowSize; int fHeight; int fMaxHeight; + public TerminalTextDataWindow(ITerminalTextData data) { - fData=data; + fData = data; } + public TerminalTextDataWindow() { this(new TerminalTextDataStore()); } + /** * This is used in asserts to throw an {@link RuntimeException}. * This is useful for tests. @@ -42,23 +45,25 @@ public TerminalTextDataWindow() { private boolean throwRuntimeException() { throw new RuntimeException(); } + /** * @param line * @return true if the line is within the window */ boolean isInWindow(int line) { - return line>=fWindowStartLine && line= fWindowStartLine && line < fWindowStartLine + fWindowSize; } + public char getChar(int line, int column) { - if(!isInWindow(line)) + if (!isInWindow(line)) return 0; - return fData.getChar(line-fWindowStartLine, column); + return fData.getChar(line - fWindowStartLine, column); } public char[] getChars(int line) { - if(!isInWindow(line)) + if (!isInWindow(line)) return null; - return fData.getChars(line-fWindowStartLine); + return fData.getChars(line - fWindowStartLine); } public int getHeight() { @@ -66,9 +71,9 @@ public int getHeight() { } public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) { - if(!isInWindow(line)) - return new LineSegment[]{new LineSegment(startCol,new String(new char[numberOfCols]),null)}; - return fData.getLineSegments(line-fWindowStartLine, startCol, numberOfCols); + if (!isInWindow(line)) + return new LineSegment[] { new LineSegment(startCol, new String(new char[numberOfCols]), null) }; + return fData.getLineSegments(line - fWindowStartLine, startCol, numberOfCols); } public int getMaxHeight() { @@ -76,15 +81,15 @@ public int getMaxHeight() { } public Style getStyle(int line, int column) { - if(!isInWindow(line)) + if (!isInWindow(line)) return null; - return fData.getStyle(line-fWindowStartLine, column); + return fData.getStyle(line - fWindowStartLine, column); } public Style[] getStyles(int line) { - if(!isInWindow(line)) + if (!isInWindow(line)) return null; - return fData.getStyles(line-fWindowStartLine); + return fData.getStyles(line - fWindowStartLine); } public int getWidth() { @@ -94,114 +99,135 @@ public int getWidth() { public ITerminalTextDataSnapshot makeSnapshot() { throw new UnsupportedOperationException(); } + public void addLine() { - if(fMaxHeight>0 && getHeight() 0 && getHeight() < fMaxHeight) { + setDimensions(getHeight() + 1, getWidth()); } else { - scroll(0,getHeight(),-1); + scroll(0, getHeight(), -1); } } + public void copy(ITerminalTextData source) { // we inherit the dimensions of the source setDimensions(source.getHeight(), source.getWidth()); - int n=Math.min(fWindowSize, source.getHeight()-fWindowStartLine); - if(n>0) + int n = Math.min(fWindowSize, source.getHeight() - fWindowStartLine); + if (n > 0) fData.copyRange(source, fWindowStartLine, 0, n); } + public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { - int n=length; - int dStart=destStartLine-fWindowStartLine; - int sStart=sourceStartLine; + int n = length; + int dStart = destStartLine - fWindowStartLine; + int sStart = sourceStartLine; // if start outside our range, cut the length to copy - if(dStart<0) { - n+=dStart; - sStart-=dStart; - dStart=0; + if (dStart < 0) { + n += dStart; + sStart -= dStart; + dStart = 0; } // do not exceed the window size - n=Math.min(n,fWindowSize); - if(n>0) + n = Math.min(n, fWindowSize); + if (n > 0) fData.copyRange(source, sStart, dStart, n); - + } + public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { - if(isInWindow(destLine)) - fData.copyLine(source, sourceLine, destLine-fWindowStartLine); + if (isInWindow(destLine)) + fData.copyLine(source, sourceLine, destLine - fWindowStartLine); } + public void scroll(int startLine, int size, int shift) { - assert (startLine>=0 && startLine+size<=fHeight) || throwRuntimeException(); - int n=size; - int start=startLine-fWindowStartLine; + assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException(); + int n = size; + int start = startLine - fWindowStartLine; // if start outside our range, cut the length to copy - if(start<0) { - n+=start; - start=0; + if (start < 0) { + n += start; + start = 0; } - n=Math.min(n,fWindowSize-start); + n = Math.min(n, fWindowSize - start); // do not exceed the window size - if(n>0) + if (n > 0) fData.scroll(start, n, shift); } + public void setChar(int line, int column, char c, Style style) { - if(!isInWindow(line)) + if (!isInWindow(line)) 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) { - if(!isInWindow(line)) + if (!isInWindow(line)) 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) { - if(!isInWindow(line)) + if (!isInWindow(line)) return; - fData.setChars(line-fWindowStartLine, column, chars, style); + fData.setChars(line - fWindowStartLine, column, chars, style); } + public void setDimensions(int height, int width) { - assert height>=0 || throwRuntimeException(); + assert height >= 0 || throwRuntimeException(); fData.setDimensions(fWindowSize, width); - fHeight=height; + fHeight = height; } + public void setMaxHeight(int height) { - fMaxHeight=height; + fMaxHeight = height; } + public void setWindow(int startLine, int size) { - fWindowStartLine=startLine; - fWindowSize=size; + fWindowStartLine = startLine; + fWindowSize = size; fData.setDimensions(fWindowSize, getWidth()); } + public int getWindowStartLine() { return fWindowStartLine; } + public int getWindowSize() { return fWindowSize; } + public void setHeight(int height) { fHeight = height; } + public void cleanLine(int line) { - if(isInWindow(line)) - fData.cleanLine(line-fWindowStartLine); + if (isInWindow(line)) + fData.cleanLine(line - fWindowStartLine); } + public int getCursorColumn() { return fData.getCursorColumn(); } + public int getCursorLine() { return fData.getCursorLine(); } + public void setCursorColumn(int column) { fData.setCursorColumn(column); } + public void setCursorLine(int line) { fData.setCursorLine(line); } + public boolean isWrappedLine(int line) { - if(isInWindow(line)) + if (isInWindow(line)) return fData.isWrappedLine(line - fWindowStartLine); return false; } + public void setWrappedLine(int line) { - if(isInWindow(line)) + if (isInWindow(line)) fData.setWrappedLine(line - fWindowStartLine); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java index b9980eec90b..0c44566fb77 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java @@ -16,19 +16,19 @@ /** * Constants for Terminal Preferences. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ 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_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$ - public static final int DEFAULT_BUFFERLINES = 1000; - public static final boolean DEFAULT_INVERT_COLORS = false; + public static final String PREF_BUFFERLINES = "TerminalPrefBufferLines"; //$NON-NLS-1$ + public static final String PREF_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$ + public static final int DEFAULT_BUFFERLINES = 1000; + 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$ } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java index 431dd902d3b..8a028812fc3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java @@ -22,7 +22,7 @@ /** * Terminal Preference Initializer. - * + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. * @noreference This class is not intended to be referenced by clients. diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java index 7bb452c5855..d9b51ff80ad 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -30,30 +30,33 @@ /** * Terminal Preference Page. - * + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. * @noreference This class is not intended to be referenced by clients. */ -public class TerminalPreferencePage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - protected BooleanFieldEditor fInvertColors; +public class TerminalPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + protected BooleanFieldEditor fInvertColors; protected IntegerFieldEditor fEditorBufferSize; public TerminalPreferencePage() { super(GRID); } + protected void createFieldEditors() { setupPage(); } + public void init(IWorkbench workbench) { // do nothing } + protected void setupPage() { setupData(); setupEditors(); } + protected void setupData() { TerminalPlugin plugin; IPreferenceStore preferenceStore; @@ -62,12 +65,12 @@ protected void setupData() { preferenceStore = plugin.getPreferenceStore(); setPreferenceStore(preferenceStore); } + protected void setupEditors() { - fInvertColors = new BooleanFieldEditor( - ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS, + fInvertColors = new BooleanFieldEditor(ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS, + getFieldEditorParent()); + fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, TerminalMessages.BUFFERLINES, getFieldEditorParent()); - fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, - TerminalMessages.BUFFERLINES, getFieldEditorParent()); fEditorBufferSize.setValidRange(0, Integer.MAX_VALUE); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java index 673716e8267..89b0d8ad095 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java @@ -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) */ public void addListener(Listener listener) { - Assert.isNotNull(listener); - listeners.add(listener); + Assert.isNotNull(listener); + listeners.add(listener); } /* (non-Javadoc) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#removeListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener) */ public void removeListener(Listener listener) { - Assert.isNotNull(listener); - listeners.remove(listener); + Assert.isNotNull(listener); + listeners.remove(listener); } /** @@ -61,8 +61,9 @@ public void fireListeners(Control control) { Object[] list = listeners.getListeners(); for (int i = 0; i < list.length; i++) { Object l = list[i]; - if (!(l instanceof Listener)) continue; - ((Listener)l).onSettingsPageChanged(control); + if (!(l instanceof Listener)) + continue; + ((Listener) l).onSettingsPageChanged(control); } } @@ -120,7 +121,8 @@ protected final boolean hasControlDecoration() { */ protected final ControlDecoration createControlDecoration(Control control) { Assert.isNotNull(control); - if (!hasDecoration) return null; + if (!hasDecoration) + return null; ControlDecoration controlDecoration = new ControlDecoration(control, getControlDecorationPosition()); controlDecoration.setShowOnlyOnFocus(false); control.setData("controlDecoration", controlDecoration); //$NON-NLS-1$ @@ -149,7 +151,7 @@ protected int getControlDecorationPosition() { protected final void updateControlDecoration(Control control, String message, int messageType) { Assert.isNotNull(control); - ControlDecoration controlDecoration = (ControlDecoration)control.getData("controlDecoration"); //$NON-NLS-1$ + ControlDecoration controlDecoration = (ControlDecoration) control.getData("controlDecoration"); //$NON-NLS-1$ if (controlDecoration != null) { // The description is the same as the message controlDecoration.setDescriptionText(message); @@ -173,8 +175,7 @@ protected final void updateControlDecoration(Control control, String message, in if (message == null || messageType == IMessageProvider.NONE) { controlDecoration.hide(); - } - else { + } else { controlDecoration.show(); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java index 7346453b4cc..71cfc58164b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ISettingsStore.java @@ -1,19 +1,19 @@ /******************************************************************************* * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified *******************************************************************************/ package org.eclipse.tm.internal.terminal.provisional.api; /** - * A simple interface to a store to persist the state of a connection. - * + * A simple interface to a store to persist the state of a connection. + * * @author Michael Scharf *

            * EXPERIMENTAL. This class or interface has been added as diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java index 244fb9ab7fb..c4869ad22f1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java @@ -104,20 +104,20 @@ public interface ITerminalConnector extends IAdaptable { */ boolean isLocalEcho(); - /** - * Notify the remote site that the size of the terminal has changed. - * @param newWidth - * @param newHeight - */ - void setTerminalSize(int newWidth, int newHeight); - - /** - * @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 - * terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()} + /** + * Notify the remote site that the size of the terminal has changed. + * @param newWidth + * @param newHeight + */ + void setTerminalSize(int newWidth, int newHeight); + + /** + * @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 + * terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()} * @since org.eclipse.tm.terminal 2.0 - */ - OutputStream getTerminalToRemoteStream(); + */ + OutputStream getTerminalToRemoteStream(); /** * Load the state of this connection. Is typically called before @@ -134,7 +134,7 @@ public interface ITerminalConnector extends IAdaptable { * @param store */ void save(ISettingsStore store); - + /** * Set or reset the settings store to the default values. */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java index ac133ffdb5c..226f03cdc36 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java @@ -131,30 +131,30 @@ public interface ITerminalControl { * the terminal connection if the user hits ENTER in a closed terminal. *

            * Reconnect on ENTER if terminal is closed is enabled by default. - * + * * @param on True to enable the reconnect, false to disable it. */ void setConnectOnEnterIfClosed(boolean on); - + /** * Returns if or if not the terminal view control should try to reconnect * the terminal connection if the user hits ENTER in a closed terminal. - * + * * @return True the reconnect is enabled, false if disabled. */ boolean isConnectOnEnterIfClosed(); - + /** * Enables VT100 line wrapping mode (default is off). * This corresponds to the VT100 'eat_newline_glitch' terminal capability. * If enabled, writing to the rightmost column does not cause * an immediate wrap to the next line. Instead the line wrap occurs on the * next output character. - * + * * @param enable whether to enable or disable VT100 line wrapping mode */ void setVT100LineWrapping(boolean enable); - + /** * @return whether VT100 line wrapping mode is enabled */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index 25f3c6649ac..1845104c0bb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -44,18 +44,18 @@ *

            */ 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_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 = "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_VT100BACKEND = "org.eclipse.tm.terminal.control/debug/log/VT100Backend"; //$NON-NLS-1$ - private static PrintStream logStream; + private static PrintStream logStream; static { // Any of the three known debugging options turns on the creation of the log file boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG) - || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR) - || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND); - + || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR) + || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND); + // Log only if tracing is enabled if (createLogFile && TerminalPlugin.getDefault() != null) { IPath logFile = Platform.getStateLocation(TerminalPlugin.getDefault().getBundle()); @@ -80,48 +80,64 @@ public final class Logger { */ public static final String encode(String message) { boolean encoded = false; - StringBuffer buf = new StringBuffer(message.length()+32); - for (int i=0; i=' ' && 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; + StringBuffer buf = new StringBuffer(message.length() + 32); + for (int i = 0; i < message.length(); i++) { + char c = message.charAt(i); + switch (c) { + case '\\': + case '\'': + buf.append('\\'); + buf.append(c); + encoded = true; + break; + case '\r': + buf.append('\\'); + buf.append('r'); + encoded = true; + break; + case '\n': + buf.append('\\'); + buf.append('n'); + encoded = true; + break; + case '\t': + buf.append('\\'); + buf.append('t'); + encoded = true; + break; + case '\f': + buf.append('\\'); + buf.append('f'); + encoded = true; + break; + case '\b': + buf.append('\\'); + buf.append('b'); + encoded = true; + break; + default: + if (c <= '\u000f') { + buf.append('\\'); + buf.append('x'); + buf.append('0'); + 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) { @@ -135,14 +151,14 @@ public static final String encode(String message) { * @return true if logging is enabled. */ public static final boolean isLogEnabled() { - return (logStream!=null); + return (logStream != null); } /** * Logs the specified message. Do not append a newline to parameter * message. 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) { if (logStream != null) { @@ -156,7 +172,7 @@ public static final void log(String message) { String methodName = caller.getMethodName(); 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(); } } @@ -168,14 +184,15 @@ public static final void log(String message) { public static final void logException(Exception ex) { // log in eclipse error log 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 { ex.printStackTrace(); } // Additional Tracing for debug purposes: // Read my own stack to get the class name, method name, and line number // of where this method was called - if(logStream!=null) { + if (logStream != null) { StackTraceElement caller = new Throwable().getStackTrace()[1]; int lineNumber = caller.getLineNumber(); String className = caller.getClassName(); @@ -188,8 +205,7 @@ public static final void logException(Exception ex) { tmpStream = logStream; } - tmpStream.println(className - + "." + methodName + ":" + lineNumber + ": " + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + tmpStream.println(className + "." + methodName + ":" + lineNumber + ": " + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ "Caught exception: " + ex); //$NON-NLS-1$ ex.printStackTrace(tmpStream); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java index 6eea871b388..0379361cca0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -41,19 +41,20 @@ public class TerminalConnectorExtension { static private ITerminalConnector makeConnector(final IConfigurationElement config) { String id = config.getAttribute("id"); //$NON-NLS-1$ - if(id==null || id.length()==0) - id=config.getAttribute("class"); //$NON-NLS-1$ - String name= config.getAttribute("name"); //$NON-NLS-1$ - if(name==null || name.length()==0) { - name=id; + if (id == null || id.length() == 0) + id = config.getAttribute("class"); //$NON-NLS-1$ + String name = config.getAttribute("name"); //$NON-NLS-1$ + if (name == null || name.length() == 0) { + name = id; } String hidden = config.getAttribute("hidden"); //$NON-NLS-1$ 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 { - return (TerminalConnectorImpl)config.createExecutableExtension("class"); //$NON-NLS-1$ - }}; - return new TerminalConnector(factory,id,name, isHidden); + return (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$ + } + }; + return new TerminalConnector(factory, id, name, isHidden); } /** @@ -68,14 +69,16 @@ public TerminalConnectorImpl makeConnector() throws Exception { * @since org.eclipse.tm.terminal 2.0 */ 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++) { - 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 null; } + /** * Return a list of available terminal connectors (connection types). * @@ -89,8 +92,9 @@ public static ITerminalConnector makeTerminalConnector(String id) { * @since org.eclipse.tm.terminal 2.0 return value is ITerminalConnector[] */ public static ITerminalConnector[] makeTerminalConnectors() { - IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$ - List result=new ArrayList(); + IConfigurationElement[] config = RegistryFactory.getRegistry() + .getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$ + List result = new ArrayList(); for (int i = 0; i < config.length; i++) { result.add(makeConnector(config[i])); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java index 9425cbf7eaf..621d5df86d3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java @@ -30,17 +30,17 @@ public class TerminalState { /** * 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. */ - 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. */ - 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; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java index 7b22cc3cdb7..79ecb9b92fd 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java @@ -9,7 +9,7 @@ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation - * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl + * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl *******************************************************************************/ package org.eclipse.tm.internal.terminal.provisional.api.provider; @@ -29,7 +29,7 @@ */ public abstract class TerminalConnectorImpl { - /** + /** * The TerminalControl associated with this connector. * Required for advertising state changes when needed. */ @@ -49,12 +49,12 @@ public void initialize() throws Exception { /** * Connect using the current state of the settings. - * + * * This method is designed to be overridden by actual implementations, in * order to open the streams required for communicating with the remote * side. Extenders must call super.connect(control) as the * first thing they are doing. - * + * * @param control Used to inform the UI about state changes and messages * from the connection. */ @@ -81,11 +81,11 @@ protected void doDisconnect() { // Do nothing by default } - /** - * @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 - * terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()} - */ + /** + * @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 + * terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()} + */ abstract public OutputStream getTerminalToRemoteStream(); /** @@ -140,7 +140,7 @@ public void save(ISettingsStore store) { // do nothing by default } - /** + /** * Notify the remote site that the size of the terminal has changed. * * Concrete connectors should override this if they have the possibility to diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java index c6035b38eb4..f3c67a96fb3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java @@ -32,13 +32,13 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel { private final ITerminalTextDataSnapshot fSnapshot; private int fLines; - private int fSelectionStartLine=-1; + private int fSelectionStartLine = -1; private int fSeletionEndLine; private int fSelectionStartCoumn; private int fSelectionEndColumn; private ITerminalTextDataSnapshot fSelectionSnapshot; - private String fCurrentSelection=""; //$NON-NLS-1$ - private final Point fSelectionAnchor=new Point(0,0); + private String fCurrentSelection = ""; //$NON-NLS-1$ + private final Point fSelectionAnchor = new Point(0, 0); /** * do not update while update is running */ @@ -46,9 +46,10 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel { private int fCols; public AbstractTextCanvasModel(ITerminalTextDataSnapshot snapshot) { - fSnapshot=snapshot; - fLines=fSnapshot.getHeight(); + fSnapshot = snapshot; + fLines = fSnapshot.getHeight(); } + public void addCellCanvasModelListener(ITextCanvasModelListener listener) { fListeners.add(listener); } @@ -63,13 +64,15 @@ protected void fireCellRangeChanged(int x, int y, int width, int height) { listener.rangeChanged(x, y, width, height); } } - protected void fireDimensionsChanged( int width,int height) { + + protected void fireDimensionsChanged(int width, int height) { for (Iterator iter = fListeners.iterator(); iter.hasNext();) { ITextCanvasModelListener listener = iter.next(); - listener.dimensionsChanged(width,height); + listener.dimensionsChanged(width, height); } } + protected void fireTerminalDataChanged() { for (Iterator iter = fListeners.iterator(); iter.hasNext();) { ITextCanvasModelListener listener = iter.next(); @@ -81,36 +84,39 @@ protected void fireTerminalDataChanged() { public ITerminalTextDataReadOnly getTerminalText() { return fSnapshot; } + protected ITerminalTextDataSnapshot getSnapshot() { return fSnapshot; } + protected void updateSnapshot() { - if(!fInUpdate && fSnapshot.isOutOfDate()) { - fInUpdate=true; + if (!fInUpdate && fSnapshot.isOutOfDate()) { + fInUpdate = true; try { fSnapshot.updateSnapshot(false); - if(fSnapshot.hasTerminalChanged()) + if (fSnapshot.hasTerminalChanged()) fireTerminalDataChanged(); // TODO why does hasDimensionsChanged not work?????? // if(fSnapshot.hasDimensionsChanged()) // fireDimensionsChanged(); - if(fLines!=fSnapshot.getHeight() || fCols!=fSnapshot.getWidth()) { - fireDimensionsChanged(fSnapshot.getWidth(),fSnapshot.getHeight()); - fLines=fSnapshot.getHeight(); - fCols=fSnapshot.getWidth(); + if (fLines != fSnapshot.getHeight() || fCols != fSnapshot.getWidth()) { + fireDimensionsChanged(fSnapshot.getWidth(), fSnapshot.getHeight()); + fLines = fSnapshot.getHeight(); + fCols = fSnapshot.getWidth(); } - int y=fSnapshot.getFirstChangedLine(); + int y = fSnapshot.getFirstChangedLine(); // has any line changed? - if(y=getSnapshot().getHeight()) { - cursorLine=getSnapshot().getHeight()-1; - cursorColumn=getSnapshot().getWidth()-1; + if (cursorLine >= getSnapshot().getHeight()) { + cursorLine = getSnapshot().getHeight() - 1; + cursorColumn = getSnapshot().getWidth() - 1; } // has the cursor moved? - if(fCursorLine!=cursorLine || fCursorColumn!=cursorColumn) { + if (fCursorLine != cursorLine || fCursorColumn != cursorColumn) { // hide the old cursor! - fShowCursor=false; + fShowCursor = false; // clean the previous cursor // bug 206363: paint also the char to the left and right of the cursor - see also below - int col=fCursorColumn; - int width=2; - if(col>0) { + int col = fCursorColumn; + int width = 2; + if (col > 0) { col--; width++; } fireCellRangeChanged(col, fCursorLine, width, 1); // the cursor is shown when it moves! - fShowCursor=true; - fCursorTime=System.currentTimeMillis(); - fCursorLine=cursorLine; - fCursorColumn=cursorColumn; + fShowCursor = true; + fCursorTime = System.currentTimeMillis(); + fCursorLine = cursorLine; + fCursorColumn = cursorColumn; // and draw the new cursor fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1); } else { - long t=System.currentTimeMillis(); + long t = System.currentTimeMillis(); // TODO make the cursor blink time customisable - if(t-fCursorTime>500) { - fShowCursor=!fShowCursor; - fCursorTime=t; + if (t - fCursorTime > 500) { + fShowCursor = !fShowCursor; + fCursorTime = t; // on some windows machines, there is some left // over when updating the cursor . // https://bugs.eclipse.org/bugs/show_bug.cgi?id=206363 - int col=fCursorColumn; - int width=2; - if(col>0) { + int col = fCursorColumn; + int width = 2; + if (col > 0) { col--; width++; } @@ -187,25 +193,29 @@ protected void updateCursor() { } } } + 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(); } + protected void showCursor(boolean show) { - fShowCursor=true; + fShowCursor = true; } + public void setCursorEnabled(boolean visible) { - fCursorTime=System.currentTimeMillis(); - fShowCursor=visible; - fCursorIsEnabled=visible; + fCursorTime = System.currentTimeMillis(); + fShowCursor = visible; + fCursorIsEnabled = visible; fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1); } + public boolean isCursorEnabled() { return fCursorIsEnabled; } public Point getSelectionEnd() { - if(fSelectionStartLine<0) + if (fSelectionStartLine < 0) return null; else return new Point(fSelectionEndColumn, fSeletionEndLine); @@ -215,57 +225,60 @@ public Point getSelectionStart() { if (fSelectionStartLine < 0) return null; else - return new Point(fSelectionStartCoumn,fSelectionStartLine); + return new Point(fSelectionStartCoumn, fSelectionStartLine); } + public Point getSelectionAnchor() { - if(fSelectionStartLine<0) + if (fSelectionStartLine < 0) return null; - return new Point(fSelectionAnchor.x,fSelectionAnchor.y); + return new Point(fSelectionAnchor.x, fSelectionAnchor.y); } + public void setSelectionAnchor(Point anchor) { - fSelectionAnchor.x=anchor.x; - fSelectionAnchor.y=anchor.y; + fSelectionAnchor.x = anchor.x; + fSelectionAnchor.y = anchor.y; } 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); - fCurrentSelection=extractSelectedText(); + fCurrentSelection = extractSelectedText(); } + private void doSetSelection(int startLine, int endLine, int startColumn, int endColumn) { - assert(startLine<0 || startLine<=endLine); - if(startLine>=0) { - if(fSelectionSnapshot==null) { - fSelectionSnapshot=fSnapshot.getTerminalTextData().makeSnapshot(); + assert (startLine < 0 || startLine <= endLine); + if (startLine >= 0) { + if (fSelectionSnapshot == null) { + fSelectionSnapshot = fSnapshot.getTerminalTextData().makeSnapshot(); fSelectionSnapshot.updateSnapshot(true); } - } else if(fSelectionSnapshot!=null) { + } else if (fSelectionSnapshot != null) { fSelectionSnapshot.detach(); - fSelectionSnapshot=null; + fSelectionSnapshot = null; } - int oldStart=fSelectionStartLine; - int oldEnd=fSeletionEndLine; + int oldStart = fSelectionStartLine; + int oldEnd = fSeletionEndLine; fSelectionStartLine = startLine; fSeletionEndLine = endLine; fSelectionStartCoumn = startColumn; fSelectionEndColumn = endColumn; - if(fSelectionSnapshot!=null) { + if (fSelectionSnapshot != null) { fSelectionSnapshot.setInterestWindow(0, fSelectionSnapshot.getHeight()); } int changedStart; int changedEnd; - if(oldStart<0) { - changedStart=fSelectionStartLine; - changedEnd=fSeletionEndLine; - } else if(fSelectionStartLine<0) { - changedStart=oldStart; - changedEnd=oldEnd; + if (oldStart < 0) { + changedStart = fSelectionStartLine; + changedEnd = fSeletionEndLine; + } else if (fSelectionStartLine < 0) { + changedStart = oldStart; + changedEnd = oldEnd; } else { - changedStart=Math.min(oldStart, fSelectionStartLine); - changedEnd=Math.max(oldEnd, fSeletionEndLine); + changedStart = Math.min(oldStart, fSelectionStartLine); + changedEnd = Math.max(oldEnd, fSeletionEndLine); } - if(changedStart>=0) { - fireCellRangeChanged(0, changedStart, fSnapshot.getWidth(), changedEnd-changedStart+1); + if (changedStart >= 0) { + fireCellRangeChanged(0, changedStart, fSnapshot.getWidth(), changedEnd - changedStart + 1); } } @@ -300,33 +313,35 @@ private static String scrubLine(String text) { * @return the currently selected text */ private String extractSelectedText() { - if(fSelectionStartLine<0 || fSelectionStartCoumn<0 || fSelectionSnapshot==null) + if (fSelectionStartLine < 0 || fSelectionStartCoumn < 0 || fSelectionSnapshot == null) return ""; //$NON-NLS-1$ - StringBuffer buffer=new StringBuffer(); + StringBuffer buffer = new StringBuffer(); for (int line = fSelectionStartLine; line <= fSeletionEndLine; line++) { String text; - char[] chars=fSelectionSnapshot.getChars(line); - if(chars!=null) { - text=new String(chars); - if(line==fSeletionEndLine && fSelectionEndColumn >= 0) - text=text.substring(0, Math.min(fSelectionEndColumn+1,text.length())); - if(line==fSelectionStartLine) - text=text.substring(Math.min(fSelectionStartCoumn,text.length())); - text=scrubLine(text); + char[] chars = fSelectionSnapshot.getChars(line); + if (chars != null) { + text = new String(chars); + if (line == fSeletionEndLine && fSelectionEndColumn >= 0) + text = text.substring(0, Math.min(fSelectionEndColumn + 1, text.length())); + if (line == fSelectionStartLine) + text = text.substring(Math.min(fSelectionStartCoumn, text.length())); + text = scrubLine(text); } else { - text=""; //$NON-NLS-1$ + text = ""; //$NON-NLS-1$ } buffer.append(text); - if(line < fSeletionEndLine && !fSelectionSnapshot.isWrappedLine(line)) + if (line < fSeletionEndLine && !fSelectionSnapshot.isWrappedLine(line)) buffer.append('\n'); } return buffer.toString(); } + private void updateSelection() { if (fSelectionSnapshot != null && fSelectionSnapshot.isOutOfDate()) { fSelectionSnapshot.updateSnapshot(true); // 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 end = fSeletionEndLine + fSelectionSnapshot.getScrollWindowShift(); if (start < 0) @@ -338,7 +353,7 @@ private void updateSelection() { } // check if the content of the selection has changed. If the content has // changed, clear the selection - if (fCurrentSelection.length()>0 && fSelectionSnapshot != null + if (fCurrentSelection.length() > 0 && fSelectionSnapshot != null && fSelectionSnapshot.getFirstChangedLine() <= fSeletionEndLine && fSelectionSnapshot.getLastChangedLine() >= fSelectionStartLine) { // has the selected text changed? diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java index dc5d4c56993..5425354f5ea 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java @@ -1,17 +1,16 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; - import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; @@ -35,13 +34,13 @@ public GridCanvas(Composite parent, int style) { super(parent, style); addListener(SWT.MouseWheel, new Listener() { public void handleEvent(Event event) { - if(getVerticalBar().isVisible()) { - int delta=-fCellHeight; - if(event.count<0) - delta=-delta; + if (getVerticalBar().isVisible()) { + int delta = -fCellHeight; + if (event.count < 0) + delta = -delta; scrollYDelta(delta); } - event.doit=false; + event.doit = false; } }); @@ -51,36 +50,37 @@ public void handleEvent(Event event) { * iterates over all cells in the clipping rectangle and paints them. */ protected void paint(GC gc) { - Rectangle clipping=gc.getClipping(); - if(clipping.width==0 || clipping.height==0) + Rectangle clipping = gc.getClipping(); + if (clipping.width == 0 || clipping.height == 0) return; - Rectangle clientArea= getScreenRectInVirtualSpace(); + Rectangle clientArea = getScreenRectInVirtualSpace(); // Beginning coordinates - int xOffset=clientArea.x; - int yOffset=clientArea.y; - int colFirst=virtualXToCell(xOffset+clipping.x); - if(colFirst>getCols()) - colFirst=getCols(); + int xOffset = clientArea.x; + int yOffset = clientArea.y; + int colFirst = virtualXToCell(xOffset + clipping.x); + if (colFirst > getCols()) + colFirst = getCols(); else if (colFirst < 0) { colFirst = 0; } - int rowFirst=virtualYToCell(yOffset+clipping.y); + int rowFirst = virtualYToCell(yOffset + clipping.y); // End coordinates - int colLast=virtualXToCell(xOffset+clipping.x+clipping.width+fCellWidth); - if(colLast>getCols()) - colLast=getCols(); - int rowLast=virtualYToCell(yOffset+clipping.y+clipping.height+fCellHeight); - if(rowLast>getRows()) - rowLast=getRows(); + int colLast = virtualXToCell(xOffset + clipping.x + clipping.width + fCellWidth); + if (colLast > getCols()) + colLast = getCols(); + int rowLast = virtualYToCell(yOffset + clipping.y + clipping.height + fCellHeight); + if (rowLast > getRows()) + rowLast = getRows(); // System.out.println(rowFirst+"->"+rowLast+" "+System.currentTimeMillis()); // draw the cells - for(int row=rowFirst;row<=rowLast;row++) { - int cx=colFirst*fCellWidth-xOffset; - int cy=row*fCellHeight-yOffset; - drawLine(gc,row,cx,cy,colFirst,colLast); + for (int row = rowFirst; row <= rowLast; row++) { + int cx = colFirst * fCellWidth - xOffset; + int cy = row * fCellHeight - yOffset; + drawLine(gc, row, cx, cy, colFirst, colLast); } - paintUnoccupiedSpace(gc,clipping); + paintUnoccupiedSpace(gc, clipping); } + /** * @param gc * @param row the line to draw @@ -92,6 +92,7 @@ else if (colFirst < 0) { abstract void drawLine(GC gc, int row, int x, int y, int colFirst, int colLast); abstract protected int getRows(); + abstract protected int getCols(); protected void setCellWidth(int cellWidth) { @@ -113,65 +114,66 @@ public int getCellHeight() { } int virtualXToCell(int x) { - return x/fCellWidth; + return x / fCellWidth; } int virtualYToCell(int y) { - return y/fCellHeight; + return y / fCellHeight; } protected Point screenPointToCell(int x, int y) { - x=screenXtoVirtual(x)/fCellWidth; - y=screenYtoVirtual(y)/fCellHeight; - return new Point(x,y); + x = screenXtoVirtual(x) / fCellWidth; + y = screenYtoVirtual(y) / fCellHeight; + return new Point(x, y); } Point screenPointToCell(Point point) { - return screenPointToCell(point.x,point.y); + return screenPointToCell(point.x, point.y); } protected Point cellToOriginOnScreen(int x, int y) { - x=virtualXtoScreen(fCellWidth*x); - y=virtualYtoScreen(fCellHeight*y); - return new Point(x,y); + x = virtualXtoScreen(fCellWidth * x); + y = virtualYtoScreen(fCellHeight * y); + return new Point(x, y); } Point cellToOriginOnScreen(Point cell) { - return cellToOriginOnScreen(cell.x,cell.y); + return cellToOriginOnScreen(cell.x, cell.y); } Rectangle getCellScreenRect(Point cell) { - return getCellScreenRect(cell.x,cell.y); + return getCellScreenRect(cell.x, cell.y); } Rectangle getCellScreenRect(int x, int y) { - x=fCellWidth*virtualXtoScreen(x); - y=fCellHeight*virtualYtoScreen(y); - return new Rectangle(x,y,fCellWidth,fCellHeight); + x = fCellWidth * virtualXtoScreen(x); + y = fCellHeight * virtualYtoScreen(y); + return new Rectangle(x, y, fCellWidth, fCellHeight); } protected Rectangle getCellVirtualRect(Point cell) { - return getCellVirtualRect(cell.x,cell.y); + return getCellVirtualRect(cell.x, cell.y); } Rectangle getCellVirtualRect(int x, int y) { - x=fCellWidth*x; - y=fCellHeight*y; - return new Rectangle(x,y,fCellWidth,fCellHeight); + x = fCellWidth * x; + y = fCellHeight * y; + return new Rectangle(x, y, fCellWidth, fCellHeight); } + protected void viewRectangleChanged(int x, int y, int width, int height) { - int cellX=virtualXToCell(x); - int cellY=virtualYToCell(y); + int cellX = virtualXToCell(x); + int cellY = virtualYToCell(y); // End coordinates - int xE=virtualXToCell(x+width); -// if(xE>getCols()) -// xE=getCols(); - int yE=virtualYToCell(y+height); -// if(yE>getRows()) -// yE=getRows(); - visibleCellRectangleChanged(cellX,cellY,xE-cellX,yE-cellY); - } - + int xE = virtualXToCell(x + width); + // if(xE>getCols()) + // xE=getCols(); + int yE = virtualYToCell(y + height); + // if(yE>getRows()) + // yE=getRows(); + visibleCellRectangleChanged(cellX, cellY, xE - cellX, yE - cellY); + } + /** * Called when the viewed part has changed. * Override when you need this information.... @@ -183,7 +185,7 @@ protected void viewRectangleChanged(int x, int y, int width, int height) { */ protected void visibleCellRectangleChanged(int x, int y, int width, int height) { } - + protected void setVirtualExtend(int width, int height) { int cellHeight = getCellHeight(); if (cellHeight > 0) { @@ -191,7 +193,7 @@ protected void setVirtualExtend(int width, int height) { } super.setVirtualExtend(width, height); } - + protected void setVirtualOrigin(int x, int y) { int cellHeight = getCellHeight(); if (cellHeight > 0) { @@ -204,9 +206,9 @@ protected void setVirtualOrigin(int x, int y) { } super.setVirtualOrigin(x, y); } - + protected void scrollY(ScrollBar vBar) { - int vSelection = vBar.getSelection (); + int vSelection = vBar.getSelection(); Rectangle bounds = getVirtualBounds(); int y = -vSelection; int cellHeight = getCellHeight(); @@ -219,8 +221,8 @@ protected void scrollY(ScrollBar vBar) { } } int deltaY = y - bounds.y; - if(deltaY!=0) { - scrollSmart(0,deltaY); + if (deltaY != 0) { + scrollSmart(0, deltaY); setVirtualOrigin(bounds.x, bounds.y += deltaY); } if (-bounds.y + getRows() * getCellHeight() >= bounds.height) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java index 9666fd9a910..efd8744bf8b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -22,18 +22,24 @@ */ public interface ILinelRenderer { int getCellWidth(); + int getCellHeight(); + 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. */ void onFontChange(); + /** * Set a new font * @param fontName Jface name of the new font * @since 3.2 */ void updateFont(String fontName); + void setInvertedColors(boolean invert); + Color getDefaultBackgroundColor(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java index 0fbba76959c..82362757726 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java @@ -17,9 +17,11 @@ public interface ITextCanvasModel { void addCellCanvasModelListener(ITextCanvasModelListener listener); + void removeCellCanvasModelListener(ITextCanvasModelListener listener); ITerminalTextDataReadOnly getTerminalText(); + /** * This is is * @param startLine @@ -33,6 +35,7 @@ public interface ITextCanvasModel { * @return true when the cursor is shown (used for blinking cursors) */ boolean isCursorOn(); + /** * Show/Hide the cursor. * @param visible @@ -48,6 +51,7 @@ public interface ITextCanvasModel { * @return the line of the cursor */ int getCursorLine(); + /** * @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. */ Point getSelectionStart(); + /** * @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. @@ -67,6 +72,7 @@ public interface ITextCanvasModel { Point getSelectionAnchor(); void setSelectionAnchor(Point anchor); + /** * Sets the selection. A negative startLine clears the selection. * @param startLine diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java index bc942890baa..4d6251844ca 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java @@ -16,7 +16,9 @@ */ public interface ITextCanvasModelListener { void rangeChanged(int col, int line, int width, int height); + void dimensionsChanged(int cols, int rows); + /** * Called when any text change happened. Used to scroll to the * end of text in auto scroll mode. This does not get fired diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java index 4c00d995454..e1acd51a222 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java @@ -7,7 +7,7 @@ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation - * Douglas Lea (Addison Wesley) - [cq:1552] BoundedBufferWithStateTracking adapted to BoundedByteBuffer + * Douglas Lea (Addison Wesley) - [cq:1552] BoundedBufferWithStateTracking adapted to BoundedByteBuffer * Martin Oberhuber (Wind River) - the waitForAvailable method * Martin Oberhuber (Wind River) - [208166] Avoid unnecessary arraycopy in BoundedByteBuffer * Pawel Piech (Wind River) - [333613] "Job found still running" after shutdown @@ -21,7 +21,7 @@ /** * The main purpose of this class is to start a runnable in the - * display thread when data is available and to pretend no data + * display thread when data is available and to pretend no data * is available after a given amount of time the runnable is running. * */ @@ -34,27 +34,27 @@ public class PipedInputStream extends InputStream { * A blocking byte queue. */ private final BoundedByteBuffer fQueue; - + /** * A byte bounded buffer used to synchronize the input and the output stream. *

            - * Adapted from BoundedBufferWithStateTracking + * Adapted from BoundedBufferWithStateTracking * http://gee.cs.oswego.edu/dl/cpj/allcode.java * http://gee.cs.oswego.edu/dl/cpj/ *

            * BoundedBufferWithStateTracking is part of the examples for the book * Concurrent Programming in Java: Design Principles and Patterns by - * Doug Lea (ISBN 0-201-31009-0). Second edition published by - * Addison-Wesley, November 1999. The code is + * Doug Lea (ISBN 0-201-31009-0). Second edition published by + * Addison-Wesley, November 1999. The code is * Copyright(c) Douglas Lea 1996, 1999 and released to the public domain - * and may be used for any purposes whatsoever. + * and may be used for any purposes whatsoever. *

            * For some reasons a solution based on * PipedOutputStream/PipedIntputStream * does work *very* slowly: * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4404700 *

            - * + * */ private class BoundedByteBuffer { protected final byte[] fBuffer; // the elements @@ -62,19 +62,22 @@ private class BoundedByteBuffer { protected int fTakePos = 0; protected int fUsedSlots = 0; // the count private boolean fClosed; + public BoundedByteBuffer(int capacity) throws IllegalArgumentException { // make sure we don't deadlock on too small capacity if (capacity <= 0) throw new IllegalArgumentException(); fBuffer = new byte[capacity]; } + /** * @return the bytes available for {@link #read()} * Must be called with a lock on this! */ public int available() { - return fUsedSlots; + return fUsedSlots; } + /** * Writes a single byte to the buffer. Blocks if the buffer is full. * @param b byte to write to the buffer @@ -93,11 +96,13 @@ public void write(byte b) throws InterruptedException { if (fUsedSlots++ == 0) // signal if was empty notifyAll(); } + public int getFreeSlots() { return fBuffer.length - fUsedSlots; } + public void write(byte[] b, int off, int len) throws InterruptedException { - assert len<=getFreeSlots(); + assert len <= getFreeSlots(); while (fUsedSlots == fBuffer.length) // wait until not full wait(); @@ -111,6 +116,7 @@ public void write(byte[] b, int off, int len) throws InterruptedException { if (wasEmpty) // signal if was empty notifyAll(); } + /** * Read a single byte. Blocks until a byte is available. * @return a byte from the buffer @@ -120,7 +126,7 @@ public void write(byte[] b, int off, int len) throws InterruptedException { */ public int read() throws InterruptedException { while (fUsedSlots == 0) { - if(fClosed) + if (fClosed) return -1; // wait until not empty wait(); @@ -132,10 +138,11 @@ public int read() throws InterruptedException { notifyAll(); return b; } + public int read(byte[] cbuf, int off, int len) throws InterruptedException { - assert len<=available(); + assert len <= available(); while (fUsedSlots == 0) { - if(fClosed) + if (fClosed) return 0; // wait until not empty wait(); @@ -147,45 +154,47 @@ public int read(byte[] cbuf, int off, int len) throws InterruptedException { fTakePos = (fTakePos + len) % fBuffer.length; boolean wasFull = fUsedSlots == fBuffer.length; fUsedSlots -= len; - if(wasFull) + if (wasFull) notifyAll(); - + return len; } + public void close() { - fClosed=true; + fClosed = true; notifyAll(); } + public boolean isClosed() { return fClosed; } } /** - * An output stream that calls {@link PipedInputStream#textAvailable} + * An output stream that calls {@link PipedInputStream#textAvailable} * every time data is written to the stream. The data is written to * {@link PipedInputStream#fQueue}. - * + * */ class PipedOutputStream extends OutputStream { public void write(byte[] b, int off, int len) throws IOException { try { synchronized (fQueue) { - if(fQueue.isClosed()) + if (fQueue.isClosed()) throw new IOException("Stream is closed!"); //$NON-NLS-1$ - int written=0; - while(writtenPipedInputStream is the same as closing the output stream. - * The stream will allow reading data that's still in the pipe after which it will - * throw an IOException. - */ + + /** + * Closing a PipedInputStream is the same as closing the output stream. + * The stream will allow reading data that's still in the pipe after which it will + * throw an IOException. + */ public void close() throws IOException { - synchronized(fQueue) { - fQueue.close(); - } + synchronized (fQueue) { + fQueue.close(); + } } public int read(byte[] cbuf, int off, int len) throws IOException { - int n=0; - if(len==0) + int n = 0; + if (len == 0) return 0; // read as much as we can using a single synchronized statement try { - synchronized (fQueue) { + synchronized (fQueue) { // if nothing available, block and read one byte if (fQueue.available() == 0) { // block now until at least one byte is available @@ -302,7 +318,7 @@ public int read(byte[] cbuf, int off, int len) throws IOException { fQueue.read(cbuf, off + n, nn); n += nn; } - + } } catch (InterruptedException e) { Thread.currentThread().interrupt(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java index 4d0a6581cc3..8f84676089d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java @@ -1,15 +1,16 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Anton Leherbauer (Wind River) - [420928] Terminal widget leaks memory *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; + import org.eclipse.swt.widgets.Display; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; @@ -22,23 +23,26 @@ public class PollingTextCanvasModel extends AbstractTextCanvasModel { int fPollInterval = -1; /** - * + * */ public PollingTextCanvasModel(ITerminalTextDataSnapshot snapshot) { super(snapshot); startPolling(); } + public void setUpdateInterval(int t) { fPollInterval = t; } + public void stopPolling() { // timerExec only dispatches if the delay is >=0 fPollInterval = -1; } + public void startPolling() { if (fPollInterval < 0) { fPollInterval = DEFAULT_POLL_INTERVAL; - Display.getDefault().timerExec(fPollInterval, new Runnable(){ + Display.getDefault().timerExec(fPollInterval, new Runnable() { public void run() { update(); Display.getDefault().timerExec(fPollInterval, this); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index 5d4e91a7a0f..e6e91d5c05e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -45,29 +45,32 @@ public class StyleMap { private static final String BLUE = "blue"; //$NON-NLS-1$ private static final String GREEN = "green"; //$NON-NLS-1$ private static final String RED = "red"; //$NON-NLS-1$ - + private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$ - String fFontName=ITerminalConstants.FONT_DEFINITION; - Map fColorMapForeground=new HashMap(); - Map fColorMapBackground=new HashMap(); - Map fColorMapIntense=new HashMap(); + String fFontName = ITerminalConstants.FONT_DEFINITION; + Map fColorMapForeground = new HashMap(); + Map fColorMapBackground = new HashMap(); + Map fColorMapIntense = new HashMap(); private Point fCharSize; private final Style fDefaultStyle; private boolean fInvertColors; private boolean fProportional; - private final int[] fOffsets=new int[256]; + private final int[] fOffsets = new int[256]; + StyleMap() { initColors(); - fDefaultStyle=Style.getStyle(StyleColor.getStyleColor(BLACK),StyleColor.getStyleColor(WHITE)); + fDefaultStyle = Style.getStyle(StyleColor.getStyleColor(BLACK), StyleColor.getStyleColor(WHITE)); updateFont(); } + private void initColors() { initForegroundColors(); initBackgroundColors(); initIntenseColors(); } + private void initForegroundColors() { - if(fInvertColors) { + if (fInvertColors) { setColor(fColorMapForeground, WHITE, 0, 0, 0); setColor(fColorMapForeground, WHITE_FOREGROUND, 50, 50, 50); setColor(fColorMapForeground, BLACK, 229, 229, 229); @@ -86,7 +89,7 @@ private void initForegroundColors() { } private void initBackgroundColors() { - if(fInvertColors) { + if (fInvertColors) { setColor(fColorMapBackground, WHITE, 0, 0, 0); setColor(fColorMapBackground, WHITE_FOREGROUND, 50, 50, 50); // only used when colors are inverse setColor(fColorMapBackground, BLACK, 255, 255, 255); @@ -105,7 +108,7 @@ private void initBackgroundColors() { } private void initIntenseColors() { - if(fInvertColors) { + if (fInvertColors) { setColor(fColorMapIntense, WHITE, 127, 127, 127); setColor(fColorMapIntense, WHITE_FOREGROUND, 0, 0, 0); // only used when colors are inverse setColor(fColorMapIntense, BLACK, 255, 255, 255); @@ -122,13 +125,13 @@ private void initIntenseColors() { setColor(fColorMapIntense, MAGENTA, 255, 0, 255); setColor(fColorMapIntense, GRAY, 255, 255, 255); } - + private void setColor(Map colorMap, String name, int r, int g, int b) { - String colorName=PREFIX+r+"-"+g+"-"+b; //$NON-NLS-1$//$NON-NLS-2$ - Color color=JFaceResources.getColorRegistry().get(colorName); - if(color==null) { - JFaceResources.getColorRegistry().put(colorName, new RGB(r,g,b)); - color=JFaceResources.getColorRegistry().get(colorName); + String colorName = PREFIX + r + "-" + g + "-" + b; //$NON-NLS-1$//$NON-NLS-2$ + Color color = JFaceResources.getColorRegistry().get(colorName); + if (color == null) { + JFaceResources.getColorRegistry().put(colorName, new RGB(r, g, b)); + color = JFaceResources.getColorRegistry().get(colorName); } colorMap.put(StyleColor.getStyleColor(name), color); colorMap.put(StyleColor.getStyleColor(name.toUpperCase()), color); @@ -138,66 +141,74 @@ public Color getForegrondColor(Style style) { style = defaultIfNull(style); Map map = style.isBold() ? fColorMapIntense : fColorMapForeground; //Map map = fColorMapForeground; - if(style.isReverse()) - return getColor(map ,style.getBackground()); + if (style.isReverse()) + return getColor(map, style.getBackground()); else - return getColor(map ,style.getForground()); + return getColor(map, style.getForground()); } + public Color getBackgroundColor(Style style) { style = defaultIfNull(style); - if(style.isReverse()) - return getColor(fColorMapBackground,style.getForground()); + if (style.isReverse()) + return getColor(fColorMapBackground, style.getForground()); else - return getColor(fColorMapBackground,style.getBackground()); + return getColor(fColorMapBackground, style.getBackground()); } - Color getColor(Map map,StyleColor color) { - Color c=map.get(color); - if(c==null) { - c=Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); + + Color getColor(Map map, StyleColor color) { + Color c = map.get(color); + if (c == null) { + c = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); } return c; } + private Style defaultIfNull(Style style) { - if(style==null) - style=fDefaultStyle; + if (style == null) + style = fDefaultStyle; return style; } + public void setInvertedColors(boolean invert) { - if(invert==fInvertColors) + if (invert == fInvertColors) return; - fInvertColors=invert; + fInvertColors = invert; initColors(); } -// static Font getBoldFont(Font font) { -// FontData fontDatas[] = font.getFontData(); -// FontData data = fontDatas[0]; -// return new Font(Display.getCurrent(), data.getName(), data.getHeight(), data.getStyle()|SWT.BOLD); -// } + // static Font getBoldFont(Font font) { + // FontData fontDatas[] = font.getFontData(); + // FontData data = fontDatas[0]; + // return new Font(Display.getCurrent(), data.getName(), data.getHeight(), data.getStyle()|SWT.BOLD); + // } public Font getFont(Style style) { style = defaultIfNull(style); - if(style.isBold()) { - return JFaceResources.getFontRegistry().getBold(fFontName); - } else if(style.isUnderline()) { - return JFaceResources.getFontRegistry().getItalic(fFontName); + if (style.isBold()) { + return JFaceResources.getFontRegistry().getBold(fFontName); + } else if (style.isUnderline()) { + return JFaceResources.getFontRegistry().getItalic(fFontName); } - return JFaceResources.getFontRegistry().get(fFontName); + return JFaceResources.getFontRegistry().get(fFontName); } public Font getFont() { - return JFaceResources.getFontRegistry().get(fFontName); + return JFaceResources.getFontRegistry().get(fFontName); } + public int getFontWidth() { return fCharSize.x; } + public int getFontHeight() { return fCharSize.y; } + public void updateFont() { updateFont(ITerminalConstants.FONT_DEFINITION); } + /** * Update the StyleMap for a new font name. * The font name must be a valid name in the Jface font registry. @@ -205,8 +216,8 @@ public void updateFont() { * @since 3.2 */ public void updateFont(String fontName) { - Display display=Display.getCurrent(); - GC gc = new GC (display); + Display display = Display.getCurrent(); + GC gc = new GC(display); if (JFaceResources.getFontRegistry().hasValueFor(fontName)) { fFontName = fontName; } else { @@ -214,55 +225,56 @@ public void updateFont(String fontName) { fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$ } gc.setFont(getFont()); - fCharSize = gc.textExtent ("W"); //$NON-NLS-1$ - fProportional=false; - + fCharSize = gc.textExtent("W"); //$NON-NLS-1$ + fProportional = false; + for (char c = ' '; c <= '~'; c++) { // consider only the first 128 chars for deciding if a font // is proportional. Collect char width as a side-effect. - if(measureChar(gc, c, true)) - fProportional=true; + if (measureChar(gc, c, true)) + fProportional = true; } - if(fProportional) { + if (fProportional) { // Widest char minus the padding on the left and right: // Looks much better for small fonts - fCharSize.x-=2; + fCharSize.x -= 2; // Collect width of the upper characters (for offset calculation) - for (char c = '~'+1; c < fOffsets.length; c++) { - measureChar(gc, c,false); + for (char c = '~' + 1; c < fOffsets.length; c++) { + measureChar(gc, c, false); } // Calculate offsets based on each character's width and the bounding box for (int i = ' '; i < fOffsets.length; i++) { - fOffsets[i]=(fCharSize.x-fOffsets[i])/2; + fOffsets[i] = (fCharSize.x - fOffsets[i]) / 2; } } else { // Non-Proportional: Reset all offsets (eg after font change) 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$ - Point ext=gc.textExtent(t); - if(ext.x != fCharSize.x * t.length()) { + Point ext = gc.textExtent(t); + if (ext.x != fCharSize.x * t.length()) { //Bug 475422: On OSX with Retina display and due to scaling, //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 //may not be an integer but a fraction eg 6.75 pixels. // //Painting in proportional mode ensures that each character //is painted individually into its proper bounding box, rather //than using an optimization where Strings would be drawn as //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 gc.setFont(getFont(fDefaultStyle.setBold(true))); Point charSizeBold = gc.textExtent("W"); //$NON-NLS-1$ if (fCharSize.x != charSizeBold.x) { - fProportional=true; + fProportional = true; } } - gc.dispose (); + gc.dispose(); } + /** * @param gc * @param c @@ -270,28 +282,30 @@ public void updateFont(String fontName) { * @return true if the the font is proportional */ private boolean measureChar(GC gc, char c, boolean updateMax) { - boolean proportional=false; - Point ext=gc.textExtent(String.valueOf(c)); - if(ext.x>0 && ext.y>0 && (fCharSize.x!=ext.x || fCharSize.y!=ext.y)) { - proportional=true; - if(updateMax) { - fCharSize.x=Math.max(fCharSize.x, ext.x); - fCharSize.y=Math.max(fCharSize.y, ext.y); + boolean proportional = false; + Point ext = gc.textExtent(String.valueOf(c)); + if (ext.x > 0 && ext.y > 0 && (fCharSize.x != ext.x || fCharSize.y != ext.y)) { + proportional = true; + if (updateMax) { + fCharSize.x = Math.max(fCharSize.x, ext.x); + fCharSize.y = Math.max(fCharSize.y, ext.y); } } - fOffsets[c]=ext.x; + fOffsets[c] = ext.x; return proportional; } + public boolean isFontProportional() { return fProportional; } + /** * Return the offset in pixels required to center a given character * @param c the character to measure * @return the offset in x direction to center this character */ public int getCharOffset(char c) { - if(c>=fOffsets.length) + if (c >= fOffsets.length) return 0; return fOffsets[c]; } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 2161798bf26..2f866c8c4f7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -23,7 +23,6 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; - import java.util.ArrayList; import java.util.List; @@ -64,10 +63,10 @@ public class TextCanvas extends GridCanvas { // than that minimum size, the backing store size remains at the minSize, // and a scrollbar is shown instead. In reality, this has the following // issues or effects today: - // (a) Bug 281328: For very early data coming in before the widget is - // realized, the minSize determines into what initial grid that is + // (a) Bug 281328: For very early data coming in before the widget is + // realized, the minSize determines into what initial grid that is // rendered. See also @link{#addResizeHandler(ResizeListener)}. - // (b) Bug 294468: Since we have redraw and size computation problems + // (b) Bug 294468: Since we have redraw and size computation problems // with horizontal scrollers, for now the minColumns must be small // enough to avoid a horizontal scroller appearing in most cases. // (b) Bug 294327: since we have problems with the vertical scroller @@ -80,35 +79,40 @@ public class TextCanvas extends GridCanvas { // - dumb terminals which expect 80x24 render garbled on small viewport. // If bug 294468 were resolved, an 80 wide minSize would be preferrable // 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. - private int fMinColumns=80; - private int fMinLines=4; + private int fMinColumns = 80; + private int fMinLines = 4; private boolean fCursorEnabled; private boolean fResizing; - + /** * Create a new CellCanvas with the given SWT style bits. * (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); - fCellRenderer=cellRenderer; + fCellRenderer = cellRenderer; setCellWidth(fCellRenderer.getCellWidth()); setCellHeight(fCellRenderer.getCellHeight()); - fCellCanvasModel=model; - fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener(){ + fCellCanvasModel = model; + fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener() { public void rangeChanged(int col, int line, int width, int height) { - if(isDisposed()) return; - repaintRange(col,line,width,height); + if (isDisposed()) + return; + repaintRange(col, line, width, height); } + public void dimensionsChanged(int cols, int rows) { - if(isDisposed()) return; + if (isDisposed()) + return; calculateGrid(); } + public void terminalDataChanged() { - if(isDisposed()) return; - + if (isDisposed()) + return; + // scroll to end (unless scroll lock is active) if (!fResizing) { calculateGrid(); @@ -117,15 +121,17 @@ public void terminalDataChanged() { } }); // let the cursor blink if the text canvas gets the focus... - addFocusListener(new FocusListener(){ + addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { fCellCanvasModel.setCursorEnabled(fCursorEnabled); } + public void focusLost(FocusEvent e) { fCellCanvasModel.setCursorEnabled(false); - }}); + } + }); fMouseListeners = new ArrayList(); - addMouseListener(new MouseListener(){ + addMouseListener(new MouseListener() { public void mouseDoubleClick(MouseEvent e) { if (fMouseListeners.size() > 0) { Point pt = screenPointToCell(e.x, e.y); @@ -136,18 +142,19 @@ public void mouseDoubleClick(MouseEvent e) { } } } + public void mouseDown(MouseEvent e) { - if(e.button==1) { // left button - fDraggingStart=screenPointToCell(e.x, e.y); - fHasSelection=false; - if((e.stateMask&SWT.SHIFT)!=0) { - Point anchor=fCellCanvasModel.getSelectionAnchor(); - if(anchor!=null) - fDraggingStart=anchor; + if (e.button == 1) { // left button + fDraggingStart = screenPointToCell(e.x, e.y); + fHasSelection = false; + if ((e.stateMask & SWT.SHIFT) != 0) { + Point anchor = fCellCanvasModel.getSelectionAnchor(); + if (anchor != null) + fDraggingStart = anchor; } else { fCellCanvasModel.setSelectionAnchor(fDraggingStart); } - fDraggingEnd=null; + fDraggingEnd = null; } if (fMouseListeners.size() > 0) { Point pt = screenPointToCell(e.x, e.y); @@ -158,14 +165,15 @@ public void mouseDown(MouseEvent e) { } } } + public void mouseUp(MouseEvent e) { - if(e.button==1) { // left button + if (e.button == 1) { // left button updateHasSelection(e); - if(fHasSelection) + if (fHasSelection) setSelection(screenPointToCell(e.x, e.y)); else - fCellCanvasModel.setSelection(-1,-1,-1,-1); - fDraggingStart=null; + fCellCanvasModel.setSelection(-1, -1, -1, -1); + fDraggingStart = null; } if (fMouseListeners.size() > 0) { Point pt = screenPointToCell(e.x, e.y); @@ -197,15 +205,15 @@ public void mouseMove(MouseEvent e) { * @param e */ private void updateHasSelection(MouseEvent e) { - if(fDraggingStart!=null) { - Point p=screenPointToCell(e.x, e.y); - if(fDraggingStart.x!=p.x||fDraggingStart.y!=p.y) - fHasSelection=true; + if (fDraggingStart != null) { + Point p = screenPointToCell(e.x, e.y); + if (fDraggingStart.x != p.x || fDraggingStart.y != p.y) + fHasSelection = true; } } void setSelection(Point p) { - if (fDraggingStart !=null && !p.equals(fDraggingEnd)) { + if (fDraggingStart != null && !p.equals(fDraggingEnd)) { fDraggingEnd = p; if (compare(p, fDraggingStart) < 0) { // bug 219589 - make sure selection start coordinates are non-negative @@ -234,6 +242,7 @@ int compare(Point p1, Point p2) { return -1; } } + public ILinelRenderer getCellRenderer() { return fCellRenderer; } @@ -255,30 +264,30 @@ public void setMinLines(int minLines) { } protected void onResize(boolean init) { - if(fResizeListener!=null) { - Rectangle bonds=getClientArea(); + if (fResizeListener != null) { + Rectangle bonds = getClientArea(); int cellHeight = getCellHeight(); int cellWidth = getCellWidth(); - int lines=bonds.height/cellHeight; - int columns=bonds.width/cellWidth; + int lines = bonds.height / cellHeight; + int columns = bonds.width / cellWidth; // when the view is minimised, its size is set to 0 // we don't sent this to the terminal! - if((lines>0 && columns>0) || init) { - if(columns 0 && columns > 0) || init) { + if (columns < fMinColumns) { + if (!isHorizontalBarVisble()) { setHorizontalBarVisible(true); - bonds=getClientArea(); - lines=bonds.height/cellHeight; + bonds = getClientArea(); + lines = bonds.height / cellHeight; } - columns=fMinColumns; - } else if(columns>=fMinColumns && isHorizontalBarVisble()) { + columns = fMinColumns; + } else if (columns >= fMinColumns && isHorizontalBarVisble()) { setHorizontalBarVisible(false); - bonds=getClientArea(); - lines=bonds.height/cellHeight; - columns=bonds.width/cellWidth; + bonds = getClientArea(); + lines = bonds.height / cellHeight; + columns = bonds.width / cellWidth; } - if(lines 0) { y = 0; } - Rectangle v=getViewRectangle(); - if(v.y!=-y) { - setVirtualOrigin(v.x,y); + Rectangle v = getViewRectangle(); + if (v.y != -y) { + setVirtualOrigin(v.x, y); } // make sure the scroll area is correct: scrollY(getVerticalBar()); scrollX(getHorizontalBar()); } } + /** * * @return true if the cursor should be shown on output.... @@ -333,37 +344,46 @@ void scrollToEnd() { public boolean isScrollLock() { return fScrollLock; } + /** * If set then if the size changes */ public void setScrollLock(boolean scrollLock) { - fScrollLock=scrollLock; + fScrollLock = scrollLock; } + protected void repaintRange(int col, int line, int width, int height) { - Point origin=cellToOriginOnScreen(col,line); - Rectangle r=new Rectangle(origin.x,origin.y,width*getCellWidth(),height*getCellHeight()); + Point origin = cellToOriginOnScreen(col, line); + Rectangle r = new Rectangle(origin.x, origin.y, width * getCellWidth(), height * getCellHeight()); repaint(r); } + 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() { return fCellRenderer.getDefaultBackgroundColor(); } + protected void visibleCellRectangleChanged(int x, int y, int width, int height) { - fCellCanvasModel.setVisibleRectangle(y,x,height,width); + fCellCanvasModel.setVisibleRectangle(y, x, height, width); update(); } + protected int getCols() { return fCellCanvasModel.getTerminalText().getWidth(); } + protected int getRows() { return fCellCanvasModel.getTerminalText().getHeight(); } + public String getSelectionText() { // TODO -- create a hasSelectionMethod! return fCellCanvasModel.getSelectedText(); } + public void copy() { String selectionText = getSelectionText(); if (selectionText != null && selectionText.length() > 0) { @@ -372,16 +392,18 @@ public void copy() { clipboard.dispose(); } } + public void selectAll() { - fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth()); - fCellCanvasModel.setSelectionAnchor(new Point(0,0)); + fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, + fCellCanvasModel.getTerminalText().getWidth()); + fCellCanvasModel.setSelectionAnchor(new Point(0, 0)); } /** * @since 4.1 */ public void clearSelection() { - fCellCanvasModel.setSelection(-1,-1,-1,-1); + fCellCanvasModel.setSelection(-1, -1, -1, -1); } /** @@ -403,6 +425,7 @@ public String getAllText() { public boolean isEmpty() { return false; } + /** * Gets notified when the visible size of the terminal changes. * This should update the model! @@ -411,23 +434,24 @@ public boolean isEmpty() { public interface ResizeListener { void sizeChanged(int lines, int columns); } + /** * @param listener this listener gets notified, when the size of * the widget changed. It should change the dimensions of the underlying * terminaldata */ 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$ - fResizeListener=listener; + fResizeListener = listener; // Bug 281328: [terminal] The very first few characters might be missing in // the terminal control if opened and connected programmatically // // 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. - Rectangle bonds=getClientArea(); - if (bonds.height=getTerminalText().getHeight() || colFirst>=getTerminalText().getWidth() || colFirst-colLast==0) { - fillBackground(gc, x, y, getCellWidth()*(colLast-colFirst), getCellHeight()); + if (line < 0 || line >= getTerminalText().getHeight() || colFirst >= getTerminalText().getWidth() + || colFirst - colLast == 0) { + fillBackground(gc, x, y, getCellWidth() * (colLast - colFirst), getCellHeight()); } else { - colLast=Math.min(colLast, getTerminalText().getWidth()); - LineSegment[] segments=getTerminalText().getLineSegments(line, colFirst, colLast-colFirst); + colLast = Math.min(colLast, getTerminalText().getWidth()); + LineSegment[] segments = getTerminalText().getLineSegments(line, colFirst, colLast - colFirst); for (int i = 0; i < segments.length; i++) { - LineSegment segment=segments[i]; - Style style=segment.getStyle(); + LineSegment segment = segments[i]; + Style style = segment.getStyle(); setupGC(gc, style); - String text=segment.getText(); + String text = segment.getText(); drawText(gc, x, y, colFirst, segment.getColumn(), text); 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.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); - Point start=model.getSelectionStart(); - Point end=model.getSelectionEnd(); - char[] chars=model.getTerminalText().getChars(line); - if(chars==null) + Point start = model.getSelectionStart(); + Point end = model.getSelectionEnd(); + char[] chars = model.getTerminalText().getChars(line); + if (chars == null) return; - int offset=0; - if(start.y==line) - offset=start.x; - offset=Math.max(offset, colFirst); + int offset = 0; + if (start.y == line) + offset = start.x; + offset = Math.max(offset, colFirst); int len; - if(end.y==line) - len=end.x-offset+1; + if (end.y == line) + len = end.x - offset + 1; else - len=chars.length-offset+1; - len=Math.min(len,chars.length-offset); - if(len>0) { - String text=new String(chars,offset,len); + len = chars.length - offset + 1; + len = Math.min(len, chars.length - offset); + if (len > 0) { + String text = new String(chars, offset, len); drawText(gc, x, y, colFirst, offset, text); } } @@ -88,9 +93,9 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int } 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.fillRectangle (x,y,width,height); + gc.fillRectangle(x, y, width, height); gc.setBackground(bg); } @@ -99,70 +104,76 @@ public Color getDefaultBackgroundColor() { // null == default style return fStyleMap.getBackgroundColor(null); } - + private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) { - if(!model.isCursorOn()) + if (!model.isCursorOn()) return; - int cursorLine=model.getCursorLine(); + int cursorLine = model.getCursorLine(); - if(row==cursorLine) { - int cursorColumn=model.getCursorColumn(); - if(cursorColumn0||marginHeight>0){ - Color bg=getBackground(); + int width = fVirtualBounds.width + fVirtualBounds.x; + int height = fVirtualBounds.height + fVirtualBounds.y; + int marginWidth = (clipping.x + clipping.width) - width; + int marginHeight = (clipping.y + clipping.height) - height; + if (marginWidth > 0 || marginHeight > 0) { + Color bg = getBackground(); gc.setBackground(getTerminalBackgroundColor()); if (marginWidth > 0) { - gc.fillRectangle (width, clipping.y, marginWidth, clipping.height); + gc.fillRectangle(width, clipping.y, marginWidth, clipping.height); } if (marginHeight > 0) { - gc.fillRectangle (clipping.x, height, clipping.width, marginHeight); + gc.fillRectangle(clipping.x, height, clipping.width, marginHeight); } gc.setBackground(bg); } } + /** * @private */ protected boolean inClipping(Rectangle clipping, Rectangle r) { // 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; - if(clipping.x+clipping.width<=r.x) + if (clipping.x + clipping.width <= r.x) return false; - if(r.y+r.height<=clipping.y) + if (r.y + r.height <= clipping.y) return false; - if(clipping.y+clipping.height<=r.y) + if (clipping.y + clipping.height <= r.y) return false; - + return true; } + /** * @return the screen rect in virtual space (starting with (0,0)) * of the visible screen. (x,y>=0) */ 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 the rect in virtual space (starting with (0,0)) * of the visible screen. (x,y>=0) */ 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); } - + /** * Sets the extent of the virtual display area * @param width width of the display area * @param height height of the display area */ protected void setVirtualExtend(int width, int height) { - fVirtualBounds.width=width; - fVirtualBounds.height=height; + fVirtualBounds.width = width; + fVirtualBounds.height = height; updateScrollbars(); updateViewRectangle(); } + /** * sets the scrolling origin. Also sets the scrollbars. * Does NOT redraw! @@ -227,54 +236,60 @@ protected void setVirtualExtend(int width, int height) { */ protected void setVirtualOrigin(int x, int y) { if (fVirtualBounds.x != x || fVirtualBounds.y != y) { - fVirtualBounds.x=x; - fVirtualBounds.y=y; + fVirtualBounds.x = x; + fVirtualBounds.y = y; getHorizontalBar().setSelection(-x); getVerticalBar().setSelection(-y); updateViewRectangle(); } } + protected Rectangle getVirtualBounds() { return cloneRectangle(fVirtualBounds); } + /** * @param x * @return the virtual coordinate in screen space */ protected int virtualXtoScreen(int x) { - return x+fVirtualBounds.x; + return x + fVirtualBounds.x; } + protected int virtualYtoScreen(int y) { - return y+fVirtualBounds.y; + return y + fVirtualBounds.y; } + protected int screenXtoVirtual(int x) { - return x-fVirtualBounds.x; + return x - fVirtualBounds.x; } + protected int screenYtoVirtual(int y) { - return y-fVirtualBounds.y; + return y - fVirtualBounds.y; } + /** 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() { - if( - fViewRectangle.x==-fVirtualBounds.x - && fViewRectangle.y==-fVirtualBounds.y - && fViewRectangle.width==fClientArea.width - && fViewRectangle.height==fClientArea.height - ) + if (fViewRectangle.x == -fVirtualBounds.x && fViewRectangle.y == -fVirtualBounds.y + && fViewRectangle.width == fClientArea.width && fViewRectangle.height == fClientArea.height) return; - fViewRectangle.x=-fVirtualBounds.x; - fViewRectangle.y=-fVirtualBounds.y; - fViewRectangle.width=fClientArea.width; - fViewRectangle.height=fClientArea.height; - viewRectangleChanged(fViewRectangle.x,fViewRectangle.y,fViewRectangle.width,fViewRectangle.height); + fViewRectangle.x = -fVirtualBounds.x; + fViewRectangle.y = -fVirtualBounds.y; + fViewRectangle.width = fClientArea.width; + fViewRectangle.height = fClientArea.height; + viewRectangleChanged(fViewRectangle.x, fViewRectangle.y, fViewRectangle.width, fViewRectangle.height); } + protected Rectangle getViewRectangle() { return cloneRectangle(fViewRectangle); } + 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. * Override when you need this information.... @@ -286,63 +301,69 @@ private Rectangle cloneRectangle(Rectangle r) { */ protected void viewRectangleChanged(int x, int y, int width, int height) { } + /** * @private */ private void updateScrollbars() { // don't get into infinite loops.... - if(!fInUpdateScrollbars) { - fInUpdateScrollbars=true; + if (!fInUpdateScrollbars) { + fInUpdateScrollbars = true; try { doUpdateScrollbar(); } finally { - fInUpdateScrollbars=false; + fInUpdateScrollbars = false; } } else { - if(!fInUpdateScrollbarsLogged) { - fInUpdateScrollbarsLogged=true; - TerminalPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, - TerminalPlugin.PLUGIN_ID, IStatus.OK, "Unexpected Recursion in terminal", //$NON-NLS-1$ - new RuntimeException())); + if (!fInUpdateScrollbarsLogged) { + fInUpdateScrollbarsLogged = true; + TerminalPlugin.getDefault().getLog() + .log(new Status(IStatus.WARNING, TerminalPlugin.PLUGIN_ID, IStatus.OK, + "Unexpected Recursion in terminal", //$NON-NLS-1$ + new RuntimeException())); } } } + private void doUpdateScrollbar() { - Rectangle clientArea= getClientArea(); - ScrollBar horizontal= getHorizontalBar(); + Rectangle clientArea = getClientArea(); + ScrollBar horizontal = getHorizontalBar(); // even if setVisible was called on the scrollbar, isVisible - // returns false if its parent is not visible. - if(!isVisible() || horizontal.isVisible()) { + // returns false if its parent is not visible. + if (!isVisible() || horizontal.isVisible()) { horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement()); - int max= fVirtualBounds.width; + int max = fVirtualBounds.width; horizontal.setMaximum(max); horizontal.setThumb(clientArea.width); } - ScrollBar vertical= getVerticalBar(); + ScrollBar vertical = getVerticalBar(); // even if setVisible was called on the scrollbar, isVisible - // returns false if its parent is not visible. - if(!isVisible() || vertical.isVisible()) { + // returns false if its parent is not visible. + if (!isVisible() || vertical.isVisible()) { vertical.setPageIncrement(clientArea.height - vertical.getIncrement()); - int max= fVirtualBounds.height; + int max = fVirtualBounds.height; vertical.setMaximum(max); vertical.setThumb(clientArea.height); } } + protected boolean isVertialBarVisible() { return getVerticalBar().isVisible(); } + protected void serVerticalBarVisible(boolean showVScrollBar) { - ScrollBar vertical= getVerticalBar(); + ScrollBar vertical = getVerticalBar(); vertical.setVisible(showVScrollBar); vertical.setSelection(0); } + protected boolean isHorizontalBarVisble() { return getHorizontalBar().isVisible(); } + protected void setHorizontalBarVisible(boolean showHScrollBar) { - ScrollBar horizontal= getHorizontalBar(); + ScrollBar horizontal = getHorizontalBar(); horizontal.setVisible(showHScrollBar); horizontal.setSelection(0); } } - diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java index 83e5e9568e1..37a85731e45 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java @@ -37,6 +37,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { void setDimensions(int height, int width); void setMaxHeight(int height); + 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); - /** * Cleans the entire line. * @param line @@ -116,18 +116,21 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { * will be scrolled. Else a line will be added. */ void addLine(); + /** * Copies the entire source into this and changes the size accordingly * @param source */ void copy(ITerminalTextData source); + /** * Copy a sourceLine from source to this at destLine. * @param source * @param sourceLine * @param destLine */ - void copyLine(ITerminalTextData source,int sourceLine, int destLine); + void copyLine(ITerminalTextData source, int sourceLine, int destLine); + /** * Copy length lines from source starting at sourceLine into this starting at * destLine. @@ -136,13 +139,14 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { * @param destStartLine * @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 setCursorColumn(int column); /** - * Makes this line a wrapped line which logically continues on next line. + * Makes this line a wrapped line which logically continues on next line. * * @param line * @since 3.3 diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java index 21a4870caaf..d935b409a71 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java @@ -66,12 +66,14 @@ public interface ITerminalTextDataReadOnly { public ITerminalTextDataSnapshot makeSnapshot(); char[] getChars(int line); + Style[] getStyles(int line); /** * @return the line in which the cursor is at the moment */ int getCursorLine(); + /** * @return the column at which the cursor is at the moment */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java index 47c7ee4cb57..24752f8fc32 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java @@ -108,7 +108,9 @@ interface SnapshotOutOfDateListener { */ void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot); } + void addListener(SnapshotOutOfDateListener listener); + void removeListener(SnapshotOutOfDateListener listener); /** @@ -116,6 +118,7 @@ interface SnapshotOutOfDateListener { * has been called no new snapshot data is collected. */ void detach(); + /** * @return true if the data has changed since the previous snapshot. */ @@ -129,7 +132,9 @@ interface SnapshotOutOfDateListener { * @param size number of lines to track. A size of -1 means track all. */ void setInterestWindow(int startLine, int size); + int getInterestWindowStartLine(); + int getInterestWindowSize(); /** @@ -195,6 +200,7 @@ interface SnapshotOutOfDateListener { * window of interest) */ boolean hasTerminalChanged(); + /** * If {@link #updateSnapshot(boolean)} was called with true, then this method * returns the top of the scroll region. diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java index 7381d0e6439..15e4121de58 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java @@ -1,35 +1,39 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.tm.terminal.model; - public class LineSegment { private final String fText; private final int fCol; private final Style fStyle; + public LineSegment(int col, String text, Style style) { fCol = col; fText = text; fStyle = style; } + public Style getStyle() { return fStyle; } + public String getText() { return fText; } + public int getColumn() { return fCol; } + 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$ } } \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java index fa7be137653..8c348918ec2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.tm.terminal.model; @@ -17,7 +17,7 @@ * @author scharf * Flyweight * Threadsafe. - * + * */ // TODO add an Object for user data, use weak map to keep track of styles with associated // user data @@ -28,8 +28,10 @@ public class Style { private final boolean fBlink; private final boolean fUnderline; private final boolean fReverse; - private final static Map fgStyles=new HashMap(); - private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, boolean reverse) { + private final static Map fgStyles = new HashMap(); + + private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, + boolean reverse) { fForground = forground; fBackground = background; fBold = bold; @@ -37,66 +39,86 @@ private Style(StyleColor forground, StyleColor background, boolean bold, boolean fUnderline = underline; 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; synchronized (fgStyles) { - cached=fgStyles.get(style); - if(cached==null) { - cached=style; + cached = fgStyles.get(style); + if (cached == null) { + cached = style; fgStyles.put(cached, cached); } } return cached; } + 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) { - return getStyle(forground, background,false,false,false,false); + return getStyle(forground, background, false, false, false, false); } + 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) { - return getStyle(fForground,background,fBold,fBlink,fUnderline,fReverse); + return getStyle(fForground, background, fBold, fBlink, fUnderline, fReverse); } + 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) { - 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) { - return getStyle(fForground,fBackground,bold,fBlink,fUnderline,fReverse); + return getStyle(fForground, fBackground, bold, fBlink, fUnderline, fReverse); } + 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) { - return getStyle(fForground,fBackground,fBold,fBlink,underline,fReverse); + return getStyle(fForground, fBackground, fBold, fBlink, underline, fReverse); } + public Style setReverse(boolean reverse) { - return getStyle(fForground,fBackground,fBold,fBlink,fUnderline,reverse); + return getStyle(fForground, fBackground, fBold, fBlink, fUnderline, reverse); } + public StyleColor getBackground() { return fBackground; } + public boolean isBlink() { return fBlink; } + public boolean isBold() { return fBold; } + public StyleColor getForground() { return fForground; } + public boolean isReverse() { return fReverse; } + public boolean isUnderline() { return fUnderline; } + public int hashCode() { final int prime = 31; int result = 1; @@ -108,6 +130,7 @@ public int hashCode() { result = prime * result + (fUnderline ? 1231 : 1237); return result; } + public boolean equals(Object obj) { if (this == obj) return true; @@ -131,24 +154,25 @@ public boolean equals(Object obj) { return false; return true; } + public String toString() { - StringBuffer result=new StringBuffer(); + StringBuffer result = new StringBuffer(); result.append("Style(foreground="); //$NON-NLS-1$ result.append(fForground); result.append(", background="); //$NON-NLS-1$ result.append(fBackground); - if(fBlink) + if (fBlink) result.append(", blink"); //$NON-NLS-1$ - if(fBold) + if (fBold) result.append(", bold"); //$NON-NLS-1$ - if(fBlink) + if (fBlink) result.append(", blink"); //$NON-NLS-1$ - if(fReverse) + if (fReverse) result.append(", reverse"); //$NON-NLS-1$ - if(fUnderline) + if (fUnderline) result.append(", underline"); //$NON-NLS-1$ result.append(")"); //$NON-NLS-1$ return result.toString(); } - + } \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java index 10e1ed55096..64c765f0b1d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.tm.terminal.model; @@ -13,15 +13,15 @@ import java.util.HashMap; import java.util.Map; -/** - * +/** + * * Flyweight * Threadsafe. */ public class StyleColor { - private final static Map fgStyleColors=new HashMap(); + private final static Map fgStyleColors = new HashMap(); final String fName; - + /** * @param name the name of the color. It is up to the UI to associate a * named color with a visual representation @@ -30,14 +30,15 @@ public class StyleColor { public static StyleColor getStyleColor(String name) { StyleColor result; synchronized (fgStyleColors) { - result=fgStyleColors.get(name); - if(result==null) { - result=new StyleColor(name); + result = fgStyleColors.get(name); + if (result == null) { + result = new StyleColor(name); fgStyleColors.put(name, result); } } return result; } + // nobody except the factory method is allowed to instantiate this class! private StyleColor(String name) { fName = name; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java index 2877c4d0631..25729aa3426 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalTextDataFactory.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.tm.terminal.model; From 15ab06d807c229f60db46172c35829626e62b28e Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 31 Jan 2020 12:45:38 -0500 Subject: [PATCH 14/76] Bug 559474: Bump all terminal versions to 4.6.0 The 4.6.0 version marks the first version of terminal built in CDT and in a different git repo - there are no API changes. Change-Id: Ic6c4089d7e6ccbb2701bf59fedba2b6a8dd4c856 --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 5150cac4ff8..03ea8d68688 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.5.102.qualifier +Bundle-Version: 4.6.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin From 55e1db3c38b50b1cdce17f7bd5c83fa1183eb7da Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 31 Jan 2020 13:21:35 -0500 Subject: [PATCH 15/76] Bug 559474: Correct feature and bundle provider names It is now Eclipse CDT providing these, so update to match Change-Id: I1bc83b77d491d1475db51cbb6396571893d8ee42 --- .../plugins/org.eclipse.tm.terminal.control/plugin.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties index 033ccc4ec69..12d28ee07dc 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties @@ -21,7 +21,7 @@ # NLS_MESSAGEFORMAT_NONE pluginName = Terminal Control (Embeddable Widget) -providerName = Eclipse.org - Target Management +providerName = Eclipse CDT terminal.context.name.edit=Terminal Control in Focus terminal.context.description.edit=Show modified keyboard shortcuts in context menu From 674c0c796e6c2f549995f8b11cc62579b68c00fa Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 14 Feb 2020 22:09:19 +0200 Subject: [PATCH 16/76] Get rid of some annoying non-Javadoc comments. Change-Id: I55b5fcce4948ec17a97a199bb75627e8e7a4c462 Signed-off-by: Alexander Kurtakov --- .../terminal/control/impl/TerminalPlugin.java | 6 - .../emulator/VT100EmulatorBackend.java | 106 +++++------------- .../emulator/VT100TerminalControl.java | 86 +------------- .../terminal/model/SnapshotChanges.java | 60 ++++------ .../model/TerminalTextDataSnapshot.java | 51 +++++---- .../terminal/model/TerminalTextDataStore.java | 59 +++++----- .../provisional/api/AbstractSettingsPage.java | 16 +-- .../provisional/api/NullSettingsStore.java | 9 -- .../terminal/textcanvas/TextLineRenderer.java | 13 ++- 9 files changed, 128 insertions(+), 278 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java index 9f96e7b28c4..6950116e1ac 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java @@ -47,18 +47,12 @@ public static TerminalPlugin getDefault() { return plugin; } - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ @Override public void stop(BundleContext context) throws Exception { plugin = null; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index 22afb9ac7e8..d66b4bcd32c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -99,9 +99,7 @@ public VT100EmulatorBackend(ITerminalTextData terminal) { fTerminal = terminal; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#clearAll() - */ + @Override public void clearAll() { synchronized (fTerminal) { // clear the history @@ -115,9 +113,7 @@ public void clearAll() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDimensions(int, int) - */ + @Override public void setDimensions(int lines, int cols) { synchronized (fTerminal) { if (lines == fLines && cols == fColumns) @@ -158,9 +154,7 @@ public int toAbsoluteLine(int line) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#insertCharacters(int) - */ + @Override public void insertCharacters(int charactersToInsert) { synchronized (fTerminal) { int line = toAbsoluteLine(fCursorLine); @@ -177,9 +171,7 @@ public void insertCharacters(int charactersToInsert) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseToEndOfScreen() - */ + @Override public void eraseToEndOfScreen() { synchronized (fTerminal) { eraseLineToEnd(); @@ -190,9 +182,7 @@ public void eraseToEndOfScreen() { } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseToCursor() - */ + @Override public void eraseToCursor() { synchronized (fTerminal) { for (int line = toAbsoluteLine(0); line < toAbsoluteLine(fCursorLine); line++) { @@ -202,9 +192,7 @@ public void eraseToCursor() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseAll() - */ + @Override public void eraseAll() { synchronized (fTerminal) { for (int line = toAbsoluteLine(0); line < toAbsoluteLine(fLines); line++) { @@ -213,18 +201,14 @@ public void eraseAll() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLine() - */ + @Override public void eraseLine() { synchronized (fTerminal) { fTerminal.cleanLine(toAbsoluteLine(fCursorLine)); } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToEnd() - */ + @Override public void eraseLineToEnd() { synchronized (fTerminal) { int line = toAbsoluteLine(fCursorLine); @@ -234,9 +218,7 @@ public void eraseLineToEnd() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#eraseLineToCursor() - */ + @Override public void eraseLineToCursor() { synchronized (fTerminal) { int line = toAbsoluteLine(fCursorLine); @@ -246,9 +228,7 @@ public void eraseLineToCursor() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#insertLines(int) - */ + @Override public void insertLines(int n) { synchronized (fTerminal) { if (!isCusorInScrollingRegion()) @@ -260,9 +240,7 @@ public void insertLines(int n) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteCharacters(int) - */ + @Override public void deleteCharacters(int n) { synchronized (fTerminal) { int line = toAbsoluteLine(fCursorLine); @@ -278,9 +256,7 @@ public void deleteCharacters(int n) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#deleteLines(int) - */ + @Override public void deleteLines(int n) { synchronized (fTerminal) { if (!isCusorInScrollingRegion()) @@ -296,27 +272,21 @@ private boolean isCusorInScrollingRegion() { return fScrollRegion.contains(fCursorLine); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getDefaultStyle() - */ + @Override public Style getDefaultStyle() { synchronized (fTerminal) { return fDefaultStyle; } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setDefaultStyle(org.eclipse.tm.terminal.model.Style) - */ + @Override public void setDefaultStyle(Style defaultStyle) { synchronized (fTerminal) { fDefaultStyle = defaultStyle; } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getStyle() - */ + @Override public Style getStyle() { synchronized (fTerminal) { if (fStyle == null) @@ -325,18 +295,14 @@ public Style getStyle() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setStyle(org.eclipse.tm.terminal.model.Style) - */ + @Override public void setStyle(Style style) { synchronized (fTerminal) { fStyle = style; } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#appendString(java.lang.String) - */ + @Override public void appendString(String buffer) { synchronized (fTerminal) { char[] chars = buffer.toCharArray(); @@ -394,36 +360,28 @@ else if (fCursorLine + 1 >= fLines) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#processNewline() - */ + @Override public void processNewline() { synchronized (fTerminal) { doNewline(); } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorLine() - */ + @Override public int getCursorLine() { synchronized (fTerminal) { return fCursorLine; } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getCursorColumn() - */ + @Override public int getCursorColumn() { synchronized (fTerminal) { return fCursorColumn; } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursor(int, int) - */ + @Override public void setCursor(int targetLine, int targetColumn) { synchronized (fTerminal) { setCursorLine(targetLine); @@ -431,9 +389,7 @@ public void setCursor(int targetLine, int targetColumn) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursorColumn(int) - */ + @Override public void setCursorColumn(int targetColumn) { synchronized (fTerminal) { if (targetColumn < 0) @@ -449,9 +405,7 @@ else if (targetColumn >= fColumns) } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setCursorLine(int) - */ + @Override public void setCursorLine(int targetLine) { synchronized (fTerminal) { if (targetLine < 0) @@ -466,36 +420,36 @@ else if (targetLine >= fLines) } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getLines() - */ + @Override public int getLines() { synchronized (fTerminal) { return fLines; } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getColumns() - */ + @Override public int getColumns() { synchronized (fTerminal) { return fColumns; } } + @Override public void setVT100LineWrapping(boolean enable) { fVT100LineWrapping = enable; } + @Override public boolean isVT100LineWrapping() { return fVT100LineWrapping; } + @Override public void setInsertMode(boolean enable) { fInsertMode = enable; } + @Override public void setScrollRegion(int top, int bottom) { if (top < 0 || bottom < 0) fScrollRegion = ScrollRegion.FULL_WINDOW; @@ -503,6 +457,7 @@ else if (top < bottom) fScrollRegion = new ScrollRegion(top, bottom); } + @Override public void scrollUp(int n) { assert n > 0; synchronized (fTerminal) { @@ -512,6 +467,7 @@ public void scrollUp(int n) { } } + @Override public void scrollDown(int n) { assert n > 0; synchronized (fTerminal) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index cd325c25874..cde56fdd270 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -252,9 +252,6 @@ public ITerminalConnector[] getConnectors() { return fConnectors; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#copy() - */ @Override public void copy() { copy(DND.CLIPBOARD); @@ -269,9 +266,6 @@ private void copy(int clipboardType) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste() - */ @Override public void paste() { paste(DND.CLIPBOARD); @@ -312,9 +306,6 @@ public boolean pasteString(String strText) { return true; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#selectAll() - */ @Override public void selectAll() { getCtlText().selectAll(); @@ -323,9 +314,6 @@ public void selectAll() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#sendKey(char) - */ @Override public void sendKey(char character) { Event event; @@ -342,9 +330,6 @@ public void sendKey(char character) { fKeyHandler.keyPressed(keyEvent); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#clearTerminal() - */ @Override public void clearTerminal() { // The TerminalText object does all text manipulation. @@ -355,9 +340,6 @@ public void clearTerminal() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getClipboard() - */ @Override public Clipboard getClipboard() { return fClipboard; @@ -374,41 +356,26 @@ public String getSelection() { return txt; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setFocus() - */ @Override public void setFocus() { getCtlText().setFocus(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isEmpty() - */ @Override public boolean isEmpty() { return getCtlText().isEmpty(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isDisposed() - */ @Override public boolean isDisposed() { return getCtlText().isDisposed(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnected() - */ @Override public boolean isConnected() { return fState == TerminalState.CONNECTED; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disposeTerminal() - */ @Override public void disposeTerminal() { Logger.log("entered."); //$NON-NLS-1$ @@ -445,9 +412,6 @@ public ITerminalConnector getTerminalConnector() { return fConnector; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disconnectTerminal() - */ @Override public void disconnectTerminal() { Logger.log("entered."); //$NON-NLS-1$ @@ -665,9 +629,6 @@ protected void sendChar(char chKey, boolean altKeyPressed) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setupTerminal(org.eclipse.swt.widgets.Composite) - */ @Override public void setupTerminal(Composite parent) { Assert.isNotNull(parent); @@ -700,10 +661,6 @@ public void setupTerminal(Composite parent) { } } - /* - * (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#updatePreferences() - */ private void updatePreferences() { int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_BUFFERLINES, 0, null); @@ -718,10 +675,6 @@ private void onTerminalFontChanged() { setFont(ITerminalConstants.FONT_DEFINITION); } - /* - * (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String) - */ @Override public void setFont(String fontName) { Font font = JFaceResources.getFont(fontName); @@ -734,9 +687,6 @@ public void setFont(String fontName) { getTerminalText().fontChanged(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(org.eclipse.swt.graphics.Font) - */ @Override @Deprecated public void setFont(Font font) { @@ -825,9 +775,6 @@ protected void setupHelp(Composite parent, String id) { PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, id); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#displayTextInTerminal(java.lang.String) - */ @Override public void displayTextInTerminal(String text) { writeToTerminal("\r\n" + text + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -865,9 +812,6 @@ public OutputStream getOutputStream() { return null; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setMsg(java.lang.String) - */ @Override public void setMsg(String msg) { fMsg = msg; @@ -877,16 +821,10 @@ public String getMsg() { return fMsg; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getCtlText() - */ protected TextCanvas getCtlText() { return fCtlText; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getTerminalText() - */ public VT100Emulator getTerminalText() { return fTerminalText; } @@ -912,8 +850,7 @@ public void mouseEnter(MouseEvent e) { if (getState() == TerminalState.CONNECTED) captureKeyEvents(true); - IContextService contextService = (IContextService) PlatformUI.getWorkbench() - .getAdapter(IContextService.class); + IContextService contextService = PlatformUI.getWorkbench().getAdapter(IContextService.class); editContextActivation = contextService.activateContext("org.eclipse.tm.terminal.EditContext"); //$NON-NLS-1$ } @@ -925,17 +862,14 @@ public void mouseExit(MouseEvent e) { // Restore the command context to its previous value. - IContextService contextService = (IContextService) PlatformUI.getWorkbench() - .getAdapter(IContextService.class); + IContextService contextService = PlatformUI.getWorkbench().getAdapter(IContextService.class); contextService.deactivateContext(editContextActivation); } @SuppressWarnings("cast") protected void captureKeyEvents(boolean capture) { - IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench() - .getAdapter(IBindingService.class); - IContextService contextService = (IContextService) PlatformUI.getWorkbench() - .getAdapter(IContextService.class); + IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class); + IContextService contextService = PlatformUI.getWorkbench().getAdapter(IContextService.class); boolean enableKeyFilter = !capture; if (bindingService.isKeyFilterEnabled() != enableKeyFilter) @@ -1247,15 +1181,13 @@ public void keyPressed(KeyEvent event) { */ @SuppressWarnings("cast") private void processKeyBinding(KeyEvent event, int accelerator) { - IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench() - .getAdapter(IBindingService.class); + IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class); KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator); Binding binding = bindingService.getPerfectMatch(KeySequence.getInstance(keyStroke)); if (binding != null) { ParameterizedCommand cmd = binding.getParameterizedCommand(); if (cmd != null) { - IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() - .getAdapter(IHandlerService.class); + IHandlerService handlerService = PlatformUI.getWorkbench().getAdapter(IHandlerService.class); Event cmdEvent = new Event(); cmdEvent.type = SWT.KeyDown; cmdEvent.display = event.display; @@ -1393,17 +1325,11 @@ public void setInvertedColors(boolean invert) { fCtlText.setInvertedColors(invert); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setConnectOnEnterIfClosed(boolean) - */ @Override public final void setConnectOnEnterIfClosed(boolean on) { connectOnEnterIfClosed = on; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#isConnectOnEnterIfClosed() - */ @Override public final boolean isConnectOnEnterIfClosed() { return connectOnEnterIfClosed; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java index a4975cfac66..c1b4638c5dc 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SnapshotChanges.java @@ -145,9 +145,7 @@ public int fitSizeToWindow(int line, int size) { return size; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLineChanged(int) - */ + @Override public void markLineChanged(int line) { if (!isInInterestWindow(line)) return; @@ -164,9 +162,7 @@ public void markLineChanged(int line) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#markLinesChanged(int, int) - */ + @Override public void markLinesChanged(int line, int n) { if (n <= 0 || !isInInterestWindow(line, n)) return; @@ -186,13 +182,12 @@ public void markLinesChanged(int line, int n) { markLineChanged(line + n - 1); } + @Override public void markCursorChanged() { fCursorHasChanged = true; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#convertScrollingIntoChanges() - */ + @Override public void convertScrollingIntoChanges() { markLinesChanged(fScrollWindowStartLine, fScrollWindowSize); fScrollWindowStartLine = 0; @@ -200,9 +195,7 @@ public void convertScrollingIntoChanges() { fScrollWindowShift = 0; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#hasChanged() - */ + @Override public boolean hasChanged() { if (fFirstChangedLine != Integer.MAX_VALUE || fLastChangedLine > 0 || fScrollWindowShift != 0 || fDimensionsChanged || fCursorHasChanged) @@ -210,25 +203,27 @@ public boolean hasChanged() { return false; } + @Override public void markDimensionsChanged() { fDimensionsChanged = true; } + @Override public boolean hasDimensionsChanged() { return fDimensionsChanged; } + @Override public boolean hasTerminalChanged() { return fTerminalHasChanged; } + @Override public void setTerminalChanged() { fTerminalHasChanged = true; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#scroll(int, int, int) - */ + @Override public void scroll(int startLine, int size, int shift) { size = fitSizeToWindow(startLine, size); startLine = fitLineToWindow(startLine); @@ -311,9 +306,7 @@ private void scrollChangesLinesWithNegativeShift(int line, int n, int shift) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#setAllChanged(int) - */ + @Override public void setAllChanged(int height) { fScrollWindowStartLine = 0; fScrollWindowSize = 0; @@ -324,44 +317,32 @@ public void setAllChanged(int height) { setChangedLinesLength(0); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getFirstChangedLine() - */ + @Override public int getFirstChangedLine() { return fFirstChangedLine; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getLastChangedLine() - */ + @Override public int getLastChangedLine() { return fLastChangedLine; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowStartLine() - */ + @Override public int getScrollWindowStartLine() { return fScrollWindowStartLine; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowSize() - */ + @Override public int getScrollWindowSize() { return fScrollWindowSize; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#getScrollWindowShift() - */ + @Override public int getScrollWindowShift() { return fScrollWindowShift; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#copyChangedLines(org.eclipse.tm.terminal.model.ITerminalTextData, org.eclipse.tm.terminal.model.ITerminalTextData) - */ + @Override public void copyChangedLines(ITerminalTextData dest, ITerminalTextData source) { int n = Math.min(fLastChangedLine + 1, source.getHeight()); for (int i = fFirstChangedLine; i < n; i++) { @@ -370,14 +351,17 @@ public void copyChangedLines(ITerminalTextData dest, ITerminalTextData source) { } } + @Override public int getInterestWindowSize() { return fInterestWindowSize; } + @Override public int getInterestWindowStartLine() { return fInterestWindowStartLine; } + @Override public void setInterestWindow(int startLine, int size) { int oldStartLine = fInterestWindowStartLine; int oldSize = fInterestWindowSize; @@ -412,9 +396,7 @@ public void setInterestWindow(int startLine, int size) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ISnapshotChanges#hasLineChanged(int) - */ + @Override public boolean hasLineChanged(int line) { if (line < fChangedLines.length) return fChangedLines[line]; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java index 6dad9798f93..7d3d5a7f88e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java @@ -73,10 +73,12 @@ private boolean throwRuntimeException() { throw new RuntimeException(); } + @Override public void detach() { fTerminal.removeSnapshot(this); } + @Override public boolean isOutOfDate() { // this is called from fTerminal, therefore we lock on fTerminal synchronized (fTerminal) { @@ -84,9 +86,7 @@ public boolean isOutOfDate() { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#snapshot() - */ + @Override public void updateSnapshot(boolean detectScrolling) { // make sure terminal does not change while we make the snapshot synchronized (fTerminal) { @@ -121,69 +121,67 @@ public void updateSnapshot(boolean detectScrolling) { } } + @Override public char getChar(int line, int column) { return fSnapshot.getChar(line, column); } + @Override public int getHeight() { return fSnapshot.getHeight(); } + @Override public LineSegment[] getLineSegments(int line, int column, int len) { return fSnapshot.getLineSegments(line, column, len); } + @Override public Style getStyle(int line, int column) { return fSnapshot.getStyle(line, column); } + @Override public int getWidth() { return fSnapshot.getWidth(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getFirstChangedLine() - */ + @Override public int getFirstChangedLine() { return fCurrentChanges.getFirstChangedLine(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getLastChangedLine() - */ + @Override public int getLastChangedLine() { return fCurrentChanges.getLastChangedLine(); } + @Override public boolean hasLineChanged(int line) { return fCurrentChanges.hasLineChanged(line); } + @Override public boolean hasDimensionsChanged() { return fCurrentChanges.hasDimensionsChanged(); } + @Override public boolean hasTerminalChanged() { return fCurrentChanges.hasTerminalChanged(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeY() - */ + @Override public int getScrollWindowStartLine() { return fCurrentChanges.getScrollWindowStartLine(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeN() - */ + @Override public int getScrollWindowSize() { return fCurrentChanges.getScrollWindowSize(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.model.ITerminalTextDataSnapshot#getScrollChangeShift() - */ + @Override public int getScrollWindowShift() { return fCurrentChanges.getScrollWindowShift(); } @@ -248,36 +246,43 @@ private void notifyListers() { } } + @Override public ITerminalTextDataSnapshot makeSnapshot() { return fSnapshot.makeSnapshot(); } + @Override synchronized public void addListener(SnapshotOutOfDateListener listener) { - List list = new ArrayList(); + List list = new ArrayList<>(); list.addAll(Arrays.asList(fListener)); list.add(listener); fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]); } + @Override synchronized public void removeListener(SnapshotOutOfDateListener listener) { - List list = new ArrayList(); + List list = new ArrayList<>(); list.addAll(Arrays.asList(fListener)); list.remove(listener); fListener = list.toArray(new SnapshotOutOfDateListener[list.size()]); } + @Override public String toString() { return fSnapshot.toString(); } + @Override public int getInterestWindowSize() { return fInterestWindowSize; } + @Override public int getInterestWindowStartLine() { return fInterestWindowStartLine; } + @Override public void setInterestWindow(int startLine, int size) { assert startLine >= 0 || throwRuntimeException(); assert size >= 0 || throwRuntimeException(); @@ -288,26 +293,32 @@ public void setInterestWindow(int startLine, int size) { notifyListers(); } + @Override public char[] getChars(int line) { return fSnapshot.getChars(line); } + @Override public Style[] getStyles(int line) { return fSnapshot.getStyles(line); } + @Override public int getCursorColumn() { return fSnapshot.getCursorColumn(); } + @Override public int getCursorLine() { return fSnapshot.getCursorLine(); } + @Override public ITerminalTextData getTerminalTextData() { return fTerminal; } + @Override public boolean isWrappedLine(int line) { return fSnapshot.isWrappedLine(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java index 83a9ca0dd35..2ab5b22025a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java @@ -50,23 +50,17 @@ private boolean throwRuntimeException() { throw new RuntimeException(); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getWidth() - */ + @Override public int getWidth() { return fWidth; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getHeight() - */ + @Override public int getHeight() { return fHeight; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setDimensions(int, int) - */ + @Override public void setDimensions(int height, int width) { assert height >= 0 || throwRuntimeException(); assert width >= 0 || throwRuntimeException(); @@ -109,9 +103,7 @@ private Object resizeArray(Object origArray, int newSize) { return newArray; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getLineSegments(int, int, int) - */ + @Override public LineSegment[] getLineSegments(int line, int column, int len) { // get the styles and chars for this line Style[] styles = fStyle[line]; @@ -132,7 +124,7 @@ else if (chars.length < n) // and create the line segments Style style = styles[column]; - List segments = new ArrayList(); + List segments = new ArrayList<>(); for (int i = column; i < n; i++) { if (styles[i] != style) { segments.add(new LineSegment(col, new String(chars, col, i - col), style)); @@ -146,9 +138,7 @@ else if (chars.length < n) return segments.toArray(new LineSegment[segments.size()]); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getChar(int, int) - */ + @Override public char getChar(int line, int column) { assert column < fWidth || throwRuntimeException(); if (fChars[line] == null || column >= fChars[line].length) @@ -156,9 +146,7 @@ public char getChar(int line, int column) { return fChars[line][column]; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#getStyle(int, int) - */ + @Override public Style getStyle(int line, int column) { assert column < fWidth || throwRuntimeException(); if (fStyle[line] == null || column >= fStyle[line].length) @@ -181,25 +169,19 @@ void ensureLineLength(int iLine, int length) { } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChar(int, int, char, org.eclipse.tm.internal.terminal.text.Style) - */ + @Override public void setChar(int line, int column, char c, Style style) { ensureLineLength(line, column + 1); fChars[line][column] = c; fStyle[line][column] = style; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChars(int, int, char[], org.eclipse.tm.internal.terminal.text.Style) - */ + @Override public void setChars(int line, int column, char[] chars, Style style) { setChars(line, column, chars, 0, chars.length, style); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#setChars(int, int, char[], int, int, org.eclipse.tm.internal.terminal.text.Style) - */ + @Override public void setChars(int line, int column, char[] chars, int start, int len, Style style) { ensureLineLength(line, column + len); for (int i = 0; i < len; i++) { @@ -208,9 +190,7 @@ public void setChars(int line, int column, char[] chars, int start, int len, Sty } } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.text.ITerminalTextData#scroll(int, int, int) - */ + @Override public void scroll(int startLine, int size, int shift) { assert startLine + size <= getHeight() || throwRuntimeException(); if (shift < 0) { @@ -249,6 +229,7 @@ private void cleanLines(int line, int len) { * @return a text representation of the object. * Lines are separated by '\n'. No style information is returned. */ + @Override public String toString() { StringBuffer buff = new StringBuffer(); for (int line = 0; line < getHeight(); line++) { @@ -261,10 +242,12 @@ public String toString() { return buff.toString(); } + @Override public ITerminalTextDataSnapshot makeSnapshot() { throw new UnsupportedOperationException(); } + @Override public void addLine() { if (fMaxHeight > 0 && getHeight() < fMaxHeight) { setDimensions(getHeight() + 1, getWidth()); @@ -273,6 +256,7 @@ public void addLine() { } } + @Override public void copy(ITerminalTextData source) { fWidth = source.getWidth(); int n = source.getHeight(); @@ -288,24 +272,28 @@ public void copy(ITerminalTextData source) { fCursorColumn = source.getCursorColumn(); } + @Override public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { for (int i = 0; i < length; i++) { copyLine(source, i + sourceStartLine, i + destStartLine); } } + @Override public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { fChars[destLine] = source.getChars(sourceLine); fStyle[destLine] = source.getStyles(sourceLine); fWrappedLines.set(destLine, source.isWrappedLine(sourceLine)); } + @Override public char[] getChars(int line) { if (fChars[line] == null) return null; return fChars[line].clone(); } + @Override public Style[] getStyles(int line) { if (fStyle[line] == null) return null; @@ -318,40 +306,49 @@ public void setLine(int line, char[] chars, Style[] styles) { fWrappedLines.clear(line); } + @Override public void setMaxHeight(int height) { fMaxHeight = height; } + @Override public int getMaxHeight() { return fMaxHeight; } + @Override public void cleanLine(int line) { fChars[line] = null; fStyle[line] = null; fWrappedLines.clear(line); } + @Override public int getCursorColumn() { return fCursorColumn; } + @Override public int getCursorLine() { return fCursorLine; } + @Override public void setCursorColumn(int column) { fCursorColumn = column; } + @Override public void setCursorLine(int line) { fCursorLine = line; } + @Override public boolean isWrappedLine(int line) { return fWrappedLines.get(line); } + @Override public void setWrappedLine(int line) { fWrappedLines.set(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java index 89b0d8ad095..324de7a1e2b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java @@ -36,17 +36,13 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro // Flag to control the control decorations private boolean hasDecoration = false; - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#addListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener) - */ + @Override public void addListener(Listener listener) { Assert.isNotNull(listener); listeners.add(listener); } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage#removeListener(org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage.Listener) - */ + @Override public void removeListener(Listener listener) { Assert.isNotNull(listener); listeners.remove(listener); @@ -67,16 +63,12 @@ public void fireListeners(Control control) { } } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IMessageProvider#getMessage() - */ + @Override public final String getMessage() { return message; } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IMessageProvider#getMessageType() - */ + @Override public final int getMessageType() { return messageType; } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java index 16e6432f826..dc7d3b668ec 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/NullSettingsStore.java @@ -16,25 +16,16 @@ */ public class NullSettingsStore implements ISettingsStore { - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String) - */ @Override public String get(String key) { return null; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String, java.lang.String) - */ @Override public String get(String key, String defaultValue) { return defaultValue; } - /* (non-Javadoc) - * @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#put(java.lang.String, java.lang.String) - */ @Override public void put(String key, String value) { } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index a4116fae971..954eeeb48fc 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -37,20 +37,17 @@ public TextLineRenderer(TextCanvas c, ITextCanvasModel model) { fModel = model; } - /* (non-Javadoc) - * @see com.imagicus.thumbs.view.ICellRenderer#getCellWidth() - */ + @Override public int getCellWidth() { return fStyleMap.getFontWidth(); } - /* (non-Javadoc) - * @see com.imagicus.thumbs.view.ICellRenderer#getCellHeight() - */ + @Override public int getCellHeight() { return fStyleMap.getFontHeight(); } + @Override 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) { @@ -100,6 +97,7 @@ private void fillBackground(GC gc, int x, int y, int width, int height) { } + @Override public Color getDefaultBackgroundColor() { // null == default style return fStyleMap.getBackgroundColor(null); @@ -166,14 +164,17 @@ ITerminalTextDataReadOnly getTerminalText() { return fModel.getTerminalText(); } + @Override public void onFontChange() { fStyleMap.updateFont(); } + @Override public void updateFont(String fontName) { fStyleMap.updateFont(fontName); } + @Override public void setInvertedColors(boolean invert) { fStyleMap.setInvertedColors(invert); From 8ac4ef0923e9a927898f1abe54305cd8a7f77547 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 14 Feb 2020 22:20:58 +0200 Subject: [PATCH 17/76] Generify some getAdapter implementations. Change-Id: I2cd3dad7821e3c6ae3f0371edda5e511beff4014 Signed-off-by: Alexander Kurtakov --- .../terminal/connector/TerminalConnector.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java index 99cb5472d72..be2350a43f1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java @@ -114,6 +114,7 @@ public TerminalConnector(TerminalConnector.Factory terminalConnectorFactory, Str fHidden = hidden; } + @Override public String getInitializationErrorMessage() { getConnectorImpl(); if (fException != null) @@ -121,14 +122,17 @@ public String getInitializationErrorMessage() { return null; } + @Override public String getId() { return fId; } + @Override public String getName() { return fName; } + @Override public boolean isHidden() { return fHidden; } @@ -141,16 +145,19 @@ private TerminalConnectorImpl getConnectorImpl() { } catch (Exception e) { fException = e; fConnector = new TerminalConnectorImpl() { + @Override public void connect(ITerminalControl control) { // super.connect(control); control.setState(TerminalState.CLOSED); control.setMsg(getInitializationErrorMessage()); } + @Override public OutputStream getTerminalToRemoteStream() { return null; } + @Override public String getSettingsSummary() { return null; } @@ -164,22 +171,27 @@ public String getSettingsSummary() { return fConnector; } + @Override public boolean isInitialized() { return fConnector != null || fException != null; } + @Override public void connect(ITerminalControl control) { getConnectorImpl().connect(control); } + @Override public void disconnect() { getConnectorImpl().disconnect(); } + @Override public OutputStream getTerminalToRemoteStream() { return getConnectorImpl().getTerminalToRemoteStream(); } + @Override public String getSettingsSummary() { if (fConnector != null) return getConnectorImpl().getSettingsSummary(); @@ -187,10 +199,12 @@ public String getSettingsSummary() { return TerminalMessages.NotInitialized; } + @Override public boolean isLocalEcho() { return getConnectorImpl().isLocalEcho(); } + @Override public void load(ISettingsStore store) { if (fConnector == null) { fStore = store; @@ -204,6 +218,7 @@ public void setDefaultSettings() { getConnectorImpl().setDefaultSettings(); } + @Override public void save(ISettingsStore store) { // no need to save the settings: it cannot have changed // because we are not initialized.... @@ -211,6 +226,7 @@ public void save(ISettingsStore store) { getConnectorImpl().save(store); } + @Override public void setTerminalSize(int newWidth, int newHeight) { // we assume that setTerminalSize is called also after // the terminal has been initialized. Else we would have to cache @@ -220,7 +236,8 @@ public void setTerminalSize(int newWidth, int newHeight) { } } - public Object getAdapter(Class adapter) { + @Override + public T getAdapter(Class adapter) { TerminalConnectorImpl connector = null; if (isInitialized()) connector = getConnectorImpl(); @@ -234,11 +251,11 @@ public Object getAdapter(Class adapter) { //defer to the platform result = Platform.getAdapterManager().getAdapter(connector, adapter); if (result != null) - return result; + return adapter.cast(result); } // maybe the real adapter is what we need.... if (adapter.isInstance(connector)) - return connector; + return adapter.cast(connector); } // maybe we have to be adapted.... return Platform.getAdapterManager().getAdapter(this, adapter); From bd0d6918007e08579f2ab8d58e6003fb8baf6f5c Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 14 Feb 2020 22:24:09 +0200 Subject: [PATCH 18/76] Remove unnecessary SuppressWarning(cast) and casts. Change-Id: I9248a3fd2481b590e8437bf7f880f936ba88ce6c Signed-off-by: Alexander Kurtakov --- .../tm/internal/terminal/emulator/EditActionAccelerators.java | 2 +- .../tm/internal/terminal/emulator/VT100TerminalControl.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java index 9f8b06f57ed..827f2a7e575 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -50,7 +50,7 @@ private static TriggerSequence[] bindingsFor(String commandId) { } private static IBindingService bindingService() { - return (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); + return PlatformUI.getWorkbench().getAdapter(IBindingService.class); } boolean isCopyAction(int accelerator) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index cde56fdd270..1a931f9abb3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -842,7 +842,6 @@ public void mouseHover(MouseEvent e) { } @Override - @SuppressWarnings("cast") public void mouseEnter(MouseEvent e) { // Disable all keyboard accelerators (e.g., Control-B) so the Terminal view // can see every keystroke. Without this, Emacs, vi, and Bash are unusable @@ -855,7 +854,6 @@ public void mouseEnter(MouseEvent e) { } @Override - @SuppressWarnings("cast") public void mouseExit(MouseEvent e) { // Enable all keybindings. captureKeyEvents(false); @@ -866,7 +864,6 @@ public void mouseExit(MouseEvent e) { contextService.deactivateContext(editContextActivation); } - @SuppressWarnings("cast") protected void captureKeyEvents(boolean capture) { IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class); IContextService contextService = PlatformUI.getWorkbench().getAdapter(IContextService.class); @@ -1179,7 +1176,6 @@ public void keyPressed(KeyEvent event) { /* * Process given event as Eclipse key binding. */ - @SuppressWarnings("cast") private void processKeyBinding(KeyEvent event, int accelerator) { IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class); KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator); From bfd8a4bea6aacd2a6c359164f4aced571221d78c Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 14 Feb 2020 22:27:25 +0200 Subject: [PATCH 19/76] Lambda conversion in terminal code. Change-Id: I30c23a89b3e78306d3e05fa65f5d2d8dd9e23540 Signed-off-by: Alexander Kurtakov --- .../control/CommandInputFieldWithHistory.java | 40 +++++++--------- .../emulator/VT100TerminalControl.java | 47 +++++++------------ .../api/TerminalConnectorExtension.java | 6 +-- .../terminal/textcanvas/GridCanvas.java | 18 +++---- .../terminal/textcanvas/TextCanvas.java | 12 ++--- .../terminal/textcanvas/VirtualCanvas.java | 31 +++--------- 6 files changed, 52 insertions(+), 102 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java index 92f3a89c549..382c588d749 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -35,8 +35,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; @@ -235,27 +233,25 @@ public void createControl(final Composite parent, final ITerminalViewControl ter final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false); gd_sash.heightHint = 5; fSash.setLayoutData(gd_sash); - fSash.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (e.detail == SWT.DRAG) { - // don't redraw during drag, it causes paint errors - bug 220971 - return; - } - // no idea why this is needed - GridData gdata = (GridData) fInputField.getLayoutData(); - Rectangle sashRect = fSash.getBounds(); - Rectangle containerRect = parent.getClientArea(); - - int h = fInputField.getLineHeight(); - // 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); - // do not show less then one line - e.y = Math.min(e.y, containerRect.height - h); - fInputField.setLayoutData(gdata); - parent.layout(); - // else the content assist icon will be replicated - parent.redraw(); + fSash.addListener(SWT.Selection, e -> { + if (e.detail == SWT.DRAG) { + // don't redraw during drag, it causes paint errors - bug 220971 + return; } + // no idea why this is needed + GridData gdata = (GridData) fInputField.getLayoutData(); + Rectangle sashRect = fSash.getBounds(); + Rectangle containerRect = parent.getClientArea(); + + int h = fInputField.getLineHeight(); + // 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); + // do not show less then one line + e.y = Math.min(e.y, containerRect.height - h); + fInputField.setLayoutData(gdata); + parent.layout(); + // else the content assist icon will be replicated + parent.redraw(); }); fPanel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 1a931f9abb3..c7c3f6d1e36 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -67,7 +67,6 @@ import org.eclipse.jface.bindings.keys.SWTKeySupport; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; @@ -165,21 +164,15 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC /** * Listens to changes in the preferences */ - private final IPropertyChangeListener fPreferenceListener = new IPropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) - || event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) { - updatePreferences(); - } + private final IPropertyChangeListener fPreferenceListener = event -> { + if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) + || event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) { + updatePreferences(); } }; - private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) { - onTerminalFontChanged(); - } + private final IPropertyChangeListener fFontListener = event -> { + if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) { + onTerminalFontChanged(); } }; @@ -731,12 +724,7 @@ protected void setupControls(Composite parent) { new TextLineRenderer(fCtlText, fPollingTextCanvasModel)); fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - fCtlText.addResizeHandler(new TextCanvas.ResizeListener() { - @Override - public void sizeChanged(int lines, int columns) { - fTerminalText.setDimensions(lines, columns); - } - }); + fCtlText.addResizeHandler((lines, columns) -> fTerminalText.setDimensions(lines, columns)); fCtlText.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { @@ -1233,17 +1221,14 @@ public void setState(TerminalState state) { fState = state; fTerminalListener.setState(state); // enable the (blinking) cursor if the terminal is connected - runAsyncInDisplayThread(new Runnable() { - @Override - public void run() { - if (fCtlText != null && !fCtlText.isDisposed()) { - if (isConnected()) { - fCtlText.setCursorEnabled(true); - } else { - fCtlText.setCursorEnabled(false); - // Stop capturing all key events - fFocusListener.captureKeyEvents(false); - } + runAsyncInDisplayThread(() -> { + if (fCtlText != null && !fCtlText.isDisposed()) { + if (isConnected()) { + fCtlText.setCursorEnabled(true); + } else { + fCtlText.setCursorEnabled(false); + // Stop capturing all key events + fFocusListener.captureKeyEvents(false); } } }); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java index 0379361cca0..383c637c415 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -49,11 +49,7 @@ static private ITerminalConnector makeConnector(final IConfigurationElement conf } String hidden = config.getAttribute("hidden"); //$NON-NLS-1$ boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false; - TerminalConnector.Factory factory = new TerminalConnector.Factory() { - public TerminalConnectorImpl makeConnector() throws Exception { - return (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$ - } - }; + TerminalConnector.Factory factory = () -> (TerminalConnectorImpl) config.createExecutableExtension("class"); return new TerminalConnector(factory, id, name, isHidden); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java index 5425354f5ea..5a52d02ad16 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java @@ -16,8 +16,6 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.ScrollBar; /** @@ -32,16 +30,14 @@ abstract public class GridCanvas extends VirtualCanvas { public GridCanvas(Composite parent, int style) { super(parent, style); - addListener(SWT.MouseWheel, new Listener() { - public void handleEvent(Event event) { - if (getVerticalBar().isVisible()) { - int delta = -fCellHeight; - if (event.count < 0) - delta = -delta; - scrollYDelta(delta); - } - event.doit = false; + addListener(SWT.MouseWheel, event -> { + if (getVerticalBar().isVisible()) { + int delta = -fCellHeight; + if (event.count < 0) + delta = -delta; + scrollYDelta(delta); } + event.doit = false; }); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 2f866c8c4f7..34fba478ba7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -34,7 +34,6 @@ import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; @@ -185,13 +184,10 @@ public void mouseUp(MouseEvent e) { } } }); - addMouseMoveListener(new MouseMoveListener() { - - public void mouseMove(MouseEvent e) { - if (fDraggingStart != null) { - updateHasSelection(e); - setSelection(screenPointToCell(e.x, e.y)); - } + addMouseMoveListener(e -> { + if (fDraggingStart != null) { + updateHasSelection(e); + setSelection(screenPointToCell(e.x, e.y)); } }); serVerticalBarVisible(true); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java index 562eaecf946..af4d794dc3e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java @@ -19,8 +19,6 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; @@ -42,30 +40,13 @@ public abstract class VirtualCanvas extends Canvas { public VirtualCanvas(Composite parent, int style) { super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE); fClientArea = getClientArea(); - addListener(SWT.Paint, new Listener() { - public void handleEvent(Event event) { - paint(event.gc); - } - }); - addListener(SWT.Resize, new Listener() { - public void handleEvent(Event event) { - fClientArea = getClientArea(); - onResize(); - } - }); - getVerticalBar().addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - scrollY((ScrollBar) e.widget); - - } - - }); - getHorizontalBar().addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - scrollX((ScrollBar) e.widget); - - } + addListener(SWT.Paint, event -> paint(event.gc)); + addListener(SWT.Resize, event -> { + fClientArea = getClientArea(); + onResize(); }); + getVerticalBar().addListener(SWT.Selection, e -> scrollY((ScrollBar) e.widget)); + getHorizontalBar().addListener(SWT.Selection, e -> scrollX((ScrollBar) e.widget)); } protected void onResize() { From b1cbadcfa4822ee4b0c9dc67a5d63aaa463b56d1 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Sat, 15 Feb 2020 22:32:24 +0200 Subject: [PATCH 20/76] Move more terminal bundles to Java 8 BREE. And run save actions to modernize code a bit. Change-Id: I4a718e73e8472679aa4ead7fdefe4259004ef6d6 Signed-off-by: Alexander Kurtakov --- .../.classpath | 2 +- .../META-INF/MANIFEST.MF | 3 +- ...TerminalToRemoteInjectionOutputStream.java | 12 +++++++ .../control/CommandInputFieldWithHistory.java | 18 ++++++++--- .../control/ITerminalViewControl.java | 1 + .../actions/AbstractTerminalAction.java | 1 + .../actions/TerminalActionClearAll.java | 2 ++ .../control/actions/TerminalActionCopy.java | 2 ++ .../control/actions/TerminalActionCut.java | 2 ++ .../control/actions/TerminalActionPaste.java | 2 ++ .../actions/TerminalActionSelectAll.java | 2 ++ .../emulator/LoggingOutputStream.java | 2 ++ .../emulator/VT100BackendTraceDecorator.java | 31 +++++++++++++++++++ .../terminal/emulator/VT100Emulator.java | 2 ++ .../model/SynchronizedTerminalTextData.java | 26 ++++++++++++++++ .../terminal/model/TerminalTextData.java | 31 +++++++++++++++++-- .../model/TerminalTextDataFastScroll.java | 26 ++++++++++++++++ .../model/TerminalTextDataWindow.java | 26 ++++++++++++++++ .../TerminalPreferenceInitializer.java | 1 + .../preferences/TerminalPreferencePage.java | 2 ++ .../api/TerminalConnectorExtension.java | 2 +- .../provisional/api/TerminalState.java | 1 + .../textcanvas/AbstractTextCanvasModel.java | 18 ++++++++++- .../terminal/textcanvas/GridCanvas.java | 5 +++ .../terminal/textcanvas/PipedInputStream.java | 7 +++++ .../textcanvas/PollingTextCanvasModel.java | 1 + .../terminal/textcanvas/StyleMap.java | 6 ++-- .../terminal/textcanvas/TextCanvas.java | 16 +++++++++- .../tm/terminal/model/LineSegment.java | 1 + .../org/eclipse/tm/terminal/model/Style.java | 5 ++- .../eclipse/tm/terminal/model/StyleColor.java | 3 +- 31 files changed, 243 insertions(+), 16 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath index 25d360efcad..ed0eb24c506 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath @@ -1,6 +1,6 @@ - + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 03ea8d68688..950506316f4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ClassPath: . Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true, org.eclipse.tm.internal.terminal.control, @@ -23,3 +23,4 @@ Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true, org.eclipse.tm.internal.terminal.provisional.api.provider, org.eclipse.tm.internal.terminal.textcanvas;x-internal:=true, org.eclipse.tm.terminal.model +Automatic-Module-Name: org.eclipse.tm.terminal.control diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java index 5dc1173c5bb..ea4b24273a0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStream.java @@ -68,14 +68,17 @@ public void flush() { static public class BufferInterceptor extends Interceptor { private final ByteArrayOutputStream fBuffer = new ByteArrayOutputStream(); + @Override public void close() throws IOException { fOriginal.write(fBuffer.toByteArray()); } + @Override public void write(byte[] b, int off, int len) throws IOException { fBuffer.write(b, off, len); } + @Override public void write(int b) throws IOException { fBuffer.write(b); } @@ -84,6 +87,7 @@ public void write(int b) throws IOException { private class TerminalFilterOutputStream extends OutputStream { final private Object fLock = TerminalToRemoteInjectionOutputStream.this; + @Override public void close() throws IOException { synchronized (fLock) { if (fInjection == this) { @@ -93,6 +97,7 @@ public void close() throws IOException { } } + @Override public void write(byte[] b, int off, int len) throws IOException { synchronized (fLock) { checkStream(); @@ -100,6 +105,7 @@ public void write(byte[] b, int off, int len) throws IOException { } } + @Override public void write(byte[] b) throws IOException { synchronized (fLock) { checkStream(); @@ -107,6 +113,7 @@ public void write(byte[] b) throws IOException { } } + @Override public void flush() throws IOException { synchronized (fLock) { checkStream(); @@ -114,6 +121,7 @@ public void flush() throws IOException { } } + @Override public void write(int b) throws IOException { synchronized (fLock) { checkStream(); @@ -167,6 +175,7 @@ public synchronized OutputStream grabOutput() throws IOException { return grabOutput(new BufferInterceptor()); } + @Override synchronized public void close() throws IOException { if (fInjection != null) { fInjection.close(); @@ -174,12 +183,14 @@ synchronized public void close() throws IOException { super.close(); } + @Override synchronized public void flush() throws IOException { if (fInterceptor != null) fInterceptor.flush(); out.flush(); } + @Override synchronized public void write(byte[] b, int off, int len) throws IOException { if (fInterceptor != null) fInterceptor.write(b, off, len); @@ -187,6 +198,7 @@ synchronized public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); } + @Override synchronized public void write(int b) throws IOException { if (fInterceptor != null) fInterceptor.write(b); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java index 382c588d749..bb9ca19a0e9 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -55,11 +55,12 @@ public class CommandInputFieldWithHistory implements ICommandInputField { private class FieldAssist implements IContentProposalProvider { + @Override public IContentProposal[] getProposals(String contents, int position) { String prefix = contents.substring(0, position); - List result = new ArrayList(); + List result = new ArrayList<>(); // show an entry only once - Set seen = new HashSet(); + Set seen = new HashSet<>(); for (Iterator iterator = fHistory.iterator(); iterator.hasNext();) { String history = iterator.next(); if (history.startsWith(prefix) && !seen.contains(history)) { @@ -85,24 +86,28 @@ private static class Proposal implements IContentProposal { fLabel = label; } + @Override public String getContent() { return fContent; } + @Override public String getLabel() { return fLabel; } + @Override public String getDescription() { return null; } + @Override public int getCursorPosition() { return fContent.length(); } } - final List fHistory = new ArrayList(); + final List fHistory = new ArrayList<>(); /** * Keeps a modifiable history while in history editing mode */ @@ -189,7 +194,7 @@ public String getHistory() { */ public String move(String currLine, int count) { if (!inHistoryMode()) { - fEditedHistory = new ArrayList(fHistory.size() + 1); + fEditedHistory = new ArrayList<>(fHistory.size() + 1); fEditedHistory.add(currLine); fEditedHistory.addAll(fHistory); fEditHistoryPos = 0; @@ -227,6 +232,7 @@ private void endHistoryMode() { fEditHistoryPos = 0; } + @Override public void createControl(final Composite parent, final ITerminalViewControl terminal) { // fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH); fSash = new Sash(parent, SWT.HORIZONTAL); @@ -279,6 +285,7 @@ public void createControl(final Composite parent, final ITerminalViewControl ter new ContentAssistCommandAdapter(fInputField, new TextContentAdapter(), new FieldAssist(), null, null, installDecoration); fInputField.addKeyListener(new KeyListener() { + @Override public void keyPressed(KeyEvent e) { // if the field assist has handled the key already then // ignore it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211659) @@ -310,16 +317,19 @@ private void setCommand(String line) { fInputField.setSelection(fInputField.getCharCount()); } + @Override public void keyReleased(KeyEvent e) { } }); } + @Override public void setFont(Font font) { fInputField.setFont(font); fInputField.getParent().layout(true); } + @Override public void dispose() { fSash.dispose(); fSash = null; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index ef309cafc19..19eb2ef3386 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -57,6 +57,7 @@ public interface ITerminalViewControl { * @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font * @param font */ + @Deprecated void setFont(Font font); /** diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java index 9745792e7af..776f8ede4c1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java @@ -44,6 +44,7 @@ public AbstractTerminalAction(ITerminalViewControl target, String strId, int sty setId(strId); } + @Override abstract public void run(); protected void setupAction(String strText, String strToolTip, String strImage, String strEnabledImage, diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java index 928465e6728..fb3e4a244de 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java @@ -37,6 +37,7 @@ public TerminalActionClearAll(ITerminalViewControl target) { ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); } + @Override public void run() { ITerminalViewControl target = getTarget(); if (target != null) { @@ -44,6 +45,7 @@ public void run() { } } + @Override public void updateAction(boolean aboutToShow) { ITerminalViewControl target = getTarget(); setEnabled(target != null && !target.isEmpty()); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java index 55cc03a3b08..48e3b3cb17f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java @@ -43,6 +43,7 @@ public TerminalActionCopy(ITerminalViewControl target) { si.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); } + @Override public void run() { ITerminalViewControl target = getTarget(); if (target != null) { @@ -56,6 +57,7 @@ public void run() { } } + @Override public void updateAction(boolean aboutToShow) { ITerminalViewControl target = getTarget(); boolean bEnabled = target != null; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java index 4b07afd75a1..172c5f3ac35 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java @@ -40,6 +40,7 @@ public TerminalActionCut(ITerminalViewControl target) { si.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); } + @Override public void run() { ITerminalViewControl target = getTarget(); if (target != null) { @@ -47,6 +48,7 @@ public void run() { } } + @Override public void updateAction(boolean aboutToShow) { // Cut is always disabled setEnabled(false); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java index 1fb92daa66b..3f086813124 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java @@ -47,6 +47,7 @@ public TerminalActionPaste(ITerminalViewControl target) { si.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), false); } + @Override public void run() { ITerminalViewControl target = getTarget(); if (target != null) { @@ -54,6 +55,7 @@ public void run() { } } + @Override public void updateAction(boolean aboutToShow) { ITerminalViewControl target = getTarget(); boolean bEnabled = target != null && target.getClipboard() != null && !target.getClipboard().isDisposed(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java index f194c97de06..23a6ebaa4d1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java @@ -36,6 +36,7 @@ public TerminalActionSelectAll(ITerminalViewControl target) { setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, (ImageDescriptor) null, null, null, false); } + @Override public void run() { ITerminalViewControl target = getTarget(); if (target != null) { @@ -43,6 +44,7 @@ public void run() { } } + @Override public void updateAction(boolean aboutToShow) { ITerminalViewControl target = getTarget(); setEnabled(target != null && !target.isEmpty()); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java index c365c87043b..24c50555b26 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/LoggingOutputStream.java @@ -22,6 +22,7 @@ public LoggingOutputStream(OutputStream out) { super(out); } + @Override public void write(byte[] b, int off, int len) throws IOException { if (Logger.isLogEnabled()) Logger.log("Received " + len + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$ @@ -38,6 +39,7 @@ public void write(byte[] b, int off, int len) throws IOException { } } + @Override public void write(int b) throws IOException { if (Logger.isLogEnabled()) Logger.log("Received " + 1 + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java index 0f5f4ad1dbf..3626f18afc2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -26,149 +26,180 @@ public VT100BackendTraceDecorator(IVT100EmulatorBackend backend, PrintStream out fWriter = out; } + @Override public void appendString(String buffer) { fWriter.println("appendString(\"" + buffer + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.appendString(buffer); } + @Override public void clearAll() { fWriter.println("clearAll()"); //$NON-NLS-1$ fBackend.clearAll(); } + @Override public void deleteCharacters(int n) { fWriter.println("deleteCharacters(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.deleteCharacters(n); } + @Override public void deleteLines(int n) { fWriter.println("deleteLines(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.deleteLines(n); } + @Override public void eraseAll() { fWriter.println("eraseAll()"); //$NON-NLS-1$ fBackend.eraseAll(); } + @Override public void eraseLine() { fWriter.println("eraseLine()"); //$NON-NLS-1$ fBackend.eraseLine(); } + @Override public void eraseLineToCursor() { fWriter.println("eraseLineToCursor()"); //$NON-NLS-1$ fBackend.eraseLineToCursor(); } + @Override public void eraseLineToEnd() { fWriter.println("eraseLineToEnd()"); //$NON-NLS-1$ fBackend.eraseLineToEnd(); } + @Override public void eraseToCursor() { fWriter.println("eraseToCursor()"); //$NON-NLS-1$ fBackend.eraseToCursor(); } + @Override public void eraseToEndOfScreen() { fWriter.println("eraseToEndOfScreen()"); //$NON-NLS-1$ fBackend.eraseToEndOfScreen(); } + @Override public int getColumns() { return fBackend.getColumns(); } + @Override public int getCursorColumn() { return fBackend.getCursorColumn(); } + @Override public int getCursorLine() { return fBackend.getCursorLine(); } + @Override public Style getDefaultStyle() { return fBackend.getDefaultStyle(); } + @Override public int getLines() { return fBackend.getLines(); } + @Override public Style getStyle() { return fBackend.getStyle(); } + @Override public void insertCharacters(int charactersToInsert) { fWriter.println("insertCharacters(" + charactersToInsert + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.insertCharacters(charactersToInsert); } + @Override public void insertLines(int n) { fWriter.println("insertLines(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.insertLines(n); } + @Override public void processNewline() { fWriter.println("processNewline()"); //$NON-NLS-1$ fBackend.processNewline(); } + @Override public void setCursor(int targetLine, int targetColumn) { fWriter.println("setCursor(" + targetLine + ", " + targetColumn + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ fBackend.setCursor(targetLine, targetColumn); } + @Override public void setCursorColumn(int targetColumn) { fWriter.println("setCursorColumn(" + targetColumn + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setCursorColumn(targetColumn); } + @Override public void setCursorLine(int targetLine) { fWriter.println("setCursorLine(" + targetLine + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setCursorLine(targetLine); } + @Override public void setDefaultStyle(Style defaultStyle) { fWriter.println("setDefaultStyle(" + defaultStyle + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setDefaultStyle(defaultStyle); } + @Override public void setDimensions(int lines, int cols) { fWriter.println("setDimensions(" + lines + "," + cols + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ fBackend.setDimensions(lines, cols); } + @Override public void setStyle(Style style) { fWriter.println("setStyle(" + style + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setStyle(style); } + @Override public void setVT100LineWrapping(boolean enable) { fWriter.println("setVT100LineWrapping(" + enable + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setVT100LineWrapping(enable); } + @Override public boolean isVT100LineWrapping() { return fBackend.isVT100LineWrapping(); } + @Override public void setInsertMode(boolean enable) { fWriter.println("setInsertMode(" + enable + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setInsertMode(enable); } + @Override public void setScrollRegion(int top, int bottom) { fWriter.println("setScrollRegion(" + top + ',' + bottom + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setScrollRegion(top, bottom); } + @Override public void scrollUp(int lines) { fWriter.println("scrollUp(" + lines + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.scrollUp(lines); } + @Override public void scrollDown(int lines) { fWriter.println("scrollDown(" + lines + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.scrollDown(lines); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 92159e8702b..1ed8cc1721c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -203,6 +203,7 @@ public void dispose() { * This method is required by interface ControlListener. It allows us to * know when the StyledText widget is moved. */ + @Override public void controlMoved(ControlEvent event) { Logger.log("entered"); //$NON-NLS-1$ // Empty. @@ -212,6 +213,7 @@ public void controlMoved(ControlEvent event) { * This method is required by interface ControlListener. It allows us to * know when the StyledText widget is resized. */ + @Override public void controlResized(ControlEvent event) { Logger.log("entered"); //$NON-NLS-1$ adjustTerminalDimensions(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java index 75178e4c799..c99d01a4a7a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java @@ -28,106 +28,132 @@ public SynchronizedTerminalTextData(ITerminalTextData data) { fData = data; } + @Override synchronized public void addLine() { fData.addLine(); } + @Override synchronized public void cleanLine(int line) { fData.cleanLine(line); } + @Override synchronized public void copy(ITerminalTextData source) { fData.copy(source); } + @Override synchronized public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { fData.copyLine(source, sourceLine, destLine); } + @Override synchronized public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { fData.copyRange(source, sourceStartLine, destStartLine, length); } + @Override synchronized public char getChar(int line, int column) { return fData.getChar(line, column); } + @Override synchronized public char[] getChars(int line) { return fData.getChars(line); } + @Override synchronized public int getCursorColumn() { return fData.getCursorColumn(); } + @Override synchronized public int getCursorLine() { return fData.getCursorLine(); } + @Override synchronized public int getHeight() { return fData.getHeight(); } + @Override synchronized public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) { return fData.getLineSegments(line, startCol, numberOfCols); } + @Override synchronized public int getMaxHeight() { return fData.getMaxHeight(); } + @Override synchronized public Style getStyle(int line, int column) { return fData.getStyle(line, column); } + @Override synchronized public Style[] getStyles(int line) { return fData.getStyles(line); } + @Override synchronized public int getWidth() { return fData.getWidth(); } + @Override synchronized public ITerminalTextDataSnapshot makeSnapshot() { return fData.makeSnapshot(); } + @Override synchronized public void scroll(int startLine, int size, int shift) { fData.scroll(startLine, size, shift); } + @Override synchronized public void setChar(int line, int column, char c, Style style) { fData.setChar(line, column, c, style); } + @Override synchronized public void setChars(int line, int column, char[] chars, int start, int len, Style style) { fData.setChars(line, column, chars, start, len, style); } + @Override synchronized public void setChars(int line, int column, char[] chars, Style style) { fData.setChars(line, column, chars, style); } + @Override synchronized public void setCursorColumn(int column) { fData.setCursorColumn(column); } + @Override synchronized public void setCursorLine(int line) { fData.setCursorLine(line); } + @Override synchronized public void setDimensions(int height, int width) { fData.setDimensions(height, width); } + @Override synchronized public void setMaxHeight(int height) { fData.setMaxHeight(height); } + @Override synchronized public boolean isWrappedLine(int line) { return fData.isWrappedLine(line); } + @Override synchronized public void setWrappedLine(int line) { fData.setWrappedLine(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java index b306df750ea..409e6bc63ee 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java @@ -91,15 +91,18 @@ public TerminalTextData(ITerminalTextData data) { fData = data; } + @Override public int getWidth() { return fData.getWidth(); } + @Override public int getHeight() { // no need for an extra variable return fData.getHeight(); } + @Override public void setDimensions(int height, int width) { int h = getHeight(); int w = getWidth(); @@ -122,38 +125,46 @@ private void sendDimensionsChanged(int oldHeight, int oldWidth, int newHeight, i sendDimensionsChanged(); } + @Override public LineSegment[] getLineSegments(int line, int column, int len) { return fData.getLineSegments(line, column, len); } + @Override public char getChar(int line, int column) { return fData.getChar(line, column); } + @Override public Style getStyle(int line, int column) { return fData.getStyle(line, column); } + @Override public void setChar(int line, int column, char c, Style style) { fData.setChar(line, column, c, style); sendLineChangedToSnapshots(line); } + @Override public void setChars(int line, int column, char[] chars, Style style) { fData.setChars(line, column, chars, style); sendLineChangedToSnapshots(line); } + @Override public void setChars(int line, int column, char[] chars, int start, int len, Style style) { fData.setChars(line, column, chars, start, len, style); sendLineChangedToSnapshots(line); } + @Override public void scroll(int startLine, int size, int shift) { fData.scroll(startLine, size, shift); sendScrolledToSnapshots(startLine, size, shift); } + @Override public String toString() { return fData.toString(); } @@ -208,23 +219,25 @@ protected void sendCursorChanged() { */ protected void removeSnapshot(TerminalTextDataSnapshot snapshot) { // poor mans approach to modify the array - List list = new ArrayList(); + List list = new ArrayList<>(); list.addAll(Arrays.asList(fSnapshots)); list.remove(snapshot); fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]); } + @Override public ITerminalTextDataSnapshot makeSnapshot() { // poor mans approach to modify the array TerminalTextDataSnapshot snapshot = new TerminalTextDataSnapshot(this); snapshot.markDimensionsChanged(); - List list = new ArrayList(); + List list = new ArrayList<>(); list.addAll(Arrays.asList(fSnapshots)); list.add(snapshot); fSnapshots = list.toArray(new TerminalTextDataSnapshot[list.size()]); return snapshot; } + @Override public void addLine() { int oldHeight = getHeight(); fData.addLine(); @@ -243,63 +256,77 @@ public void addLine() { } + @Override public void copy(ITerminalTextData source) { fData.copy(source); fCursorLine = source.getCursorLine(); fCursorColumn = source.getCursorColumn(); } + @Override public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { fData.copyLine(source, sourceLine, destLine); } + @Override public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { fData.copyRange(source, sourceStartLine, destStartLine, length); } + @Override public char[] getChars(int line) { return fData.getChars(line); } + @Override public Style[] getStyles(int line) { return fData.getStyles(line); } + @Override public int getMaxHeight() { return fData.getMaxHeight(); } + @Override public void setMaxHeight(int height) { fData.setMaxHeight(height); } + @Override public void cleanLine(int line) { fData.cleanLine(line); sendLineChangedToSnapshots(line); } + @Override public int getCursorColumn() { return fCursorColumn; } + @Override public int getCursorLine() { return fCursorLine; } + @Override public void setCursorColumn(int column) { fCursorColumn = column; sendCursorChanged(); } + @Override public void setCursorLine(int line) { fCursorLine = line; sendCursorChanged(); } + @Override public boolean isWrappedLine(int line) { return fData.isWrappedLine(line); } + @Override public void setWrappedLine(int line) { fData.setWrappedLine(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java index 14dbbaef115..8cb0bd3cad5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java @@ -86,6 +86,7 @@ private boolean shiftOffset(int shift) { return true; } + @Override public void addLine() { if (getHeight() < fMaxHeight) { setDimensions(getHeight() + 1, getWidth()); @@ -94,10 +95,12 @@ public void addLine() { } } + @Override public void cleanLine(int line) { fData.cleanLine(getPositionOfLine(line)); } + @Override public void copy(ITerminalTextData source) { int n = source.getHeight(); setDimensions(source.getHeight(), source.getWidth()); @@ -106,10 +109,12 @@ public void copy(ITerminalTextData source) { } } + @Override public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { fData.copyLine(source, sourceLine, getPositionOfLine(destLine)); } + @Override public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { assert (destStartLine >= 0 && destStartLine + length <= fHeight) || throwRuntimeException(); for (int i = 0; i < length; i++) { @@ -117,43 +122,52 @@ public void copyRange(ITerminalTextData source, int sourceStartLine, int destSta } } + @Override public char getChar(int line, int column) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getChar(getPositionOfLine(line), column); } + @Override public char[] getChars(int line) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getChars(getPositionOfLine(line)); } + @Override public int getHeight() { return fHeight; } + @Override public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getLineSegments(getPositionOfLine(line), startCol, numberOfCols); } + @Override public int getMaxHeight() { return fMaxHeight; } + @Override public Style getStyle(int line, int column) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getStyle(getPositionOfLine(line), column); } + @Override public Style[] getStyles(int line) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getStyles(getPositionOfLine(line)); } + @Override public int getWidth() { return fData.getWidth(); } + @Override public ITerminalTextDataSnapshot makeSnapshot() { return fData.makeSnapshot(); } @@ -164,6 +178,7 @@ private void cleanLines(int line, int len) { } } + @Override public void scroll(int startLine, int size, int shift) { assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException(); if (shift >= fMaxHeight || -shift >= fMaxHeight) { @@ -198,21 +213,25 @@ public void scroll(int startLine, int size, int shift) { } } + @Override public void setChar(int line, int column, char c, Style style) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setChar(getPositionOfLine(line), column, c, style); } + @Override public void setChars(int line, int column, char[] chars, int start, int len, Style style) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setChars(getPositionOfLine(line), column, chars, start, len, style); } + @Override public void setChars(int line, int column, char[] chars, Style style) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setChars(getPositionOfLine(line), column, chars, style); } + @Override public void setDimensions(int height, int width) { assert height >= 0 || throwRuntimeException(); assert width >= 0 || throwRuntimeException(); @@ -223,6 +242,7 @@ public void setDimensions(int height, int width) { fData.setDimensions(fMaxHeight, width); } + @Override public void setMaxHeight(int maxHeight) { assert maxHeight >= fHeight || throwRuntimeException(); // move everything to offset0 @@ -247,27 +267,33 @@ public void setMaxHeight(int maxHeight) { fMaxHeight = maxHeight; } + @Override public int getCursorColumn() { throw new UnsupportedOperationException(); } + @Override public int getCursorLine() { throw new UnsupportedOperationException(); } + @Override public void setCursorColumn(int column) { throw new UnsupportedOperationException(); } + @Override public void setCursorLine(int line) { throw new UnsupportedOperationException(); } + @Override public boolean isWrappedLine(int line) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.isWrappedLine(getPositionOfLine(line)); } + @Override public void setWrappedLine(int line) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setWrappedLine(getPositionOfLine(line)); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java index 57321df54f7..f9ec141d858 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java @@ -54,52 +54,62 @@ boolean isInWindow(int line) { return line >= fWindowStartLine && line < fWindowStartLine + fWindowSize; } + @Override public char getChar(int line, int column) { if (!isInWindow(line)) return 0; return fData.getChar(line - fWindowStartLine, column); } + @Override public char[] getChars(int line) { if (!isInWindow(line)) return null; return fData.getChars(line - fWindowStartLine); } + @Override public int getHeight() { return fHeight; } + @Override public LineSegment[] getLineSegments(int line, int startCol, int numberOfCols) { if (!isInWindow(line)) return new LineSegment[] { new LineSegment(startCol, new String(new char[numberOfCols]), null) }; return fData.getLineSegments(line - fWindowStartLine, startCol, numberOfCols); } + @Override public int getMaxHeight() { return fMaxHeight; } + @Override public Style getStyle(int line, int column) { if (!isInWindow(line)) return null; return fData.getStyle(line - fWindowStartLine, column); } + @Override public Style[] getStyles(int line) { if (!isInWindow(line)) return null; return fData.getStyles(line - fWindowStartLine); } + @Override public int getWidth() { return fData.getWidth(); } + @Override public ITerminalTextDataSnapshot makeSnapshot() { throw new UnsupportedOperationException(); } + @Override public void addLine() { if (fMaxHeight > 0 && getHeight() < fMaxHeight) { setDimensions(getHeight() + 1, getWidth()); @@ -108,6 +118,7 @@ public void addLine() { } } + @Override public void copy(ITerminalTextData source) { // we inherit the dimensions of the source setDimensions(source.getHeight(), source.getWidth()); @@ -116,6 +127,7 @@ public void copy(ITerminalTextData source) { fData.copyRange(source, fWindowStartLine, 0, n); } + @Override public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine, int length) { int n = length; int dStart = destStartLine - fWindowStartLine; @@ -133,11 +145,13 @@ public void copyRange(ITerminalTextData source, int sourceStartLine, int destSta } + @Override public void copyLine(ITerminalTextData source, int sourceLine, int destLine) { if (isInWindow(destLine)) fData.copyLine(source, sourceLine, destLine - fWindowStartLine); } + @Override public void scroll(int startLine, int size, int shift) { assert (startLine >= 0 && startLine + size <= fHeight) || throwRuntimeException(); int n = size; @@ -153,30 +167,35 @@ public void scroll(int startLine, int size, int shift) { fData.scroll(start, n, shift); } + @Override public void setChar(int line, int column, char c, Style style) { if (!isInWindow(line)) return; fData.setChar(line - fWindowStartLine, column, c, style); } + @Override public void setChars(int line, int column, char[] chars, int start, int len, Style style) { if (!isInWindow(line)) return; fData.setChars(line - fWindowStartLine, column, chars, start, len, style); } + @Override public void setChars(int line, int column, char[] chars, Style style) { if (!isInWindow(line)) return; fData.setChars(line - fWindowStartLine, column, chars, style); } + @Override public void setDimensions(int height, int width) { assert height >= 0 || throwRuntimeException(); fData.setDimensions(fWindowSize, width); fHeight = height; } + @Override public void setMaxHeight(int height) { fMaxHeight = height; } @@ -199,33 +218,40 @@ public void setHeight(int height) { fHeight = height; } + @Override public void cleanLine(int line) { if (isInWindow(line)) fData.cleanLine(line - fWindowStartLine); } + @Override public int getCursorColumn() { return fData.getCursorColumn(); } + @Override public int getCursorLine() { return fData.getCursorLine(); } + @Override public void setCursorColumn(int column) { fData.setCursorColumn(column); } + @Override public void setCursorLine(int line) { fData.setCursorLine(line); } + @Override public boolean isWrappedLine(int line) { if (isInWindow(line)) return fData.isWrappedLine(line - fWindowStartLine); return false; } + @Override public void setWrappedLine(int line) { if (isInWindow(line)) fData.setWrappedLine(line - fWindowStartLine); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java index 8a028812fc3..df901498ce6 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java @@ -32,6 +32,7 @@ public class TerminalPreferenceInitializer extends AbstractPreferenceInitializer public TerminalPreferenceInitializer() { } + @Override public void initializeDefaultPreferences() { //DefaultScope.INSTANCE was added in Eclipse 3.7 IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java index d9b51ff80ad..e3b0691977a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -44,10 +44,12 @@ public TerminalPreferencePage() { super(GRID); } + @Override protected void createFieldEditors() { setupPage(); } + @Override public void init(IWorkbench workbench) { // do nothing } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java index 383c637c415..333df8d2f60 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -90,7 +90,7 @@ public static ITerminalConnector makeTerminalConnector(String id) { public static ITerminalConnector[] makeTerminalConnectors() { IConfigurationElement[] config = RegistryFactory.getRegistry() .getConfigurationElementsFor("org.eclipse.tm.terminal.control.connectors"); //$NON-NLS-1$ - List result = new ArrayList(); + List result = new ArrayList<>(); for (int i = 0; i < config.length; i++) { result.add(makeConnector(config[i])); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java index 621d5df86d3..2304d0a6be1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalState.java @@ -48,6 +48,7 @@ public TerminalState(String state) { fState = state; } + @Override public String toString() { return fState; } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java index f3c67a96fb3..cd32a5c8c9f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java @@ -23,7 +23,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; abstract public class AbstractTextCanvasModel implements ITextCanvasModel { - protected List fListeners = new ArrayList(); + protected List fListeners = new ArrayList<>(); private int fCursorLine; private int fCursorColumn; private boolean fShowCursor; @@ -50,10 +50,12 @@ public AbstractTextCanvasModel(ITerminalTextDataSnapshot snapshot) { fLines = fSnapshot.getHeight(); } + @Override public void addCellCanvasModelListener(ITextCanvasModelListener listener) { fListeners.add(listener); } + @Override public void removeCellCanvasModelListener(ITextCanvasModelListener listener) { fListeners.remove(listener); } @@ -81,6 +83,7 @@ protected void fireTerminalDataChanged() { } + @Override public ITerminalTextDataReadOnly getTerminalText() { return fSnapshot; } @@ -127,14 +130,17 @@ public void update() { updateCursor(); } + @Override public int getCursorColumn() { return fCursorColumn; } + @Override public int getCursorLine() { return fCursorLine; } + @Override public boolean isCursorOn() { return fShowCursor && fCursorIsEnabled; } @@ -194,6 +200,7 @@ protected void updateCursor() { } } + @Override public void setVisibleRectangle(int startLine, int startCol, int height, int width) { fSnapshot.setInterestWindow(Math.max(0, startLine), Math.max(1, height)); update(); @@ -203,6 +210,7 @@ protected void showCursor(boolean show) { fShowCursor = true; } + @Override public void setCursorEnabled(boolean visible) { fCursorTime = System.currentTimeMillis(); fShowCursor = visible; @@ -210,10 +218,12 @@ public void setCursorEnabled(boolean visible) { fireCellRangeChanged(fCursorColumn, fCursorLine, 1, 1); } + @Override public boolean isCursorEnabled() { return fCursorIsEnabled; } + @Override public Point getSelectionEnd() { if (fSelectionStartLine < 0) return null; @@ -221,6 +231,7 @@ public Point getSelectionEnd() { return new Point(fSelectionEndColumn, fSeletionEndLine); } + @Override public Point getSelectionStart() { if (fSelectionStartLine < 0) return null; @@ -228,17 +239,20 @@ public Point getSelectionStart() { return new Point(fSelectionStartCoumn, fSelectionStartLine); } + @Override public Point getSelectionAnchor() { if (fSelectionStartLine < 0) return null; return new Point(fSelectionAnchor.x, fSelectionAnchor.y); } + @Override public void setSelectionAnchor(Point anchor) { fSelectionAnchor.x = anchor.x; fSelectionAnchor.y = anchor.y; } + @Override public void setSelection(int startLine, int endLine, int startColumn, int endColumn) { // System.err.println(startLine+","+endLine+","+startColumn+","+endColumn); doSetSelection(startLine, endLine, startColumn, endColumn); @@ -282,6 +296,7 @@ private void doSetSelection(int startLine, int endLine, int startColumn, int end } } + @Override public boolean hasLineSelection(int line) { if (fSelectionStartLine < 0) return false; @@ -289,6 +304,7 @@ public boolean hasLineSelection(int line) { return line >= fSelectionStartLine && line <= fSeletionEndLine; } + @Override public String getSelectedText() { return fCurrentSelection; } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java index 5a52d02ad16..7c9f4fd2f6d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java @@ -45,6 +45,7 @@ public GridCanvas(Composite parent, int style) { /** template method paint. * iterates over all cells in the clipping rectangle and paints them. */ + @Override protected void paint(GC gc) { Rectangle clipping = gc.getClipping(); if (clipping.width == 0 || clipping.height == 0) @@ -157,6 +158,7 @@ Rectangle getCellVirtualRect(int x, int y) { return new Rectangle(x, y, fCellWidth, fCellHeight); } + @Override protected void viewRectangleChanged(int x, int y, int width, int height) { int cellX = virtualXToCell(x); int cellY = virtualYToCell(y); @@ -182,6 +184,7 @@ protected void viewRectangleChanged(int x, int y, int width, int height) { protected void visibleCellRectangleChanged(int x, int y, int width, int height) { } + @Override protected void setVirtualExtend(int width, int height) { int cellHeight = getCellHeight(); if (cellHeight > 0) { @@ -190,6 +193,7 @@ protected void setVirtualExtend(int width, int height) { super.setVirtualExtend(width, height); } + @Override protected void setVirtualOrigin(int x, int y) { int cellHeight = getCellHeight(); if (cellHeight > 0) { @@ -203,6 +207,7 @@ protected void setVirtualOrigin(int x, int y) { super.setVirtualOrigin(x, y); } + @Override protected void scrollY(ScrollBar vBar) { int vSelection = vBar.getSelection(); Rectangle bounds = getVirtualBounds(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java index e1acd51a222..29c00356cbf 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java @@ -177,6 +177,7 @@ public boolean isClosed() { * */ class PipedOutputStream extends OutputStream { + @Override public void write(byte[] b, int off, int len) throws IOException { try { synchronized (fQueue) { @@ -203,6 +204,7 @@ public void write(byte[] b, int off, int len) throws IOException { } } + @Override public void write(int b) throws IOException { try { synchronized (fQueue) { @@ -215,6 +217,7 @@ public void write(int b) throws IOException { } } + @Override public void close() throws IOException { synchronized (fQueue) { fQueue.close(); @@ -254,6 +257,7 @@ public void waitForAvailable(long millis) throws InterruptedException { * Must be called in the Display Thread! * @return number of characters available for reading. */ + @Override public int available() { synchronized (fQueue) { return fQueue.available(); @@ -264,6 +268,7 @@ public int available() { * @return the next available byte. Check with {@link #available} * if characters are available. */ + @Override public int read() throws IOException { try { synchronized (fQueue) { @@ -280,12 +285,14 @@ public int read() throws IOException { * The stream will allow reading data that's still in the pipe after which it will * throw an IOException. */ + @Override public void close() throws IOException { synchronized (fQueue) { fQueue.close(); } } + @Override public int read(byte[] cbuf, int off, int len) throws IOException { int n = 0; if (len == 0) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java index 8f84676089d..d2fe910e5de 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/PollingTextCanvasModel.java @@ -43,6 +43,7 @@ public void startPolling() { if (fPollInterval < 0) { fPollInterval = DEFAULT_POLL_INTERVAL; Display.getDefault().timerExec(fPollInterval, new Runnable() { + @Override public void run() { update(); Display.getDefault().timerExec(fPollInterval, this); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index e6e91d5c05e..605c50ec0fd 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -48,9 +48,9 @@ public class StyleMap { private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$ String fFontName = ITerminalConstants.FONT_DEFINITION; - Map fColorMapForeground = new HashMap(); - Map fColorMapBackground = new HashMap(); - Map fColorMapIntense = new HashMap(); + Map fColorMapForeground = new HashMap<>(); + Map fColorMapBackground = new HashMap<>(); + Map fColorMapIntense = new HashMap<>(); private Point fCharSize; private final Style fDefaultStyle; private boolean fInvertColors; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 34fba478ba7..0d7397520a4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -96,18 +96,21 @@ public TextCanvas(Composite parent, ITextCanvasModel model, int style, ILinelRen setCellHeight(fCellRenderer.getCellHeight()); fCellCanvasModel = model; fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener() { + @Override public void rangeChanged(int col, int line, int width, int height) { if (isDisposed()) return; repaintRange(col, line, width, height); } + @Override public void dimensionsChanged(int cols, int rows) { if (isDisposed()) return; calculateGrid(); } + @Override public void terminalDataChanged() { if (isDisposed()) return; @@ -121,16 +124,19 @@ public void terminalDataChanged() { }); // let the cursor blink if the text canvas gets the focus... addFocusListener(new FocusListener() { + @Override public void focusGained(FocusEvent e) { fCellCanvasModel.setCursorEnabled(fCursorEnabled); } + @Override public void focusLost(FocusEvent e) { fCellCanvasModel.setCursorEnabled(false); } }); - fMouseListeners = new ArrayList(); + fMouseListeners = new ArrayList<>(); addMouseListener(new MouseListener() { + @Override public void mouseDoubleClick(MouseEvent e) { if (fMouseListeners.size() > 0) { Point pt = screenPointToCell(e.x, e.y); @@ -142,6 +148,7 @@ public void mouseDoubleClick(MouseEvent e) { } } + @Override public void mouseDown(MouseEvent e) { if (e.button == 1) { // left button fDraggingStart = screenPointToCell(e.x, e.y); @@ -165,6 +172,7 @@ public void mouseDown(MouseEvent e) { } } + @Override public void mouseUp(MouseEvent e) { if (e.button == 1) { // left button updateHasSelection(e); @@ -291,6 +299,7 @@ protected void onResize(boolean init) { calculateGrid(); } + @Override protected void onResize() { fResizing = true; try { @@ -354,23 +363,28 @@ protected void repaintRange(int col, int line, int width, int height) { repaint(r); } + @Override protected void drawLine(GC gc, int line, int x, int y, int colFirst, int colLast) { fCellRenderer.drawLine(fCellCanvasModel, gc, line, x, y, colFirst, colLast); } + @Override protected Color getTerminalBackgroundColor() { return fCellRenderer.getDefaultBackgroundColor(); } + @Override protected void visibleCellRectangleChanged(int x, int y, int width, int height) { fCellCanvasModel.setVisibleRectangle(y, x, height, width); update(); } + @Override protected int getCols() { return fCellCanvasModel.getTerminalText().getWidth(); } + @Override protected int getRows() { return fCellCanvasModel.getTerminalText().getHeight(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java index 15e4121de58..d92100fd6ce 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java @@ -33,6 +33,7 @@ public int getColumn() { return fCol; } + @Override public String toString() { return "LineSegment(" + fCol + ", \"" + fText + "\"," + fStyle + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java index 8c348918ec2..d79cab30e23 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java @@ -28,7 +28,7 @@ public class Style { private final boolean fBlink; private final boolean fUnderline; private final boolean fReverse; - private final static Map fgStyles = new HashMap(); + private final static Map fgStyles = new HashMap<>(); private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, boolean reverse) { @@ -119,6 +119,7 @@ public boolean isUnderline() { return fUnderline; } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -131,6 +132,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -155,6 +157,7 @@ public boolean equals(Object obj) { return true; } + @Override public String toString() { StringBuffer result = new StringBuffer(); result.append("Style(foreground="); //$NON-NLS-1$ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java index 64c765f0b1d..be4611fb880 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java @@ -19,7 +19,7 @@ * Threadsafe. */ public class StyleColor { - private final static Map fgStyleColors = new HashMap(); + private final static Map fgStyleColors = new HashMap<>(); final String fName; /** @@ -48,6 +48,7 @@ public String getName() { return fName; } + @Override public String toString() { return fName; } From 4441aad8121a8fcaf2e1307367b42c7689a740da Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Sat, 15 Feb 2020 22:37:24 +0200 Subject: [PATCH 21/76] Move away of deprecated Integer/Boolean constructor. Change-Id: Iab91e05314206725d8175d30bfb2866c0d99a8d7 Signed-off-by: Alexander Kurtakov --- .../tm/internal/terminal/control/impl/TerminalPlugin.java | 2 +- .../tm/internal/terminal/emulator/EditActionAccelerators.java | 4 ++-- .../terminal/provisional/api/TerminalConnectorExtension.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java index 6950116e1ac..f8a46ccda47 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java @@ -64,7 +64,7 @@ public static boolean isOptionEnabled(String strOption) { if (strEnabled == null) return false; - return new Boolean(strEnabled).booleanValue(); + return Boolean.parseBoolean(strEnabled); } @Override diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java index 827f2a7e575..86d25d4519c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -38,7 +38,7 @@ private void addAccelerator(String commandId) { KeyStroke[] keyStrokes = ((KeySequence) bindings[i]).getKeyStrokes(); if (keyStrokes.length != 0) { int accelerator = SWTKeySupport.convertKeyStrokeToAccelerator(keyStrokes[0]); - commandIdsByAccelerator.put(new Integer(accelerator), commandId); + commandIdsByAccelerator.put(Integer.valueOf(accelerator), commandId); } } } @@ -65,6 +65,6 @@ private boolean isMatchingAction(int accelerator, String commandId) { if (commandIdsByAccelerator.isEmpty()) { load(); } - return commandId.equals(commandIdsByAccelerator.get(new Integer(accelerator))); + return commandId.equals(commandIdsByAccelerator.get(Integer.valueOf(accelerator))); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java index 333df8d2f60..d9717d6bca1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -48,7 +48,7 @@ static private ITerminalConnector makeConnector(final IConfigurationElement conf name = id; } String hidden = config.getAttribute("hidden"); //$NON-NLS-1$ - boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false; + boolean isHidden = hidden != null ? Boolean.parseBoolean(hidden) : false; TerminalConnector.Factory factory = () -> (TerminalConnectorImpl) config.createExecutableExtension("class"); return new TerminalConnector(factory, id, name, isHidden); } From 5bb5c8c963971f3aa2ef49490e05a87149890b76 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 28 Mar 2020 16:43:39 -0400 Subject: [PATCH 22/76] Bug 561319: Remove flickering in terminal when changing selection This is done by buffering the drawing of the line of the terminal. Change-Id: I593a3b99080d779046ea37497d93a25584c472c1 --- .../META-INF/MANIFEST.MF | 2 +- .../terminal/textcanvas/TextLineRenderer.java | 52 +++++++++++-------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 950506316f4..14b8ffa5393 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.6.0.qualifier +Bundle-Version: 4.6.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 954eeeb48fc..a441210698f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -20,6 +20,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; @@ -49,44 +50,53 @@ public int getCellHeight() { @Override public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast) { + int width = getCellWidth() * (colLast - colFirst); + int height = getCellHeight(); + if (width <= 0 || height <= 0) { + return; + } + Image buffer = new Image(gc.getDevice(), width, height); + GC doubleBufferGC = new GC(buffer); if (line < 0 || line >= getTerminalText().getHeight() || colFirst >= getTerminalText().getWidth() || colFirst - colLast == 0) { - fillBackground(gc, x, y, getCellWidth() * (colLast - colFirst), getCellHeight()); + fillBackground(doubleBufferGC, 0, 0, width, height); } else { colLast = Math.min(colLast, getTerminalText().getWidth()); LineSegment[] segments = getTerminalText().getLineSegments(line, colFirst, colLast - colFirst); for (int i = 0; i < segments.length; i++) { LineSegment segment = segments[i]; Style style = segment.getStyle(); - setupGC(gc, style); + setupGC(doubleBufferGC, style); String text = segment.getText(); - drawText(gc, x, y, colFirst, segment.getColumn(), text); - drawCursor(model, gc, line, x, y, colFirst); + drawText(doubleBufferGC, 0, 0, colFirst, segment.getColumn(), text); + drawCursor(model, doubleBufferGC, line, 0, 0, colFirst); } if (fModel.hasLineSelection(line)) { - gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); - gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); + doubleBufferGC.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); + doubleBufferGC.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); Point start = model.getSelectionStart(); Point end = model.getSelectionEnd(); char[] chars = model.getTerminalText().getChars(line); - if (chars == null) - return; - int offset = 0; - if (start.y == line) - offset = start.x; - offset = Math.max(offset, colFirst); - int len; - if (end.y == line) - len = end.x - offset + 1; - else - len = chars.length - offset + 1; - len = Math.min(len, chars.length - offset); - if (len > 0) { - String text = new String(chars, offset, len); - drawText(gc, x, y, colFirst, offset, text); + if (chars != null) { + int offset = 0; + if (start.y == line) + offset = start.x; + offset = Math.max(offset, colFirst); + int len; + if (end.y == line) + len = end.x - offset + 1; + else + len = chars.length - offset + 1; + len = Math.min(len, chars.length - offset); + if (len > 0) { + String text = new String(chars, offset, len); + drawText(doubleBufferGC, 0, 0, colFirst, offset, text); + } } } } + gc.drawImage(buffer, x, y); + doubleBufferGC.dispose(); } private void fillBackground(GC gc, int x, int y, int width, int height) { From 3fd8dd26ceb75d808fcb1195b8903355dbed8585 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 29 Mar 2020 13:58:28 -0400 Subject: [PATCH 23/76] Fix warnings in o.e.tm.terminal.control bundle Change-Id: Ief69751ba4affc13240cfdb4b79e190b3356bbd9 --- .../plugin.properties | 2 ++ .../org.eclipse.tm.terminal.control/plugin.xml | 2 +- .../control/actions/TerminalActionCopy.java | 8 ++++---- .../control/actions/TerminalActionPaste.java | 14 ++++++++++---- .../terminal/emulator/EditActionAccelerators.java | 2 +- .../provisional/api/AbstractSettingsPage.java | 2 +- .../api/TerminalConnectorExtension.java | 2 +- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties index 12d28ee07dc..6ac4936405a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties @@ -42,3 +42,5 @@ terminal.command.quickaccess.name=Quick Access terminal.preferences.name = Terminal terminal.font.description = The font for the terminal console. terminal.font.label = Terminal Console Font + +terminal.connectors.name = Terminal Connector Extensions diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml index ed656d41978..6ec699f0f5c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml @@ -19,7 +19,7 @@ # Martin Oberhuber (Wind River) - [434939] Fix Keybinding conflicts with JEE Luna package --> - + 0; + if (aboutToShow && target != null) { + setEnabled(!target.getSelection().isEmpty()); + } else { + setEnabled(false); } - setEnabled(bEnabled); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java index 3f086813124..2003f8e9270 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java @@ -58,10 +58,16 @@ public void run() { @Override public void updateAction(boolean aboutToShow) { ITerminalViewControl target = getTarget(); - boolean bEnabled = target != null && target.getClipboard() != null && !target.getClipboard().isDisposed(); - if (bEnabled) { - String strText = (String) target.getClipboard().getContents(TextTransfer.getInstance()); - bEnabled = ((strText != null) && (!strText.equals("")) && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$ + boolean bEnabled = false; + if (target != null) { + if (target.getState() == TerminalState.CONNECTED) { + if (target.getClipboard() != null && !target.getClipboard().isDisposed()) { + String strText = (String) target.getClipboard().getContents(TextTransfer.getInstance()); + if (strText != null && !strText.isEmpty()) { + bEnabled = true; + } + } + } } setEnabled(bEnabled); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java index 86d25d4519c..2a08ae46685 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -24,7 +24,7 @@ class EditActionAccelerators { private static final String COPY_COMMAND_ID = "org.eclipse.tm.terminal.copy"; //$NON-NLS-1$ private static final String PASTE_COMMAND_ID = "org.eclipse.tm.terminal.paste"; //$NON-NLS-1$ - private final Map commandIdsByAccelerator = new HashMap(); + private final Map commandIdsByAccelerator = new HashMap(); private void load() { addAccelerator(COPY_COMMAND_ID); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java index 324de7a1e2b..971e30e05f1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/AbstractSettingsPage.java @@ -31,7 +31,7 @@ public abstract class AbstractSettingsPage implements ISettingsPage, IMessagePro private int messageType = IMessageProvider.NONE; // Reference to the listener - private final ListenerList listeners = new ListenerList(); + private final ListenerList listeners = new ListenerList<>(); // Flag to control the control decorations private boolean hasDecoration = false; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java index d9717d6bca1..1db1bbb54eb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java @@ -49,7 +49,7 @@ static private ITerminalConnector makeConnector(final IConfigurationElement conf } String hidden = config.getAttribute("hidden"); //$NON-NLS-1$ boolean isHidden = hidden != null ? Boolean.parseBoolean(hidden) : false; - TerminalConnector.Factory factory = () -> (TerminalConnectorImpl) config.createExecutableExtension("class"); + TerminalConnector.Factory factory = () -> (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$ return new TerminalConnector(factory, id, name, isHidden); } From ce2c72d792377a45e44a274fd688412d395e281c Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 29 Mar 2020 13:30:54 -0400 Subject: [PATCH 24/76] Bug 561319: Remove flickering in terminal when changing selection (fixup) Dispose of the image used for buffering GC. Change-Id: I80b6edea3211847265140aa8992546a16474cadf --- .../tm/internal/terminal/textcanvas/TextLineRenderer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index a441210698f..b45506abe13 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -97,6 +97,7 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int } gc.drawImage(buffer, x, y); doubleBufferGC.dispose(); + buffer.dispose(); } private void fillBackground(GC gc, int x, int y, int width, int height) { From 51f82d36857d41442b637e32787c51ee28dabb46 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 1 May 2020 12:21:02 -0400 Subject: [PATCH 25/76] Bug 542957: Scroll terminal number of lines indicated in wheel scroll event The original code used the direction provided by the scroll wheel, but not the magnitude. Change-Id: I7f5e2083599990f4f4999aba46ef38602b9fe565 --- .../eclipse/tm/internal/terminal/textcanvas/GridCanvas.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java index 7c9f4fd2f6d..c727d9910f4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java @@ -32,9 +32,7 @@ public GridCanvas(Composite parent, int style) { super(parent, style); addListener(SWT.MouseWheel, event -> { if (getVerticalBar().isVisible()) { - int delta = -fCellHeight; - if (event.count < 0) - delta = -delta; + int delta = -fCellHeight * event.count; scrollYDelta(delta); } event.doit = false; From 0bf643d287fdd57e5d7cb80f16be9c6ebfdbf5af Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 2 May 2020 10:14:18 -0400 Subject: [PATCH 26/76] Cosmetics. Change-Id: Ibb31fa697065add6d3341faf5bdc84e24504e1e3 --- .../org.eclipse.tm.terminal.control/plugin.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml index 6ec699f0f5c..a5ca83d730d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml @@ -10,7 +10,7 @@ SPDX-License-Identifier: EPL-2.0 # # Contributors: -# Michael Scharf (Wind River) - initial API and implementation +# Michael Scharf (Wind River) - initial API and implementation # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Michael Scharf (Wind River) - [237425] undefined tm.terminal command # Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget @@ -20,8 +20,8 @@ --> - - + + - + + From 4b9db48ed0c337207e706bab29c838f66f68a090 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 1 May 2020 16:58:02 -0400 Subject: [PATCH 27/76] Bug 549697: Extract standard colour names The inconsistency of lower case and upper case in the internal representation of the colour names made it harder than it should be to find where colours are used in the code. Note that the SytleMap creates lower and uppercase entries for each colour. Change-Id: I16b4ebe4a97adecd01f835319aa0f0d175ae3bb6 --- .../terminal/emulator/VT100Emulator.java | 42 ++++++++++++------- .../terminal/textcanvas/AnsiColorNames.java | 26 ++++++++++++ .../terminal/textcanvas/StyleMap.java | 21 +++++----- 3 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 1ed8cc1721c..080c26258e7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -29,6 +29,16 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLACK; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLUE; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.CYAN; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.GREEN; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.MAGENTA; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.RED; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE_FOREGROUND; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.YELLOW; + import java.io.IOException; import java.io.Reader; @@ -894,35 +904,35 @@ private void processAnsiCommand_m() { break; case 30: - style = style.setForground("BLACK"); //$NON-NLS-1$ + style = style.setForground(BLACK); break; case 31: - style = style.setForground("RED"); //$NON-NLS-1$ + style = style.setForground(RED); break; case 32: - style = style.setForground("GREEN"); //$NON-NLS-1$ + style = style.setForground(GREEN); break; case 33: - style = style.setForground("YELLOW"); //$NON-NLS-1$ + style = style.setForground(YELLOW); break; case 34: - style = style.setForground("BLUE"); //$NON-NLS-1$ + style = style.setForground(BLUE); break; case 35: - style = style.setForground("MAGENTA"); //$NON-NLS-1$ + style = style.setForground(MAGENTA); break; case 36: - style = style.setForground("CYAN"); //$NON-NLS-1$ + style = style.setForground(CYAN); break; case 37: - style = style.setForground("WHITE_FOREGROUND"); //$NON-NLS-1$ + style = style.setForground(WHITE_FOREGROUND); break; case 39: //Foreground: Default @@ -930,35 +940,35 @@ private void processAnsiCommand_m() { break; case 40: - style = style.setBackground("BLACK"); //$NON-NLS-1$ + style = style.setBackground(BLACK); break; case 41: - style = style.setBackground("RED"); //$NON-NLS-1$ + style = style.setBackground(RED); break; case 42: - style = style.setBackground("GREEN"); //$NON-NLS-1$ + style = style.setBackground(GREEN); break; case 43: - style = style.setBackground("YELLOW"); //$NON-NLS-1$ + style = style.setBackground(YELLOW); break; case 44: - style = style.setBackground("BLUE"); //$NON-NLS-1$ + style = style.setBackground(BLUE); break; case 45: - style = style.setBackground("MAGENTA"); //$NON-NLS-1$ + style = style.setBackground(MAGENTA); break; case 46: - style = style.setBackground("CYAN"); //$NON-NLS-1$ + style = style.setBackground(CYAN); break; case 47: - style = style.setBackground("WHITE"); //$NON-NLS-1$ + style = style.setBackground(WHITE); break; case 49: //Background: Default diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java new file mode 100644 index 00000000000..b57da7239f3 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2007, 2020 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Jonah Graham - extracted colour names from StyleMap to be reused and cross referenced in VT100Emulator + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.textcanvas; + +public class AnsiColorNames { + public static final String BLACK = "black"; //$NON-NLS-1$ + public static final String WHITE = "white"; //$NON-NLS-1$ + public static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$ + public static final String GRAY = "gray"; //$NON-NLS-1$ + public static final String MAGENTA = "magenta"; //$NON-NLS-1$ + public static final String CYAN = "cyan"; //$NON-NLS-1$ + public static final String YELLOW = "yellow"; //$NON-NLS-1$ + public static final String BLUE = "blue"; //$NON-NLS-1$ + public static final String GREEN = "green"; //$NON-NLS-1$ + public static final String RED = "red"; //$NON-NLS-1$ +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index 605c50ec0fd..3b7a16e8e73 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -19,6 +19,17 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLACK; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLUE; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.CYAN; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.GRAY; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.GREEN; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.MAGENTA; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.RED; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE_FOREGROUND; +import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.YELLOW; + import java.util.HashMap; import java.util.Map; @@ -35,16 +46,6 @@ import org.eclipse.tm.terminal.model.StyleColor; public class StyleMap { - private static final String BLACK = "black"; //$NON-NLS-1$ - private static final String WHITE = "white"; //$NON-NLS-1$ - private static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$ - private static final String GRAY = "gray"; //$NON-NLS-1$ - private static final String MAGENTA = "magenta"; //$NON-NLS-1$ - private static final String CYAN = "cyan"; //$NON-NLS-1$ - private static final String YELLOW = "yellow"; //$NON-NLS-1$ - private static final String BLUE = "blue"; //$NON-NLS-1$ - private static final String GREEN = "green"; //$NON-NLS-1$ - private static final String RED = "red"; //$NON-NLS-1$ private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$ String fFontName = ITerminalConstants.FONT_DEFINITION; From f856a7dc968e187242cb0ff80abb2dfaa4cb307a Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 1 May 2020 19:36:20 -0400 Subject: [PATCH 28/76] Bug 540737: Rework cache storage of styles This may need to change to an LRU cache if we end up with too many potential styles Change-Id: I66bb6a4b9f67c6fd8656875f138899dd3a67a360 --- .../org/eclipse/tm/terminal/model/Style.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java index d79cab30e23..e05d17e9eb7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java @@ -10,9 +10,13 @@ *******************************************************************************/ package org.eclipse.tm.terminal.model; -import java.util.HashMap; +import java.util.Collections; +import java.util.LinkedHashMap; import java.util.Map; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; + /** * @author scharf * Flyweight @@ -28,7 +32,21 @@ public class Style { private final boolean fBlink; private final boolean fUnderline; private final boolean fReverse; - private final static Map fgStyles = new HashMap<>(); + private final static Map fgStyles = Collections.synchronizedMap(new LinkedHashMap() { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + int size = size(); + boolean removeEldest = size >= 1000; + if (TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) { + if (removeEldest) { + Logger.log("Removing eldest Style from style cache, size = " + size); //$NON-NLS-1$ + } else { + Logger.log("Leaving eldest Style in style cache, size = " + size); //$NON-NLS-1$ + } + } + return removeEldest; + } + }); private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline, boolean reverse) { @@ -43,15 +61,8 @@ private Style(StyleColor forground, StyleColor background, boolean bold, boolean 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; - synchronized (fgStyles) { - cached = fgStyles.get(style); - if (cached == null) { - cached = style; - fgStyles.put(cached, cached); - } - } - return cached; + // If set had a computeIfAbsent we would use a set, instead just store 1-2-1 mapping + return fgStyles.computeIfAbsent(style, (s) -> style); } public static Style getStyle(String forground, String background) { From 7f9e48c2c7f1acaa44b483ab20ef600147259d42 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 1 May 2020 20:33:05 -0400 Subject: [PATCH 29/76] Bug 540737: Remove false optimization GC.getForeground / Background always create a new Color object, so this if expression was always true. Change-Id: Ief4ccaf1adb70967301411b012c0474608f425cb --- .../internal/terminal/textcanvas/TextLineRenderer.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index b45506abe13..67fea2e88c0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -157,14 +157,8 @@ private void drawText(GC gc, int x, int y, int colFirst, int col, String text) { } private void setupGC(GC gc, Style style) { - Color c = fStyleMap.getForegrondColor(style); - if (c != gc.getForeground()) { - gc.setForeground(c); - } - c = fStyleMap.getBackgroundColor(style); - if (c != gc.getBackground()) { - gc.setBackground(c); - } + gc.setForeground(fStyleMap.getForegrondColor(style)); + gc.setBackground(fStyleMap.getBackgroundColor(style)); Font f = fStyleMap.getFont(style); if (f != gc.getFont()) { gc.setFont(f); From 366c8c80fef1e2a27ab5703b369d1545ce09e6df Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 3 May 2020 14:39:28 -0400 Subject: [PATCH 30/76] Bug 549697: Mark update font methods in Terminal as deprecated There are two ways of specifying fonts in the terminal, one via font definitions, and one via the font directly. The method via the font directly was already deprecated in the public API, this commit follows that deprecation chain through to make it easier to identify which code paths are not likely relevant anymore. These methods could simply be removed as part of the major version bump. Change-Id: I05d746c429c4e6c3ced5ee7bb7a6172e0a255c2d --- .../tm/internal/terminal/textcanvas/ILinelRenderer.java | 2 ++ .../org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java | 4 ++++ .../eclipse/tm/internal/terminal/textcanvas/TextCanvas.java | 2 ++ .../tm/internal/terminal/textcanvas/TextLineRenderer.java | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java index efd8744bf8b..2d38a96eac0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -29,7 +29,9 @@ public interface ILinelRenderer { /** * Update for a font change from the global JFace Registry. + * @deprecated Use {@link #updateFont(String)} */ + @Deprecated void onFontChange(); /** diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index 3b7a16e8e73..6a0a7c0dd8b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -206,6 +206,10 @@ public int getFontHeight() { return fCharSize.y; } + /** + * @deprecated Use {@link #updateFont(String)} + */ + @Deprecated public void updateFont() { updateFont(ITerminalConstants.FONT_DEFINITION); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 0d7397520a4..5913fde1d9b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -473,7 +473,9 @@ public void addResizeHandler(ResizeListener listener) { /** * Notify about a change of the global Font Preference. + * @deprecated Use {@link #updateFont(String)} */ + @Deprecated public void onFontChange() { fCellRenderer.onFontChange(); setCellWidth(fCellRenderer.getCellWidth()); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 67fea2e88c0..88babe72d6e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -169,6 +169,10 @@ ITerminalTextDataReadOnly getTerminalText() { return fModel.getTerminalText(); } + /** + * @deprecated Use {@link #updateFont(String)} + */ + @Deprecated @Override public void onFontChange() { fStyleMap.updateFont(); From 1c13affe9237750a688b8ee49cd58090ac3fc604 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 16 May 2020 15:55:19 -0400 Subject: [PATCH 31/76] Bug 558536: Revert "Bug 549013 - Eclipse menu won't display on Ubuntu 16.04 LTS when SSH/Serial command shells are opened" Using the mouse and not the focus listeners leads to lots of weird, unintended consequences. For example: - If mouse does not exit the control (because, e.g. it was not in the control) then captureKeyEvents(false) is never issued - If mouse does leave control, then control stops capturing events. This means that although the cursor and focus is still on the control, keyboard shortcuts no longer go to the control, so Ctrl-C becomes copy again. This means, depending on where you move the mouse changes the behaviour of the control. This reverts commit 3aa1b023ebc3f276ea25a6a227fcaab2bc86a65b. Change-Id: I4f57c659e21d823df049b095159a34e5c110ef29 --- .../emulator/VT100TerminalControl.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index c7c3f6d1e36..ae58e006baf 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -73,12 +73,13 @@ import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -140,7 +141,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private KeyListener fKeyHandler; private final ITerminalListener fTerminalListener; private String fMsg = ""; //$NON-NLS-1$ - private TerminalMouseTrackListener fFocusListener; + private TerminalFocusListener fFocusListener; private ITerminalConnector fConnector; private final ITerminalConnector[] fConnectors; private final boolean fUseCommonPrefs; @@ -741,10 +742,10 @@ public void mouseUp(MouseEvent e) { protected void setupListeners() { fKeyHandler = new TerminalKeyHandler(); - fFocusListener = new TerminalMouseTrackListener(); + fFocusListener = new TerminalFocusListener(); getCtlText().addKeyListener(fKeyHandler); - getCtlText().addMouseTrackListener(fFocusListener); + getCtlText().addFocusListener(fFocusListener); } @@ -817,20 +818,16 @@ public VT100Emulator getTerminalText() { return fTerminalText; } - protected class TerminalMouseTrackListener implements MouseTrackListener { + protected class TerminalFocusListener implements FocusListener { private IContextActivation terminalContextActivation = null; private IContextActivation editContextActivation = null; - protected TerminalMouseTrackListener() { + protected TerminalFocusListener() { super(); } @Override - public void mouseHover(MouseEvent e) { - } - - @Override - public void mouseEnter(MouseEvent e) { + public void focusGained(FocusEvent event) { // Disable all keyboard accelerators (e.g., Control-B) so the Terminal view // can see every keystroke. Without this, Emacs, vi, and Bash are unusable // in the Terminal view. @@ -842,7 +839,7 @@ public void mouseEnter(MouseEvent e) { } @Override - public void mouseExit(MouseEvent e) { + public void focusLost(FocusEvent event) { // Enable all keybindings. captureKeyEvents(false); From 1c72a98a4524088213b270e6dfe501ea2849332c Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 10 May 2020 14:18:37 -0400 Subject: [PATCH 32/76] Bug 549697: Define standard terminal colors with Eclipse preferences New types TerminalColor and TerminalStyle replace StyleColor and Style to separate the meta information about styles and colors from the user currently selected colors. The StyleMap maps the TerminalColor/Style to the concrete fonts and colors used in the display. Colors are now configurable via the terminal preference page using the new TerminalColorsFieldEditor. All preferences are now passed in to the VT100 control so that different terminal consumers can have different preferences and styles. Remove dark theme contribution. The colors of the terminal are now inherited from the editor settings (using SystemDefaultColors) which come from the theme. If we were to invert colors too when in Dark theme then the colors actually end up light background. Change-Id: I2cf5427ac0be9a189a7f0d3565cfc97ceedb8749 --- .../META-INF/MANIFEST.MF | 2 +- .../build.properties | 1 - ...rg.eclipse.tm.terminal.stylesheet.dark.css | 15 -- .../plugin.properties | 7 +- .../plugin.xml | 17 +- .../control/impl/TerminalMessages.java | 27 +++ .../control/impl/TerminalMessages.properties | 30 ++- .../emulator/IVT100EmulatorBackend.java | 10 +- .../emulator/VT100BackendTraceDecorator.java | 10 +- .../terminal/emulator/VT100Emulator.java | 43 ++-- .../emulator/VT100EmulatorBackend.java | 18 +- .../emulator/VT100TerminalControl.java | 124 +++++++--- .../model/SynchronizedTerminalTextData.java | 12 +- .../terminal/model/SystemDefaultColors.java | 113 +++++++++ .../terminal/model/TerminalTextData.java | 12 +- .../model/TerminalTextDataFastScroll.java | 12 +- .../model/TerminalTextDataSnapshot.java | 6 +- .../terminal/model/TerminalTextDataStore.java | 34 +-- .../model/TerminalTextDataWindow.java | 12 +- .../preferences/ITerminalConstants.java | 18 +- .../preferences/TerminalColorPresets.java | 134 +++++++++++ .../TerminalColorsFieldEditor.java | 227 ++++++++++++++++++ .../TerminalPreferenceInitializer.java | 11 + .../preferences/TerminalPreferencePage.java | 15 +- .../terminal/textcanvas/AnsiColorNames.java | 26 -- .../terminal/textcanvas/ILinelRenderer.java | 14 ++ .../terminal/textcanvas/StyleMap.java | 169 ++++--------- .../terminal/textcanvas/TextCanvas.java | 16 ++ .../terminal/textcanvas/TextLineRenderer.java | 40 ++- .../terminal/textcanvas/VirtualCanvas.java | 7 + .../tm/terminal/model/ITerminalTextData.java | 19 +- .../model/ITerminalTextDataReadOnly.java | 8 +- .../tm/terminal/model/LineSegment.java | 12 +- .../org/eclipse/tm/terminal/model/Style.java | 192 --------------- .../eclipse/tm/terminal/model/StyleColor.java | 56 ----- .../tm/terminal/model/TerminalColor.java | 168 +++++++++++++ .../tm/terminal/model/TerminalStyle.java | 193 +++++++++++++++ 37 files changed, 1261 insertions(+), 569 deletions(-) delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SystemDefaultColors.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorPresets.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 14b8ffa5393..f37c8e4105b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 4.6.100.qualifier +Bundle-Version: 5.0.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties index 4e1b392a770..eb7d53d07b5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/build.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/build.properties @@ -28,7 +28,6 @@ bin.includes = .,\ about.properties,\ icons/,\ HelpContexts.xml,\ - css/,\ about.mappings,\ cdt_logo_icon32.png diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css b/terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css deleted file mode 100644 index 6b612015089..00000000000 --- a/terminal/plugins/org.eclipse.tm.terminal.control/css/org.eclipse.tm.terminal.stylesheet.dark.css +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2015 vogella GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * Contributors: - * Lars Vogel - initial API and implementation - ******************************************************************************/ - -IEclipsePreferences#org-eclipse-tm-terminal-control { - preferences: - "TerminalPrefInvertColors=true" -} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties index 6ac4936405a..e3c9236c3f2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003 - 2018 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2020 Wind River Systems, Inc. and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at @@ -40,7 +40,10 @@ terminal.command.maximize.name=Maximize Active View or Editor terminal.command.quickaccess.name=Quick Access terminal.preferences.name = Terminal -terminal.font.description = The font for the terminal console. +terminal.font.description = The font for the terminal console. Please also see the Terminal Preference pages for changing colors. terminal.font.label = Terminal Console Font +terminal.views.theme.category.label = Terminal +terminal.views.theme.category.description = Fonts used in the Terminal View. Please also see the Terminal Preference pages for changing colors. + terminal.connectors.name = Terminal Connector Extensions diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml index a5ca83d730d..ee9eaaf0a03 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.control/plugin.xml @@ -257,6 +257,7 @@ @@ -264,14 +265,14 @@ %terminal.font.description - + + + %terminal.views.theme.category.description + + - - - - - - + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java index cf95067c05c..2826d00fc31 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java @@ -19,6 +19,33 @@ public class TerminalMessages extends NLS { NLS.initializeMessages(TerminalMessages.class.getName(), TerminalMessages.class); } + public static String TerminalColorPresets_EclipseDark; + public static String TerminalColorPresets_EclipseLight; + public static String TerminalColorPresets_TerminalDefaults; + public static String TerminalColorsFieldEditor_Background; + public static String TerminalColorsFieldEditor_Black; + public static String TerminalColorsFieldEditor_Blue; + public static String TerminalColorsFieldEditor_BrightBlack; + public static String TerminalColorsFieldEditor_BrightBlue; + public static String TerminalColorsFieldEditor_BrightCyan; + public static String TerminalColorsFieldEditor_BrightGreen; + public static String TerminalColorsFieldEditor_BrightMagenta; + public static String TerminalColorsFieldEditor_BrightRed; + public static String TerminalColorsFieldEditor_BrightWhite; + public static String TerminalColorsFieldEditor_BrightYellow; + public static String TerminalColorsFieldEditor_Cyan; + public static String TerminalColorsFieldEditor_GeneralColors; + public static String TerminalColorsFieldEditor_Green; + public static String TerminalColorsFieldEditor_LoadPresets; + public static String TerminalColorsFieldEditor_Magenta; + public static String TerminalColorsFieldEditor_PaletteColors; + public static String TerminalColorsFieldEditor_Presets; + public static String TerminalColorsFieldEditor_Red; + public static String TerminalColorsFieldEditor_SelectedText; + public static String TerminalColorsFieldEditor_Selection; + public static String TerminalColorsFieldEditor_TextColor; + public static String TerminalColorsFieldEditor_White; + public static String TerminalColorsFieldEditor_Yellow; public static String TerminalError; public static String SocketError; public static String IOError; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties index 34492a197cb..7d6366889ea 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2020 Wind River Systems, Inc. and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at @@ -19,7 +19,33 @@ ############################################################################### # NLS_MESSAGEFORMAT_VAR - +TerminalColorPresets_EclipseLight=Eclipse Light +TerminalColorPresets_TerminalDefaults=Terminal Defaults +TerminalColorPresets_EclipseDark=Eclipse Dark +TerminalColorsFieldEditor_Background=Background +TerminalColorsFieldEditor_Black=Black +TerminalColorsFieldEditor_Blue=Blue +TerminalColorsFieldEditor_BrightBlack=Bright Black +TerminalColorsFieldEditor_BrightBlue=Bright Blue +TerminalColorsFieldEditor_BrightCyan=Bright Cyan +TerminalColorsFieldEditor_BrightGreen=Bright Green +TerminalColorsFieldEditor_BrightMagenta=Bright Magenta +TerminalColorsFieldEditor_BrightRed=Bright Red +TerminalColorsFieldEditor_BrightWhite=Bright White +TerminalColorsFieldEditor_BrightYellow=Bright Yellow +TerminalColorsFieldEditor_Cyan=Cyan +TerminalColorsFieldEditor_GeneralColors=General colors +TerminalColorsFieldEditor_Green=Green +TerminalColorsFieldEditor_LoadPresets=Load Presets... +TerminalColorsFieldEditor_Magenta=Magenta +TerminalColorsFieldEditor_PaletteColors=Palette colors +TerminalColorsFieldEditor_Presets=Presets +TerminalColorsFieldEditor_Red=Red +TerminalColorsFieldEditor_SelectedText=Selected text +TerminalColorsFieldEditor_Selection=Selection +TerminalColorsFieldEditor_TextColor=Text color +TerminalColorsFieldEditor_White=White +TerminalColorsFieldEditor_Yellow=Yellow TerminalError = Terminal Error SocketError = Socket Error IOError = IO Error diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java index 6e67c970dcc..77f6f428aea 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * @@ -100,17 +100,17 @@ public interface IVT100EmulatorBackend { */ void deleteLines(int n); - Style getDefaultStyle(); + TerminalStyle getDefaultStyle(); - void setDefaultStyle(Style defaultStyle); + void setDefaultStyle(TerminalStyle defaultStyle); - Style getStyle(); + TerminalStyle getStyle(); /** * Sets the style to be used from now on * @param style */ - void setStyle(Style style); + void setStyle(TerminalStyle style); /** * This method displays a subset of the newly-received text in the Terminal diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java index 3626f18afc2..1c589c258c3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -15,7 +15,7 @@ import java.io.PrintStream; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; public class VT100BackendTraceDecorator implements IVT100EmulatorBackend { final IVT100EmulatorBackend fBackend; @@ -102,7 +102,7 @@ public int getCursorLine() { } @Override - public Style getDefaultStyle() { + public TerminalStyle getDefaultStyle() { return fBackend.getDefaultStyle(); } @@ -112,7 +112,7 @@ public int getLines() { } @Override - public Style getStyle() { + public TerminalStyle getStyle() { return fBackend.getStyle(); } @@ -153,7 +153,7 @@ public void setCursorLine(int targetLine) { } @Override - public void setDefaultStyle(Style defaultStyle) { + public void setDefaultStyle(TerminalStyle defaultStyle) { fWriter.println("setDefaultStyle(" + defaultStyle + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setDefaultStyle(defaultStyle); } @@ -165,7 +165,7 @@ public void setDimensions(int lines, int cols) { } @Override - public void setStyle(Style style) { + public void setStyle(TerminalStyle style) { fWriter.println("setStyle(" + style + ")"); //$NON-NLS-1$ //$NON-NLS-2$ fBackend.setStyle(style); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 080c26258e7..f6c20042b25 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -29,15 +29,14 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLACK; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLUE; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.CYAN; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.GREEN; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.MAGENTA; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.RED; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE_FOREGROUND; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.YELLOW; +import static org.eclipse.tm.terminal.model.TerminalColor.BLACK; +import static org.eclipse.tm.terminal.model.TerminalColor.BLUE; +import static org.eclipse.tm.terminal.model.TerminalColor.CYAN; +import static org.eclipse.tm.terminal.model.TerminalColor.GREEN; +import static org.eclipse.tm.terminal.model.TerminalColor.MAGENTA; +import static org.eclipse.tm.terminal.model.TerminalColor.RED; +import static org.eclipse.tm.terminal.model.TerminalColor.WHITE; +import static org.eclipse.tm.terminal.model.TerminalColor.YELLOW; import java.io.IOException; import java.io.Reader; @@ -49,7 +48,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.Logger; import org.eclipse.tm.terminal.model.ITerminalTextData; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * This class processes character data received from the remote host and @@ -170,7 +169,7 @@ public VT100Emulator(ITerminalTextData data, ITerminalControlForText terminal, R text = new VT100EmulatorBackend(data); // text.setDimensions(24, 80); - Style style = Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$ //$NON-NLS-2$ + TerminalStyle style = TerminalStyle.getDefaultStyle(); text.setDefaultStyle(style); text.setStyle(style); } @@ -851,7 +850,7 @@ private void processAnsiCommand_m() { ansiParameters[0].append('0'); } - Style style = text.getStyle(); + TerminalStyle style = text.getStyle(); // There are a non-zero number of ANSI parameters. Process each one in // order. @@ -904,39 +903,39 @@ private void processAnsiCommand_m() { break; case 30: - style = style.setForground(BLACK); + style = style.setForeground(BLACK); break; case 31: - style = style.setForground(RED); + style = style.setForeground(RED); break; case 32: - style = style.setForground(GREEN); + style = style.setForeground(GREEN); break; case 33: - style = style.setForground(YELLOW); + style = style.setForeground(YELLOW); break; case 34: - style = style.setForground(BLUE); + style = style.setForeground(BLUE); break; case 35: - style = style.setForground(MAGENTA); + style = style.setForeground(MAGENTA); break; case 36: - style = style.setForground(CYAN); + style = style.setForeground(CYAN); break; case 37: - style = style.setForground(WHITE_FOREGROUND); + style = style.setForeground(WHITE); break; case 39: //Foreground: Default - style = style.setForground(text.getDefaultStyle().getForground()); + style = style.setForeground(text.getDefaultStyle()); break; case 40: @@ -972,7 +971,7 @@ private void processAnsiCommand_m() { break; case 49: //Background: Default - style = style.setBackground(text.getDefaultStyle().getBackground()); + style = style.setBackground(text.getDefaultStyle()); break; default: diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index d66b4bcd32c..959e8e85a2d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -15,7 +15,7 @@ package org.eclipse.tm.internal.terminal.emulator; import org.eclipse.tm.terminal.model.ITerminalTextData; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * @noextend This class is not intended to be subclassed by clients. @@ -87,8 +87,8 @@ int getHeight() { * and next output requires line wrap */ private boolean fWrapPending; private boolean fInsertMode; - private Style fDefaultStyle; - private Style fStyle; + private TerminalStyle fDefaultStyle; + private TerminalStyle fStyle; int fLines; int fColumns; final private ITerminalTextData fTerminal; @@ -161,7 +161,7 @@ public void insertCharacters(int charactersToInsert) { int n = charactersToInsert; for (int col = fColumns - 1; col >= fCursorColumn + n; col--) { char c = fTerminal.getChar(line, col - n); - Style style = fTerminal.getStyle(line, col - n); + TerminalStyle style = fTerminal.getStyle(line, col - n); fTerminal.setChar(line, col, c, style); } int last = Math.min(fCursorColumn + n, fColumns); @@ -246,7 +246,7 @@ public void deleteCharacters(int n) { int line = toAbsoluteLine(fCursorLine); for (int col = fCursorColumn + n; col < fColumns; col++) { char c = fTerminal.getChar(line, col); - Style style = fTerminal.getStyle(line, col); + TerminalStyle style = fTerminal.getStyle(line, col); fTerminal.setChar(line, col - n, c, style); } int first = Math.max(fCursorColumn, fColumns - n); @@ -273,21 +273,21 @@ private boolean isCusorInScrollingRegion() { } @Override - public Style getDefaultStyle() { + public TerminalStyle getDefaultStyle() { synchronized (fTerminal) { return fDefaultStyle; } } @Override - public void setDefaultStyle(Style defaultStyle) { + public void setDefaultStyle(TerminalStyle defaultStyle) { synchronized (fTerminal) { fDefaultStyle = defaultStyle; } } @Override - public Style getStyle() { + public TerminalStyle getStyle() { synchronized (fTerminal) { if (fStyle == null) return fDefaultStyle; @@ -296,7 +296,7 @@ public Style getStyle() { } @Override - public void setStyle(Style style) { + public void setStyle(TerminalStyle style) { synchronized (fTerminal) { fStyle = style; } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index ae58e006baf..6271c0d8733 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -52,21 +52,26 @@ import java.lang.reflect.Field; import java.net.SocketException; import java.nio.charset.Charset; +import java.util.EnumMap; +import java.util.Map; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.bindings.Binding; import org.eclipse.jface.bindings.keys.KeySequence; import org.eclipse.jface.bindings.keys.KeyStroke; import org.eclipse.jface.bindings.keys.SWTKeySupport; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.DataFormatException; import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.resource.StringConverter; import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; @@ -81,6 +86,7 @@ import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -98,6 +104,7 @@ import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; +import org.eclipse.tm.internal.terminal.preferences.TerminalColorPresets; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; import org.eclipse.tm.internal.terminal.provisional.api.Logger; @@ -108,6 +115,7 @@ import org.eclipse.tm.internal.terminal.textcanvas.TextLineRenderer; import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; +import org.eclipse.tm.terminal.model.TerminalColor; import org.eclipse.tm.terminal.model.TerminalTextDataFactory; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.contexts.IContextActivation; @@ -144,7 +152,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private TerminalFocusListener fFocusListener; private ITerminalConnector fConnector; private final ITerminalConnector[] fConnectors; - private final boolean fUseCommonPrefs; + private final IPreferenceStore fPreferenceStore; private boolean connectOnEnterIfClosed = true; PipedInputStream fInputStream; @@ -165,17 +173,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC /** * Listens to changes in the preferences */ - private final IPropertyChangeListener fPreferenceListener = event -> { - if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) - || event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) { - updatePreferences(); - } - }; - private final IPropertyChangeListener fFontListener = event -> { - if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) { - onTerminalFontChanged(); - } - }; + private final IPropertyChangeListener fPreferenceListener = this::updatePreferences; + private final IPropertyChangeListener fFontListener = this::updateFont; /** * Is protected by synchronize on this @@ -184,12 +183,22 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private PollingTextCanvasModel fPollingTextCanvasModel; + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + * @param preferenceStore If non-null, the Terminal widget will pick up settings + * from the given store. + * @since 3.2 + */ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { - this(target, wndParent, connectors, false); + this(target, wndParent, connectors, null); } /** - * Instantiate a Terminal widget. + * Instantiate a Terminal widget using the org.eclipse.tm.terminal.TerminalPreferencePage Preference page's + * default preference store. * @param target Callback for notifying the owner of Terminal state changes. * @param wndParent The Window parent to embed the Terminal in. * @param connectors Provided connectors. @@ -200,8 +209,22 @@ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerm */ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) { + this(target, wndParent, connectors, useCommonPrefs ? TerminalPlugin.getDefault().getPreferenceStore() : null); + } + + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + * @param preferenceStore If non-null, the Terminal widget will pick up settings + * from the given store. + * @since 5.0 + */ + public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, + IPreferenceStore preferenceStore) { fConnectors = connectors; - fUseCommonPrefs = useCommonPrefs; + fPreferenceStore = preferenceStore; fTerminalListener = target; fTerminalModel = TerminalTextDataFactory.makeTerminalTextData(); fTerminalModel.setMaxHeight(1000); @@ -373,10 +396,10 @@ public boolean isConnected() { @Override public void disposeTerminal() { Logger.log("entered."); //$NON-NLS-1$ - if (fUseCommonPrefs) { - TerminalPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); - JFaceResources.getFontRegistry().removeListener(fFontListener); + if (fPreferenceStore != null) { + fPreferenceStore.removePropertyChangeListener(fPreferenceListener); } + JFaceResources.getFontRegistry().removeListener(fFontListener); disconnectTerminal(); fClipboard.dispose(); getTerminalText().dispose(); @@ -642,12 +665,11 @@ public void setupTerminal(Composite parent) { setupControls(parent); setCommandInputField(fCommandInputField); setupListeners(); - if (fUseCommonPrefs && wasDisposed) { - updatePreferences(); - onTerminalFontChanged(); - TerminalPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); - JFaceResources.getFontRegistry().addListener(fFontListener); + if (fPreferenceStore != null && wasDisposed) { + updatePreferences(null); + fPreferenceStore.addPropertyChangeListener(fPreferenceListener); } + JFaceResources.getFontRegistry().addListener(fFontListener); setupHelp(fWndParent, TerminalPlugin.HELP_VIEW); if (!wasDisposed) { @@ -655,18 +677,58 @@ public void setupTerminal(Composite parent) { } } - private void updatePreferences() { - int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, - ITerminalConstants.PREF_BUFFERLINES, 0, null); - boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID, - ITerminalConstants.PREF_INVERT_COLORS, false, null); + private void updatePreferences(PropertyChangeEvent unused) { + int bufferLineLimit = fPreferenceStore.getInt(ITerminalConstants.PREF_BUFFERLINES); + boolean invert = fPreferenceStore.getBoolean(ITerminalConstants.PREF_INVERT_COLORS); setBufferLineLimit(bufferLineLimit); setInvertedColors(invert); + onTerminalColorsChanged(); + onTerminalFontChanged(); + } + + private void onTerminalColorsChanged() { + Map map = new EnumMap<>(TerminalColor.class); + TerminalColor[] values = TerminalColor.values(); + for (TerminalColor terminalColor : values) { + RGB rgb = null; + if (fPreferenceStore != null) { + try { + rgb = StringConverter.asRGB( + fPreferenceStore.getString(ITerminalConstants.getPrefForTerminalColor(terminalColor))); + } catch (DataFormatException dfe) { + // bad color, use default preset value instead + } + } + + if (rgb == null) { + rgb = TerminalColorPresets.INSTANCE.getDefaultPreset().getRGB(terminalColor); + } + map.put(terminalColor, rgb); + } + fCtlText.updateColors(map); + } + + private String getFontDefinition() { + String definition; + if (fPreferenceStore != null) { + definition = fPreferenceStore.getString(ITerminalConstants.PREF_FONT_DEFINITION); + } else { + definition = ITerminalConstants.DEFAULT_FONT_DEFINITION; + } + if (definition == null || definition.isEmpty()) { + definition = "org.eclipse.jface.textfont"; //$NON-NLS-1$ + } + return definition; } private void onTerminalFontChanged() { - // set the font for all - setFont(ITerminalConstants.FONT_DEFINITION); + setFont(getFontDefinition()); + } + + private void updateFont(PropertyChangeEvent event) { + if (event.getProperty().equals(getFontDefinition())) { + onTerminalFontChanged(); + } } @Override diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java index c99d01a4a7a..54f637a78ab 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java @@ -14,7 +14,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * This is a decorator to make all access to @@ -89,12 +89,12 @@ synchronized public int getMaxHeight() { } @Override - synchronized public Style getStyle(int line, int column) { + synchronized public TerminalStyle getStyle(int line, int column) { return fData.getStyle(line, column); } @Override - synchronized public Style[] getStyles(int line) { + synchronized public TerminalStyle[] getStyles(int line) { return fData.getStyles(line); } @@ -114,17 +114,17 @@ synchronized public void scroll(int startLine, int size, int shift) { } @Override - synchronized public void setChar(int line, int column, char c, Style style) { + synchronized public void setChar(int line, int column, char c, TerminalStyle style) { fData.setChar(line, column, c, style); } @Override - 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, TerminalStyle style) { fData.setChars(line, column, chars, start, len, style); } @Override - synchronized public void setChars(int line, int column, char[] chars, Style style) { + synchronized public void setChars(int line, int column, char[] chars, TerminalStyle style) { fData.setChars(line, column, chars, style); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SystemDefaultColors.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SystemDefaultColors.java new file mode 100644 index 00000000000..930a97a1e73 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/SystemDefaultColors.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2020 Kichwa Coders Canada Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.model; + +import java.util.function.Supplier; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.eclipse.ui.themes.ColorUtil; + +/** + * Wrapper class to get standard colors from Eclipse trying to match existing theme where possible + * by using standard editor colors. + * + * This class has an implied and optional dependency on org.eclipse.ui.editors bundle by reading + * that bundles preferences. + */ +public enum SystemDefaultColors implements Supplier { + + /** + * Standard text foreground. Typically black in Light theme. + */ + FOREGROUND("Foreground", "COLOR_LIST_FOREGROUND", new RGB(0, 0, 0)), //$NON-NLS-1$ //$NON-NLS-2$ + + /** + * Standard text background. Typically white in Light theme. + */ + BACKGROUND("Background", "COLOR_LIST_BACKGROUND", new RGB(255, 255, 255)), //$NON-NLS-1$ //$NON-NLS-2$ + + /** + * Selection foreground. Typically white in Light theme. + */ + SELECTION_FOREGROUND("SelectionForeground", "COLOR_LIST_SELECTION_TEXT", //$NON-NLS-1$ //$NON-NLS-2$ + new RGB(255, 255, 255)), + + /** + * Selection background. Typically blue in Light theme. + */ + SELECTION_BACKGROUND("SelectionBackground", "COLOR_LIST_SELECTION", new RGB(74, 144, 9)); //$NON-NLS-1$ //$NON-NLS-2$ + + private static final String EDITOR_SCOPE = "org.eclipse.ui.editors"; //$NON-NLS-1$ + private static final String PREF_PREFIX = "AbstractTextEditor.Color."; //$NON-NLS-1$ + private static final String PREF_SYSTEM_DEFAULT_SUFFIX = ".SystemDefault"; //$NON-NLS-1$ + + /** + * SWT Name of Color + * + * Values from SWT + */ + private String swtColor; + + /** + * Preference name for color. + * + * Values from org.eclipse.ui.texteditor.AbstractTextEditor.... + */ + private String editorColor; + + /** If all else fails, use this standard color */ + private RGB fallbackColor; + + SystemDefaultColors(String editorColor, String swtColor, RGB rgb) { + this.editorColor = editorColor; + this.swtColor = swtColor; + this.fallbackColor = rgb; + } + + /** + * Get the color for this enum value. + * + * @return the RGB color or a non-null color as a fallback. + */ + @Override + public RGB get() { + IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, EDITOR_SCOPE); + + RGB rgb = null; + String pref = PREF_PREFIX + editorColor; + String prefSystemDefault = pref + PREF_SYSTEM_DEFAULT_SUFFIX; + if (Platform.getPreferencesService() != null) { + if (!store.getBoolean(prefSystemDefault)) { + if (store.contains(pref)) { + if (store.isDefault(pref)) + rgb = PreferenceConverter.getDefaultColor(store, pref); + else { + rgb = PreferenceConverter.getColor(store, pref); + } + } + } + } + + if (rgb == null) { + rgb = ColorUtil.getColorValue(swtColor); + } + + if (rgb == null) { + rgb = fallbackColor; + } + + return rgb; + } +} \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java index 409e6bc63ee..9e6cf40f9d1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java @@ -22,7 +22,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * This class is thread safe. @@ -136,24 +136,24 @@ public char getChar(int line, int column) { } @Override - public Style getStyle(int line, int column) { + public TerminalStyle getStyle(int line, int column) { return fData.getStyle(line, column); } @Override - public void setChar(int line, int column, char c, Style style) { + public void setChar(int line, int column, char c, TerminalStyle style) { fData.setChar(line, column, c, style); sendLineChangedToSnapshots(line); } @Override - public void setChars(int line, int column, char[] chars, Style style) { + public void setChars(int line, int column, char[] chars, TerminalStyle style) { fData.setChars(line, column, chars, style); sendLineChangedToSnapshots(line); } @Override - 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, TerminalStyle style) { fData.setChars(line, column, chars, start, len, style); sendLineChangedToSnapshots(line); } @@ -279,7 +279,7 @@ public char[] getChars(int line) { } @Override - public Style[] getStyles(int line) { + public TerminalStyle[] getStyles(int line) { return fData.getStyles(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java index 8cb0bd3cad5..519fad0a3e1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java @@ -14,7 +14,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * This class is optimized for scrolling the entire {@link #getHeight()}. @@ -151,13 +151,13 @@ public int getMaxHeight() { } @Override - public Style getStyle(int line, int column) { + public TerminalStyle getStyle(int line, int column) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getStyle(getPositionOfLine(line), column); } @Override - public Style[] getStyles(int line) { + public TerminalStyle[] getStyles(int line) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); return fData.getStyles(getPositionOfLine(line)); } @@ -214,19 +214,19 @@ public void scroll(int startLine, int size, int shift) { } @Override - public void setChar(int line, int column, char c, Style style) { + public void setChar(int line, int column, char c, TerminalStyle style) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setChar(getPositionOfLine(line), column, c, style); } @Override - 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, TerminalStyle style) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setChars(getPositionOfLine(line), column, chars, start, len, style); } @Override - public void setChars(int line, int column, char[] chars, Style style) { + public void setChars(int line, int column, char[] chars, TerminalStyle style) { assert (line >= 0 && line < fHeight) || throwRuntimeException(); fData.setChars(getPositionOfLine(line), column, chars, style); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java index 7d3d5a7f88e..26a6982c871 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshot.java @@ -18,7 +18,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * The public methods of this class have to be called from one thread! @@ -137,7 +137,7 @@ public LineSegment[] getLineSegments(int line, int column, int len) { } @Override - public Style getStyle(int line, int column) { + public TerminalStyle getStyle(int line, int column) { return fSnapshot.getStyle(line, column); } @@ -299,7 +299,7 @@ public char[] getChars(int line) { } @Override - public Style[] getStyles(int line) { + public TerminalStyle[] getStyles(int line) { return fSnapshot.getStyles(line); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java index 2ab5b22025a..f0472aba928 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStore.java @@ -19,7 +19,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * This class is thread safe. @@ -27,7 +27,7 @@ */ public class TerminalTextDataStore implements ITerminalTextData { private char[][] fChars; - private Style[][] fStyle; + private TerminalStyle[][] fStyle; private int fWidth; private int fHeight; private int fMaxHeight; @@ -37,7 +37,7 @@ public class TerminalTextDataStore implements ITerminalTextData { public TerminalTextDataStore() { fChars = new char[0][]; - fStyle = new Style[0][]; + fStyle = new TerminalStyle[0][]; fWidth = 0; } @@ -69,7 +69,7 @@ public void setDimensions(int height, int width) { int h = 4 * height / 3; if (fMaxHeight > 0 && h > fMaxHeight) h = fMaxHeight; - fStyle = (Style[][]) resizeArray(fStyle, height); + fStyle = (TerminalStyle[][]) resizeArray(fStyle, height); fChars = (char[][]) resizeArray(fChars, height); } // clean the new lines @@ -106,16 +106,16 @@ private Object resizeArray(Object origArray, int newSize) { @Override public LineSegment[] getLineSegments(int line, int column, int len) { // get the styles and chars for this line - Style[] styles = fStyle[line]; + TerminalStyle[] styles = fStyle[line]; char[] chars = fChars[line]; int col = column; int n = column + len; // expand the line if needed.... if (styles == null) - styles = new Style[n]; + styles = new TerminalStyle[n]; else if (styles.length < n) - styles = (Style[]) resizeArray(styles, n); + styles = (TerminalStyle[]) resizeArray(styles, n); if (chars == null) chars = new char[n]; @@ -123,7 +123,7 @@ else if (chars.length < n) chars = (char[]) resizeArray(chars, n); // and create the line segments - Style style = styles[column]; + TerminalStyle style = styles[column]; List segments = new ArrayList<>(); for (int i = column; i < n; i++) { if (styles[i] != style) { @@ -147,7 +147,7 @@ public char getChar(int line, int column) { } @Override - public Style getStyle(int line, int column) { + public TerminalStyle getStyle(int line, int column) { assert column < fWidth || throwRuntimeException(); if (fStyle[line] == null || column >= fStyle[line].length) return null; @@ -163,26 +163,26 @@ void ensureLineLength(int iLine, int length) { fChars[iLine] = (char[]) resizeArray(fChars[iLine], length); } if (fStyle[iLine] == null) { - fStyle[iLine] = new Style[length]; + fStyle[iLine] = new TerminalStyle[length]; } else if (fStyle[iLine].length < length) { - fStyle[iLine] = (Style[]) resizeArray(fStyle[iLine], length); + fStyle[iLine] = (TerminalStyle[]) resizeArray(fStyle[iLine], length); } } @Override - public void setChar(int line, int column, char c, Style style) { + public void setChar(int line, int column, char c, TerminalStyle style) { ensureLineLength(line, column + 1); fChars[line][column] = c; fStyle[line][column] = style; } @Override - public void setChars(int line, int column, char[] chars, Style style) { + public void setChars(int line, int column, char[] chars, TerminalStyle style) { setChars(line, column, chars, 0, chars.length, style); } @Override - 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, TerminalStyle style) { ensureLineLength(line, column + len); for (int i = 0; i < len; i++) { fChars[line][column + i] = chars[i + start]; @@ -262,7 +262,7 @@ public void copy(ITerminalTextData source) { int n = source.getHeight(); if (getHeight() != n) { fChars = new char[n][]; - fStyle = new Style[n][]; + fStyle = new TerminalStyle[n][]; } for (int i = 0; i < n; i++) { copyLine(source, i, i); @@ -294,13 +294,13 @@ public char[] getChars(int line) { } @Override - public Style[] getStyles(int line) { + public TerminalStyle[] getStyles(int line) { if (fStyle[line] == null) return null; return fStyle[line].clone(); } - public void setLine(int line, char[] chars, Style[] styles) { + public void setLine(int line, char[] chars, TerminalStyle[] styles) { fChars[line] = chars.clone(); fStyle[line] = styles.clone(); fWrappedLines.clear(line); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java index f9ec141d858..31e6d625901 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java @@ -14,7 +14,7 @@ import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * This class stores the data only within a window {@link #setWindow(int, int)} and @@ -86,14 +86,14 @@ public int getMaxHeight() { } @Override - public Style getStyle(int line, int column) { + public TerminalStyle getStyle(int line, int column) { if (!isInWindow(line)) return null; return fData.getStyle(line - fWindowStartLine, column); } @Override - public Style[] getStyles(int line) { + public TerminalStyle[] getStyles(int line) { if (!isInWindow(line)) return null; return fData.getStyles(line - fWindowStartLine); @@ -168,21 +168,21 @@ public void scroll(int startLine, int size, int shift) { } @Override - public void setChar(int line, int column, char c, Style style) { + public void setChar(int line, int column, char c, TerminalStyle style) { if (!isInWindow(line)) return; fData.setChar(line - fWindowStartLine, column, c, style); } @Override - 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, TerminalStyle style) { if (!isInWindow(line)) return; fData.setChars(line - fWindowStartLine, column, chars, start, len, style); } @Override - public void setChars(int line, int column, char[] chars, Style style) { + public void setChars(int line, int column, char[] chars, TerminalStyle style) { if (!isInWindow(line)) return; fData.setChars(line - fWindowStartLine, column, chars, style); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java index 0c44566fb77..9f87a310388 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.preferences; +import org.eclipse.tm.terminal.model.TerminalColor; + /** * Constants for Terminal Preferences. * @@ -22,13 +24,27 @@ */ public interface ITerminalConstants { + public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$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_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$ + /** + * @since 5.0 + */ + public static final String PREF_FONT_DEFINITION = "TerminalFontDefinition"; //$NON-NLS-1$ public static final int DEFAULT_BUFFERLINES = 1000; public static final boolean DEFAULT_INVERT_COLORS = false; + /** + * @since 5.0 + */ + public static final String DEFAULT_FONT_DEFINITION = FONT_DEFINITION; - public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$ + /** + * @since 5.0 + */ + public static String getPrefForTerminalColor(TerminalColor tc) { + return tc.toString(); + } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorPresets.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorPresets.java new file mode 100644 index 00000000000..108ac7de0c2 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorPresets.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2020 Kichwa Coders Canada Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import static org.eclipse.tm.terminal.model.TerminalColor.BACKGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.BLACK; +import static org.eclipse.tm.terminal.model.TerminalColor.BLUE; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_BLACK; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_BLUE; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_CYAN; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_GREEN; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_MAGENTA; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_RED; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_WHITE; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_YELLOW; +import static org.eclipse.tm.terminal.model.TerminalColor.CYAN; +import static org.eclipse.tm.terminal.model.TerminalColor.FOREGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.GREEN; +import static org.eclipse.tm.terminal.model.TerminalColor.MAGENTA; +import static org.eclipse.tm.terminal.model.TerminalColor.RED; +import static org.eclipse.tm.terminal.model.TerminalColor.SELECTION_BACKGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.SELECTION_FOREGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.WHITE; +import static org.eclipse.tm.terminal.model.TerminalColor.YELLOW; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import org.eclipse.swt.graphics.RGB; +import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; +import org.eclipse.tm.internal.terminal.model.SystemDefaultColors; +import org.eclipse.tm.terminal.model.TerminalColor; + +/** + * @since 5.0 + */ +public enum TerminalColorPresets { + + INSTANCE; + + private final List presets = new ArrayList<>(); + + public List getPresets() { + return presets.stream().map(Preset::getName).collect(Collectors.toList()); + } + + public Preset getPreset(int index) { + return presets.get(index); + } + + public static class Preset { + private String name; + private Map> map = new EnumMap<>(TerminalColor.class); + + Preset(String name) { + this.name = name; + set(BLACK, 0, 0, 0); + set(RED, 205, 0, 0); + set(GREEN, 0, 205, 0); + set(YELLOW, 205, 205, 0); + set(BLUE, 0, 0, 238); + set(MAGENTA, 205, 0, 205); + set(CYAN, 0, 205, 205); + set(WHITE, 229, 229, 229); + + set(BRIGHT_BLACK, 0, 0, 0); + set(BRIGHT_RED, 255, 0, 0); + set(BRIGHT_GREEN, 0, 255, 0); + set(BRIGHT_YELLOW, 255, 255, 0); + set(BRIGHT_BLUE, 92, 92, 255); + set(BRIGHT_MAGENTA, 255, 0, 255); + set(BRIGHT_CYAN, 0, 255, 255); + set(BRIGHT_WHITE, 255, 255, 255); + + set(FOREGROUND, SystemDefaultColors.FOREGROUND); + set(BACKGROUND, SystemDefaultColors.BACKGROUND); + set(SELECTION_FOREGROUND, SystemDefaultColors.SELECTION_FOREGROUND); + set(SELECTION_BACKGROUND, SystemDefaultColors.SELECTION_BACKGROUND); + } + + Preset set(TerminalColor color, RGB rgb) { + return set(color, () -> rgb); + } + + Preset set(TerminalColor color, int r, int g, int b) { + return set(color, new RGB(r, g, b)); + } + + Preset set(TerminalColor color, Supplier rgbSupplier) { + map.put(color, rgbSupplier); + return this; + } + + public String getName() { + return name; + } + + /** + * Returns the preset value for the given color. Will never return null + * because each color must be defined in the map. + * + * @param terminalColor to get RGB value for + * @return non-null color + */ + public RGB getRGB(TerminalColor terminalColor) { + return map.getOrDefault(terminalColor, () -> new RGB(0, 0, 0)).get(); + } + } + + TerminalColorPresets() { + presets.add(new Preset(TerminalMessages.TerminalColorPresets_TerminalDefaults)); + presets.add(new Preset(TerminalMessages.TerminalColorPresets_EclipseLight) // + .set(FOREGROUND, getDefaultPreset().getRGB(BLACK)) // + .set(BACKGROUND, getDefaultPreset().getRGB(WHITE))); + presets.add(new Preset(TerminalMessages.TerminalColorPresets_EclipseDark) // + .set(FOREGROUND, getDefaultPreset().getRGB(WHITE)) // + .set(BACKGROUND, getDefaultPreset().getRGB(BLACK))); + } + + public Preset getDefaultPreset() { + return presets.get(0); + } +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java new file mode 100644 index 00000000000..1ea8983c5ac --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java @@ -0,0 +1,227 @@ +/******************************************************************************* + * Copyright (c) 2020 Kichwa Coders Canada Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import static org.eclipse.tm.terminal.model.TerminalColor.BACKGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.BLACK; +import static org.eclipse.tm.terminal.model.TerminalColor.BLUE; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_BLACK; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_BLUE; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_CYAN; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_GREEN; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_MAGENTA; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_RED; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_WHITE; +import static org.eclipse.tm.terminal.model.TerminalColor.BRIGHT_YELLOW; +import static org.eclipse.tm.terminal.model.TerminalColor.CYAN; +import static org.eclipse.tm.terminal.model.TerminalColor.FOREGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.GREEN; +import static org.eclipse.tm.terminal.model.TerminalColor.MAGENTA; +import static org.eclipse.tm.terminal.model.TerminalColor.RED; +import static org.eclipse.tm.terminal.model.TerminalColor.SELECTION_BACKGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.SELECTION_FOREGROUND; +import static org.eclipse.tm.terminal.model.TerminalColor.WHITE; +import static org.eclipse.tm.terminal.model.TerminalColor.YELLOW; + +import java.util.EnumMap; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.preference.ColorSelector; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.resource.FontDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; +import org.eclipse.tm.terminal.model.TerminalColor; + +/** + * A field editor that can be used for editing terminal colors. + * + * @since 5.0 + */ +public class TerminalColorsFieldEditor extends FieldEditor { + + private EnumMap colorSelectors; + private Composite controls; + private Font boldFont; + + /** + * Creates a field editor for editing colors of {@link TerminalColor}. + * The preference names used are as they are returned from {@link TerminalColor#getPreferenceName()} + * @param labelText + * @param parent + */ + public TerminalColorsFieldEditor(Composite parent) { + super("", "", parent); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected void adjustForNumColumns(int numColumns) { + GridData gd = (GridData) controls.getLayoutData(); + gd.horizontalSpan = numColumns; + } + + @Override + public int getNumberOfControls() { + return 1; + } + + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + colorSelectors = new EnumMap<>(TerminalColor.class); + controls = new Composite(parent, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(controls); + GridLayoutFactory.fillDefaults().applyTo(controls); + + FontDescriptor boldDescriptor = FontDescriptor.createFrom(parent.getFont()).setStyle(SWT.BOLD); + boldFont = boldDescriptor.createFont(parent.getDisplay()); + + Group general = new Group(controls, SWT.SHADOW_NONE); + general.setText(TerminalMessages.TerminalColorsFieldEditor_GeneralColors); + general.setFont(boldFont); + GridDataFactory.fillDefaults().applyTo(general); + GridLayoutFactory.swtDefaults().numColumns(4).applyTo(general); + + createLabelledSelector(general, FOREGROUND, TerminalMessages.TerminalColorsFieldEditor_TextColor); + createLabelledSelector(general, BACKGROUND, TerminalMessages.TerminalColorsFieldEditor_Background); + createLabelledSelector(general, SELECTION_BACKGROUND, TerminalMessages.TerminalColorsFieldEditor_Selection); + createLabelledSelector(general, SELECTION_FOREGROUND, TerminalMessages.TerminalColorsFieldEditor_SelectedText); + + Group palette = new Group(controls, SWT.SHADOW_NONE); + palette.setText(TerminalMessages.TerminalColorsFieldEditor_PaletteColors); + palette.setFont(boldFont); + GridDataFactory.fillDefaults().applyTo(palette); + GridLayoutFactory.swtDefaults().numColumns(8).applyTo(palette); + + createSelector(palette, BLACK, TerminalMessages.TerminalColorsFieldEditor_Black); + createSelector(palette, RED, TerminalMessages.TerminalColorsFieldEditor_Red); + createSelector(palette, GREEN, TerminalMessages.TerminalColorsFieldEditor_Green); + createSelector(palette, YELLOW, TerminalMessages.TerminalColorsFieldEditor_Yellow); + createSelector(palette, BLUE, TerminalMessages.TerminalColorsFieldEditor_Blue); + createSelector(palette, MAGENTA, TerminalMessages.TerminalColorsFieldEditor_Magenta); + createSelector(palette, CYAN, TerminalMessages.TerminalColorsFieldEditor_Cyan); + createSelector(palette, WHITE, TerminalMessages.TerminalColorsFieldEditor_White); + + createSelector(palette, BRIGHT_BLACK, TerminalMessages.TerminalColorsFieldEditor_BrightBlack); + createSelector(palette, BRIGHT_RED, TerminalMessages.TerminalColorsFieldEditor_BrightRed); + createSelector(palette, BRIGHT_GREEN, TerminalMessages.TerminalColorsFieldEditor_BrightGreen); + createSelector(palette, BRIGHT_YELLOW, TerminalMessages.TerminalColorsFieldEditor_BrightYellow); + createSelector(palette, BRIGHT_BLUE, TerminalMessages.TerminalColorsFieldEditor_BrightBlue); + createSelector(palette, BRIGHT_MAGENTA, TerminalMessages.TerminalColorsFieldEditor_BrightMagenta); + createSelector(palette, BRIGHT_CYAN, TerminalMessages.TerminalColorsFieldEditor_BrightCyan); + createSelector(palette, BRIGHT_WHITE, TerminalMessages.TerminalColorsFieldEditor_BrightWhite); + + Group presets = new Group(controls, SWT.SHADOW_NONE); + presets.setText(TerminalMessages.TerminalColorsFieldEditor_Presets); + presets.setFont(boldFont); + GridDataFactory.fillDefaults().applyTo(presets); + GridLayoutFactory.swtDefaults().numColumns(2).applyTo(presets); + Combo presetsCombo = new Combo(presets, SWT.DROP_DOWN | SWT.READ_ONLY); + presetsCombo.add(TerminalMessages.TerminalColorsFieldEditor_LoadPresets); + TerminalColorPresets colorPresets = TerminalColorPresets.INSTANCE; + colorPresets.getPresets().forEach(presetsCombo::add); + presetsCombo.addListener(SWT.Selection, e -> { + int selectionIndex = presetsCombo.getSelectionIndex(); + if (selectionIndex > 0) { + int selectedPresetIndex = selectionIndex - 1; // account for "Load Presets..." entry + colorSelectors.forEach((terminalColor, colorSelector) -> colorSelector + .setColorValue(colorPresets.getPreset(selectedPresetIndex).getRGB(terminalColor))); + + } + }); + presetsCombo.select(0); + } + + @Override + public void dispose() { + if (boldFont != null) { + boldFont.dispose(); + } + } + + private void createLabelledSelector(Composite parent, TerminalColor color, String label) { + Label labelControl = new Label(parent, SWT.LEFT); + labelControl.setText(label); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(labelControl); + createSelector(parent, color, label); + } + + private void createSelector(Composite parent, TerminalColor color, String label) { + ColorSelector colorSelector = new ColorSelector(parent); + colorSelector.getButton().setToolTipText(label); + GridDataFactory.fillDefaults().applyTo(colorSelector.getButton()); + colorSelectors.put(color, colorSelector); + } + + @Override + protected void doLoad() { + IPreferenceStore store = getPreferenceStore(); + colorSelectors.forEach((terminalColor, colorSelector) -> colorSelector.setColorValue( + PreferenceConverter.getColor(store, ITerminalConstants.getPrefForTerminalColor(terminalColor)))); + } + + @Override + protected void doLoadDefault() { + IPreferenceStore store = getPreferenceStore(); + colorSelectors.forEach((terminalColor, colorSelector) -> colorSelector.setColorValue( + PreferenceConverter.getDefaultColor(store, ITerminalConstants.getPrefForTerminalColor(terminalColor)))); + } + + @Override + public void store() { + IPreferenceStore store = getPreferenceStore(); + if (store == null) { + return; + } + + if (presentsDefaultValue()) { + doStoreDefault(store); + } else { + doStore(); + } + } + + /** + * Stores the default preference value from this field editor into + * the preference store. + */ + protected void doStoreDefault(IPreferenceStore store) { + colorSelectors.forEach((terminalColor, colorSelector) -> store + .setToDefault(ITerminalConstants.getPrefForTerminalColor(terminalColor))); + } + + @Override + protected void doStore() { + IPreferenceStore store = getPreferenceStore(); + colorSelectors.forEach((terminalColor, colorSelector) -> PreferenceConverter.setValue(store, + ITerminalConstants.getPrefForTerminalColor(terminalColor), colorSelector.getColorValue())); + } + + @Override + public String getPreferenceName() { + throw new IllegalArgumentException( + "preference name should not be accessed as this class represent multiple preferences"); //$NON-NLS-1$ + } + + @Override + public String getLabelText() { + throw new IllegalArgumentException( + "label text should not be accessed as this class represent multiple preferences"); //$NON-NLS-1$ + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java index df901498ce6..d6d737459b4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java @@ -18,7 +18,10 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.jface.resource.StringConverter; import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.preferences.TerminalColorPresets.Preset; +import org.eclipse.tm.terminal.model.TerminalColor; /** * Terminal Preference Initializer. @@ -38,5 +41,13 @@ public void initializeDefaultPreferences() { IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); defaultPrefs.putBoolean(ITerminalConstants.PREF_INVERT_COLORS, ITerminalConstants.DEFAULT_INVERT_COLORS); defaultPrefs.putInt(ITerminalConstants.PREF_BUFFERLINES, ITerminalConstants.DEFAULT_BUFFERLINES); + defaultPrefs.put(ITerminalConstants.PREF_FONT_DEFINITION, ITerminalConstants.DEFAULT_FONT_DEFINITION); + + Preset defaultPresets = TerminalColorPresets.INSTANCE.getDefaultPreset(); + TerminalColor[] colors = TerminalColor.values(); + for (TerminalColor color : colors) { + defaultPrefs.put(ITerminalConstants.getPrefForTerminalColor(color), + StringConverter.asString(defaultPresets.getRGB(color))); + } } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java index e3b0691977a..6dcc77da03f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -36,9 +36,6 @@ * @noreference This class is not intended to be referenced by clients. */ public class TerminalPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - protected BooleanFieldEditor fInvertColors; - - protected IntegerFieldEditor fEditorBufferSize; public TerminalPreferencePage() { super(GRID); @@ -69,14 +66,12 @@ protected void setupData() { } protected void setupEditors() { - fInvertColors = new BooleanFieldEditor(ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS, - getFieldEditorParent()); - fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, TerminalMessages.BUFFERLINES, - getFieldEditorParent()); + addField(new BooleanFieldEditor(ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS, + getFieldEditorParent())); - fEditorBufferSize.setValidRange(0, Integer.MAX_VALUE); + addField(new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, TerminalMessages.BUFFERLINES, + getFieldEditorParent())); - addField(fInvertColors); - addField(fEditorBufferSize); + addField(new TerminalColorsFieldEditor(getFieldEditorParent())); } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java deleted file mode 100644 index b57da7239f3..00000000000 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AnsiColorNames.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2020 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Jonah Graham - extracted colour names from StyleMap to be reused and cross referenced in VT100Emulator - *******************************************************************************/ -package org.eclipse.tm.internal.terminal.textcanvas; - -public class AnsiColorNames { - public static final String BLACK = "black"; //$NON-NLS-1$ - public static final String WHITE = "white"; //$NON-NLS-1$ - public static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$ - public static final String GRAY = "gray"; //$NON-NLS-1$ - public static final String MAGENTA = "magenta"; //$NON-NLS-1$ - public static final String CYAN = "cyan"; //$NON-NLS-1$ - public static final String YELLOW = "yellow"; //$NON-NLS-1$ - public static final String BLUE = "blue"; //$NON-NLS-1$ - public static final String GREEN = "green"; //$NON-NLS-1$ - public static final String RED = "red"; //$NON-NLS-1$ -} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java index 2d38a96eac0..8ef7c58cb89 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -14,8 +14,13 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; +import java.util.Map; + import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.tm.terminal.model.TerminalColor; /** * @@ -41,7 +46,16 @@ public interface ILinelRenderer { */ void updateFont(String fontName); + void updateColors(Map map); + void setInvertedColors(boolean invert); + /** + * @deprecated use {@link #getDefaultBackgroundColor(Device)} + */ + @Deprecated Color getDefaultBackgroundColor(); + + Color getDefaultBackgroundColor(Device device); + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index 6a0a7c0dd8b..badc43b6730 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -19,170 +19,104 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLACK; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.BLUE; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.CYAN; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.GRAY; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.GREEN; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.MAGENTA; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.RED; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.WHITE_FOREGROUND; -import static org.eclipse.tm.internal.terminal.textcanvas.AnsiColorNames.YELLOW; - -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; -import org.eclipse.tm.terminal.model.Style; -import org.eclipse.tm.terminal.model.StyleColor; - +import org.eclipse.tm.internal.terminal.preferences.TerminalColorPresets; +import org.eclipse.tm.terminal.model.TerminalColor; +import org.eclipse.tm.terminal.model.TerminalStyle; + +/** + * The split between responsibilities of StyleMap and TerminalStyle are not always clear. Generally + * the style parts that are global for a terminal are here, where as in TerminalStyle is about + * a specific range. + */ public class StyleMap { - private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$ String fFontName = ITerminalConstants.FONT_DEFINITION; - Map fColorMapForeground = new HashMap<>(); - Map fColorMapBackground = new HashMap<>(); - Map fColorMapIntense = new HashMap<>(); private Point fCharSize; - private final Style fDefaultStyle; + private final TerminalStyle fDefaultStyle; private boolean fInvertColors; private boolean fProportional; private final int[] fOffsets = new int[256]; + private final Map fColorMap = new EnumMap<>(TerminalColor.class); - StyleMap() { + public StyleMap() { + fDefaultStyle = TerminalStyle.getDefaultStyle(); + initFont(); initColors(); - fDefaultStyle = Style.getStyle(StyleColor.getStyleColor(BLACK), StyleColor.getStyleColor(WHITE)); - updateFont(); } private void initColors() { - initForegroundColors(); - initBackgroundColors(); - initIntenseColors(); + Map map = new EnumMap<>(TerminalColor.class); + TerminalColor[] values = TerminalColor.values(); + for (TerminalColor terminalColor : values) { + RGB rgb = TerminalColorPresets.INSTANCE.getDefaultPreset().getRGB(terminalColor); + map.put(terminalColor, rgb); + } + updateColors(map); } - private void initForegroundColors() { - if (fInvertColors) { - setColor(fColorMapForeground, WHITE, 0, 0, 0); - setColor(fColorMapForeground, WHITE_FOREGROUND, 50, 50, 50); - setColor(fColorMapForeground, BLACK, 229, 229, 229); - } else { - setColor(fColorMapForeground, WHITE, 255, 255, 255); - setColor(fColorMapForeground, WHITE_FOREGROUND, 229, 229, 229); - setColor(fColorMapForeground, BLACK, 50, 50, 50); - } - setColor(fColorMapForeground, RED, 205, 0, 0); - setColor(fColorMapForeground, GREEN, 0, 205, 0); - setColor(fColorMapForeground, BLUE, 0, 0, 238); - setColor(fColorMapForeground, YELLOW, 205, 205, 0); - setColor(fColorMapForeground, CYAN, 0, 205, 205); - setColor(fColorMapForeground, MAGENTA, 205, 0, 205); - setColor(fColorMapForeground, GRAY, 229, 229, 229); + private void initFont() { + updateFont(ITerminalConstants.FONT_DEFINITION); } - private void initBackgroundColors() { - if (fInvertColors) { - setColor(fColorMapBackground, WHITE, 0, 0, 0); - setColor(fColorMapBackground, WHITE_FOREGROUND, 50, 50, 50); // only used when colors are inverse - setColor(fColorMapBackground, BLACK, 255, 255, 255); - } else { - setColor(fColorMapBackground, WHITE, 255, 255, 255); - setColor(fColorMapBackground, WHITE_FOREGROUND, 229, 229, 229); - setColor(fColorMapBackground, BLACK, 0, 0, 0); - } - setColor(fColorMapBackground, RED, 205, 0, 0); - setColor(fColorMapBackground, GREEN, 0, 205, 0); - setColor(fColorMapBackground, BLUE, 0, 0, 238); - setColor(fColorMapBackground, YELLOW, 205, 205, 0); - setColor(fColorMapBackground, CYAN, 0, 205, 205); - setColor(fColorMapBackground, MAGENTA, 205, 0, 205); - setColor(fColorMapBackground, GRAY, 229, 229, 229); + private RGB getRGB(TerminalColor color) { + return fColorMap.get(color); } - private void initIntenseColors() { - if (fInvertColors) { - setColor(fColorMapIntense, WHITE, 127, 127, 127); - setColor(fColorMapIntense, WHITE_FOREGROUND, 0, 0, 0); // only used when colors are inverse - setColor(fColorMapIntense, BLACK, 255, 255, 255); + public RGB getForegrondRGB(TerminalStyle style) { + style = defaultIfNull(style); + TerminalColor color; + if (style.isReverse()) { + color = style.getBackgroundTerminalColor(); } else { - setColor(fColorMapIntense, WHITE, 255, 255, 255); - setColor(fColorMapIntense, WHITE_FOREGROUND, 255, 255, 255); - setColor(fColorMapIntense, BLACK, 0, 0, 0); + color = style.getForegroundTerminalColor(); } - setColor(fColorMapIntense, RED, 255, 0, 0); - setColor(fColorMapIntense, GREEN, 0, 255, 0); - setColor(fColorMapIntense, BLUE, 92, 92, 255); - setColor(fColorMapIntense, YELLOW, 255, 255, 0); - setColor(fColorMapIntense, CYAN, 0, 255, 255); - setColor(fColorMapIntense, MAGENTA, 255, 0, 255); - setColor(fColorMapIntense, GRAY, 255, 255, 255); - } - private void setColor(Map colorMap, String name, int r, int g, int b) { - String colorName = PREFIX + r + "-" + g + "-" + b; //$NON-NLS-1$//$NON-NLS-2$ - Color color = JFaceResources.getColorRegistry().get(colorName); if (color == null) { - JFaceResources.getColorRegistry().put(colorName, new RGB(r, g, b)); - color = JFaceResources.getColorRegistry().get(colorName); + color = TerminalColor.FOREGROUND; } - colorMap.put(StyleColor.getStyleColor(name), color); - colorMap.put(StyleColor.getStyleColor(name.toUpperCase()), color); - } - public Color getForegrondColor(Style style) { - style = defaultIfNull(style); - Map map = style.isBold() ? fColorMapIntense : fColorMapForeground; - //Map map = fColorMapForeground; - if (style.isReverse()) - return getColor(map, style.getBackground()); - else - return getColor(map, style.getForground()); + color = color.convertColor(fInvertColors, style.isBold()); + return getRGB(color); } - public Color getBackgroundColor(Style style) { + public RGB getBackgroundRGB(TerminalStyle style) { style = defaultIfNull(style); - if (style.isReverse()) - return getColor(fColorMapBackground, style.getForground()); - else - return getColor(fColorMapBackground, style.getBackground()); - } + TerminalColor color; + if (style.isReverse()) { + color = style.getForegroundTerminalColor(); + } else { + color = style.getBackgroundTerminalColor(); + } - Color getColor(Map map, StyleColor color) { - Color c = map.get(color); - if (c == null) { - c = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); + if (color == null) { + color = TerminalColor.BACKGROUND; } - return c; + + color = color.convertColor(fInvertColors, style.isBold()); + return getRGB(color); } - private Style defaultIfNull(Style style) { + private TerminalStyle defaultIfNull(TerminalStyle style) { if (style == null) style = fDefaultStyle; return style; } public void setInvertedColors(boolean invert) { - if (invert == fInvertColors) - return; fInvertColors = invert; - initColors(); } - // static Font getBoldFont(Font font) { - // FontData fontDatas[] = font.getFontData(); - // FontData data = fontDatas[0]; - // return new Font(Display.getCurrent(), data.getName(), data.getHeight(), data.getStyle()|SWT.BOLD); - // } - public Font getFont(Style style) { + public Font getFont(TerminalStyle style) { style = defaultIfNull(style); if (style.isBold()) { return JFaceResources.getFontRegistry().getBold(fFontName); @@ -195,7 +129,6 @@ public Font getFont(Style style) { public Font getFont() { return JFaceResources.getFontRegistry().get(fFontName); - } public int getFontWidth() { @@ -314,4 +247,8 @@ public int getCharOffset(char c) { return 0; return fOffsets[c]; } + + public void updateColors(Map colorMap) { + fColorMap.putAll(colorMap); + } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 5913fde1d9b..493b8b17c88 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; @@ -35,11 +36,14 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener; +import org.eclipse.tm.terminal.model.TerminalColor; /** * A cell oriented Canvas. Maintains a list of "cells". @@ -369,6 +373,12 @@ protected void drawLine(GC gc, int line, int x, int y, int colFirst, int colLast } @Override + protected Color getTerminalBackgroundColor(Device device) { + return fCellRenderer.getDefaultBackgroundColor(device); + } + + @Override + @Deprecated protected Color getTerminalBackgroundColor() { return fCellRenderer.getDefaultBackgroundColor(); } @@ -490,6 +500,11 @@ public void updateFont(String fontName) { calculateGrid(); } + public void updateColors(Map map) { + fCellRenderer.updateColors(map); + redraw(); + } + public void setInvertedColors(boolean invert) { fCellRenderer.setInvertedColors(invert); redraw(); @@ -520,4 +535,5 @@ public void addTerminalMouseListener(final ITerminalMouseListener listener) { public void removeTerminalMouseListener(ITerminalMouseListener listener) { fMouseListeners.remove(listener); } + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 88babe72d6e..6f4cc343fbe 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -16,26 +16,32 @@ *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; +import java.util.Map; + import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; import org.eclipse.tm.terminal.model.LineSegment; -import org.eclipse.tm.terminal.model.Style; +import org.eclipse.tm.terminal.model.TerminalColor; +import org.eclipse.tm.terminal.model.TerminalStyle; /** * */ public class TextLineRenderer implements ILinelRenderer { private final ITextCanvasModel fModel; - StyleMap fStyleMap = new StyleMap(); + private final StyleMap fStyleMap; public TextLineRenderer(TextCanvas c, ITextCanvasModel model) { fModel = model; + fStyleMap = new StyleMap(); } @Override @@ -65,7 +71,7 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int LineSegment[] segments = getTerminalText().getLineSegments(line, colFirst, colLast - colFirst); for (int i = 0; i < segments.length; i++) { LineSegment segment = segments[i]; - Style style = segment.getStyle(); + TerminalStyle style = segment.getStyle(); setupGC(doubleBufferGC, style); String text = segment.getText(); drawText(doubleBufferGC, 0, 0, colFirst, segment.getColumn(), text); @@ -102,7 +108,7 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int private void fillBackground(GC gc, int x, int y, int width, int height) { Color bg = gc.getBackground(); - gc.setBackground(getDefaultBackgroundColor()); + gc.setBackground(getDefaultBackgroundColor(gc.getDevice())); gc.fillRectangle(x, y, width, height); gc.setBackground(bg); @@ -110,8 +116,14 @@ private void fillBackground(GC gc, int x, int y, int width, int height) { @Override public Color getDefaultBackgroundColor() { + return getDefaultBackgroundColor(Display.getDefault()); + } + + @Override + public Color getDefaultBackgroundColor(Device device) { // null == default style - return fStyleMap.getBackgroundColor(null); + RGB backgroundRGB = fStyleMap.getBackgroundRGB(null); + return new Color(device, backgroundRGB); } private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) { @@ -122,10 +134,10 @@ private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, in if (row == cursorLine) { int cursorColumn = model.getCursorColumn(); if (cursorColumn < getTerminalText().getWidth()) { - Style style = getTerminalText().getStyle(row, cursorColumn); + TerminalStyle style = getTerminalText().getStyle(row, cursorColumn); if (style == null) { // TODO make the cursor color customizable - style = Style.getStyle("BLACK", "WHITE"); //$NON-NLS-1$//$NON-NLS-2$ + style = TerminalStyle.getStyle(TerminalColor.FOREGROUND, TerminalColor.BACKGROUND); } style = style.setReverse(!style.isReverse()); setupGC(gc, style); @@ -156,9 +168,12 @@ private void drawText(GC gc, int x, int y, int colFirst, int col, String text) { } } - private void setupGC(GC gc, Style style) { - gc.setForeground(fStyleMap.getForegrondColor(style)); - gc.setBackground(fStyleMap.getBackgroundColor(style)); + private void setupGC(GC gc, TerminalStyle style) { + RGB foregrondColor = fStyleMap.getForegrondRGB(style); + gc.setForeground(new Color(gc.getDevice(), foregrondColor)); + RGB backgroundColor = fStyleMap.getBackgroundRGB(style); + gc.setBackground(new Color(gc.getDevice(), backgroundColor)); + Font f = fStyleMap.getFont(style); if (f != gc.getFont()) { gc.setFont(f); @@ -183,6 +198,11 @@ public void updateFont(String fontName) { fStyleMap.updateFont(fontName); } + @Override + public void updateColors(Map map) { + fStyleMap.updateColors(map); + } + @Override public void setInvertedColors(boolean invert) { fStyleMap.setInvertedColors(invert); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java index af4d794dc3e..2fc846e7dbc 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java @@ -15,6 +15,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; @@ -136,6 +137,12 @@ protected void repaint(Rectangle r) { */ abstract protected void paint(GC gc); + abstract protected Color getTerminalBackgroundColor(Device device); + + /** + * @deprecated Use {@link #getTerminalBackgroundColor(Device)} + */ + @Deprecated protected Color getTerminalBackgroundColor() { // return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); return getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java index 37a85731e45..37a563284b2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextData.java @@ -15,7 +15,7 @@ package org.eclipse.tm.terminal.model; /** - * A writable matrix of characters and {@link Style}. This is intended to be the + * A writable matrix of characters and {@link TerminalStyle}. This is intended to be the * low level representation of the text of a Terminal. Higher layers are * responsible to fill the text and styles into this representation. *

            @@ -41,33 +41,36 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { int getMaxHeight(); /** - * Set a single character and the associated {@link Style}. + * Set a single character and the associated {@link TerminalStyle}. * @param line line must be >=0 and < height * @param column column must be >=0 and < width * @param c the new character at this position * @param style the style or null + * @since 5.0 */ - void setChar(int line, int column, char c, Style style); + void setChar(int line, int column, char c, TerminalStyle style); /** - * Set an array of characters showing in the same {@link Style}. + * Set an array of characters showing in the same {@link TerminalStyle}. * @param line line must be >=0 and < height * @param column column must be >=0 and < width * @param chars the new characters at this position * @param style the style or null + * @since 5.0 */ - void setChars(int line, int column, char[] chars, Style style); + void setChars(int line, int column, char[] chars, TerminalStyle style); /** - * Set a subrange of an array of characters showing in the same {@link Style}. + * Set a subrange of an array of characters showing in the same {@link TerminalStyle}. * @param line line must be >=0 and < height * @param column column must be >=0 and < width * @param chars the new characters at this position * @param start the start index in the chars array * @param len the number of characters to insert. Characters beyond width are not inserted. * @param style the style or null + * @since 5.0 */ - 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, TerminalStyle style); /** * Cleans the entire line. @@ -77,7 +80,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { /** * Shifts some lines up or down. The "empty" space is filled with '\000' chars - * and null {@link Style} + * and null {@link TerminalStyle} *

            To illustrate shift, here is some sample data: *

             	 * 0 aaaa
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java
            index d935b409a71..af30864e56f 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java
            @@ -49,8 +49,9 @@ public interface ITerminalTextDataReadOnly {
             	 * @param line must be >=0 and < height
             	 * @param column must be >=0 and < width
             	 * @return style at column,line or null
            +	 * @since 5.0
             	 */
            -	Style getStyle(int line, int column);
            +	TerminalStyle getStyle(int line, int column);
             
             	/**
             	 * Creates a new instance of {@link ITerminalTextDataSnapshot} that
            @@ -67,7 +68,10 @@ public interface ITerminalTextDataReadOnly {
             
             	char[] getChars(int line);
             
            -	Style[] getStyles(int line);
            +	/**
            +	 * @since 5.0
            +	 */
            +	TerminalStyle[] getStyles(int line);
             
             	/**
             	 * @return the line in which the cursor is at the moment
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java
            index d92100fd6ce..548dc705891 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/LineSegment.java
            @@ -13,15 +13,21 @@
             public class LineSegment {
             	private final String fText;
             	private final int fCol;
            -	private final Style fStyle;
            +	private final TerminalStyle fStyle;
             
            -	public LineSegment(int col, String text, Style style) {
            +	/**
            +	 * @since 5.0
            +	 */
            +	public LineSegment(int col, String text, TerminalStyle style) {
             		fCol = col;
             		fText = text;
             		fStyle = style;
             	}
             
            -	public Style getStyle() {
            +	/**
            +	 * @since 5.0
            +	 */
            +	public TerminalStyle getStyle() {
             		return fStyle;
             	}
             
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java
            deleted file mode 100644
            index e05d17e9eb7..00000000000
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/Style.java
            +++ /dev/null
            @@ -1,192 +0,0 @@
            -/*******************************************************************************
            - * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others.
            - * All rights reserved. This program and the accompanying materials
            - * are made available under the terms of the Eclipse Public License 2.0
            - * which accompanies this distribution, and is available at
            - * https://www.eclipse.org/legal/epl-2.0/
            - *
            - * Contributors:
            - * Michael Scharf (Wind River) - initial API and implementation
            - *******************************************************************************/
            -package org.eclipse.tm.terminal.model;
            -
            -import java.util.Collections;
            -import java.util.LinkedHashMap;
            -import java.util.Map;
            -
            -import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
            -import org.eclipse.tm.internal.terminal.provisional.api.Logger;
            -
            -/**
            - * @author scharf
            - * Flyweight
            - * Threadsafe.
            - *
            - */
            -// TODO add an Object for user data, use weak map to keep track of styles with associated
            -// user data
            -public class Style {
            -	private final StyleColor fForground;
            -	private final StyleColor fBackground;
            -	private final boolean fBold;
            -	private final boolean fBlink;
            -	private final boolean fUnderline;
            -	private final boolean fReverse;
            -	private final static Map fgStyles = Collections.synchronizedMap(new LinkedHashMap() {
            -		@Override
            -		protected boolean removeEldestEntry(Map.Entry eldest) {
            -			int size = size();
            -			boolean removeEldest = size >= 1000;
            -			if (TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) {
            -				if (removeEldest) {
            -					Logger.log("Removing eldest Style from style cache, size = " + size); //$NON-NLS-1$
            -				} else {
            -					Logger.log("Leaving eldest Style in style cache, size = " + size); //$NON-NLS-1$
            -				}
            -			}
            -			return removeEldest;
            -		}
            -	});
            -
            -	private Style(StyleColor forground, StyleColor background, boolean bold, boolean blink, boolean underline,
            -			boolean reverse) {
            -		fForground = forground;
            -		fBackground = background;
            -		fBold = bold;
            -		fBlink = blink;
            -		fUnderline = underline;
            -		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);
            -		// If set had a computeIfAbsent we would use a set, instead just store 1-2-1 mapping
            -		return fgStyles.computeIfAbsent(style, (s) -> style);
            -	}
            -
            -	public static Style getStyle(String forground, String background) {
            -		return getStyle(StyleColor.getStyleColor(forground), StyleColor.getStyleColor(background), false, false, false,
            -				false);
            -	}
            -
            -	public static Style getStyle(StyleColor forground, StyleColor background) {
            -		return getStyle(forground, background, false, false, false, false);
            -	}
            -
            -	public Style setForground(StyleColor forground) {
            -		return getStyle(forground, fBackground, fBold, fBlink, fUnderline, fReverse);
            -	}
            -
            -	public Style setBackground(StyleColor background) {
            -		return getStyle(fForground, background, fBold, fBlink, fUnderline, fReverse);
            -	}
            -
            -	public Style setForground(String colorName) {
            -		return getStyle(StyleColor.getStyleColor(colorName), fBackground, fBold, fBlink, fUnderline, fReverse);
            -	}
            -
            -	public Style setBackground(String colorName) {
            -		return getStyle(fForground, StyleColor.getStyleColor(colorName), fBold, fBlink, fUnderline, fReverse);
            -	}
            -
            -	public Style setBold(boolean bold) {
            -		return getStyle(fForground, fBackground, bold, fBlink, fUnderline, fReverse);
            -	}
            -
            -	public Style setBlink(boolean blink) {
            -		return getStyle(fForground, fBackground, fBold, blink, fUnderline, fReverse);
            -	}
            -
            -	public Style setUnderline(boolean underline) {
            -		return getStyle(fForground, fBackground, fBold, fBlink, underline, fReverse);
            -	}
            -
            -	public Style setReverse(boolean reverse) {
            -		return getStyle(fForground, fBackground, fBold, fBlink, fUnderline, reverse);
            -	}
            -
            -	public StyleColor getBackground() {
            -		return fBackground;
            -	}
            -
            -	public boolean isBlink() {
            -		return fBlink;
            -	}
            -
            -	public boolean isBold() {
            -		return fBold;
            -	}
            -
            -	public StyleColor getForground() {
            -		return fForground;
            -	}
            -
            -	public boolean isReverse() {
            -		return fReverse;
            -	}
            -
            -	public boolean isUnderline() {
            -		return fUnderline;
            -	}
            -
            -	@Override
            -	public int hashCode() {
            -		final int prime = 31;
            -		int result = 1;
            -		result = prime * result + ((fBackground == null) ? 0 : fBackground.hashCode());
            -		result = prime * result + (fBlink ? 1231 : 1237);
            -		result = prime * result + (fBold ? 1231 : 1237);
            -		result = prime * result + ((fForground == null) ? 0 : fForground.hashCode());
            -		result = prime * result + (fReverse ? 1231 : 1237);
            -		result = prime * result + (fUnderline ? 1231 : 1237);
            -		return result;
            -	}
            -
            -	@Override
            -	public boolean equals(Object obj) {
            -		if (this == obj)
            -			return true;
            -		if (obj == null)
            -			return false;
            -		if (getClass() != obj.getClass())
            -			return false;
            -		final Style other = (Style) obj;
            -		// background == is the same as equals
            -		if (fBackground != other.fBackground)
            -			return false;
            -		if (fBlink != other.fBlink)
            -			return false;
            -		if (fBold != other.fBold)
            -			return false;
            -		if (fForground != other.fForground)
            -			return false;
            -		if (fReverse != other.fReverse)
            -			return false;
            -		if (fUnderline != other.fUnderline)
            -			return false;
            -		return true;
            -	}
            -
            -	@Override
            -	public String toString() {
            -		StringBuffer result = new StringBuffer();
            -		result.append("Style(foreground="); //$NON-NLS-1$
            -		result.append(fForground);
            -		result.append(", background="); //$NON-NLS-1$
            -		result.append(fBackground);
            -		if (fBlink)
            -			result.append(", blink"); //$NON-NLS-1$
            -		if (fBold)
            -			result.append(", bold"); //$NON-NLS-1$
            -		if (fBlink)
            -			result.append(", blink"); //$NON-NLS-1$
            -		if (fReverse)
            -			result.append(", reverse"); //$NON-NLS-1$
            -		if (fUnderline)
            -			result.append(", underline"); //$NON-NLS-1$
            -		result.append(")"); //$NON-NLS-1$
            -		return result.toString();
            -	}
            -
            -}
            \ No newline at end of file
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java
            deleted file mode 100644
            index be4611fb880..00000000000
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/StyleColor.java
            +++ /dev/null
            @@ -1,56 +0,0 @@
            -/*******************************************************************************
            - * Copyright (c) 2007, 2018 Wind River Systems, Inc. and others.
            - * All rights reserved. This program and the accompanying materials
            - * are made available under the terms of the Eclipse Public License 2.0
            - * which accompanies this distribution, and is available at
            - * https://www.eclipse.org/legal/epl-2.0/
            - *
            - * Contributors:
            - * Michael Scharf (Wind River) - initial API and implementation
            - *******************************************************************************/
            -package org.eclipse.tm.terminal.model;
            -
            -import java.util.HashMap;
            -import java.util.Map;
            -
            -/**
            - *
            - * Flyweight
            - * Threadsafe.
            - */
            -public class StyleColor {
            -	private final static Map fgStyleColors = new HashMap<>();
            -	final String fName;
            -
            -	/**
            -	 * @param name the name of the color. It is up to the UI to associate a
            -	 * named color with a visual representation
            -	 * @return a StyleColor
            -	 */
            -	public static StyleColor getStyleColor(String name) {
            -		StyleColor result;
            -		synchronized (fgStyleColors) {
            -			result = fgStyleColors.get(name);
            -			if (result == null) {
            -				result = new StyleColor(name);
            -				fgStyleColors.put(name, result);
            -			}
            -		}
            -		return result;
            -	}
            -
            -	// nobody except the factory method is allowed to instantiate this class!
            -	private StyleColor(String name) {
            -		fName = name;
            -	}
            -
            -	public String getName() {
            -		return fName;
            -	}
            -
            -	@Override
            -	public String toString() {
            -		return fName;
            -	}
            -	// no need to override equals and hashCode, because Object uses object identity
            -}
            \ No newline at end of file
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java
            new file mode 100644
            index 00000000000..6ed0a1e89a3
            --- /dev/null
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java
            @@ -0,0 +1,168 @@
            +/*******************************************************************************
            + * Copyright (c) 2020 Kichwa Coders Canada Inc. and others.
            + * All rights reserved. This program and the accompanying materials
            + * are made available under the terms of the Eclipse Public License 2.0
            + * which accompanies this distribution, and is available at
            + * https://www.eclipse.org/legal/epl-2.0/
            + *
            + * SPDX-License-Identifier: EPL-2.0
            + *******************************************************************************/
            +package org.eclipse.tm.terminal.model;
            +
            +import org.eclipse.core.runtime.Assert;
            +import org.eclipse.jface.resource.ColorDescriptor;
            +import org.eclipse.swt.graphics.Color;
            +import org.eclipse.swt.graphics.RGB;
            +import org.eclipse.swt.widgets.Display;
            +
            +/**
            + * Colors that can be used in the Terminal are represented by this class. The enum contains
            + * the colors with well known names defined by the ANSI Escape Sequences, plus other colors needed
            + * to render a display (such as Background color).
            + *
            + * @since 5.0
            + */
            +public enum TerminalColor {
            +	BLACK, //
            +	RED, //
            +	GREEN, //
            +	YELLOW, //
            +	BLUE, //
            +	MAGENTA, //
            +	CYAN, //
            +	WHITE, //
            +
            +	BRIGHT_BLACK, //
            +	BRIGHT_RED, //
            +	BRIGHT_GREEN, //
            +	BRIGHT_YELLOW, //
            +	BRIGHT_BLUE, //
            +	BRIGHT_MAGENTA, //
            +	BRIGHT_CYAN, //
            +	BRIGHT_WHITE, //
            +
            +	FOREGROUND, //
            +	BACKGROUND, //
            +	SELECTION_FOREGROUND, //
            +	SELECTION_BACKGROUND;
            +
            +	/**
            +	 * The first 16-items in the 8-bit lookup table map to the user changeable colors
            +	 * above, so this array handles that mapping.
            +	 */
            +	private final static TerminalColor table8bitIndexedTerminalColors[] = new TerminalColor[16];
            +
            +	/**
            +	 * The rest of the colors in the lookup table (240 colors) are pre-defined by
            +	 * the standard. The colors that fill this table were derived from
            +	 * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit which was more
            +	 * digestible and accessible than the underlying ITU and ISO standards.
            +	 */
            +	private final static RGB table8bitIndexedRGB[] = new RGB[256 - 16];
            +
            +	/**
            +	 * Color to use instead when inverted color is selected
            +	 */
            +	private TerminalColor invertColor;
            +
            +	/**
            +	 * Color to use instead when bright color is selected
            +	 */
            +	private TerminalColor brightColor;
            +
            +	/**
            +	 * Pre-calculate the lookup tables for 8-bit colors, inverses and equivalent brights.
            +	 */
            +	static {
            +		TerminalColor[] values = TerminalColor.values();
            +
            +		// 8-bit color lookup tables
            +		{
            +			int index = 0;
            +			for (; index < 16; index++) {
            +				TerminalColor c = values[index];
            +				table8bitIndexedTerminalColors[index] = c;
            +			}
            +
            +			int vals[] = { 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff };
            +			Assert.isTrue(index == 16);
            +			for (int r = 0; r < 6; r++) {
            +				for (int g = 0; g < 6; g++) {
            +					for (int b = 0; b < 6; b++) {
            +						table8bitIndexedRGB[index++ - 16] = new RGB(vals[r], vals[g], vals[b]);
            +					}
            +				}
            +			}
            +
            +			int greys[] = { 0x08, 0x12, 0x1c, 0x26, 0x30, 0x3a, 0x44, 0x4e, 0x58, 0x62, 0x6c, 0x76, 0x80, 0x8a, 0x94,
            +					0x9e, 0xa8, 0xb2, 0xbc, 0xc6, 0xd0, 0xda, 0xe4, 0xee };
            +
            +			Assert.isTrue(index == 232);
            +			for (int g : greys) {
            +				table8bitIndexedRGB[index++ - 16] = new RGB(g, g, g);
            +			}
            +			Assert.isTrue(index == 256);
            +		}
            +
            +		// bright equivalents
            +		{
            +			// The second set of 8 colors are the bright of the first 8.
            +			for (int i = 0; i < 8; i++) {
            +				values[i].brightColor = values[i + 8];
            +			}
            +			// The rest of the colors are not brightened
            +			for (int i = 8; i < values.length; i++) {
            +				values[i].brightColor = values[i];
            +			}
            +		}
            +
            +		// inverses
            +		{
            +			// by default make all colors invert of themself
            +			for (int i = 0; i < values.length; i++) {
            +				values[i].invertColor = values[i];
            +			}
            +			// and then mark the colors that are actual inverts
            +			inverts(BLACK, WHITE);
            +			inverts(BRIGHT_BLACK, BRIGHT_WHITE);
            +			inverts(BACKGROUND, FOREGROUND);
            +		}
            +
            +	}
            +
            +	private static void inverts(TerminalColor a, TerminalColor b) {
            +		a.invertColor = b;
            +		b.invertColor = a;
            +	}
            +
            +	/**
            +	 * Return a new color for the given color with inversions or brightness attributes applied.
            +	 *
            +	 * @param invert For invertible colors, return the inverse (typically white <-> black)
            +	 * @param bright returns the brighter version of the color if one is available
            +	 * @return {@link ColorDescriptor} that a {@link Color} can be made from
            +	 *     using {@link ColorDescriptor#createColor(org.eclipse.swt.graphics.Device)}
            +	 * @throws NullPointerException if there is no current {@link Display}
            +	 */
            +	public TerminalColor convertColor(boolean invert, boolean bright) {
            +		TerminalColor selected = this;
            +		// it doesn't matter which order you apply bright and invert, you get to
            +		// the same color when both are set
            +		if (invert) {
            +			selected = selected.invertColor;
            +		}
            +		if (bright) {
            +			selected = selected.brightColor;
            +		}
            +		return selected;
            +	}
            +
            +	/**
            +	 * FOR TEST ONLY.
            +	 *
            +	 * @noreference This enum method is not intended to be referenced by clients.
            +	 */
            +	public static TerminalColor getForTest(int c) {
            +		return TerminalColor.values()[c % TerminalColor.values().length];
            +	}
            +}
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java
            new file mode 100644
            index 00000000000..f63d0f0be2b
            --- /dev/null
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java
            @@ -0,0 +1,193 @@
            +/*******************************************************************************
            + * Copyright (c) 2007, 2020 Wind River Systems, Inc. and others.
            + * All rights reserved. This program and the accompanying materials
            + * are made available under the terms of the Eclipse Public License 2.0
            + * which accompanies this distribution, and is available at
            + * https://www.eclipse.org/legal/epl-2.0/
            + *
            + * Contributors:
            + * Michael Scharf (Wind River) - initial API and implementation
            + *******************************************************************************/
            +package org.eclipse.tm.terminal.model;
            +
            +import java.util.Collections;
            +import java.util.LinkedHashMap;
            +import java.util.Map;
            +
            +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
            +import org.eclipse.tm.internal.terminal.provisional.api.Logger;
            +
            +/**
            + * @author scharf
            + * Flyweight
            + * Threadsafe.
            + * @since 5.0
            + *
            + */
            +// TODO add an Object for user data, use weak map to keep track of styles with associated
            +// user data
            +public class TerminalStyle {
            +	private final TerminalColor fForegroundTerminalColor;
            +	private final TerminalColor fBackgroundTerminalColor;
            +	private final boolean fBold;
            +	private final boolean fBlink;
            +	private final boolean fUnderline;
            +	private final boolean fReverse;
            +	private final static Map fgStyles = Collections
            +			.synchronizedMap(new LinkedHashMap() {
            +				@Override
            +				protected boolean removeEldestEntry(Map.Entry eldest) {
            +					int size = size();
            +					boolean removeEldest = size >= 1000;
            +					if (TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) {
            +						if (removeEldest) {
            +							Logger.log("Removing eldest Style from style cache, size = " + size); //$NON-NLS-1$
            +						} else {
            +							Logger.log("Leaving eldest Style in style cache, size = " + size); //$NON-NLS-1$
            +						}
            +					}
            +					return removeEldest;
            +				}
            +			});
            +
            +	private TerminalStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor, boolean bold,
            +			boolean blink, boolean underline, boolean reverse) {
            +		fForegroundTerminalColor = foregroundTerminalColor;
            +		fBackgroundTerminalColor = backgroundTerminalColor;
            +		fBold = bold;
            +		fBlink = blink;
            +		fUnderline = underline;
            +		fReverse = reverse;
            +	}
            +
            +	public static TerminalStyle getStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor,
            +			boolean bold, boolean blink, boolean underline, boolean reverse) {
            +		TerminalStyle style = new TerminalStyle(foregroundTerminalColor, backgroundTerminalColor, bold, blink,
            +				underline, reverse);
            +		// If set had a computeIfAbsent we would use a set, instead just store 1-2-1 mapping
            +		return fgStyles.computeIfAbsent(style, (s) -> style);
            +	}
            +
            +	public static TerminalStyle getDefaultStyle() {
            +		return getStyle(TerminalColor.FOREGROUND, TerminalColor.BACKGROUND);
            +	}
            +
            +	public static TerminalStyle getStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor) {
            +		return getStyle(foregroundTerminalColor, backgroundTerminalColor, false, false, false, false);
            +	}
            +
            +	public TerminalStyle setForeground(TerminalColor foregroundTerminalColor) {
            +		return getStyle(foregroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setBackground(TerminalColor backgroundTerminalColor) {
            +		return getStyle(fForegroundTerminalColor, backgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setForeground(TerminalStyle other) {
            +		return getStyle(other.fForegroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setBackground(TerminalStyle other) {
            +		return getStyle(fForegroundTerminalColor, other.fBackgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setBold(boolean bold) {
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, bold, fBlink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setBlink(boolean blink) {
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fBold, blink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setUnderline(boolean underline) {
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, underline, fReverse);
            +	}
            +
            +	public TerminalStyle setReverse(boolean reverse) {
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, fUnderline, reverse);
            +	}
            +
            +	public TerminalColor getForegroundTerminalColor() {
            +		return fForegroundTerminalColor;
            +	}
            +
            +	public TerminalColor getBackgroundTerminalColor() {
            +		return fBackgroundTerminalColor;
            +	}
            +
            +	public boolean isBlink() {
            +		return fBlink;
            +	}
            +
            +	public boolean isBold() {
            +		return fBold;
            +	}
            +
            +	public boolean isReverse() {
            +		return fReverse;
            +	}
            +
            +	public boolean isUnderline() {
            +		return fUnderline;
            +	}
            +
            +	@Override
            +	public int hashCode() {
            +		final int prime = 31;
            +		int result = 1;
            +		result = prime * result + ((fBackgroundTerminalColor == null) ? 0 : fBackgroundTerminalColor.hashCode());
            +		result = prime * result + (fBlink ? 1231 : 1237);
            +		result = prime * result + (fBold ? 1231 : 1237);
            +		result = prime * result + ((fForegroundTerminalColor == null) ? 0 : fForegroundTerminalColor.hashCode());
            +		result = prime * result + (fReverse ? 1231 : 1237);
            +		result = prime * result + (fUnderline ? 1231 : 1237);
            +		return result;
            +	}
            +
            +	@Override
            +	public boolean equals(Object obj) {
            +		if (this == obj)
            +			return true;
            +		if (obj == null)
            +			return false;
            +		if (getClass() != obj.getClass())
            +			return false;
            +		TerminalStyle other = (TerminalStyle) obj;
            +		if (fBackgroundTerminalColor != other.fBackgroundTerminalColor)
            +			return false;
            +		if (fBlink != other.fBlink)
            +			return false;
            +		if (fBold != other.fBold)
            +			return false;
            +		if (fForegroundTerminalColor != other.fForegroundTerminalColor)
            +			return false;
            +		if (fReverse != other.fReverse)
            +			return false;
            +		if (fUnderline != other.fUnderline)
            +			return false;
            +		return true;
            +	}
            +
            +	@Override
            +	public String toString() {
            +		StringBuffer result = new StringBuffer();
            +		result.append("Style(foreground="); //$NON-NLS-1$
            +		result.append(fForegroundTerminalColor);
            +		result.append(", background="); //$NON-NLS-1$
            +		result.append(fBackgroundTerminalColor);
            +		if (fBlink)
            +			result.append(", blink"); //$NON-NLS-1$
            +		if (fBold)
            +			result.append(", bold"); //$NON-NLS-1$
            +		if (fBlink)
            +			result.append(", blink"); //$NON-NLS-1$
            +		if (fReverse)
            +			result.append(", reverse"); //$NON-NLS-1$
            +		if (fUnderline)
            +			result.append(", underline"); //$NON-NLS-1$
            +		result.append(")"); //$NON-NLS-1$
            +		return result.toString();
            +	}
            +
            +}
            
            From 8e4007435d1e4c000ec5bd3e5b546e48d4dac003 Mon Sep 17 00:00:00 2001
            From: Jonah Graham 
            Date: Sun, 10 May 2020 14:39:08 -0400
            Subject: [PATCH 33/76] Bug 540737: Add 8 and 24-bit color support to terminal
            
            Change-Id: Iab3b648fb3bfa8f43f333371bd118e90a3a182f2
            ---
             .../terminal/emulator/VT100Emulator.java      | 130 +++++++++++++++++-
             .../terminal/textcanvas/StyleMap.java         |  20 +++
             .../tm/terminal/model/TerminalColor.java      |  43 +++++-
             .../tm/terminal/model/TerminalStyle.java      | 124 ++++++++++++++---
             4 files changed, 296 insertions(+), 21 deletions(-)
            
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java
            index f6c20042b25..03baff99903 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java
            @@ -40,9 +40,11 @@
             
             import java.io.IOException;
             import java.io.Reader;
            +import java.util.Arrays;
             
             import org.eclipse.swt.events.ControlEvent;
             import org.eclipse.swt.events.ControlListener;
            +import org.eclipse.swt.graphics.RGB;
             import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
             import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
             import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
            @@ -859,6 +861,19 @@ private void processAnsiCommand_m() {
             
             		while (parameterIndex < totalParameters && ansiParameters[parameterIndex].length() > 0) {
             			int ansiParameter = getAnsiParameter(parameterIndex);
            +			if (ansiParameter == 1) {
            +				String parameter = ansiParameters[parameterIndex].toString();
            +				// Special case for  ITU's T.416 foreground/background color specification
            +				// which uses : to separate parameters instead of ;
            +				if (parameter.startsWith("38:") || parameter.startsWith("48:")) { //$NON-NLS-1$ //$NON-NLS-2$
            +					String[] split = parameter.split(":"); //$NON-NLS-1$
            +					ProcessExtendedColorsReturn retval = processExtendedColors(split, style, true);
            +					style = retval.style();
            +					parameterIndex++;
            +					continue;
            +				}
            +
            +			}
             
             			switch (ansiParameter) {
             			case 0:
            @@ -974,6 +989,14 @@ private void processAnsiCommand_m() {
             				style = style.setBackground(text.getDefaultStyle());
             				break;
             
            +			case 38: // Foreground color defined by sequence
            +			case 48: // Background color defined by sequence
            +				CharSequence[] params = Arrays.copyOfRange(ansiParameters, parameterIndex, ansiParameters.length);
            +				ProcessExtendedColorsReturn retval = processExtendedColors(params, style, false);
            +				parameterIndex += retval.consumed() - 1;
            +				style = retval.style();
            +				break;
            +
             			default:
             				Logger.log("Unsupported graphics rendition parameter: " + ansiParameter); //$NON-NLS-1$
             				break;
            @@ -984,6 +1007,110 @@ private void processAnsiCommand_m() {
             		text.setStyle(style);
             	}
             
            +	private interface ProcessExtendedColorsReturn {
            +		/**
            +		 * @return the new style
            +		 */
            +		TerminalStyle style();
            +
            +		/**
            +		 * @return number of parameters consumed
            +		 */
            +		int consumed();
            +	}
            +
            +	/**
            +	 *
            +	 * @param params array of parameters, starting with 38 or 48 being the command
            +	 * @param colorspace if a colorspace may be included (ITU T.416 mode)
            +	 */
            +	private ProcessExtendedColorsReturn processExtendedColors(CharSequence[] paramStrings, TerminalStyle style,
            +			boolean colorspace) {
            +		int params[] = new int[paramStrings.length];
            +		for (int i = 0; i < params.length; i++) {
            +			try {
            +				int parseInt = Integer.parseInt(paramStrings[i].toString());
            +				int inMagnitude = parseInt % 256;
            +				int inRange = inMagnitude < 0 ? inMagnitude + 256 : inMagnitude;
            +				params[i] = inRange;
            +			} catch (NumberFormatException ex) {
            +				params[i] = 0;
            +			}
            +		}
            +
            +		boolean foreground = params[0] == 38;
            +		int consumed = 1;
            +		if (params.length > 1) {
            +			int colorDepth = params[1];
            +			switch (colorDepth) {
            +			case 2: // 24-bit RGB color
            +				int r = 0, g = 0, b = 0;
            +				if (colorspace) {
            +					if (params.length < 6) {
            +						Logger.log(
            +								"Not enough parameters for 24-bit color depth, expected 5, one for color space and one for each of RGB"); //$NON-NLS-1$
            +					}
            +				} else {
            +					if (params.length < 5) {
            +						Logger.log("Not enough parameters for 24-bit color depth, expected 3, one for each of RGB"); //$NON-NLS-1$
            +					}
            +				}
            +				int start = colorspace ? 3 : 2;
            +				if (params.length > start + 0) {
            +					r = params[start + 0];
            +				}
            +				if (params.length > start + 1) {
            +					g = params[start + 1];
            +				}
            +				if (params.length > start + 2) {
            +					b = params[start + 2];
            +				}
            +
            +				RGB rgb = new RGB(r, g, b);
            +				if (foreground) {
            +					style = style.setForeground(rgb);
            +				} else {
            +					style = style.setBackground(rgb);
            +				}
            +				consumed = Math.min(6, params.length);
            +				break;
            +			case 5: // 8-bit color table lookup
            +				int index = 0;
            +				if (params.length < 3) {
            +					Logger.log("Missing parameter for 8-bit color depth"); //$NON-NLS-1$
            +				} else {
            +					index = params[2];
            +				}
            +				if (foreground) {
            +					style = style.setForeground(index);
            +				} else {
            +					style = style.setBackground(index);
            +				}
            +				consumed = Math.min(3, params.length);
            +				break;
            +			default:
            +				Logger.log("Unsupported color depth " + colorDepth + " for: " + params[0]); //$NON-NLS-1$ //$NON-NLS-2$
            +			}
            +
            +		} else {
            +			Logger.log("Missing color depth for " + params[0]); //$NON-NLS-1$
            +		}
            +
            +		TerminalStyle finalStyle = style;
            +		int finalConsumed = consumed;
            +		return new ProcessExtendedColorsReturn() {
            +			@Override
            +			public TerminalStyle style() {
            +				return finalStyle;
            +			}
            +
            +			@Override
            +			public int consumed() {
            +				return finalConsumed;
            +			}
            +		};
            +	}
            +
             	/**
             	 * This method responds to an ANSI Device Status Report (DSR) command from
             	 * the remote endpoint requesting the ready status or the cursor position.
            @@ -1096,7 +1223,7 @@ private void processDecPrivateCommand_l() {
             	 * most recent escape sequence.
             	 *
             	 * @return The parameterIndexth numeric ANSI parameter or -1 if the
            -	 *         index is out of range.
            +	 *         index is out of range or 1 if parse failed (1 is also a legitimate value)
             	 */
             	private int getAnsiParameter(int parameterIndex) {
             		if (parameterIndex < 0 || parameterIndex >= ansiParameters.length) {
            @@ -1109,6 +1236,7 @@ private int getAnsiParameter(int parameterIndex) {
             		if (parameter.length() == 0)
             			return 1;
             
            +		// return 1 on failed parseInt
             		int parameterValue = 1;
             
             		// Don't trust the remote endpoint to send well formed numeric
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
            index badc43b6730..f2af6cbe4de 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
            @@ -74,6 +74,16 @@ private RGB getRGB(TerminalColor color) {
             
             	public RGB getForegrondRGB(TerminalStyle style) {
             		style = defaultIfNull(style);
            +		RGB foregroundRGB;
            +		if (style.isReverse()) {
            +			foregroundRGB = style.getBackgroundRGB();
            +		} else {
            +			foregroundRGB = style.getForegroundRGB();
            +		}
            +		if (foregroundRGB != null) {
            +			return foregroundRGB;
            +		}
            +
             		TerminalColor color;
             		if (style.isReverse()) {
             			color = style.getBackgroundTerminalColor();
            @@ -91,6 +101,16 @@ public RGB getForegrondRGB(TerminalStyle style) {
             
             	public RGB getBackgroundRGB(TerminalStyle style) {
             		style = defaultIfNull(style);
            +		RGB backgroundRGB;
            +		if (style.isReverse()) {
            +			backgroundRGB = style.getForegroundRGB();
            +		} else {
            +			backgroundRGB = style.getBackgroundRGB();
            +		}
            +		if (backgroundRGB != null) {
            +			return backgroundRGB;
            +		}
            +
             		TerminalColor color;
             		if (style.isReverse()) {
             			color = style.getForegroundTerminalColor();
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java
            index 6ed0a1e89a3..0bc12ebabdb 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalColor.java
            @@ -20,6 +20,15 @@
              * the colors with well known names defined by the ANSI Escape Sequences, plus other colors needed
              * to render a display (such as Background color).
              *
            + * Rather than name all the colors when using ANSI 8-bit indexed colors, the indexed colors
            + * can be accessed via the {@link #getIndexedRGBColor(int)} or {@link #getIndexedRGBColor(int)}
            + * (use {@link #isIndexedTerminalColor(int)} to determine which one is appropriate.
            + *
            + * The {@link TerminalStyle} supports any arbitrary color by using {@link RGB} defined colors.
            + * This class provides the connection between the names exposed to the user in preferences
            + * and their use in the terminal, along with how colors change when other attributes (such as
            + * bright and invertColors) are applied to them.
            + *
              * @since 5.0
              */
             public enum TerminalColor {
            @@ -158,11 +167,37 @@ public TerminalColor convertColor(boolean invert, boolean bright) {
             	}
             
             	/**
            -	 * FOR TEST ONLY.
            +	 * Query for whether the 8-bit color index will return a named color, in which case
            +	 * {@link #getIndexedTerminalColor(int)} must be called to get the named color. Use
            +	 * {@link #convertColor(boolean, boolean)} if this method returns false.
            +	 *
            +	 * @param index 8-bit index.
            +	 * @return true for named colors, false for RGB colors
            +	 */
            +	public static boolean isIndexedTerminalColor(int index) {
            +		Assert.isLegal(index >= 0 && index < 256, "Invalid 8-bit table index out of range 0-255"); //$NON-NLS-1$
            +		return index < table8bitIndexedTerminalColors.length && index >= 0;
            +	}
            +
            +	/**
            +	 * Return the named color for the given 8-bit index.
            +	 *
            +	 * @param index 8-bit index in 0-15 range.
            +	 * @return named color
            +	 */
            +	public static TerminalColor getIndexedTerminalColor(int index) {
            +		Assert.isLegal(isIndexedTerminalColor(index), "Invalid table index used for ANSI Color"); //$NON-NLS-1$
            +		return table8bitIndexedTerminalColors[index];
            +	}
            +
            +	/**
            +	 * Return the RGB color for the given 8-bit index.
             	 *
            -	 * @noreference This enum method is not intended to be referenced by clients.
            +	 * @param index 8-bit index in 16-255 range.
            +	 * @return RGB color
             	 */
            -	public static TerminalColor getForTest(int c) {
            -		return TerminalColor.values()[c % TerminalColor.values().length];
            +	public static RGB getIndexedRGBColor(int index) {
            +		Assert.isLegal(index >= 16 && index < 256, "Invalid table index used for RGB Color"); //$NON-NLS-1$
            +		return table8bitIndexedRGB[index - 16];
             	}
             }
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java
            index f63d0f0be2b..d81d4b8466e 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TerminalStyle.java
            @@ -14,6 +14,8 @@
             import java.util.LinkedHashMap;
             import java.util.Map;
             
            +import org.eclipse.core.runtime.Assert;
            +import org.eclipse.swt.graphics.RGB;
             import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
             import org.eclipse.tm.internal.terminal.provisional.api.Logger;
             
            @@ -29,6 +31,8 @@
             public class TerminalStyle {
             	private final TerminalColor fForegroundTerminalColor;
             	private final TerminalColor fBackgroundTerminalColor;
            +	private final RGB fForegroundRGB;
            +	private final RGB fBackgroundRGB;
             	private final boolean fBold;
             	private final boolean fBlink;
             	private final boolean fUnderline;
            @@ -50,10 +54,16 @@ protected boolean removeEldestEntry(Map.Entry elde
             				}
             			});
             
            -	private TerminalStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor, boolean bold,
            -			boolean blink, boolean underline, boolean reverse) {
            +	private TerminalStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor,
            +			RGB foregroundRGB, RGB backgroundRGB, boolean bold, boolean blink, boolean underline, boolean reverse) {
            +		Assert.isLegal(foregroundTerminalColor == null || foregroundRGB == null,
            +				"Only one of ANSI or RGB colors can be specified as a foreground color"); //$NON-NLS-1$
            +		Assert.isLegal(backgroundTerminalColor == null || backgroundRGB == null,
            +				"Only one of ANSI or RGB colors can be specified as a background color"); //$NON-NLS-1$
             		fForegroundTerminalColor = foregroundTerminalColor;
             		fBackgroundTerminalColor = backgroundTerminalColor;
            +		fForegroundRGB = foregroundRGB;
            +		fBackgroundRGB = backgroundRGB;
             		fBold = bold;
             		fBlink = blink;
             		fUnderline = underline;
            @@ -61,51 +71,105 @@ private TerminalStyle(TerminalColor foregroundTerminalColor, TerminalColor backg
             	}
             
             	public static TerminalStyle getStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor,
            -			boolean bold, boolean blink, boolean underline, boolean reverse) {
            -		TerminalStyle style = new TerminalStyle(foregroundTerminalColor, backgroundTerminalColor, bold, blink,
            -				underline, reverse);
            +			RGB foregroundRGB, RGB backgroundRGB, boolean bold, boolean blink, boolean underline, boolean reverse) {
            +		TerminalStyle style = new TerminalStyle(foregroundTerminalColor, backgroundTerminalColor, foregroundRGB,
            +				backgroundRGB, bold, blink, underline, reverse);
             		// If set had a computeIfAbsent we would use a set, instead just store 1-2-1 mapping
             		return fgStyles.computeIfAbsent(style, (s) -> style);
             	}
             
            +	public static TerminalStyle getStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor,
            +			boolean bold, boolean blink, boolean underline, boolean reverse) {
            +		return getStyle(foregroundTerminalColor, backgroundTerminalColor, null, null, bold, blink, underline, reverse);
            +	}
            +
            +	public static TerminalStyle getStyle(RGB foregroundRGB, RGB backgroundRGB, boolean bold, boolean blink,
            +			boolean underline, boolean reverse) {
            +		return getStyle(null, null, foregroundRGB, backgroundRGB, bold, blink, underline, reverse);
            +	}
            +
             	public static TerminalStyle getDefaultStyle() {
             		return getStyle(TerminalColor.FOREGROUND, TerminalColor.BACKGROUND);
             	}
             
             	public static TerminalStyle getStyle(TerminalColor foregroundTerminalColor, TerminalColor backgroundTerminalColor) {
            -		return getStyle(foregroundTerminalColor, backgroundTerminalColor, false, false, false, false);
            +		return getStyle(foregroundTerminalColor, backgroundTerminalColor, null, null, false, false, false, false);
             	}
             
             	public TerminalStyle setForeground(TerminalColor foregroundTerminalColor) {
            -		return getStyle(foregroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +		return getStyle(foregroundTerminalColor, fBackgroundTerminalColor, null, fBackgroundRGB, fBold, fBlink,
            +				fUnderline, fReverse);
             	}
             
             	public TerminalStyle setBackground(TerminalColor backgroundTerminalColor) {
            -		return getStyle(fForegroundTerminalColor, backgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +		return getStyle(fForegroundTerminalColor, backgroundTerminalColor, fForegroundRGB, null, fBold, fBlink,
            +				fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setForeground(RGB foregroundRGB) {
            +		return getStyle(null, fBackgroundTerminalColor, foregroundRGB, fBackgroundRGB, fBold, fBlink, fUnderline,
            +				fReverse);
            +	}
            +
            +	public TerminalStyle setBackground(RGB backgroundRGB) {
            +		return getStyle(fForegroundTerminalColor, null, fForegroundRGB, backgroundRGB, fBold, fBlink, fUnderline,
            +				fReverse);
             	}
             
             	public TerminalStyle setForeground(TerminalStyle other) {
            -		return getStyle(other.fForegroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +		return getStyle(other.fForegroundTerminalColor, fBackgroundTerminalColor, other.fForegroundRGB, fBackgroundRGB,
            +				fBold, fBlink, fUnderline, fReverse);
             	}
             
             	public TerminalStyle setBackground(TerminalStyle other) {
            -		return getStyle(fForegroundTerminalColor, other.fBackgroundTerminalColor, fBold, fBlink, fUnderline, fReverse);
            +		return getStyle(fForegroundTerminalColor, other.fBackgroundTerminalColor, fForegroundRGB, other.fBackgroundRGB,
            +				fBold, fBlink, fUnderline, fReverse);
            +	}
            +
            +	public TerminalStyle setForeground(int eightBitindexedColor) {
            +		boolean isIndexTerminalColor = TerminalColor.isIndexedTerminalColor(eightBitindexedColor);
            +		if (isIndexTerminalColor) {
            +			TerminalColor foregroundTerminalColor = TerminalColor.getIndexedTerminalColor(eightBitindexedColor);
            +			return getStyle(foregroundTerminalColor, fBackgroundTerminalColor, null, fBackgroundRGB, fBold, fBlink,
            +					fUnderline, fReverse);
            +		} else {
            +			RGB foregroundRGB = TerminalColor.getIndexedRGBColor(eightBitindexedColor);
            +			return getStyle(null, fBackgroundTerminalColor, foregroundRGB, fBackgroundRGB, fBold, fBlink, fUnderline,
            +					fReverse);
            +		}
            +	}
            +
            +	public TerminalStyle setBackground(int eightBitindexedColor) {
            +		boolean isIndexTerminalColor = TerminalColor.isIndexedTerminalColor(eightBitindexedColor);
            +		if (isIndexTerminalColor) {
            +			TerminalColor backgroundTerminalColor = TerminalColor.getIndexedTerminalColor(eightBitindexedColor);
            +			return getStyle(fForegroundTerminalColor, backgroundTerminalColor, fForegroundRGB, null, fBold, fBlink,
            +					fUnderline, fReverse);
            +		} else {
            +			RGB backgroundRGB = TerminalColor.getIndexedRGBColor(eightBitindexedColor);
            +			return getStyle(fForegroundTerminalColor, null, fForegroundRGB, backgroundRGB, fBold, fBlink, fUnderline,
            +					fReverse);
            +		}
             	}
             
             	public TerminalStyle setBold(boolean bold) {
            -		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, bold, fBlink, fUnderline, fReverse);
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fForegroundRGB, fBackgroundRGB, bold,
            +				fBlink, fUnderline, fReverse);
             	}
             
             	public TerminalStyle setBlink(boolean blink) {
            -		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fBold, blink, fUnderline, fReverse);
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fForegroundRGB, fBackgroundRGB, fBold,
            +				blink, fUnderline, fReverse);
             	}
             
             	public TerminalStyle setUnderline(boolean underline) {
            -		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, underline, fReverse);
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fForegroundRGB, fBackgroundRGB, fBold,
            +				fBlink, underline, fReverse);
             	}
             
             	public TerminalStyle setReverse(boolean reverse) {
            -		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fBold, fBlink, fUnderline, reverse);
            +		return getStyle(fForegroundTerminalColor, fBackgroundTerminalColor, fForegroundRGB, fBackgroundRGB, fBold,
            +				fBlink, fUnderline, reverse);
             	}
             
             	public TerminalColor getForegroundTerminalColor() {
            @@ -116,6 +180,14 @@ public TerminalColor getBackgroundTerminalColor() {
             		return fBackgroundTerminalColor;
             	}
             
            +	public RGB getForegroundRGB() {
            +		return fForegroundRGB;
            +	}
            +
            +	public RGB getBackgroundRGB() {
            +		return fBackgroundRGB;
            +	}
            +
             	public boolean isBlink() {
             		return fBlink;
             	}
            @@ -137,9 +209,11 @@ public int hashCode() {
             		final int prime = 31;
             		int result = 1;
             		result = prime * result + ((fBackgroundTerminalColor == null) ? 0 : fBackgroundTerminalColor.hashCode());
            +		result = prime * result + ((fBackgroundRGB == null) ? 0 : fBackgroundRGB.hashCode());
             		result = prime * result + (fBlink ? 1231 : 1237);
             		result = prime * result + (fBold ? 1231 : 1237);
             		result = prime * result + ((fForegroundTerminalColor == null) ? 0 : fForegroundTerminalColor.hashCode());
            +		result = prime * result + ((fForegroundRGB == null) ? 0 : fForegroundRGB.hashCode());
             		result = prime * result + (fReverse ? 1231 : 1237);
             		result = prime * result + (fUnderline ? 1231 : 1237);
             		return result;
            @@ -156,12 +230,22 @@ public boolean equals(Object obj) {
             		TerminalStyle other = (TerminalStyle) obj;
             		if (fBackgroundTerminalColor != other.fBackgroundTerminalColor)
             			return false;
            +		if (fBackgroundRGB == null) {
            +			if (other.fBackgroundRGB != null)
            +				return false;
            +		} else if (!fBackgroundRGB.equals(other.fBackgroundRGB))
            +			return false;
             		if (fBlink != other.fBlink)
             			return false;
             		if (fBold != other.fBold)
             			return false;
             		if (fForegroundTerminalColor != other.fForegroundTerminalColor)
             			return false;
            +		if (fForegroundRGB == null) {
            +			if (other.fForegroundRGB != null)
            +				return false;
            +		} else if (!fForegroundRGB.equals(other.fForegroundRGB))
            +			return false;
             		if (fReverse != other.fReverse)
             			return false;
             		if (fUnderline != other.fUnderline)
            @@ -173,9 +257,17 @@ public boolean equals(Object obj) {
             	public String toString() {
             		StringBuffer result = new StringBuffer();
             		result.append("Style(foreground="); //$NON-NLS-1$
            -		result.append(fForegroundTerminalColor);
            +		if (fForegroundTerminalColor != null) {
            +			result.append(fForegroundTerminalColor);
            +		} else {
            +			result.append(fForegroundRGB);
            +		}
             		result.append(", background="); //$NON-NLS-1$
            -		result.append(fBackgroundTerminalColor);
            +		if (fForegroundTerminalColor != null) {
            +			result.append(fBackgroundTerminalColor);
            +		} else {
            +			result.append(fBackgroundRGB);
            +		}
             		if (fBlink)
             			result.append(", blink"); //$NON-NLS-1$
             		if (fBold)
            
            From f478323e6559ed9a8f85eca92cd051deda60d6d0 Mon Sep 17 00:00:00 2001
            From: Jonah Graham 
            Date: Sun, 23 Aug 2020 08:05:03 -0400
            Subject: [PATCH 34/76] Bug 562494: Update BREE to Java 11
            
            Change-Id: I0c91aafc0cb1b179936acbd4c9df2d961899e3fa
            ---
             .../.classpath                                |  2 +-
             .../.settings/org.eclipse.jdt.core.prefs      | 38 +++++++++++++++----
             .../META-INF/MANIFEST.MF                      |  2 +-
             3 files changed, 32 insertions(+), 10 deletions(-)
            
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath
            index ed0eb24c506..edc8895124d 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath
            @@ -1,6 +1,6 @@
             
             
            -	
            +	
             	
             	
             	
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs
            index 2b6ecff8a01..e3a8104f9ca 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs
            @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
             org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
             org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
             org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
            -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
            +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
             org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
            -org.eclipse.jdt.core.compiler.compliance=1.8
            +org.eclipse.jdt.core.compiler.compliance=11
             org.eclipse.jdt.core.compiler.debug.lineNumber=generate
             org.eclipse.jdt.core.compiler.debug.localVariable=generate
             org.eclipse.jdt.core.compiler.debug.sourceFile=generate
            @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
             org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
             org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
             org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
            +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
             org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
             org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
             org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
            @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno
             org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
             org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
             org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
            +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
             org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
             org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
             org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
            @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
             org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
             org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
             org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
            -org.eclipse.jdt.core.compiler.release=disabled
            -org.eclipse.jdt.core.compiler.source=1.8
            +org.eclipse.jdt.core.compiler.release=enabled
            +org.eclipse.jdt.core.compiler.source=11
             org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
             org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
             org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
             org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
             org.eclipse.jdt.core.formatter.align_with_spaces=false
            +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
             org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
             org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
             org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
            @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c
             org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
             org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
             org.eclipse.jdt.core.formatter.alignment_for_assignment=0
            -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
            +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
             org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
             org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
             org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
             org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
             org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
             org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
            +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
             org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
             org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
             org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
            +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
             org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
             org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
             org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
             org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
             org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
            +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
             org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
             org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
             org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
            @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
             org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
             org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
             org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
            +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
             org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
             org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
            -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
            +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
             org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
             org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
            @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
             org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
             org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
             org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
            +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
            +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
             org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
             org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
            @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
             org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
             org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
             org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
            +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
             org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
            +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
            +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
             org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
            +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
             org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
            -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
            +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
            @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no
             org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
            +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
            +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
            @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
             org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
             org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
            +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
             org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
             org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
            +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
            +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
             org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
             org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
             org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
            @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab
             org.eclipse.jdt.core.formatter.tabulation.size=4
             org.eclipse.jdt.core.formatter.use_on_off_tags=true
             org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
            +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
             org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
            -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
            +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
             org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
            +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
            +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
             org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
            +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
             org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
             org.eclipse.jdt.core.incompatibleJDKLevel=ignore
             org.eclipse.jdt.core.incompleteClasspath=error
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF
            index f37c8e4105b..73943f780ef 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF
            @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
              org.eclipse.ui
             Bundle-ActivationPolicy: lazy
             Eclipse-LazyStart: true
            -Bundle-RequiredExecutionEnvironment: JavaSE-1.8
            +Bundle-RequiredExecutionEnvironment: JavaSE-11
             Bundle-ClassPath: .
             Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true,
              org.eclipse.tm.internal.terminal.control,
            
            From 8e192f07c35f32ab3a2873be556ef207f29ff201 Mon Sep 17 00:00:00 2001
            From: Jonah Graham 
            Date: Sun, 30 Aug 2020 16:14:42 -0400
            Subject: [PATCH 35/76] Bug 566511: [releng] Add missing UTF-8 encoding for all
             CDT projects
            
            Includes updates to code cleanliness script
            
            Change-Id: Ic495124285e3e002993f34dc12be5ad7337fe13b
            ---
             .../.settings/org.eclipse.core.resources.prefs                  | 2 +-
             1 file changed, 1 insertion(+), 1 deletion(-)
            
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs
            index 775bde20f32..99f26c0203a 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.core.resources.prefs
            @@ -1,2 +1,2 @@
             eclipse.preferences.version=1
            -encoding//src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java=UTF-8
            +encoding/=UTF-8
            
            From 70f7320f6e55e2be00384717c214e646b567f031 Mon Sep 17 00:00:00 2001
            From: Jonah Graham 
            Date: Sun, 30 Aug 2020 20:59:37 -0400
            Subject: [PATCH 36/76] Bug 551817: Fix legal docs - and automate their checks
            
            Change-Id: I6f97927f0df64a28e71a2d7ab4c55b609794f751
            ---
             .../about.html                                | 40 +++++++++++--------
             1 file changed, 24 insertions(+), 16 deletions(-)
            
            diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.html b/terminal/plugins/org.eclipse.tm.terminal.control/about.html
            index 62cf4ee7eb8..164f781a8fd 100644
            --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.html
            +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.html
            @@ -2,27 +2,35 @@
                 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
             
             
            -
            +
             About
             
             
            -

            About This Content

            - -

            June 5, 2007

            -

            License

            +

            About This Content

            -

            The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License 2.0 ("EPL"). A copy of the EPL is available -at https://www.eclipse.org/legal/epl-2.0/. -For purposes of the EPL, "Program" will mean the Content.

            +

            November 30, 2017

            +

            License

            -

            If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

            +

            + The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 2.0 ("EPL"). A copy of the EPL is + available at http://www.eclipse.org/legal/epl-2.0. + For purposes of the EPL, "Program" will mean the Content. +

            + +

            + If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL still apply to any source + code in the Content and such source code may be obtained at http://www.eclipse.org. +

            \ No newline at end of file From 9de7bcf9b53b31ccf0077f7a554801bf1556240a Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 7 Sep 2020 09:50:43 -0400 Subject: [PATCH 37/76] Bug 566732: Connect selection preference page to terminal Bug 549697 introduced the new UI for setting colors, but the selection color (while added to the pref page) was never connected to the code. Change-Id: I9934efe595efe141a14f0bca3bdf355f436d907d --- .../tm/internal/terminal/textcanvas/TextLineRenderer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 6f4cc343fbe..d092bc6fc8b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -18,7 +18,6 @@ import java.util.Map; -import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.Font; @@ -78,8 +77,9 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int drawCursor(model, doubleBufferGC, line, 0, 0, colFirst); } if (fModel.hasLineSelection(line)) { - doubleBufferGC.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); - doubleBufferGC.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); + TerminalStyle style = TerminalStyle.getStyle(TerminalColor.SELECTION_FOREGROUND, + TerminalColor.SELECTION_BACKGROUND); + setupGC(doubleBufferGC, style); Point start = model.getSelectionStart(); Point end = model.getSelectionEnd(); char[] chars = model.getTerminalText().getChars(line); From 58581628416056f53f9cb114257c7a66126d0104 Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Sat, 23 Jan 2021 17:28:30 +0100 Subject: [PATCH 38/76] Bug 570588: Some Private CSI sequences are not correctly interpreted CSI commands should be recognised as private if the first character is one of <=>? and not only ? Change-Id: Idca36ba4dc6bb1bcb3d10f921b2315876769ea5b Signed-off-by: Fabrizio Iannetti --- .../META-INF/MANIFEST.MF | 2 +- .../org.eclipse.tm.terminal.control/about.properties | 4 ++-- .../tm/internal/terminal/emulator/VT100Emulator.java | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 73943f780ef..e9749de69dd 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.0.0.qualifier +Bundle-Version: 5.0.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties index e6e6518939a..ad195fd530c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation +# Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -24,7 +24,7 @@ blurb=TM Terminal Control\n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ -Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation +Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation \n\ See the NOTICE file(s) distributed with this work for additional\n\ information regarding copyright ownership.\n\ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 03baff99903..b82f38fd01f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2021 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -403,7 +403,8 @@ private void processNewText() throws IOException { break; case ANSISTATE_EXPECTING_PARAMETER_OR_COMMAND: - if (character == '?') { + // characters `<=>?` mark private commands + if (character >= '\u003c' && character <= '\u003f') { ansiState = ANSISTATE_EXPECTING_DEC_PRIVATE_COMMAND; break; } @@ -411,8 +412,7 @@ private void processNewText() throws IOException { // Parameters can appear after the '[' in an escape sequence, but they // are optional. - if (character == '@' || (character >= 'A' && character <= 'Z') - || (character >= 'a' && character <= 'z')) { + if (character >= '\u0040' && character < '\u007f') { ansiState = ANSISTATE_INITIAL; processAnsiCommandCharacter(character); } else { @@ -435,8 +435,7 @@ private void processNewText() throws IOException { // Parameters can appear after the '[?' in an escape sequence, but they // are optional. - if (character == '@' || (character >= 'A' && character <= 'Z') - || (character >= 'a' && character <= 'z')) { + if (character >= '\u0040' && character < '\u007f') { ansiState = ANSISTATE_INITIAL; processDecPrivateCommandCharacter(character); } else { From 7c1f00190bbf8a440d8531feea8359dc1697fe67 Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Sat, 30 Jan 2021 12:43:57 +0100 Subject: [PATCH 39/76] Bug 570775: Add pop-up action to invert terminal colors on the fly New action to temporarily invert the terminal colors, the preference setting is not altered by this action. Only the active terminal is affected. Change-Id: Idc01163838539c2ba5699556951c1742bbf07ad6 Signed-off-by: Fabrizio Iannetti --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- .../tm/internal/terminal/control/ITerminalViewControl.java | 7 ++++++- .../internal/terminal/emulator/VT100TerminalControl.java | 7 ++++++- .../tm/internal/terminal/textcanvas/ILinelRenderer.java | 2 ++ .../eclipse/tm/internal/terminal/textcanvas/StyleMap.java | 4 ++++ .../tm/internal/terminal/textcanvas/TextCanvas.java | 4 ++++ .../tm/internal/terminal/textcanvas/TextLineRenderer.java | 5 +++++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index e9749de69dd..4279683d5a8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.0.100.qualifier +Bundle-Version: 5.1.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index 19eb2ef3386..5b20b09d97d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2018 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2021 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -70,6 +70,11 @@ public interface ITerminalViewControl { void setInvertedColors(boolean invert); + /** + * @since 5.1 + */ + boolean isInvertedColors(); + Font getFont(); /** diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 6271c0d8733..2205ce34002 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2018 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2021 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -1365,6 +1365,11 @@ public void setInvertedColors(boolean invert) { fCtlText.setInvertedColors(invert); } + @Override + public boolean isInvertedColors() { + return fCtlText.isInvertedColors(); + } + @Override public final void setConnectOnEnterIfClosed(boolean on) { connectOnEnterIfClosed = on; diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java index 8ef7c58cb89..a02b67fcfa9 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -50,6 +50,8 @@ public interface ILinelRenderer { void setInvertedColors(boolean invert); + boolean isInvertedColors(); + /** * @deprecated use {@link #getDefaultBackgroundColor(Device)} */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java index f2af6cbe4de..330070cdafb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java @@ -136,6 +136,10 @@ public void setInvertedColors(boolean invert) { fInvertColors = invert; } + public boolean isInvertedColors() { + return fInvertColors; + } + public Font getFont(TerminalStyle style) { style = defaultIfNull(style); if (style.isBold()) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 493b8b17c88..449914c1f09 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -510,6 +510,10 @@ public void setInvertedColors(boolean invert) { redraw(); } + public boolean isInvertedColors() { + return fCellRenderer.isInvertedColors(); + } + /** * @return true if the cursor is enabled (blinking). By default the cursor is not enabled. */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index d092bc6fc8b..884232b78dd 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -208,4 +208,9 @@ public void setInvertedColors(boolean invert) { fStyleMap.setInvertedColors(invert); } + + @Override + public boolean isInvertedColors() { + return fStyleMap.isInvertedColors(); + } } From b341beb179204e39677e77e15dc732cc2d4494bf Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 26 Feb 2021 14:10:01 -0500 Subject: [PATCH 40/76] Bug 341721: Add context menu item to change terminal name Change-Id: Idd41b58ad4f052c32d6a9c57303f1b9ef05aff7c --- .../tm/internal/terminal/control/ITerminalViewControl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index 5b20b09d97d..6891cbcb1e4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -166,4 +166,9 @@ public interface ITerminalViewControl { * @since 4.1 */ void removeMouseListener(ITerminalMouseListener listener); + + /** + * @since 5.1 + */ + void setTerminalTitle(String newTitle); } From 0c7ffd48f18ce5c0a42cd96468bfac8d09f0e6e9 Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Thu, 4 Mar 2021 14:22:02 -0500 Subject: [PATCH 41/76] Bug 563015: terminal: open files/links with ctrl-click - hover with ctrl+mouse underlines word under cursor - ctrl-click tries to open the word: - if a relative path (not starting with /) a full path is obtained by prepending the shell cwd - if the fullpath maps to a workspace file, it is opened - otherwise open the OpenResource dialog with the word as filter text - if there is line/column information (separated by colons) then the opened editor jumps to that line - http and https words are opened in a browser window Change-Id: I3f46accbf1eac6743d7b0c3b34bf30ac5e7523bb Signed-off-by: Fabrizio Iannetti Also-by: Jonah Graham Signed-off-by: Jonah Graham --- .../org.eclipse.tm.terminal.control/.options | 1 + .../META-INF/MANIFEST.MF | 2 +- .../terminal/connector/TerminalConnector.java | 9 ++ .../control/ITerminalMouseListener.java | 1 + .../control/ITerminalMouseListener2.java | 74 ++++++++++++++ .../control/ITerminalViewControl.java | 7 ++ .../emulator/VT100TerminalControl.java | 5 + .../provisional/api/ITerminalConnector.java | 9 ++ .../terminal/provisional/api/Logger.java | 7 +- .../api/provider/TerminalConnectorImpl.java | 9 ++ .../textcanvas/AbstractTextCanvasModel.java | 98 +++++++++++++++++++ .../terminal/textcanvas/ITextCanvasModel.java | 40 ++++++++ .../terminal/textcanvas/TextCanvas.java | 35 ++++++- .../terminal/textcanvas/TextLineRenderer.java | 32 ++++++ .../eclipse/tm/terminal/model/TextRange.java | 96 ++++++++++++++++++ 15 files changed, 419 insertions(+), 6 deletions(-) create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener2.java create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TextRange.java diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.options b/terminal/plugins/org.eclipse.tm.terminal.control/.options index 7e591a4d4e7..752c05f737c 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.options +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.options @@ -1,3 +1,4 @@ org.eclipse.tm.terminal.control/debug/log = false org.eclipse.tm.terminal.control/debug/log/char = false org.eclipse.tm.terminal.control/debug/log/VT100Backend = false +org.eclipse.tm.terminal.control/debug/log/hover = false diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 4279683d5a8..6689e2ee7a5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.1.0.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java index be2350a43f1..3737a5cde3f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java @@ -16,6 +16,7 @@ package org.eclipse.tm.internal.terminal.connector; import java.io.OutputStream; +import java.util.Optional; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; @@ -260,4 +261,12 @@ public T getAdapter(Class adapter) { // maybe we have to be adapted.... return Platform.getAdapterManager().getAdapter(this, adapter); } + + @Override + public Optional getWorkingDirectory() { + if (fConnector != null) { + return fConnector.getWorkingDirectory(); + } + return Optional.empty(); + } } \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java index d926433c83b..0de6ff105ae 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener.java @@ -16,6 +16,7 @@ /** * Terminal specific version of {@link org.eclipse.swt.events.MouseListener} * @since 4.1 + * @see ITerminalMouseListener2 */ public interface ITerminalMouseListener { /** diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener2.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener2.java new file mode 100644 index 00000000000..e33a663ab5a --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalMouseListener2.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2021 Kichwa Coders Canada Inc. and others. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License 2.0 which accompanies this distribution, and is + * available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; + +/** + * Extension of {@link ITerminalMouseListener} for consumers that need the stateMask for a button mouse action. + * + * If ITerminalMouseListener2 is used, the methods in ITerminalMouseListener will not be called. + * + * @since 5.2 + * @see ITerminalMouseListener + */ +public interface ITerminalMouseListener2 extends ITerminalMouseListener { + /** + * Invoked when a double-click has happend inside the terminal control.
            + *
            + * Important: the event fires for every click, even outside the text region. + * @param terminalText a read-only view of the current terminal text + * @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values + * @param stateMask see {@link org.eclipse.swt.events.MouseEvent#stateMask} for the meaning of the values + */ + default void mouseDoubleClick(ITerminalTextDataReadOnly terminalText, int line, int column, int button, + int stateMask) { + // do nothing by default so that implementors only need to implement methods they care about + } + + @Override + default void mouseDoubleClick(ITerminalTextDataReadOnly terminalText, int line, int column, int button) { + throw new UnsupportedOperationException(); + } + + /** + * Invoked when a mouse button is pushed down inside the terminal control.
            + *
            + * Important: the event fires for every mouse down, even outside the text region. + * @param terminalText a read-only view of the current terminal text + * @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values + * @param stateMask see {@link org.eclipse.swt.events.MouseEvent#stateMask} for the meaning of the values + */ + default void mouseDown(ITerminalTextDataReadOnly terminalText, int line, int column, int button, int stateMask) { + // do nothing by default so that implementors only need to implement methods they care about + } + + @Override + default void mouseDown(ITerminalTextDataReadOnly terminalText, int line, int column, int button) { + throw new UnsupportedOperationException(); + } + + /** + * Invoked when a mouse button is released inside the terminal control.
            + *
            + * Important: the event fires for every mouse up, even outside the text region. + * @param terminalText a read-only view of the current terminal text + * @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values + * @param stateMask see {@link org.eclipse.swt.events.MouseEvent#stateMask} for the meaning of the values + */ + default void mouseUp(ITerminalTextDataReadOnly terminalText, int line, int column, int button, int stateMask) { + // do nothing by default so that implementors only need to implement methods they care about + } + + @Override + default void mouseUp(ITerminalTextDataReadOnly terminalText, int line, int column, int button) { + throw new UnsupportedOperationException(); + } + +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index 6891cbcb1e4..8ecccd536a9 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -159,11 +159,13 @@ public interface ITerminalViewControl { /** * @since 4.1 + * @param listener may be a {@link ITerminalMouseListener2} for extra callbacks */ void addMouseListener(ITerminalMouseListener listener); /** * @since 4.1 + * @param listener may be a {@link ITerminalMouseListener2} for extra callbacks */ void removeMouseListener(ITerminalMouseListener listener); @@ -171,4 +173,9 @@ public interface ITerminalViewControl { * @since 5.1 */ void setTerminalTitle(String newTitle); + + /** + * @since 5.2 + */ + String getHoverSelection(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 2205ce34002..18fa668c9a2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -1405,4 +1405,9 @@ public void removeMouseListener(ITerminalMouseListener listener) { getCtlText().removeTerminalMouseListener(listener); } + @Override + public String getHoverSelection() { + return fCtlText.getHoverSelection(); + } + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java index c4869ad22f1..d1a5fe55f70 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java @@ -16,6 +16,7 @@ package org.eclipse.tm.internal.terminal.provisional.api; import java.io.OutputStream; +import java.util.Optional; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; @@ -146,4 +147,12 @@ public interface ITerminalConnector extends IAdaptable { */ String getSettingsSummary(); + /** + * @return An optional with the absolute path if available of the current working dir, empty otherwise. + * @since 5.2 + */ + default Optional getWorkingDirectory() { + return Optional.empty(); + } + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index 1845104c0bb..f967bbf9e96 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -47,14 +47,17 @@ 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_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$ + /** @since 5.2 */ + public static final String TRACE_DEBUG_LOG_HOVER = "org.eclipse.tm.terminal.control/debug/log/hover"; //$NON-NLS-1$ private static PrintStream logStream; static { - // Any of the three known debugging options turns on the creation of the log file + // Any of the known debugging options turns on the creation of the log file boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG) || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR) - || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND); + || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND) + || TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_HOVER); // Log only if tracing is enabled if (createLogFile && TerminalPlugin.getDefault() != null) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java index 79ecb9b92fd..c19296bb725 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/provider/TerminalConnectorImpl.java @@ -14,6 +14,7 @@ package org.eclipse.tm.internal.terminal.provisional.api.provider; import java.io.OutputStream; +import java.util.Optional; import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; @@ -151,4 +152,12 @@ public void save(ISettingsStore store) { */ public void setTerminalSize(int newWidth, int newHeight) { } + + /** + * @since 5.2 + */ + public Optional getWorkingDirectory() { + return Optional.empty(); + } + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java index cd32a5c8c9f..0d0e151a1a8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java @@ -19,10 +19,14 @@ import java.util.List; import org.eclipse.swt.graphics.Point; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; +import org.eclipse.tm.terminal.model.TextRange; abstract public class AbstractTextCanvasModel implements ITextCanvasModel { + private static final boolean DEBUG_HOVER = TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_HOVER); protected List fListeners = new ArrayList<>(); private int fCursorLine; private int fCursorColumn; @@ -45,6 +49,8 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel { boolean fInUpdate; private int fCols; + private TextRange fHoverRange = TextRange.EMPTY; + public AbstractTextCanvasModel(ITerminalTextDataSnapshot snapshot) { fSnapshot = snapshot; fLines = fSnapshot.getHeight(); @@ -309,6 +315,98 @@ public String getSelectedText() { return fCurrentSelection; } + @Override + public boolean hasHoverSelection(int line) { + if (fHoverRange.isEmpty()) { + return false; + } + return fHoverRange.contains(line); + } + + @Override + public Point getHoverSelectionStart() { + if (!fHoverRange.isEmpty()) { + return fHoverRange.getStart(); + } + return null; + } + + @Override + public Point getHoverSelectionEnd() { + // Note - to match behaviour of getSelectionEnd this method + // returns the inclusive end. As the fHoverRange is exclusive + // we need to decrement the end positions before returning them. + if (!fHoverRange.isEmpty()) { + Point end = fHoverRange.getEnd(); + end.x--; + end.y--; + return end; + } + return null; + } + + @Override + public void expandHoverSelectionAt(final int line, final int col) { + if (fHoverRange.contains(col, line)) { + // position is inside current hover range -> no change + return; + } + fHoverRange = TextRange.EMPTY; + if (line < 0 || line > fSnapshot.getHeight() || col < 0) { + return; + } + int row1 = line; + int row2 = line; + while (row1 > 0 && fSnapshot.isWrappedLine(row1 - 1)) + row1--; + while (row2 < fSnapshot.getHeight() && fSnapshot.isWrappedLine(row2)) + row2++; + row2++; + String lineText = ""; //$NON-NLS-1$ + for (int l = row1; l < row2; l++) { + char[] chars = fSnapshot.getChars(l); + if (chars == null) + return; + lineText += String.valueOf(chars); + } + int width = fSnapshot.getWidth(); + int col1 = col + (line - row1) * width; + if (lineText.length() <= col1 || isBoundaryChar(lineText.charAt(col1))) { + return; + } + int wordStart = 0; + int wordEnd = lineText.length(); + for (int c = col1; c >= 1; c--) { + if (isBoundaryChar(lineText.charAt(c - 1))) { + wordStart = c; + break; + } + } + for (int c = col1; c < lineText.length(); c++) { + if (isBoundaryChar(lineText.charAt(c))) { + wordEnd = c; + break; + } + } + if (wordStart < wordEnd) { + fHoverRange = new TextRange(row1 + wordStart / width, row1 + (wordEnd - 1) / width + 1, (wordStart % width), + (wordEnd - 1) % width + 1, lineText.substring(wordStart, wordEnd)); + if (DEBUG_HOVER) { + System.out.format("hover: %s <- [%s,%s][%s,%s]\n", //$NON-NLS-1$ + fHoverRange, col, line, wordStart, wordEnd); + } + } + } + + @Override + public String getHoverSelectionText() { + return fHoverRange.text; + } + + private boolean isBoundaryChar(char c) { + return Character.isWhitespace(c) || (c < '\u0020') || c == '"' || c == '\''; + } + // helper to sanitize text copied out of a snapshot private static String scrubLine(String text) { // get rid of the empty space at the end of the lines diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java index 82362757726..01beac0789d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModel.java @@ -90,6 +90,45 @@ public interface ITextCanvasModel { String getSelectedText(); + /** + * Expand the hover selection to the word at the given position. + * + * @param line line + * @param col column + */ + void expandHoverSelectionAt(int line, int col); + + /** + * @param line + * @return true if line is part of the hover selection + */ + boolean hasHoverSelection(int line); + + /** + * Get the text of the current hover selection. + * + * @return the hover selection text, never null. + */ + String getHoverSelectionText(); + + /** + * Get the start of the hover selection. + * + * @return the start of the hover selection or null if nothing is selected + * {@link Point#x} is the column and {@link Point#y} is the line. + * Returns non-null if {@link #hasHoverSelection(int)} returns true + */ + Point getHoverSelectionStart(); + + /** + * Get the end of the hover selection (inclusive). + * + * @return the end of the hover selection or null if nothing is selected + * {@link Point#x} is the column and {@link Point#y} is the line. + * Returns non-null if {@link #hasHoverSelection(int)} returns true + */ + Point getHoverSelectionEnd(); + /** * Collect and return all text present in the model. * @@ -100,4 +139,5 @@ public interface ITextCanvasModel { * @since 4.4 */ String getAllText(); + } \ No newline at end of file diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 449914c1f09..0d7e8bda732 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -43,6 +43,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener; +import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener2; import org.eclipse.tm.terminal.model.TerminalColor; /** @@ -146,7 +147,13 @@ public void mouseDoubleClick(MouseEvent e) { Point pt = screenPointToCell(e.x, e.y); if (pt != null) { for (ITerminalMouseListener l : fMouseListeners) { - l.mouseDoubleClick(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + if (l instanceof ITerminalMouseListener2) { + ITerminalMouseListener2 l2 = (ITerminalMouseListener2) l; + l2.mouseDoubleClick(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button, + e.stateMask); + } else { + l.mouseDoubleClick(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + } } } } @@ -170,7 +177,12 @@ public void mouseDown(MouseEvent e) { Point pt = screenPointToCell(e.x, e.y); if (pt != null) { for (ITerminalMouseListener l : fMouseListeners) { - l.mouseDown(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + if (l instanceof ITerminalMouseListener2) { + ITerminalMouseListener2 l2 = (ITerminalMouseListener2) l; + l2.mouseDown(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button, e.stateMask); + } else { + l.mouseDown(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + } } } } @@ -190,7 +202,12 @@ public void mouseUp(MouseEvent e) { Point pt = screenPointToCell(e.x, e.y); if (pt != null) { for (ITerminalMouseListener l : fMouseListeners) { - l.mouseUp(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + if (l instanceof ITerminalMouseListener2) { + ITerminalMouseListener2 l2 = (ITerminalMouseListener2) l; + l2.mouseUp(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button, e.stateMask); + } else { + l.mouseUp(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button); + } } } } @@ -200,7 +217,15 @@ public void mouseUp(MouseEvent e) { if (fDraggingStart != null) { updateHasSelection(e); setSelection(screenPointToCell(e.x, e.y)); + fCellCanvasModel.expandHoverSelectionAt(-1, -1); + } else if ((e.stateMask & SWT.MODIFIER_MASK) == SWT.MOD1) { + // highlight (underline) word that would be used by MOD1 + mouse click + Point pt = screenPointToCell(e.x, e.y); + fCellCanvasModel.expandHoverSelectionAt(pt.y, pt.x); + } else { + fCellCanvasModel.expandHoverSelectionAt(-1, -1); } + redraw(); }); serVerticalBarVisible(true); setHorizontalBarVisible(false); @@ -540,4 +565,8 @@ public void removeTerminalMouseListener(ITerminalMouseListener listener) { fMouseListeners.remove(listener); } + public String getHoverSelection() { + return fCellCanvasModel.getHoverSelectionText(); + } + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 884232b78dd..ab3d08080e3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -26,6 +26,8 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.provisional.api.Logger; import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly; import org.eclipse.tm.terminal.model.LineSegment; import org.eclipse.tm.terminal.model.TerminalColor; @@ -35,6 +37,7 @@ * */ public class TextLineRenderer implements ILinelRenderer { + private static final boolean DEBUG_HOVER = TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_HOVER); private final ITextCanvasModel fModel; private final StyleMap fStyleMap; @@ -76,6 +79,20 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int drawText(doubleBufferGC, 0, 0, colFirst, segment.getColumn(), text); drawCursor(model, doubleBufferGC, line, 0, 0, colFirst); } + if (fModel.hasHoverSelection(line)) { + if (DEBUG_HOVER) { + System.out.format("hover: %s contains hover selection\n", line); //$NON-NLS-1$ + } + Point hsStart = fModel.getHoverSelectionStart(); + Point hsEnd = fModel.getHoverSelectionEnd(); + int colStart = line == hsStart.y ? hsStart.x : 0; + int colEnd = line == hsEnd.y ? hsEnd.x : getTerminalText().getWidth(); + if (colStart < colEnd) { + RGB defaultFg = fStyleMap.getForegrondRGB(null); + doubleBufferGC.setForeground(new Color(doubleBufferGC.getDevice(), defaultFg)); + drawUnderline(doubleBufferGC, colStart, colEnd); + } + } if (fModel.hasLineSelection(line)) { TerminalStyle style = TerminalStyle.getStyle(TerminalColor.SELECTION_FOREGROUND, TerminalColor.SELECTION_BACKGROUND); @@ -168,6 +185,21 @@ private void drawText(GC gc, int x, int y, int colFirst, int col, String text) { } } + /** + * + * @param gc + * @param colStart Starting text column to underline (inclusive) + * @param colEnd Ending text column to underline (inclusive) + */ + private void drawUnderline(GC gc, int colStart, int colEnd) { + int y = getCellHeight() - 1; + int x = getCellWidth() * colStart; + + // x2 is the right side of last column being underlined. + int x2 = (colEnd + 1) * getCellWidth() - 1; + gc.drawLine(x, y, x2, y); + } + private void setupGC(GC gc, TerminalStyle style) { RGB foregrondColor = fStyleMap.getForegrondRGB(style); gc.setForeground(new Color(gc.getDevice(), foregrondColor)); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TextRange.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TextRange.java new file mode 100644 index 00000000000..b73576f4c3c --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/terminal/model/TextRange.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2021 Fabrizio Iannetti. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.tm.terminal.model; + +import org.eclipse.swt.graphics.Point; + +/** + * Represents a range of text in the terminal. + *

            + * Used, for example, to store location of active hover + * + * @since 5.2 + */ +public final class TextRange { + public final int colStart; + public final int colEnd; + public final int rowStart; + public final int rowEnd; + public final String text; + + public static final TextRange EMPTY = new TextRange(0, 0, 0, 0, ""); //$NON-NLS-1$ + + /** + * Constructor. + * + * @param rowStart start row + * @param rowEnd end row + * @param colStart start column (exclusive) + * @param colEnd end column (exclusive) + * @param text text in the range + */ + public TextRange(int rowStart, int rowEnd, int colStart, int colEnd, String text) { + super(); + this.colStart = colStart; + this.colEnd = colEnd; + this.rowStart = rowStart; + this.rowEnd = rowEnd; + this.text = text; + } + + public boolean contains(int col, int row) { + int colStartInrow = row == rowStart ? colStart : 0; + int colEndInRow = row == rowEnd - 1 ? colEnd : col + 1; + return col >= colStartInrow && col < colEndInRow && row >= rowStart && row < rowEnd; + } + + public boolean contains(int line) { + return line >= rowStart && line < rowEnd; + } + + /** + * Whether the range represents a non-empty (non-zero) amount of text + */ + public boolean isEmpty() { + return !(colEnd > colStart || rowEnd > rowStart); + } + + public Point getStart() { + return new Point(colStart, rowStart); + } + + public Point getEnd() { + return new Point(colEnd, rowEnd); + } + + public int getColStart() { + return colStart; + } + + public int getColEnd() { + return colEnd; + } + + public int getRowStart() { + return rowStart; + } + + public int getRowEnd() { + return rowEnd; + } + + @Override + public String toString() { + return String.format("TextRange (%s,%s)-(%s,%s)-'%s'", //$NON-NLS-1$ + colStart, rowStart, colEnd, rowEnd, text); + } +} From 03b2e7c5d853c769eebd5ba260764adedc66368d Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Sun, 18 Apr 2021 10:53:04 +0200 Subject: [PATCH 42/76] Bug 572938 Terminal: add support for reverse linefeed Scroll up is not working with `less`, `man`, probably other programs. Change-Id: I99d2472ab09df6b79fffbcaa581f3024c44d3ead Signed-off-by: Fabrizio Iannetti --- .../tm/internal/terminal/emulator/VT100Emulator.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index b82f38fd01f..98327bad6b9 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -395,6 +395,14 @@ private void processNewText() throws IOException { resetTerminal(); break; + case 'M': + // Reverse line feed + ansiState = ANSISTATE_INITIAL; + if (text.getCursorLine() == 0) + text.scrollDown(1); + moveCursorUp(1); + break; + default: Logger.log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$ ansiState = ANSISTATE_INITIAL; From fe7628671e5e0eec1f02f018e1c305694a95d47f Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 21 Apr 2021 15:36:31 -0400 Subject: [PATCH 43/76] Bug 573064: Support full clear - extended "E3" capability Change-Id: I9d4f7fffb11cc5386eb0a4e5c0445f1fc518b0a5 --- .../eclipse/tm/internal/terminal/emulator/VT100Emulator.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 98327bad6b9..8149e01c484 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -784,6 +784,11 @@ private void processAnsiCommand_J() { text.eraseAll(); break; + case 3: + // Erase display and clear scrollback (extended "E3" capability) + text.clearAll(); + break; + default: Logger.log("Unexpected J-command parameter: " + ansiParameter); //$NON-NLS-1$ break; From 01a17e2bdea96ee7d4efc038978edd20c66844e5 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 22 Apr 2021 15:50:41 -0400 Subject: [PATCH 44/76] Bug 573109: Use new StackWalker API Java 9+ contains new API for getting/walking stack frames. It is much faster and has a much cleaner API than using Throwable.getStackTrace Change-Id: Id0c888aeb06665f10605ce5ab5f0a567249e068c --- .../terminal/provisional/api/Logger.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index f967bbf9e96..8d109eadf76 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -17,6 +17,8 @@ import java.io.FileOutputStream; import java.io.PrintStream; +import java.lang.StackWalker.StackFrame; +import java.util.Optional; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; @@ -51,6 +53,7 @@ public final class Logger { public static final String TRACE_DEBUG_LOG_HOVER = "org.eclipse.tm.terminal.control/debug/log/hover"; //$NON-NLS-1$ private static PrintStream logStream; + private static StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); static { // Any of the known debugging options turns on the creation of the log file @@ -165,17 +168,7 @@ public static final boolean isLogEnabled() { */ public static final void log(String message) { if (logStream != null) { - // Read my own stack to get the class name, method name, and line - // number of - // where this method was called. - - StackTraceElement caller = new Throwable().getStackTrace()[1]; - int lineNumber = caller.getLineNumber(); - String className = caller.getClassName(); - String methodName = caller.getMethodName(); - className = className.substring(className.lastIndexOf('.') + 1); - - logStream.println(className + "." + methodName + ":" + lineNumber + ": " + message); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + logStream.println(getCallSiteDescription() + ": " + message); //$NON-NLS-1$ logStream.flush(); } } @@ -196,21 +189,30 @@ public static final void logException(Exception ex) { // Read my own stack to get the class name, method name, and line number // of where this method was called if (logStream != null) { - StackTraceElement caller = new Throwable().getStackTrace()[1]; - int lineNumber = caller.getLineNumber(); - String className = caller.getClassName(); - String methodName = caller.getMethodName(); - className = className.substring(className.lastIndexOf('.') + 1); - PrintStream tmpStream = System.err; - if (logStream != null) { tmpStream = logStream; } - tmpStream.println(className + "." + methodName + ":" + lineNumber + ": " + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + tmpStream.println(getCallSiteDescription() + ": " + //$NON-NLS-1$ "Caught exception: " + ex); //$NON-NLS-1$ ex.printStackTrace(tmpStream); } } + + /** + * Return a description string of the call site of this logging call for use in logged messages. + * This method will walk the stack to find the first method in the call stack not from the Logger + * class. + */ + private static String getCallSiteDescription() { + Optional stackFrame = walker + .walk(stream -> stream.filter(f -> f.getDeclaringClass() != Logger.class).findFirst()); + int lineNumber = stackFrame.map(StackFrame::getLineNumber).orElse(0); + String className = stackFrame.map(StackFrame::getDeclaringClass).map(Class::getName) + .map(name -> name.substring(name.lastIndexOf('.') + 1)).orElse("UnknownClass"); //$NON-NLS-1$ + String methodName = stackFrame.map(StackFrame::getMethodName).orElse("unknownMethod"); //$NON-NLS-1$ + String locationString = className + "." + methodName + ":" + lineNumber; //$NON-NLS-1$//$NON-NLS-2$ + return locationString; + } } From 035c41947d1306ef6edd4bbc7c2b800e97120e7e Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 22 Apr 2021 15:58:14 -0400 Subject: [PATCH 45/76] Bug 573109: Add new logging options for terminal Change-Id: I0c35b7ce0c4350081eac6ace974dbcee3e0f103d --- .../terminal/provisional/api/Logger.java | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index 8d109eadf76..e993ff8b7b8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -164,6 +164,8 @@ public static final boolean isLogEnabled() { * Logs the specified message. Do not append a newline to parameter * message. This method does that for you. * + * Does not write to the message to the Eclipse log + * * @param message A String containing the message to log. */ public static final void log(String message) { @@ -174,29 +176,43 @@ public static final void log(String message) { } /** - * Writes a stack trace for an exception to both Standard Error and to the - * log file. + * Writes an error message to the Terminal log and the Eclipse log + * @since 5.2 + */ + public static final void logError(String message) { + logStatus(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, message, null)); + } + + /** + * Writes an exception to the Terminal log and the Eclipse log */ public static final void logException(Exception ex) { + logStatus(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex)); + } + + /** + * Writes a Status to the Terminal log and the Eclipse log + * @since 5.2 + */ + public static final void logStatus(IStatus status) { // log in eclipse error log if (TerminalPlugin.getDefault() != null) { - TerminalPlugin.getDefault().getLog() - .log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex)); + TerminalPlugin.getDefault().getLog().log(status); } else { - ex.printStackTrace(); + System.err.println(status); + if (status.getException() != null) { + status.getException().printStackTrace(); + } } // Additional Tracing for debug purposes: // Read my own stack to get the class name, method name, and line number // of where this method was called if (logStream != null) { - PrintStream tmpStream = System.err; - if (logStream != null) { - tmpStream = logStream; + logStream.println(getCallSiteDescription() + ": " + //$NON-NLS-1$ + status); + if (status.getException() != null) { + status.getException().printStackTrace(logStream); } - - tmpStream.println(getCallSiteDescription() + ": " + //$NON-NLS-1$ - "Caught exception: " + ex); //$NON-NLS-1$ - ex.printStackTrace(tmpStream); } } From fa1639a67939219d5ef116d0a9a59f9e7ffe2be5 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 23 Apr 2021 10:13:05 -0400 Subject: [PATCH 46/76] Bug 573110: Emulator can spin if Reader is ready but not available The implementation of the read loop in the emulator can spin because it uses Reader.ready() to determine if there is more data to read. However the Reader contract does not specify that ready() means that read() will return a character, simply it means that read() won't block. As such, if a Reader won't block, but it has no characters, the inner read loop will spin constantly polling. The outer loop uses polling too - but it has a wait so that the CPU does not hit 100% and yields. Change-Id: Id9b2426c65e6c2a2c3ae817a78d2be435e568c1f --- .../tm/internal/terminal/emulator/VT100Emulator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 8149e01c484..95969a16712 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -1515,9 +1515,10 @@ private char getNextChar() throws IOException { } private boolean hasNextChar() throws IOException { - if (fNextChar >= 0) - return true; - return fReader.ready(); + if (fNextChar < 0 && fReader.ready()) { + fNextChar = fReader.read(); + } + return fNextChar >= 0; } /** From ac217c81f10d33da209939f1e25edd23f985dcf0 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 22 Apr 2021 21:19:25 -0400 Subject: [PATCH 47/76] Bug 573108: Add test harness for VT100Emulator This contains basic tests so far, as bugs are fixed other tests can be added here, leading to easier development of escape sequences. Change-Id: Iadd0b24d400f72927c446d61386f19cfd8bd05a0 --- .../internal/terminal/provisional/api/Logger.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index e993ff8b7b8..36096598ac4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -55,6 +55,16 @@ public final class Logger { private static PrintStream logStream; private static StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); + private static boolean underTest = false; + + /** + * When underTest we want exception that are deep inside the code to be surfaced to the test + * @noreference This method is not intended to be referenced by clients. + */ + public static void setUnderTest(boolean underTest) { + Logger.underTest = underTest; + } + static { // Any of the known debugging options turns on the creation of the log file boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG) @@ -187,6 +197,9 @@ public static final void logError(String message) { * Writes an exception to the Terminal log and the Eclipse log */ public static final void logException(Exception ex) { + if (underTest) { + throw new RuntimeException("Terminal Under Test - examine cause for real failure", ex); //$NON-NLS-1$ + } logStatus(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex)); } From 2bfec491f14e15d9d269b3abab6ed7d53342acbb Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Sat, 1 May 2021 21:18:17 +0200 Subject: [PATCH 48/76] Bug 572938 [terminal] reverse linefeed: Honour the scrolling region The reverse linefeed should scroll down when the cursor is on the first line of the scrolling region, not only on the first screen line Change-Id: I628ab135d48d868bc8e3eacd2ea57dda948873a8 Signed-off-by: Fabrizio Iannetti --- .../terminal/emulator/IVT100EmulatorBackend.java | 8 ++++++++ .../emulator/VT100BackendTraceDecorator.java | 6 ++++++ .../internal/terminal/emulator/VT100Emulator.java | 4 +--- .../terminal/emulator/VT100EmulatorBackend.java | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java index 77f6f428aea..c835bb817c4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java @@ -219,4 +219,12 @@ public interface IVT100EmulatorBackend { * @param lines number of lines to scroll */ void scrollDown(int lines); + + /** + * Process a reverse line feed/reverse index. + * + * The content is scrolled down if the cursor is at the top of the + * scroll region. + */ + void processReverseLineFeed(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java index 1c589c258c3..615a7d6f618 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -205,4 +205,10 @@ public void scrollDown(int lines) { fBackend.scrollDown(lines); } + @Override + public void processReverseLineFeed() { + fWriter.println("processReverseLineFeed()"); //$NON-NLS-1$ + fBackend.processReverseLineFeed(); + } + } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 95969a16712..f899dcafb60 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -398,9 +398,7 @@ private void processNewText() throws IOException { case 'M': // Reverse line feed ansiState = ANSISTATE_INITIAL; - if (text.getCursorLine() == 0) - text.scrollDown(1); - moveCursorUp(1); + text.processReverseLineFeed(); break; default: diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index 959e8e85a2d..514ec7c6a0f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -367,6 +367,20 @@ public void processNewline() { } } + private void doReverseLineFeed() { + if (fCursorLine == fScrollRegion.getTopLine()) + scrollDown(1); + else + setCursorLine(fCursorLine - 1); + } + + @Override + public void processReverseLineFeed() { + synchronized (fTerminal) { + doReverseLineFeed(); + } + } + @Override public int getCursorLine() { synchronized (fTerminal) { From 9493fbc702f2e131c0845d833686b2a527d48945 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 22 May 2021 19:54:58 -0400 Subject: [PATCH 49/76] Bug 573713: Support alternate way of bright escape codes ConPTY uses 90-107 to indicate bright instead of using extra 1; parameter. Change-Id: I42263edd5dbe78fe164f00b99d1850ca5be85081 --- .../terminal/emulator/VT100Emulator.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index f899dcafb60..093fa472a9d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -927,34 +927,58 @@ private void processAnsiCommand_m() { style = style.setReverse(false); break; + case 90: + style = style.setBold(true); + //$FALL-THROUGH$ case 30: style = style.setForeground(BLACK); break; + case 91: + style = style.setBold(true); + //$FALL-THROUGH$ case 31: style = style.setForeground(RED); break; + case 92: + style = style.setBold(true); + //$FALL-THROUGH$ case 32: style = style.setForeground(GREEN); break; + case 93: + style = style.setBold(true); + //$FALL-THROUGH$ case 33: style = style.setForeground(YELLOW); break; + case 94: + style = style.setBold(true); + //$FALL-THROUGH$ case 34: style = style.setForeground(BLUE); break; + case 95: + style = style.setBold(true); + //$FALL-THROUGH$ case 35: style = style.setForeground(MAGENTA); break; + case 96: + style = style.setBold(true); + //$FALL-THROUGH$ case 36: style = style.setForeground(CYAN); break; + case 97: + style = style.setBold(true); + //$FALL-THROUGH$ case 37: style = style.setForeground(WHITE); break; @@ -963,34 +987,58 @@ private void processAnsiCommand_m() { style = style.setForeground(text.getDefaultStyle()); break; + case 100: + style = style.setBold(true); + //$FALL-THROUGH$ case 40: style = style.setBackground(BLACK); break; + case 101: + style = style.setBold(true); + //$FALL-THROUGH$ case 41: style = style.setBackground(RED); break; + case 102: + style = style.setBold(true); + //$FALL-THROUGH$ case 42: style = style.setBackground(GREEN); break; + case 103: + style = style.setBold(true); + //$FALL-THROUGH$ case 43: style = style.setBackground(YELLOW); break; + case 104: + style = style.setBold(true); + //$FALL-THROUGH$ case 44: style = style.setBackground(BLUE); break; + case 105: + style = style.setBold(true); + //$FALL-THROUGH$ case 45: style = style.setBackground(MAGENTA); break; + case 106: + style = style.setBold(true); + //$FALL-THROUGH$ case 46: style = style.setBackground(CYAN); break; + case 107: + style = style.setBold(true); + //$FALL-THROUGH$ case 47: style = style.setBackground(WHITE); break; From d3d3410f0a5cc794c14d24754230cd822421d83c Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 17 Jun 2021 15:54:51 -0400 Subject: [PATCH 50/76] Bug 573797: Always use sendString, regardless of encoding This removes a TODO in the code that makes no sense, and in most cases the else branch is not taken as a common operating mode is the default charset/encoding is windows-1252 but the current charset is utf-8. The effective difference between the two branches is that the else does a flush after character rather than after each string. Change-Id: I50b3cc5837d783ba20b88c2efa44d9c4e6381d30 --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- .../internal/terminal/emulator/VT100TerminalControl.java | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 6689e2ee7a5..2a6a4972479 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.2.0.qualifier +Bundle-Version: 5.2.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 18fa668c9a2..dda09807a04 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -312,14 +312,7 @@ public boolean pasteString(String strText) { return false; if (strText == null) return false; - if (!fEncoding.equals(defaultEncoding)) { - sendString(strText); - } else { - // TODO I do not understand why pasteString would do this here... - for (int i = 0; i < strText.length(); i++) { - sendChar(strText.charAt(i), false); - } - } + sendString(strText); return true; } From b9694e5db4c7578acd63d0f184cbb15bd58594fa Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 27 May 2021 01:02:20 -0400 Subject: [PATCH 51/76] Bug 573797: Refactor code to use Charset instead of passing around Strings This simplifies error handling as once you have a Charset you don't have to worry about whether or not an UnsupportedEncodingException can be thrown anymore. In addition it is a little easier on type safety. Change-Id: I4292878a7c621f9d05fdb98f5c26a0ae8bfec062 --- .../META-INF/MANIFEST.MF | 2 +- .../control/ITerminalViewControl.java | 21 +++++++ .../emulator/VT100TerminalControl.java | 57 ++++++++++--------- .../provisional/api/ITerminalControl.java | 41 +++++++++++++ 4 files changed, 92 insertions(+), 29 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 2a6a4972479..c2f710d67d6 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.2.100.qualifier +Bundle-Version: 5.3.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index 8ecccd536a9..d08a36c5586 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -17,6 +17,7 @@ package org.eclipse.tm.internal.terminal.control; import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.graphics.Font; @@ -38,18 +39,38 @@ public interface ITerminalViewControl { * * @see ITerminalControl#setEncoding(String) * @since org.eclipse.tm.terminal 2.0 + * @deprecated Use {@link #setCharset(Charset)} and do the error handling in the UI code. */ + @Deprecated void setEncoding(String encoding) throws UnsupportedEncodingException; + /** + * Set the charset that the Terminal uses to decode byte streams into + * characters. + * + * @see ITerminalControl#setCharset(Charset) + * @since 5.3 + */ + void setCharset(Charset charset); + /** * Get the Terminal's current encoding. * * @return the current Encoding of the Terminal. * @see ITerminalControl#getEncoding() * @since org.eclipse.tm.terminal 2.0 + * @deprecated Use {@link #getCharset()} and call {@link Charset#name()} on the result */ + @Deprecated String getEncoding(); + /** + * @return the non-null current Charset of the Terminal. + * @see ITerminalControl#getCharset() + * @since 5.3 + */ + Charset getCharset(); + boolean isEmpty(); /** diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index dda09807a04..759c16c750a 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -156,8 +156,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private boolean connectOnEnterIfClosed = true; PipedInputStream fInputStream; - private static final String defaultEncoding = Charset.defaultCharset().name(); - private String fEncoding = defaultEncoding; + private Charset fCharset = Charset.defaultCharset(); private InputStreamReader fInputStreamReader; private ICommandInputField fCommandInputField; @@ -230,38 +229,43 @@ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerm fTerminalModel.setMaxHeight(1000); fInputStream = new PipedInputStream(8 * 1024); fTerminalText = new VT100Emulator(fTerminalModel, this, null); - try { - // Use Default Encoding as start, until setEncoding() is called - setEncoding(null); - } catch (UnsupportedEncodingException e) { - // Should never happen - e.printStackTrace(); - // Fall back to local Platform Default Encoding - fEncoding = defaultEncoding; - fInputStreamReader = new InputStreamReader(fInputStream); - fTerminalText.setInputStreamReader(fInputStreamReader); - } - + // Use Default Charset as start, until setCharset() is called + setCharset(Charset.defaultCharset()); setupTerminal(wndParent); } @Override + @Deprecated public void setEncoding(String encoding) throws UnsupportedEncodingException { + Charset charset; if (encoding == null) { - // TODO better use a standard remote-to-local encoding? - encoding = "ISO-8859-1"; //$NON-NLS-1$ - // TODO or better use the local default encoding? - // encoding = defaultEncoding; + charset = Charset.defaultCharset(); + } else { + charset = Charset.forName(encoding); } - fInputStreamReader = new InputStreamReader(fInputStream, encoding); // remember encoding if above didn't throw an exception - fEncoding = encoding; + setCharset(charset); + } + + @Override + public void setCharset(Charset charset) { + if (charset == null) { + charset = Charset.defaultCharset(); + } + fInputStreamReader = new InputStreamReader(fInputStream, charset); + fCharset = charset; fTerminalText.setInputStreamReader(fInputStreamReader); } @Override + @Deprecated public String getEncoding() { - return fEncoding; + return fCharset.name(); + } + + @Override + public Charset getCharset() { + return fCharset; } @Override @@ -547,7 +551,7 @@ protected void sendString(String string) { // TODO: Find a way to force this to use the ISO Latin-1 encoding. // TODO: handle Encoding Errors in a better way - getOutputStream().write(string.getBytes(fEncoding)); + getOutputStream().write(string.getBytes(fCharset)); getOutputStream().flush(); } catch (SocketException socketException) { displayTextInTerminal(socketException.getMessage()); @@ -591,7 +595,7 @@ protected void sendChar(char chKey, boolean altKeyPressed) { // // TODO: Make the ESCAPE-vs-highbit behavior user configurable. - byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding); + byte[] bytesToSend = String.valueOf(chKey).getBytes(fCharset); StringBuilder b = new StringBuilder("sending ESC"); //$NON-NLS-1$ for (int i = 0; i < bytesToSend.length; i++) { if (i != 0) @@ -602,7 +606,7 @@ protected void sendChar(char chKey, boolean altKeyPressed) { os.write('\u001b'); os.write(bytesToSend); } else { - byte[] bytesToSend = String.valueOf(chKey).getBytes(fEncoding); + byte[] bytesToSend = String.valueOf(chKey).getBytes(fCharset); StringBuilder b = new StringBuilder("sending"); //$NON-NLS-1$ for (int i = 0; i < bytesToSend.length; i++) { if (i != 0) @@ -826,10 +830,7 @@ public void displayTextInTerminal(String text) { private void writeToTerminal(String text) { try { - getRemoteToTerminalOutputStream().write(text.getBytes(fEncoding)); - } catch (UnsupportedEncodingException e) { - // should never happen! - e.printStackTrace(); + getRemoteToTerminalOutputStream().write(text.getBytes(fCharset)); } catch (IOException e) { // should never happen! e.printStackTrace(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java index 226f03cdc36..267f7ac5f11 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java @@ -18,6 +18,7 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; @@ -83,9 +84,39 @@ public interface ITerminalControl { * LANG on UNIX systems. * * @since org.eclipse.tm.terminal 2.0 + * @deprecated Use {@link #setCharset(Charset)} and do the error handling in the UI code. */ + @Deprecated void setEncoding(String encoding) throws UnsupportedEncodingException; + /** + * Set the charset that the Terminal uses to decode bytes from the + * Terminal-to-remote-Stream into Unicode Characters used in Java; or, to + * encode Characters typed by the user into bytes sent over the wire to the + * remote. + * + * By default, the local Platform Default charset is used. Also note that + * the encoding must not be applied in case the terminal stream is processed + * by some data transfer protocol which requires binary data. + * + * Validity of the charset set here is not checked. Since some encodings do + * not cover the entire range of Unicode characters, it can happen that a + * particular Unicode String typed in by the user can not be encoded into a + * byte Stream with the encoding specified. and UnsupportedEncodingException + * will be thrown in this case at the time the String is about to be + * processed. + * + * The concrete encoding to use can either be specified manually by a user, + * by means of a dialog, or a connector can try to obtain it automatically + * from the remote side e.g. by evaluating an environment variable such as + * LANG on UNIX systems. + * + * @param charset Charset to use, or null for platform's default charset. + * + * @since 5.3 + */ + void setCharset(Charset charset); + /** * Return the current encoding. That's interesting when the previous * setEncoding() call failed and the fallback default encoding should be @@ -94,9 +125,19 @@ public interface ITerminalControl { * * @return the current Encoding of the Terminal. * @since org.eclipse.tm.terminal 2.0 + * @deprecated Use {@link #getCharset()} and call {@link Charset#name()} on the result */ + @Deprecated String getEncoding(); + /** + * Return the current charset. + * + * @return the non-null current charset of the Terminal + * @since 5.3 + */ + Charset getCharset(); + /** * Show a text in the terminal. If puts newlines at the beginning and the * end. From b5a38e3651b9d0e7eb050997068d9ca42c261bc7 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 19 Jun 2021 10:11:05 -0400 Subject: [PATCH 52/76] Bug 574271: Draw characters in the correct color on macos There is a bug in SWT on macos - Bug 568777 - with the cache of single character drawStrings with transparent backgrounds as a performance boost. This causes the terminal to draw some characters in the wrong color. The workaround is to not draw with transparency, which should be fine because we just filled the background with the same color that the 1 character string will draw with. The performance, measured with TerminalTextUITest in Fast mode with no throttling, does not seem affected and in my testing there does not seem to be any graphic side effects. Change-Id: I1b0aadae100d81a8f4533ba73273ccc8202e068f --- .../tm/internal/terminal/textcanvas/TextLineRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index ab3d08080e3..845ee499581 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -176,7 +176,7 @@ private void drawText(GC gc, int x, int y, int colFirst, int col, String text) { // TODO why do I have to draw the background character by character?????? gc.fillRectangle(xx, y, fStyleMap.getFontWidth(), fStyleMap.getFontHeight()); 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, false); } } } else { From 99bf324e60aca973b14059661d4fc7c413930d95 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 9 Jul 2021 12:44:02 -0400 Subject: [PATCH 53/76] Fix typo. Change-Id: I0f4fb95c1a44088d19ae9f98abd98765f456d110 --- .../eclipse/tm/internal/terminal/model/TerminalTextData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java index 9e6cf40f9d1..675bfd66de2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java @@ -40,7 +40,7 @@ public class TerminalTextData implements ITerminalTextData { /** * Debug helper method -- use as "New Detail Formatter.." in the * debugger variables view: - *

            TerminalTextData.toMultiLineText(this,0,200))
            + *
            TerminalTextData.toMultiLineText(this,0,200)
            * @param term the terminal * @param start start line to show * @param len number of lines to show -- negative numbers means show all From 51ecfc338ff696e7e588f147f8b6f5355c013e81 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 12 Jan 2022 15:05:21 -0500 Subject: [PATCH 54/76] [releng] Bump end year on copyright on all modified features Change-Id: I0d35eb6514d87fb6dcba0a284f58963b80861d51 --- .../plugins/org.eclipse.tm.terminal.control/about.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties index ad195fd530c..39c4c3fbac2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation +# Copyright (c) 2018, 2022 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -24,7 +24,7 @@ blurb=TM Terminal Control\n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ -Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation +Copyright (c) 2018, 2022 Contributors to the Eclipse Foundation \n\ See the NOTICE file(s) distributed with this work for additional\n\ information regarding copyright ownership.\n\ From 1a153e8897ac1384c309ca0bdbff0bee4e7652f8 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 12 Jan 2022 15:23:40 -0500 Subject: [PATCH 55/76] [releng] Bump version numbers for all modified projects Change-Id: I0d78c550512d8e63374bf1bc3a53f80e5d387e31 --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index c2f710d67d6..87990ede830 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.3.0.qualifier +Bundle-Version: 5.3.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin From c4f1ff207404d8a5baaf9e0db66d0948c3bcf23b Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 25 Feb 2022 11:26:49 -0500 Subject: [PATCH 56/76] Dispose font in TerminalColorsFieldEditor TerminalColorsFieldEditor had a dispose method, but FieldEditorPreferencePage does not call dispose on the individual field editors despite API implication that it should. Change-Id: I98c2987446d8b005cbca571763a9e811e966e0d3 --- .../preferences/TerminalPreferencePage.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java index 6dcc77da03f..27888302669 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -37,6 +37,8 @@ */ public class TerminalPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + private TerminalColorsFieldEditor terminalColorsFieldEditor; + public TerminalPreferencePage() { super(GRID); } @@ -72,6 +74,16 @@ protected void setupEditors() { addField(new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, TerminalMessages.BUFFERLINES, getFieldEditorParent())); - addField(new TerminalColorsFieldEditor(getFieldEditorParent())); + terminalColorsFieldEditor = new TerminalColorsFieldEditor(getFieldEditorParent()); + addField(terminalColorsFieldEditor); + } + + @Override + public void dispose() { + if (terminalColorsFieldEditor != null) { + terminalColorsFieldEditor.dispose(); + } + + super.dispose(); } } From cb76eb4ecaf70ea695ee842b70b2c12b929b06af Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 13 Apr 2022 10:58:02 -0400 Subject: [PATCH 57/76] [releng] Prepare for 10.7.0 with version bumps All the about.html files are updated, so every bundle that hasn't already had a bump in 10.7 needs one now Change-Id: I6143d2fbe77a58a3a6d2f4a226d96087117f9ac1 --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 87990ede830..3e9b1c5d695 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.3.100.qualifier +Bundle-Version: 5.3.200.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin From b5d1c8137157172dda54575013abf4d85d55bc78 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 13 Apr 2022 10:32:47 -0400 Subject: [PATCH 58/76] [releng] Update all legal files with update_legal_files.sh The about.html was changed as per https://gitlab.eclipse.org/eclipsefdn/it/websites/eclipse.org/-/issues/90 Change-Id: Ied879279460a8fc610630fc26794ab3df9eae39f --- .../org.eclipse.tm.terminal.control/about.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.html b/terminal/plugins/org.eclipse.tm.terminal.control/about.html index 164f781a8fd..b3134865230 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.html +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.html @@ -1,10 +1,11 @@ - + + - -About + + About +

            About This Content

            @@ -16,7 +17,7 @@

            License

            ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at http://www.eclipse.org/legal/epl-2.0. + available at https://www.eclipse.org/legal/epl-2.0. For purposes of the EPL, "Program" will mean the Content.

            @@ -29,8 +30,9 @@

            License

            license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org. + href="https://www.eclipse.org/">https://www.eclipse.org.

            + \ No newline at end of file From 1d6d8bd453ea342387f9eceed5ebfcb235f5df50 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 17 Apr 2022 15:28:31 -0400 Subject: [PATCH 59/76] [releng] Make CDT Clean-up profile match Editor on save actions The CDT Cleanup profile had a bunch of extra cleanups applied to it, this prevents running the CDT cleanup profile manually to simulate running the save actions on all Java files Change-Id: Iad491e1258a4ba90d81d1457ea0f6779e3663e38 --- .../.settings/org.eclipse.jdt.ui.prefs | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 From a6db7b7d47849c8f3965c10869e0ebe95d9f2dd0 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 17 Apr 2022 15:34:43 -0400 Subject: [PATCH 60/76] [releng] Apply auto-clean of save to all files with Eclipse 4.23 This mostly is using diamond operator, but includes adding missing @Override and organizing imports and applying formatting improvements in the JDT formatter. Change-Id: Id91cbff33b0a039cc5121945ffbc407ecba45866 --- .../tm/internal/terminal/emulator/EditActionAccelerators.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java index 2a08ae46685..af825928674 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java @@ -24,7 +24,7 @@ class EditActionAccelerators { private static final String COPY_COMMAND_ID = "org.eclipse.tm.terminal.copy"; //$NON-NLS-1$ private static final String PASTE_COMMAND_ID = "org.eclipse.tm.terminal.paste"; //$NON-NLS-1$ - private final Map commandIdsByAccelerator = new HashMap(); + private final Map commandIdsByAccelerator = new HashMap<>(); private void load() { addAccelerator(COPY_COMMAND_ID); From a4ec6cd4d5f6aa0fc0018e8bdf8b14615561c197 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 1 Oct 2022 19:59:59 -0400 Subject: [PATCH 61/76] Update to Java 17 as BREE. Fixes #80 --- terminal/plugins/org.eclipse.tm.terminal.control/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +++--- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath index edc8895124d..a7bc712151f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.classpath +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.classpath @@ -1,6 +1,6 @@ - + diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs index e3a8104f9ca..9df862f8d49 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -147,7 +147,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 3e9b1c5d695..19875a6916e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.3.200.qualifier +Bundle-Version: 5.4.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ClassPath: . Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true, org.eclipse.tm.internal.terminal.control, From b1cce33702e9edbcedae32750d821173235651a5 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 31 Oct 2022 21:31:38 -0400 Subject: [PATCH 62/76] Make missing identifiers and classes in plugin.xml errors Subsequent commits fix the errors --- .../.settings/org.eclipse.pde.prefs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs index d2dc703ba9e..c51d9ddc384 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs @@ -12,6 +12,7 @@ compilers.p.build.source.library=1 compilers.p.build.src.includes=1 compilers.p.deprecated=1 compilers.p.discouraged-class=1 +compilers.p.exec-env-too-low=1 compilers.p.internal=1 compilers.p.missing-packages=2 compilers.p.missing-version-export-package=2 @@ -22,10 +23,10 @@ compilers.p.no.automatic.module=1 compilers.p.not-externalized-att=1 compilers.p.service.component.without.lazyactivation=1 compilers.p.unknown-attribute=1 -compilers.p.unknown-class=1 +compilers.p.unknown-class=0 compilers.p.unknown-element=1 -compilers.p.unknown-identifier=1 -compilers.p.unknown-resource=1 +compilers.p.unknown-identifier=0 +compilers.p.unknown-resource=0 compilers.p.unresolved-ex-points=0 compilers.p.unresolved-import=0 compilers.s.create-docs=false From b785516c428f4cd7bbcd01ceb07a1f246251c087 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 27 Oct 2022 20:26:45 -0400 Subject: [PATCH 63/76] Upgrade build.properties warnings to errors Warning in build.properties will be errors when they run in the tycho build, like this: ``` Error: Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:2.7.5:package-plugin (default-package-plugin) on project org.eclipse.cdt.core.tests: /home/runner/work/cdt/cdt/core/org.eclipse.cdt.core.tests/build.properties: bin.includes value(s) [test.xml] do not match any files. -> [Help 1] ``` So make them errors in the workspace so that the issue is detected before push. Some build.properties issues don't affect the build, but are still indicative of a problem. --- .../.settings/org.eclipse.pde.prefs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs index c51d9ddc384..ffaa8e3f1a7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs +++ b/terminal/plugins/org.eclipse.tm.terminal.control/.settings/org.eclipse.pde.prefs @@ -2,14 +2,14 @@ compilers.f.unresolved-features=1 compilers.f.unresolved-plugins=1 compilers.incompatible-environment=1 compilers.p.build=1 -compilers.p.build.bin.includes=1 +compilers.p.build.bin.includes=0 compilers.p.build.encodings=2 compilers.p.build.java.compiler=2 compilers.p.build.java.compliance=1 compilers.p.build.missing.output=2 compilers.p.build.output.library=1 compilers.p.build.source.library=1 -compilers.p.build.src.includes=1 +compilers.p.build.src.includes=0 compilers.p.deprecated=1 compilers.p.discouraged-class=1 compilers.p.exec-env-too-low=1 From be7969edf363c7e7b6e08d83e4551817527e38c8 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 13 Mar 2023 14:42:36 -0400 Subject: [PATCH 64/76] Update copyright year on all features Part of #320 --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- .../plugins/org.eclipse.tm.terminal.control/about.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 19875a6916e..a684dd2c5a1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.4.0.qualifier +Bundle-Version: 5.4.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties index 39c4c3fbac2..b63893001c4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2018, 2022 Contributors to the Eclipse Foundation +# Copyright (c) 2018, 2023 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -24,7 +24,7 @@ blurb=TM Terminal Control\n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ -Copyright (c) 2018, 2022 Contributors to the Eclipse Foundation +Copyright (c) 2018, 2023 Contributors to the Eclipse Foundation \n\ See the NOTICE file(s) distributed with this work for additional\n\ information regarding copyright ownership.\n\ From 9cb730fa46e50cad25997a37cd68ee6ddb74c8c1 Mon Sep 17 00:00:00 2001 From: Maksym Oleksiv Date: Sat, 19 Aug 2023 03:36:56 +0300 Subject: [PATCH 65/76] Add ability to prevent terminal title updates from ANSI Escape sequence When a more complete implementation of ANSI Escape sequence for renaming terminal titles was added in [CDT 10.2](https://github.com/eclipse-cdt/cdt/blob/main/NewAndNoteworthy/CDT-10.2.md#rename-terminal-tab) it caused a regression in use cases where extenders of the terminal wanted to retain control of the terminal's title. This commit adds a new flag that will prevent the title of the terminal tab from being updated from ANSI escape sequences. Fixes #494 --- .../META-INF/MANIFEST.MF | 2 +- .../terminal/control/ITerminalListener.java | 4 +- .../terminal/control/ITerminalListener3.java | 40 +++++++++++++++++++ .../control/ITerminalViewControl.java | 11 +++++ .../control/impl/ITerminalControlForText.java | 9 ++++- .../terminal/emulator/VT100Emulator.java | 3 +- .../emulator/VT100TerminalControl.java | 14 ++++++- .../provisional/api/ITerminalControl.java | 13 +++++- 8 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener3.java diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index a684dd2c5a1..e368e8d27cb 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.4.100.qualifier +Bundle-Version: 5.5.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java index 62d548c29a0..400521ae774 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener.java @@ -28,8 +28,10 @@ public interface ITerminalListener { void setState(TerminalState state); /** - * Set the title of the terminal. + * @deprecated Migrate to implementing {@link ITerminalListener3} and + * override {@link ITerminalListener3#setTerminalTitle(String, String) * @param title */ + @Deprecated(forRemoval = true) void setTerminalTitle(String title); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener3.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener3.java new file mode 100644 index 00000000000..e9e983621e8 --- /dev/null +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalListener3.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2023 Infineon Technologies AG. All Rights Reserved. + * + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License 2.0 which accompanies this distribution, and is + * available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control; + +/** + * Terminal listener allowing to listen to terminal selection changes. + * The interface overrides the deprecated {@link #setTerminalTitle(String)} with + * {@link #setTerminalTitle(String, String)} that should be called instead. + * + * @since 5.5 + */ +public interface ITerminalListener3 extends ITerminalListener2 { + + /** + * Enum defines terminal title change requestors for + * setTerminalTitle method. + * + * @since 5.5 + */ + enum TerminalTitleRequestor { + ANSI, // Terminal tab title change requested using ANSI command in terminal. + MENU, // Terminal tab title change requested from menu. + OTHER; // Terminal tab title change requested by other requestors. + } + + /** + * Set the title of the terminal. + * + * @param title Terminal title. + * @param requestor Item that requests terminal title update. + */ + void setTerminalTitle(String title, TerminalTitleRequestor requestor); +} diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index d08a36c5586..d19b6516975 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -22,6 +22,7 @@ import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Control; +import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; @@ -192,9 +193,19 @@ public interface ITerminalViewControl { /** * @since 5.1 + * @deprecated call {@link #setTerminalTitle(String, String)} instead */ + @Deprecated(forRemoval = true) void setTerminalTitle(String newTitle); + /** + * Set the title of the terminal. + * @param newTitle + * @param requestor Item that requests terminal title update. + * @since 5.5 + */ + void setTerminalTitle(String newTitle, TerminalTitleRequestor requestor); + /** * @since 5.2 */ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java index 7fa736975e5..fc492dea59d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java @@ -14,6 +14,7 @@ import java.io.OutputStream; +import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; @@ -28,7 +29,13 @@ public interface ITerminalControlForText { void setState(TerminalState state); - void setTerminalTitle(String title); + /** + * Set the title of the terminal. + * + * @param title Termianl title. + * @param requestor Item that requests terminal title update. + */ + void setTerminalTitle(String title, TerminalTitleRequestor requestor); ITerminalConnector getTerminalConnector(); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 093fa472a9d..56970c23a63 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -45,6 +45,7 @@ import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.graphics.RGB; +import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor; import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText; import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; @@ -486,7 +487,7 @@ private void processAnsiOsCommand() { Logger.log("Ignoring unsupported ANSI OSC sequence: '" + ansiOsCommand + "'"); //$NON-NLS-1$ //$NON-NLS-2$ return; } - terminal.setTerminalTitle(ansiOsCommand.substring(2)); + terminal.setTerminalTitle(ansiOsCommand.substring(2), TerminalTitleRequestor.ANSI); } /** diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 759c16c750a..5680e3b1fc5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -98,6 +98,8 @@ import org.eclipse.tm.internal.terminal.control.ICommandInputField; import org.eclipse.tm.internal.terminal.control.ITerminalListener; import org.eclipse.tm.internal.terminal.control.ITerminalListener2; +import org.eclipse.tm.internal.terminal.control.ITerminalListener3; +import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor; import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText; @@ -1261,7 +1263,17 @@ private void processKeyBinding(KeyEvent event, int accelerator) { @Override public void setTerminalTitle(String title) { - fTerminalListener.setTerminalTitle(title); + setTerminalTitle(title, TerminalTitleRequestor.OTHER); + } + + @Override + public void setTerminalTitle(String title, TerminalTitleRequestor requestor) { + if (fTerminalListener instanceof ITerminalListener3 listener3) { + listener3.setTerminalTitle(title, requestor); + } else { + fTerminalListener.setTerminalTitle(title); + } + } @Override diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java index 267f7ac5f11..b47c0788a2e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalControl.java @@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; +import org.eclipse.tm.internal.terminal.control.ITerminalListener3.TerminalTitleRequestor; /** * Represents the terminal view as seen by a terminal connection. @@ -155,11 +156,19 @@ public interface ITerminalControl { OutputStream getRemoteToTerminalOutputStream(); /** - * Set the title of the terminal view. - * @param title + * @deprecated call {@link #setTerminalTitle(String, String)} instead */ + @Deprecated(forRemoval = true) void setTerminalTitle(String title); + /** + * Set the title of the terminal view. + * @param title Termianl title. + * @param requestor Item that requests terminal title update. + * @since 5.5 + */ + void setTerminalTitle(String title, TerminalTitleRequestor requestor); + /** * Show an error message during connect. * @param msg From 21206fd2e08b5de8f33c57a7d9ea24960d8035a1 Mon Sep 17 00:00:00 2001 From: coehlrich Date: Wed, 5 Jul 2023 15:04:57 +1200 Subject: [PATCH 66/76] Add support for ESC[#X to VT100 This escape sequence can be generated when using Powershell on Windows (and possibly other places too) to erase number of characters. Change-Id: I32405f51a3f91fd8653d44f2676a5c85b696ef99 --- .../terminal/emulator/IVT100EmulatorBackend.java | 7 +++++++ .../terminal/emulator/VT100BackendTraceDecorator.java | 5 +++++ .../tm/internal/terminal/emulator/VT100Emulator.java | 10 ++++++++-- .../terminal/emulator/VT100EmulatorBackend.java | 11 +++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java index c835bb817c4..1323f3a1f35 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java @@ -227,4 +227,11 @@ public interface IVT100EmulatorBackend { * scroll region. */ void processReverseLineFeed(); + + /** + * Replaces characters from the cursor position with space characters. + * + * @param n number of characters to replace + */ + void eraseCharacters(int n); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java index 615a7d6f618..013beb1c189 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java @@ -211,4 +211,9 @@ public void processReverseLineFeed() { fBackend.processReverseLineFeed(); } + @Override + public void eraseCharacters(int n) { + fWriter.println("eraseCharacters(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + fBackend.eraseCharacters(n); + } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 56970c23a63..af7eadd8254 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -617,8 +617,7 @@ private void processAnsiCommandCharacter(char ansiCommandCharacter) { case 'X': // Erase character. - // Emacs, vi, and GNU readline don't seem to use this command, so we ignore - // it for now. + processAnsiCommand_X(); break; case 'Z': @@ -1238,6 +1237,13 @@ private void processAnsiCommand_T() { text.scrollDown(getAnsiParameter(0)); } + /** + * Erases n characters from cursor (default = 1 character) + */ + private void processAnsiCommand_X() { + text.eraseCharacters(getAnsiParameter(0)); + } + private void processDecPrivateCommand_h() { int param = getAnsiParameter(0); switch (param) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index 514ec7c6a0f..14d79198ce1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -490,4 +490,15 @@ public void scrollDown(int n) { fTerminal.scroll(line, nLines, n); } } + + @Override + public void eraseCharacters(int n) { + synchronized (fTerminal) { + int line = toAbsoluteLine(fCursorLine); + int end = Math.min(fCursorColumn + n, fColumns); + for (int col = fCursorColumn; col < end; col++) { + fTerminal.setChar(line, col, '\000', null); + } + } + } } From 79a83586e6fd2b9bce599d483e687c6343524e3e Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 14 Sep 2023 21:17:28 -0400 Subject: [PATCH 67/76] Bump all bundles that are missing BREE in 11.3.0 Part of #551 --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index e368e8d27cb..865b710255b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.5.0.qualifier +Bundle-Version: 5.5.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin From 7e24bfa84faff2f66105dd357e22007fbe5f6d14 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Tue, 14 Nov 2023 17:53:17 -0500 Subject: [PATCH 68/76] Convert \b to 0x7f to properly handle backspace in the terminal (#619) Includes a new system property `org.eclipse.tm.terminal.control.convertBackspace` to allow us to disable this new behaviour in the field if it turns out that some terminal/host combination does not like this conversion. Fixes #392 --- .../emulator/VT100TerminalControl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 5680e3b1fc5..d6c94710ab1 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -184,6 +184,19 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private PollingTextCanvasModel fPollingTextCanvasModel; + /** + * In some circumstances (e.g PowerShell on Windows) the backspace + * character received from the keypress needs modifying. This + * system property allows disabling this new feature in case there + * are users who are negatively affected by this conversion. + * + * \b is ^H which is interpreted by the console as Ctrl + Backspace + * which deletes a word. \b on its own should just delete a character + * so we send 0x7f to do that. + */ + private boolean convertBackspace = Boolean + .parseBoolean(System.getProperty("org.eclipse.tm.terminal.control.convertBackspace", "true")); //$NON-NLS-1$ //$NON-NLS-2$ + /** * Instantiate a Terminal widget. * @param target Callback for notifying the owner of Terminal state changes. @@ -1175,6 +1188,11 @@ public void keyPressed(KeyEvent event) { } } + // see javadoc on convertBackspace for details + if (convertBackspace && !ctrlKeyPressed && character == '\b') { + character = 0x7f; + } + //TODO: At this point, Ctrl+M sends the same as Ctrl+Shift+M . //This is undesired. Fixing this here might make the special Ctrl+Shift+C //handling unnecessary further up. From d9cb83ce25d0d57801dd2f1db93d7e8e314196f0 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Thu, 28 Dec 2023 20:35:58 +0100 Subject: [PATCH 69/76] Clean up Maven build (#662) * remove invalid tycho resolver config (not valid since many versions) * fix PMD plugin configuration (config attribute was renamed in 3.18) * remove duplicate versions already managed in pluginManagement section * fix indentation * move all not yet configured versions into pluginManagement of the parent module to avoid further duplication * consume the target platform as file, not as maven artifact (this simplifies building a single module A LOT) * remove invalid tycho-source-plugin configuration * disable tycho consumer POM generation (not needed here, and avoids a warning in each module) * remove prerequisites. that's for maven plugins only, and this POM already contains the better suited similar maven enforcer rule * enforce UTF-8 for javadoc generation (the build fails on Windows otherwise, trying to read some Japanese? characters with the Windows default encoding) --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 865b710255b..07a75dc9417 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.5.100.qualifier +Bundle-Version: 5.5.200.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin From 2c096bf0470fbfaf1c9b4c60abfe3a8d1ccda00d Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 7 Mar 2024 14:17:45 -0500 Subject: [PATCH 70/76] Prep repo for 11.6.0 (#729) --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- .../plugins/org.eclipse.tm.terminal.control/about.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index 07a75dc9417..f208d8ece0e 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.5.200.qualifier +Bundle-Version: 5.5.300.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties index b63893001c4..195382071c7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2018, 2023 Contributors to the Eclipse Foundation +# Copyright (c) 2018, 2024 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -24,7 +24,7 @@ blurb=TM Terminal Control\n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ -Copyright (c) 2018, 2023 Contributors to the Eclipse Foundation +Copyright (c) 2018, 2024 Contributors to the Eclipse Foundation \n\ See the NOTICE file(s) distributed with this work for additional\n\ information regarding copyright ownership.\n\ From 512d3e2614b9f54bfc00b5ddc4ed7128db900558 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 19 Jun 2024 14:11:12 -0400 Subject: [PATCH 71/76] Add support for String Terminator to be ESC \ This fixes support to properly identify the end of OSC control sequences which can be terminated with a BEL or ESC \. Fixes https://github.com/eclipse-cdt/cdt/issues/831 --- .../terminal/emulator/VT100Emulator.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index af7eadd8254..e75a0f6d75d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -97,6 +97,12 @@ public class VT100Emulator implements ControlListener { */ private static final int ANSISTATE_EXPECTING_CHARSET_DESIGNATION = 5; + /** + * For cases where the OSC (OS Command) ends with a multi-byte ST (i.e. ESC \) + * we use this extra state. + */ + private static final int ANSISTATE_EXPECTING_OS_COMMAND_END = 6; + /** * This field holds the current state of the Finite TerminalState Automaton (FSA) * that recognizes ANSI escape sequences. @@ -428,16 +434,27 @@ private void processNewText() throws IOException { break; case ANSISTATE_EXPECTING_OS_COMMAND: - // A BEL (\u0007) character marks the end of the OSC sequence. + // A BEL (\u0007) or ESC \ ('\e\\') character marks the end of the OSC sequence. if (character == '\u0007') { ansiState = ANSISTATE_INITIAL; processAnsiOsCommand(); + } else if (character == '\u001b') { + ansiState = ANSISTATE_EXPECTING_OS_COMMAND_END; } else { ansiOsCommand.append(character); } break; + case ANSISTATE_EXPECTING_OS_COMMAND_END: + ansiState = ANSISTATE_INITIAL; + if (character == '\\') { + processAnsiOsCommand(); + } else { + Logger.log("Unsupported escape sequence: escape '" + ansiOsCommand + " \\e" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + break; + case ANSISTATE_EXPECTING_DEC_PRIVATE_COMMAND: // Parameters can appear after the '[?' in an escape sequence, but they // are optional. From e0552f019c8a1a8841f62427887f3e379cc7073b Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Wed, 19 Jun 2024 14:13:32 -0400 Subject: [PATCH 72/76] Bump version number for org.eclipse.tm.terminal.control --- .../org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index f208d8ece0e..c77b89c1bef 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.5.300.qualifier +Bundle-Version: 5.5.400.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin From 31aa75b7f6b7420fac437d5f58773e1ac6e59f9c Mon Sep 17 00:00:00 2001 From: astrograph Date: Fri, 17 Jan 2025 15:25:06 +0100 Subject: [PATCH 73/76] use UTF-8 as default encoding in the Terminal (#1020) the rest of Eclipse now uses UTF-8 as default encoding. The tm.terminal code reverts to null when the encoding begins with "Default" and this leads to UTF-8 being selected from Charset.defaultEncoding instead of ISO-8859 when the displayed default value is selected. Co-authored-by: Philipp SALZGEBER --- .../plugins/org.eclipse.tm.terminal.control/about.properties | 4 ++-- .../eclipse/tm/internal/terminal/emulator/VT100Emulator.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties index 195382071c7..1d0621870d8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/about.properties +++ b/terminal/plugins/org.eclipse.tm.terminal.control/about.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2018, 2024 Contributors to the Eclipse Foundation +# Copyright (c) 2018, 2025 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -24,7 +24,7 @@ blurb=TM Terminal Control\n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ -Copyright (c) 2018, 2024 Contributors to the Eclipse Foundation +Copyright (c) 2018, 2025 Contributors to the Eclipse Foundation \n\ See the NOTICE file(s) distributed with this work for additional\n\ information regarding copyright ownership.\n\ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index e75a0f6d75d..3e9323812e0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -1210,7 +1210,7 @@ private void processAnsiCommand_n() { } try { - terminal.getOutputStream().write(reply.getBytes("ISO-8859-1")); //$NON-NLS-1$ + terminal.getOutputStream().write(reply.getBytes("UTF-8")); //$NON-NLS-1$ terminal.getOutputStream().flush(); } catch (IOException ex) { Logger.log("Caught IOException!"); //$NON-NLS-1$ From 17979aff7d366c05c0ed0442e2fc7c40e0a8a650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 3 May 2025 19:23:13 +0200 Subject: [PATCH 74/76] Integrate Terminal control into platform build --- pom.xml | 1 + .../META-INF/MANIFEST.MF | 3 +- terminal/pom.xml | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 terminal/pom.xml diff --git a/pom.xml b/pom.xml index 2a60df405ae..c3bb950784f 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,7 @@ resources debug ua + terminal/ diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF index c77b89c1bef..a18b05e42c7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.control/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true -Bundle-Version: 5.5.400.qualifier +Bundle-Version: 5.6.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.core.runtime, Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: JavaSE-17 -Bundle-ClassPath: . Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true, org.eclipse.tm.internal.terminal.control, org.eclipse.tm.internal.terminal.control.actions, diff --git a/terminal/pom.xml b/terminal/pom.xml new file mode 100644 index 00000000000..61ee14a8c4a --- /dev/null +++ b/terminal/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + + org.eclipse.platform + eclipse.platform + 4.36.0-SNAPSHOT + + + eclipse.platform.terminal + pom + + + plugins + + + From dd352088c2dfc3e813ae8ad4ab977a8102e0d70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 4 May 2025 13:08:22 +0200 Subject: [PATCH 75/76] Fix javadoc --- .../tm/internal/terminal/control/ICommandInputField.java | 8 +++++--- .../internal/terminal/control/ITerminalViewControl.java | 5 +++-- .../internal/terminal/emulator/VT100TerminalControl.java | 2 -- .../terminal/preferences/TerminalColorsFieldEditor.java | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java index 8e314acd78b..874247b3fb3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ICommandInputField.java @@ -19,8 +19,10 @@ */ public interface ICommandInputField { /** - * @param parent - * @param terminal + * Create Control + * + * @param parent the parent of the input field + * @param terminal the terminal */ void createControl(Composite parent, ITerminalViewControl terminal); @@ -28,7 +30,7 @@ public interface ICommandInputField { /** * Sets the font of a control created with {@link #createControl(Composite, ITerminalViewControl)} - * @param control + * * @param font the new text font */ void setFont(Font font); diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java index d19b6516975..bf05fdc4874 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java @@ -142,9 +142,10 @@ public interface ITerminalViewControl { void connectTerminal(); /** - * @param write a single character to terminal + * write a single character to terminal + * @param c char to write */ - void sendKey(char arg0); + void sendKey(char c); /** * @param string write string to terminal diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index d6c94710ab1..9e5a4730cd3 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -202,8 +202,6 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC * @param target Callback for notifying the owner of Terminal state changes. * @param wndParent The Window parent to embed the Terminal in. * @param connectors Provided connectors. - * @param preferenceStore If non-null, the Terminal widget will pick up settings - * from the given store. * @since 3.2 */ public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java index 1ea8983c5ac..c8835ae1965 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalColorsFieldEditor.java @@ -63,7 +63,6 @@ public class TerminalColorsFieldEditor extends FieldEditor { /** * Creates a field editor for editing colors of {@link TerminalColor}. * The preference names used are as they are returned from {@link TerminalColor#getPreferenceName()} - * @param labelText * @param parent */ public TerminalColorsFieldEditor(Composite parent) { From 120ff885b6ea6e86184281561a2781fa3b6a273a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 4 May 2025 15:50:32 +0200 Subject: [PATCH 76/76] Fix compiler warning --- .../tm/internal/terminal/emulator/VT100TerminalControl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 9e5a4730cd3..3345e2d9ef4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -1282,6 +1282,7 @@ public void setTerminalTitle(String title) { setTerminalTitle(title, TerminalTitleRequestor.OTHER); } + @SuppressWarnings("removal") @Override public void setTerminalTitle(String title, TerminalTitleRequestor requestor) { if (fTerminalListener instanceof ITerminalListener3 listener3) {