mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Modernize tm.terminal.test.
Bump BREE to Java 1.8 and fix various warnings as they are seen. Change-Id: I3fb68f164832e6fa28c088c98ba57a7506365590 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
5e6ca30126
commit
ce7ecf4d04
28 changed files with 376 additions and 319 deletions
|
@ -1,11 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
|
||||||
<accessrules>
|
<accessrules>
|
||||||
<accessrule kind="accessible" pattern="org/eclipse/tm/internal/terminal/**"/>
|
<accessrule kind="accessible" pattern="org/eclipse/tm/internal/terminal/**"/>
|
||||||
</accessrules>
|
</accessrules>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -9,7 +9,7 @@ Require-Bundle: org.junit,
|
||||||
org.eclipse.tm.terminal.control;bundle-version="4.5.0",
|
org.eclipse.tm.terminal.control;bundle-version="4.5.0",
|
||||||
org.eclipse.core.runtime,
|
org.eclipse.core.runtime,
|
||||||
org.eclipse.ui
|
org.eclipse.ui
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true,
|
Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true,
|
||||||
org.eclipse.tm.internal.terminal.emulator;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.model;x-internal:=true,
|
||||||
|
|
|
@ -18,8 +18,6 @@ package org.eclipse.tm.internal.terminal.connector;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
@ -28,17 +26,22 @@ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TerminalConnectorFactoryTest extends TestCase {
|
public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
public class SettingsMock implements ISettingsStore {
|
public class SettingsMock implements ISettingsStore {
|
||||||
|
|
||||||
|
@Override
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String get(String key, String defaultValue) {
|
public String get(String key, String defaultValue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void put(String key, String value) {
|
public void put(String key, String value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,50 +49,64 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
|
|
||||||
public static class TerminalControlMock implements ITerminalControl {
|
public static class TerminalControlMock implements ITerminalControl {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setEncoding(String encoding) {
|
public void setEncoding(String encoding) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
return "ISO-8859-1"; //$NON-NLS-1$
|
return "ISO-8859-1"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void displayTextInTerminal(String text) {
|
public void displayTextInTerminal(String text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OutputStream getRemoteToTerminalOutputStream() {
|
public OutputStream getRemoteToTerminalOutputStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Shell getShell() {
|
public Shell getShell() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TerminalState getState() {
|
public TerminalState getState() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMsg(String msg) {
|
public void setMsg(String msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setState(TerminalState state) {
|
public void setState(TerminalState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTerminalTitle(String title) {
|
public void setTerminalTitle(String title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setupTerminal(Composite parent) {
|
public void setupTerminal(Composite parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isConnectOnEnterIfClosed() {
|
public boolean isConnectOnEnterIfClosed() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setConnectOnEnterIfClosed(boolean on) {
|
public void setConnectOnEnterIfClosed(boolean on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setVT100LineWrapping(boolean enable) {
|
public void setVT100LineWrapping(boolean enable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVT100LineWrapping() {
|
public boolean isVT100LineWrapping() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -105,36 +122,44 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
public ISettingsStore fLoadStore;
|
public ISettingsStore fLoadStore;
|
||||||
public boolean fDisconnect;
|
public boolean fDisconnect;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isLocalEcho() {
|
public boolean isLocalEcho() {
|
||||||
return fEcho;
|
return fEcho;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
fWidth = newWidth;
|
fWidth = newWidth;
|
||||||
fHeight = newHeight;
|
fHeight = newHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fTerminalControl = control;
|
fTerminalControl = control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void doDisconnect() {
|
public void doDisconnect() {
|
||||||
fDisconnect = true;
|
fDisconnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OutputStream getTerminalToRemoteStream() {
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
return "Summary";
|
return "Summary";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fLoadStore = store;
|
fLoadStore = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
fSaveStore = store;
|
fSaveStore = store;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +171,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
|
|
||||||
protected TerminalConnector makeTerminalConnector(final TerminalConnectorImpl mock) {
|
protected TerminalConnector makeTerminalConnector(final TerminalConnectorImpl mock) {
|
||||||
TerminalConnector c = new TerminalConnector(new TerminalConnector.Factory() {
|
TerminalConnector c = new TerminalConnector(new TerminalConnector.Factory() {
|
||||||
|
@Override
|
||||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
public TerminalConnectorImpl makeConnector() throws Exception {
|
||||||
return mock;
|
return mock;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +185,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
assertNull(c.getInitializationErrorMessage());
|
assertNull(c.getInitializationErrorMessage());
|
||||||
|
|
||||||
c = makeTerminalConnector(new ConnectorMock() {
|
c = makeTerminalConnector(new ConnectorMock() {
|
||||||
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
throw new Exception("FAILED");
|
throw new Exception("FAILED");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ package org.eclipse.tm.internal.terminal.connector;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.tm.internal.terminal.connector.TerminalConnector.Factory;
|
import org.eclipse.tm.internal.terminal.connector.TerminalConnector.Factory;
|
||||||
|
@ -28,17 +26,22 @@ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TerminalConnectorTest extends TestCase {
|
public class TerminalConnectorTest extends TestCase {
|
||||||
public class SettingsMock implements ISettingsStore {
|
public class SettingsMock implements ISettingsStore {
|
||||||
|
|
||||||
|
@Override
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String get(String key, String defaultValue) {
|
public String get(String key, String defaultValue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void put(String key, String value) {
|
public void put(String key, String value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,50 +49,64 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
|
|
||||||
public static class TerminalControlMock implements ITerminalControl {
|
public static class TerminalControlMock implements ITerminalControl {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setEncoding(String encoding) {
|
public void setEncoding(String encoding) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
return "ISO-8859-1"; //$NON-NLS-1$
|
return "ISO-8859-1"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void displayTextInTerminal(String text) {
|
public void displayTextInTerminal(String text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OutputStream getRemoteToTerminalOutputStream() {
|
public OutputStream getRemoteToTerminalOutputStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Shell getShell() {
|
public Shell getShell() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TerminalState getState() {
|
public TerminalState getState() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMsg(String msg) {
|
public void setMsg(String msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setState(TerminalState state) {
|
public void setState(TerminalState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTerminalTitle(String title) {
|
public void setTerminalTitle(String title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setupTerminal(Composite parent) {
|
public void setupTerminal(Composite parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isConnectOnEnterIfClosed() {
|
public boolean isConnectOnEnterIfClosed() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setConnectOnEnterIfClosed(boolean on) {
|
public void setConnectOnEnterIfClosed(boolean on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setVT100LineWrapping(boolean enable) {
|
public void setVT100LineWrapping(boolean enable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVT100LineWrapping() {
|
public boolean isVT100LineWrapping() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -105,36 +122,44 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
public ISettingsStore fLoadStore;
|
public ISettingsStore fLoadStore;
|
||||||
public boolean fDisconnect;
|
public boolean fDisconnect;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isLocalEcho() {
|
public boolean isLocalEcho() {
|
||||||
return fEcho;
|
return fEcho;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
fWidth = newWidth;
|
fWidth = newWidth;
|
||||||
fHeight = newHeight;
|
fHeight = newHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void connect(ITerminalControl control) {
|
public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fTerminalControl = control;
|
fTerminalControl = control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void doDisconnect() {
|
public void doDisconnect() {
|
||||||
fDisconnect = true;
|
fDisconnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OutputStream getTerminalToRemoteStream() {
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
return "Summary";
|
return "Summary";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fLoadStore = store;
|
fLoadStore = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
fSaveStore = store;
|
fSaveStore = store;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +172,7 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
fConnector = connector;
|
fConnector = connector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
public TerminalConnectorImpl makeConnector() throws Exception {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return fConnector;
|
return fConnector;
|
||||||
|
@ -159,6 +185,7 @@ public class TerminalConnectorTest extends TestCase {
|
||||||
assertNull(c.getInitializationErrorMessage());
|
assertNull(c.getInitializationErrorMessage());
|
||||||
|
|
||||||
c = new TerminalConnector(new SimpleFactory(new ConnectorMock() {
|
c = new TerminalConnector(new SimpleFactory(new ConnectorMock() {
|
||||||
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
throw new Exception("FAILED");
|
throw new Exception("FAILED");
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,13 @@ package org.eclipse.tm.internal.terminal.connector;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
final static String ENCODING = "UTF-8";
|
final static Charset ENCODING = StandardCharsets.UTF_8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class escapes strings coming on the original
|
* This class escapes strings coming on the original
|
||||||
|
@ -29,15 +30,18 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
class CleverInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
|
class CleverInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
fOriginal.write('[');
|
fOriginal.write('[');
|
||||||
fOriginal.write(b);
|
fOriginal.write(b);
|
||||||
fOriginal.write(']');
|
fOriginal.write(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
fOriginal.write('[');
|
fOriginal.write('[');
|
||||||
fOriginal.write(b, off, len);
|
fOriginal.write(b, off, len);
|
||||||
|
@ -49,44 +53,45 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
class NullInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
|
class NullInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClose() throws UnsupportedEncodingException, IOException {
|
public void testClose() throws IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
try (TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs)) {
|
||||||
s.write("begin:".getBytes(ENCODING));
|
s.write("begin:".getBytes(ENCODING));
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
OutputStream os1 = s.grabOutput();
|
OutputStream os1 = s.grabOutput();
|
||||||
os1.write('x');
|
os1.write('x');
|
||||||
s.write('A');
|
s.write('A');
|
||||||
os1.write('y');
|
os1.write('y');
|
||||||
s.write('B');
|
s.write('B');
|
||||||
os1.close();
|
os1.close();
|
||||||
|
|
||||||
s.write('-');
|
s.write('-');
|
||||||
OutputStream os = s.grabOutput();
|
OutputStream os = s.grabOutput();
|
||||||
// make sure the closed output does not inject anything
|
// make sure the closed output does not inject anything
|
||||||
try {
|
try {
|
||||||
os1.write('k');
|
os1.write('k');
|
||||||
fail("...");
|
fail("...");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
os.write('X');
|
||||||
|
s.write('a');
|
||||||
|
os.write('Y');
|
||||||
|
// make sure the closed output does not inject anything
|
||||||
|
try {
|
||||||
|
os1.write('l');
|
||||||
|
fail("...");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
s.write('b');
|
||||||
|
os.close();
|
||||||
|
assertEquals("begin:xyAB-XYab", new String(bs.toByteArray(), ENCODING));
|
||||||
}
|
}
|
||||||
os.write('X');
|
|
||||||
s.write('a');
|
|
||||||
os.write('Y');
|
|
||||||
// make sure the closed output does not inject anything
|
|
||||||
try {
|
|
||||||
os1.write('l');
|
|
||||||
fail("...");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
s.write('b');
|
|
||||||
os.close();
|
|
||||||
assertEquals("begin:xyAB-XYab", new String(bs.toByteArray(), ENCODING));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFlush() {
|
public void testFlush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWriteInt() throws UnsupportedEncodingException, IOException {
|
public void testWriteInt() throws IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
||||||
s.write("begin:".getBytes(ENCODING));
|
s.write("begin:".getBytes(ENCODING));
|
||||||
|
@ -107,78 +112,79 @@ public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
|
||||||
public void testWriteByteArrayIntInt() {
|
public void testWriteByteArrayIntInt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGrabOutput() throws UnsupportedEncodingException, IOException {
|
public void testGrabOutput() throws IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
try (TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs)) {
|
||||||
s.write("begin:".getBytes(ENCODING));
|
s.write("begin:".getBytes(ENCODING));
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
OutputStream os1 = s.grabOutput();
|
OutputStream os1 = s.grabOutput();
|
||||||
OutputStream os2;
|
OutputStream os2;
|
||||||
try {
|
try {
|
||||||
|
os2 = s.grabOutput();
|
||||||
|
fail("should fail until the foirst output is closed");
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
os1.close();
|
||||||
os2 = s.grabOutput();
|
os2 = s.grabOutput();
|
||||||
fail("should fail until the foirst output is closed");
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
} catch (IOException e) {
|
os2.write("Test".getBytes(ENCODING));
|
||||||
|
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
||||||
|
s.write(" west".getBytes(ENCODING));
|
||||||
|
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
||||||
|
os2.write(" the".getBytes(ENCODING));
|
||||||
|
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
||||||
|
os2.close();
|
||||||
|
assertEquals("begin:Test the west", new String(bs.toByteArray(), ENCODING));
|
||||||
|
s.write('!');
|
||||||
|
assertEquals("begin:Test the west!", new String(bs.toByteArray(), ENCODING));
|
||||||
}
|
}
|
||||||
os1.close();
|
|
||||||
os2 = s.grabOutput();
|
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
|
||||||
os2.write("Test".getBytes(ENCODING));
|
|
||||||
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
|
||||||
s.write(" west".getBytes(ENCODING));
|
|
||||||
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
|
||||||
os2.write(" the".getBytes(ENCODING));
|
|
||||||
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
|
||||||
os2.close();
|
|
||||||
assertEquals("begin:Test the west", new String(bs.toByteArray(), ENCODING));
|
|
||||||
s.write('!');
|
|
||||||
assertEquals("begin:Test the west!", new String(bs.toByteArray(), ENCODING));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGrabOutputWithCleverInterceptor() throws UnsupportedEncodingException, IOException {
|
public void testGrabOutputWithCleverInterceptor() throws IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
try (TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs)) {
|
||||||
s.write("begin:".getBytes(ENCODING));
|
s.write("begin:".getBytes(ENCODING));
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
// the injector escapes the output coming from the main stream
|
// the injector escapes the output coming from the main stream
|
||||||
OutputStream os = s.grabOutput(new CleverInterceptor());
|
OutputStream os = s.grabOutput(new CleverInterceptor());
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
os.write("Test".getBytes(ENCODING));
|
os.write("Test".getBytes(ENCODING));
|
||||||
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
||||||
s.write(" west".getBytes(ENCODING));
|
s.write(" west".getBytes(ENCODING));
|
||||||
assertEquals("begin:Test[ west]", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test[ west]", new String(bs.toByteArray(), ENCODING));
|
||||||
os.write(" the".getBytes(ENCODING));
|
os.write(" the".getBytes(ENCODING));
|
||||||
assertEquals("begin:Test[ west] the", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test[ west] the", new String(bs.toByteArray(), ENCODING));
|
||||||
s.write('x');
|
s.write('x');
|
||||||
assertEquals("begin:Test[ west] the[x]", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test[ west] the[x]", new String(bs.toByteArray(), ENCODING));
|
||||||
os.close();
|
os.close();
|
||||||
assertEquals("begin:Test[ west] the[x]", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test[ west] the[x]", new String(bs.toByteArray(), ENCODING));
|
||||||
s.write('!');
|
s.write('!');
|
||||||
assertEquals("begin:Test[ west] the[x]!", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test[ west] the[x]!", new String(bs.toByteArray(), ENCODING));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGrabOutputWithNullInterceptor() throws UnsupportedEncodingException, IOException {
|
public void testGrabOutputWithNullInterceptor() throws IOException {
|
||||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||||
TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs);
|
try (TerminalToRemoteInjectionOutputStream s = new TerminalToRemoteInjectionOutputStream(bs)) {
|
||||||
s.write("begin:".getBytes(ENCODING));
|
s.write("begin:".getBytes(ENCODING));
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
// bytes written to the main stream are ignored while the injector
|
// bytes written to the main stream are ignored while the injector
|
||||||
// is active
|
// is active
|
||||||
OutputStream os = s.grabOutput(new NullInterceptor());
|
OutputStream os = s.grabOutput(new NullInterceptor());
|
||||||
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:", new String(bs.toByteArray(), ENCODING));
|
||||||
os.write("Test".getBytes(ENCODING));
|
os.write("Test".getBytes(ENCODING));
|
||||||
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
||||||
s.write(" west".getBytes(ENCODING));
|
s.write(" west".getBytes(ENCODING));
|
||||||
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test", new String(bs.toByteArray(), ENCODING));
|
||||||
os.write(" the".getBytes(ENCODING));
|
os.write(" the".getBytes(ENCODING));
|
||||||
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
||||||
s.write('x');
|
s.write('x');
|
||||||
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
||||||
os.close();
|
os.close();
|
||||||
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test the", new String(bs.toByteArray(), ENCODING));
|
||||||
s.write('!');
|
s.write('!');
|
||||||
assertEquals("begin:Test the!", new String(bs.toByteArray(), ENCODING));
|
assertEquals("begin:Test the!", new String(bs.toByteArray(), ENCODING));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,18 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.model;
|
package org.eclipse.tm.internal.terminal.model;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
||||||
import org.eclipse.tm.terminal.model.LineSegment;
|
import org.eclipse.tm.terminal.model.LineSegment;
|
||||||
import org.eclipse.tm.terminal.model.Style;
|
import org.eclipse.tm.terminal.model.Style;
|
||||||
import org.eclipse.tm.terminal.model.StyleColor;
|
import org.eclipse.tm.terminal.model.StyleColor;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
abstract public class AbstractITerminalTextDataTest extends TestCase {
|
abstract public class AbstractITerminalTextDataTest extends TestCase {
|
||||||
abstract protected ITerminalTextData makeITerminalTextData();
|
abstract protected ITerminalTextData makeITerminalTextData();
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
try {
|
try {
|
||||||
assert false;
|
assert false;
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.tm.internal.terminal.model;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
|
||||||
public class SynchronizedTerminalTextDataTest extends AbstractITerminalTextDataTest {
|
public class SynchronizedTerminalTextDataTest extends AbstractITerminalTextDataTest {
|
||||||
|
@Override
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
return new SynchronizedTerminalTextData(new TerminalTextData());
|
return new SynchronizedTerminalTextData(new TerminalTextData());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.tm.internal.terminal.model;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
|
||||||
public class TerminalTextDataFastScrollTest extends AbstractITerminalTextDataTest {
|
public class TerminalTextDataFastScrollTest extends AbstractITerminalTextDataTest {
|
||||||
|
@Override
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
return new TerminalTextDataFastScroll(3);
|
return new TerminalTextDataFastScroll(3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.tm.internal.terminal.model;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
|
||||||
public class TerminalTextDataFastScrollTestMaxHeigth extends AbstractITerminalTextDataTest {
|
public class TerminalTextDataFastScrollTestMaxHeigth extends AbstractITerminalTextDataTest {
|
||||||
|
@Override
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
return new TerminalTextDataFastScroll(1);
|
return new TerminalTextDataFastScroll(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.model;
|
package org.eclipse.tm.internal.terminal.model;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
|
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
|
||||||
import org.eclipse.tm.terminal.model.Style;
|
import org.eclipse.tm.terminal.model.Style;
|
||||||
import org.eclipse.tm.terminal.model.StyleColor;
|
import org.eclipse.tm.terminal.model.StyleColor;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TerminalTextDataPerformanceTest extends TestCase {
|
public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
long TIME = 100;
|
long TIME = 100;
|
||||||
|
|
||||||
|
@ -40,11 +40,7 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
N = 0;
|
N = 0;
|
||||||
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
snapshot.addListener(snapshot1 -> N++);
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
|
||||||
N++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
method0(term, "0b");
|
method0(term, "0b");
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
@ -88,11 +84,7 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
ITerminalTextData term = new TerminalTextData();
|
ITerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
N = 0;
|
N = 0;
|
||||||
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
snapshot.addListener(snapshot1 -> N++);
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
|
||||||
N++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
method1(term, "1b");
|
method1(term, "1b");
|
||||||
snapshot.updateSnapshot(true);
|
snapshot.updateSnapshot(true);
|
||||||
}
|
}
|
||||||
|
@ -185,11 +177,7 @@ public class TerminalTextDataPerformanceTest extends TestCase {
|
||||||
TerminalTextData term = new TerminalTextData();
|
TerminalTextData term = new TerminalTextData();
|
||||||
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
ITerminalTextDataSnapshot snapshot = term.makeSnapshot();
|
||||||
N = 0;
|
N = 0;
|
||||||
snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener() {
|
snapshot.addListener(snapshot1 -> N++);
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
|
||||||
N++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
Style style = Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false,
|
||||||
false, false);
|
false, false);
|
||||||
initPerformance(term);
|
initPerformance(term);
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.model;
|
package org.eclipse.tm.internal.terminal.model;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
|
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
|
||||||
import org.eclipse.tm.terminal.model.Style;
|
import org.eclipse.tm.terminal.model.Style;
|
||||||
import org.eclipse.tm.terminal.model.StyleColor;
|
import org.eclipse.tm.terminal.model.StyleColor;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TerminalTextDataSnapshotTest extends TestCase {
|
public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
String toMultiLineText(ITerminalTextDataReadOnly term) {
|
String toMultiLineText(ITerminalTextDataReadOnly term) {
|
||||||
return TerminalTextTestHelper.toMultiLineText(term);
|
return TerminalTextTestHelper.toMultiLineText(term);
|
||||||
|
@ -794,6 +794,7 @@ public class TerminalTextDataSnapshotTest extends TestCase {
|
||||||
private final class SnapshotListener implements ITerminalTextDataSnapshot.SnapshotOutOfDateListener {
|
private final class SnapshotListener implements ITerminalTextDataSnapshot.SnapshotOutOfDateListener {
|
||||||
int N;
|
int N;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
|
||||||
N++;
|
N++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.tm.internal.terminal.model;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
|
||||||
public class TerminalTextDataStoreTest extends AbstractITerminalTextDataTest {
|
public class TerminalTextDataStoreTest extends AbstractITerminalTextDataTest {
|
||||||
|
@Override
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
return new TerminalTextDataStore();
|
return new TerminalTextDataStore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.tm.internal.terminal.model;
|
||||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||||
|
|
||||||
public class TerminalTextDataTest extends AbstractITerminalTextDataTest {
|
public class TerminalTextDataTest extends AbstractITerminalTextDataTest {
|
||||||
|
@Override
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
return new TerminalTextData();
|
return new TerminalTextData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
fSize = 2;
|
fSize = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected ITerminalTextData makeITerminalTextData() {
|
protected ITerminalTextData makeITerminalTextData() {
|
||||||
TerminalTextDataWindow term = new TerminalTextDataWindow();
|
TerminalTextDataWindow term = new TerminalTextDataWindow();
|
||||||
term.setWindow(fOffset, fSize);
|
term.setWindow(fOffset, fSize);
|
||||||
|
@ -40,6 +41,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
* @param expected
|
* @param expected
|
||||||
* @param actual
|
* @param actual
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void assertEqualsTerm(String expected, String actual) {
|
protected void assertEqualsTerm(String expected, String actual) {
|
||||||
assertEquals(stripMultiLine(expected), stripMultiLine(actual));
|
assertEquals(stripMultiLine(expected), stripMultiLine(actual));
|
||||||
}
|
}
|
||||||
|
@ -48,7 +50,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
StringBuffer b = new StringBuffer();
|
StringBuffer b = new StringBuffer();
|
||||||
// String[] lines=s.split("\n");
|
// String[] lines=s.split("\n");
|
||||||
// <J2ME CDC-1.1 Foundation-1.1 variant>
|
// <J2ME CDC-1.1 Foundation-1.1 variant>
|
||||||
ArrayList<String> l = new ArrayList<String>();
|
ArrayList<String> l = new ArrayList<>();
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int k = 0; k < s.length(); k++) {
|
for (int k = 0; k < s.length(); k++) {
|
||||||
if (s.charAt(k) == '\n') {
|
if (s.charAt(k) == '\n') {
|
||||||
|
@ -82,6 +84,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
* @param expected
|
* @param expected
|
||||||
* @param actual
|
* @param actual
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void assertEqualsSimple(String expected, String actual) {
|
protected void assertEqualsSimple(String expected, String actual) {
|
||||||
assertEquals(stripSimple(expected), stripSimple(actual));
|
assertEquals(stripSimple(expected), stripSimple(actual));
|
||||||
}
|
}
|
||||||
|
@ -97,6 +100,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testAddLine() {
|
public void testAddLine() {
|
||||||
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
|
@ -105,6 +109,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEqualsTerm("222\n" + "333\n" + "444\n" + "\0\0\0\n" + "\000\000\000", toMultiLineText(term));
|
assertEqualsTerm("222\n" + "333\n" + "444\n" + "\0\0\0\n" + "\000\000\000", toMultiLineText(term));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testMaxSize() {
|
public void testMaxSize() {
|
||||||
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
|
@ -130,6 +135,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
+ "\000\000\000\n" + "\000\000\000", toMultiLineText(term));
|
+ "\000\000\000\n" + "\000\000\000", toMultiLineText(term));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testGetLineSegments() {
|
public void testGetLineSegments() {
|
||||||
Style s1 = getDefaultStyle();
|
Style s1 = getDefaultStyle();
|
||||||
Style s2 = s1.setBold(true);
|
Style s2 = s1.setBold(true);
|
||||||
|
@ -178,6 +184,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testGetChar() {
|
public void testGetChar() {
|
||||||
String s = "12345\n" + "abcde\n" + "ABCDE";
|
String s = "12345\n" + "abcde\n" + "ABCDE";
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
|
@ -199,6 +206,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEquals('E', term.getChar(2, 4));
|
assertEquals('E', term.getChar(2, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testGetStyle() {
|
public void testGetStyle() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
Style style = getDefaultStyle();
|
Style style = getDefaultStyle();
|
||||||
|
@ -221,6 +229,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testSetChar() {
|
public void testSetChar() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(6, 3);
|
term.setDimensions(6, 3);
|
||||||
|
@ -240,6 +249,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "def\n" + "efg\n" + "fgh", toMultiLineText(term));
|
assertEqualsTerm("abc\n" + "bcd\n" + "cde\n" + "def\n" + "efg\n" + "fgh", toMultiLineText(term));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testSetChars() {
|
public void testSetChars() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(6, 3);
|
term.setDimensions(6, 3);
|
||||||
|
@ -268,6 +278,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testSetCharsLen() {
|
public void testSetCharsLen() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s = "ZYXWVU\n" + "abcdef\n" + "ABCDEF";
|
String s = "ZYXWVU\n" + "abcdef\n" + "ABCDEF";
|
||||||
|
@ -295,6 +306,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
fill(term, s);
|
fill(term, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testSetCopyLines() {
|
public void testSetCopyLines() {
|
||||||
ITerminalTextData term = new TerminalTextDataStore();
|
ITerminalTextData term = new TerminalTextDataStore();
|
||||||
String s = "012345";
|
String s = "012345";
|
||||||
|
@ -337,6 +349,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
assertEqualsSimple("a2345", toSimple(termCopy));
|
assertEqualsSimple("a2345", toSimple(termCopy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testScrollNegative() {
|
public void testScrollNegative() {
|
||||||
scrollTest(0, 2, -1, " 23 ", " 23 ");
|
scrollTest(0, 2, -1, " 23 ", " 23 ");
|
||||||
scrollTest(0, 1, -1, " 23 ", " 23 ");
|
scrollTest(0, 1, -1, " 23 ", " 23 ");
|
||||||
|
@ -351,6 +364,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
scrollTest(5, 1, -1, " 23 ", " 23 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testScrollAll() {
|
public void testScrollAll() {
|
||||||
scrollTest(0, 6, 1, " 2345", " 2 ");
|
scrollTest(0, 6, 1, " 2345", " 2 ");
|
||||||
scrollTest(0, 6, -1, " 2345", " 3 ");
|
scrollTest(0, 6, -1, " 2345", " 3 ");
|
||||||
|
@ -358,6 +372,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
scrollTest(0, 6, -2, " 2345", " ");
|
scrollTest(0, 6, -2, " 2345", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testCopyLineWithOffset() {
|
public void testCopyLineWithOffset() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
String s = "111\n" + "222\n" + "333\n" + "444\n" + "555";
|
||||||
|
@ -393,6 +408,7 @@ public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
|
||||||
term.copy(data);
|
term.copy(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testWrappedLines() {
|
public void testWrappedLines() {
|
||||||
ITerminalTextData term = makeITerminalTextData();
|
ITerminalTextData term = makeITerminalTextData();
|
||||||
term.setDimensions(4, 4);
|
term.setDimensions(4, 4);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class SpeedTestConnection extends Thread {
|
||||||
fSettings = settings;
|
fSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fControl.setState(TerminalState.CONNECTED);
|
fControl.setState(TerminalState.CONNECTED);
|
||||||
|
|
||||||
|
@ -113,11 +114,7 @@ public class SpeedTestConnection extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTitle(final String title) {
|
private void setTitle(final String title) {
|
||||||
Display.getDefault().asyncExec(new Runnable() {
|
Display.getDefault().asyncExec(() -> fControl.setTerminalTitle(title));
|
||||||
public void run() {
|
|
||||||
fControl.setTerminalTitle(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||||
public SpeedTestConnector() {
|
public SpeedTestConnector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
synchronized public void connect(ITerminalControl control) {
|
synchronized public void connect(ITerminalControl control) {
|
||||||
super.connect(control);
|
super.connect(control);
|
||||||
fControl.setState(TerminalState.CONNECTING);
|
fControl.setState(TerminalState.CONNECTING);
|
||||||
|
@ -52,6 +53,7 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||||
fConnection.start();
|
fConnection.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
synchronized public void doDisconnect() {
|
synchronized public void doDisconnect() {
|
||||||
if (fConnection != null) {
|
if (fConnection != null) {
|
||||||
fConnection.interrupt();
|
fConnection.interrupt();
|
||||||
|
@ -79,10 +81,12 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||||
return fInputStream;
|
return fInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
synchronized public OutputStream getTerminalToRemoteStream() {
|
synchronized public OutputStream getTerminalToRemoteStream() {
|
||||||
return fOutputStream;
|
return fOutputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
return fSettings.getInputFile();
|
return fSettings.getInputFile();
|
||||||
}
|
}
|
||||||
|
@ -92,14 +96,17 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||||
fSettings.load(new NullSettingsStore());
|
fSettings.load(new NullSettingsStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fSettings.load(store);
|
fSettings.load(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
fSettings.save(store);
|
fSettings.save(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,7 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
import org.eclipse.swt.widgets.Canvas;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.FileDialog;
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
@ -49,64 +47,56 @@ public class Snippet48 {
|
||||||
final Point origin = new Point(0, 0);
|
final Point origin = new Point(0, 0);
|
||||||
final Canvas canvas = new Canvas(shell, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
|
final Canvas canvas = new Canvas(shell, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
final ScrollBar hBar = canvas.getHorizontalBar();
|
final ScrollBar hBar = canvas.getHorizontalBar();
|
||||||
hBar.addListener(SWT.Selection, new Listener() {
|
hBar.addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event e) {
|
int hSelection = hBar.getSelection();
|
||||||
int hSelection = hBar.getSelection();
|
int destX = -hSelection - origin.x;
|
||||||
int destX = -hSelection - origin.x;
|
Rectangle rect = image.getBounds();
|
||||||
Rectangle rect = image.getBounds();
|
canvas.scroll(destX, 0, 0, 0, rect.width, rect.height, false);
|
||||||
canvas.scroll(destX, 0, 0, 0, rect.width, rect.height, false);
|
origin.x = -hSelection;
|
||||||
origin.x = -hSelection;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
final ScrollBar vBar = canvas.getVerticalBar();
|
final ScrollBar vBar = canvas.getVerticalBar();
|
||||||
vBar.addListener(SWT.Selection, new Listener() {
|
vBar.addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event e) {
|
int vSelection = vBar.getSelection();
|
||||||
int vSelection = vBar.getSelection();
|
int destY = -vSelection - origin.y;
|
||||||
int destY = -vSelection - origin.y;
|
Rectangle rect = image.getBounds();
|
||||||
Rectangle rect = image.getBounds();
|
canvas.scroll(0, destY, 0, 0, rect.width, rect.height, false);
|
||||||
canvas.scroll(0, destY, 0, 0, rect.width, rect.height, false);
|
origin.y = -vSelection;
|
||||||
|
});
|
||||||
|
canvas.addListener(SWT.Resize, e -> {
|
||||||
|
Rectangle rect = image.getBounds();
|
||||||
|
Rectangle client = canvas.getClientArea();
|
||||||
|
hBar.setMaximum(rect.width);
|
||||||
|
vBar.setMaximum(rect.height);
|
||||||
|
hBar.setThumb(Math.min(rect.width, client.width));
|
||||||
|
vBar.setThumb(Math.min(rect.height, client.height));
|
||||||
|
int hPage = rect.width - client.width;
|
||||||
|
int vPage = rect.height - client.height;
|
||||||
|
int hSelection = hBar.getSelection();
|
||||||
|
int vSelection = vBar.getSelection();
|
||||||
|
if (hSelection >= hPage) {
|
||||||
|
if (hPage <= 0)
|
||||||
|
hSelection = 0;
|
||||||
|
origin.x = -hSelection;
|
||||||
|
}
|
||||||
|
if (vSelection >= vPage) {
|
||||||
|
if (vPage <= 0)
|
||||||
|
vSelection = 0;
|
||||||
origin.y = -vSelection;
|
origin.y = -vSelection;
|
||||||
}
|
}
|
||||||
|
canvas.redraw();
|
||||||
});
|
});
|
||||||
canvas.addListener(SWT.Resize, new Listener() {
|
canvas.addListener(SWT.Paint, e -> {
|
||||||
public void handleEvent(Event e) {
|
GC gc = e.gc;
|
||||||
Rectangle rect = image.getBounds();
|
gc.drawImage(image, origin.x, origin.y);
|
||||||
Rectangle client = canvas.getClientArea();
|
Rectangle rect = image.getBounds();
|
||||||
hBar.setMaximum(rect.width);
|
Rectangle client = canvas.getClientArea();
|
||||||
vBar.setMaximum(rect.height);
|
int marginWidth = client.width - rect.width;
|
||||||
hBar.setThumb(Math.min(rect.width, client.width));
|
if (marginWidth > 0) {
|
||||||
vBar.setThumb(Math.min(rect.height, client.height));
|
gc.fillRectangle(rect.width, 0, marginWidth, client.height);
|
||||||
int hPage = rect.width - client.width;
|
|
||||||
int vPage = rect.height - client.height;
|
|
||||||
int hSelection = hBar.getSelection();
|
|
||||||
int vSelection = vBar.getSelection();
|
|
||||||
if (hSelection >= hPage) {
|
|
||||||
if (hPage <= 0)
|
|
||||||
hSelection = 0;
|
|
||||||
origin.x = -hSelection;
|
|
||||||
}
|
|
||||||
if (vSelection >= vPage) {
|
|
||||||
if (vPage <= 0)
|
|
||||||
vSelection = 0;
|
|
||||||
origin.y = -vSelection;
|
|
||||||
}
|
|
||||||
canvas.redraw();
|
|
||||||
}
|
}
|
||||||
});
|
int marginHeight = client.height - rect.height;
|
||||||
canvas.addListener(SWT.Paint, new Listener() {
|
if (marginHeight > 0) {
|
||||||
public void handleEvent(Event e) {
|
gc.fillRectangle(0, rect.height, client.width, marginHeight);
|
||||||
GC gc = e.gc;
|
|
||||||
gc.drawImage(image, origin.x, origin.y);
|
|
||||||
Rectangle rect = image.getBounds();
|
|
||||||
Rectangle client = canvas.getClientArea();
|
|
||||||
int marginWidth = client.width - rect.width;
|
|
||||||
if (marginWidth > 0) {
|
|
||||||
gc.fillRectangle(rect.width, 0, marginWidth, client.height);
|
|
||||||
}
|
|
||||||
int marginHeight = client.height - rect.height;
|
|
||||||
if (marginHeight > 0) {
|
|
||||||
gc.fillRectangle(0, rect.height, client.width, marginHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
shell.setSize(200, 150);
|
shell.setSize(200, 150);
|
||||||
|
|
|
@ -17,9 +17,7 @@ import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
import org.eclipse.swt.widgets.Canvas;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.FileDialog;
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
|
|
||||||
public class TerminalTextCanvas extends Canvas {
|
public class TerminalTextCanvas extends Canvas {
|
||||||
|
@ -31,65 +29,57 @@ public class TerminalTextCanvas extends Canvas {
|
||||||
loadImage(parent);
|
loadImage(parent);
|
||||||
|
|
||||||
final ScrollBar hBar = getHorizontalBar();
|
final ScrollBar hBar = getHorizontalBar();
|
||||||
hBar.addListener(SWT.Selection, new Listener() {
|
hBar.addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event e) {
|
int hSelection = hBar.getSelection();
|
||||||
int hSelection = hBar.getSelection();
|
int destX = -hSelection - origin.x;
|
||||||
int destX = -hSelection - origin.x;
|
Rectangle rect = image.getBounds();
|
||||||
Rectangle rect = image.getBounds();
|
scroll(destX, 0, 0, 0, rect.width, rect.height, false);
|
||||||
scroll(destX, 0, 0, 0, rect.width, rect.height, false);
|
origin.x = -hSelection;
|
||||||
origin.x = -hSelection;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
final ScrollBar vBar = getVerticalBar();
|
final ScrollBar vBar = getVerticalBar();
|
||||||
vBar.addListener(SWT.Selection, new Listener() {
|
vBar.addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event e) {
|
int vSelection = vBar.getSelection();
|
||||||
int vSelection = vBar.getSelection();
|
int destY = -vSelection - origin.y;
|
||||||
int destY = -vSelection - origin.y;
|
Rectangle rect = image.getBounds();
|
||||||
Rectangle rect = image.getBounds();
|
scroll(0, destY, 0, 0, rect.width, rect.height, false);
|
||||||
scroll(0, destY, 0, 0, rect.width, rect.height, false);
|
origin.y = -vSelection;
|
||||||
|
});
|
||||||
|
addListener(SWT.Resize, e -> {
|
||||||
|
Rectangle rect = image.getBounds();
|
||||||
|
Rectangle client = getClientArea();
|
||||||
|
hBar.setMaximum(rect.width);
|
||||||
|
vBar.setMaximum(rect.height);
|
||||||
|
hBar.setThumb(Math.min(rect.width, client.width));
|
||||||
|
vBar.setThumb(Math.min(rect.height, client.height));
|
||||||
|
int hPage = rect.width - client.width;
|
||||||
|
int vPage = rect.height - client.height;
|
||||||
|
int hSelection = hBar.getSelection();
|
||||||
|
int vSelection = vBar.getSelection();
|
||||||
|
if (hSelection >= hPage) {
|
||||||
|
if (hPage <= 0)
|
||||||
|
hSelection = 0;
|
||||||
|
origin.x = -hSelection;
|
||||||
|
}
|
||||||
|
if (vSelection >= vPage) {
|
||||||
|
if (vPage <= 0)
|
||||||
|
vSelection = 0;
|
||||||
origin.y = -vSelection;
|
origin.y = -vSelection;
|
||||||
}
|
}
|
||||||
|
redraw();
|
||||||
});
|
});
|
||||||
addListener(SWT.Resize, new Listener() {
|
addListener(SWT.Paint, e -> {
|
||||||
public void handleEvent(Event e) {
|
GC gc = e.gc;
|
||||||
Rectangle rect = image.getBounds();
|
System.out.println(gc.getClipping() + " " + origin);
|
||||||
Rectangle client = getClientArea();
|
gc.drawImage(image, origin.x, origin.y);
|
||||||
hBar.setMaximum(rect.width);
|
Rectangle rect = image.getBounds();
|
||||||
vBar.setMaximum(rect.height);
|
Rectangle client = getClientArea();
|
||||||
hBar.setThumb(Math.min(rect.width, client.width));
|
int marginWidth = client.width - rect.width;
|
||||||
vBar.setThumb(Math.min(rect.height, client.height));
|
if (marginWidth > 0) {
|
||||||
int hPage = rect.width - client.width;
|
gc.fillRectangle(rect.width, 0, marginWidth, client.height);
|
||||||
int vPage = rect.height - client.height;
|
|
||||||
int hSelection = hBar.getSelection();
|
|
||||||
int vSelection = vBar.getSelection();
|
|
||||||
if (hSelection >= hPage) {
|
|
||||||
if (hPage <= 0)
|
|
||||||
hSelection = 0;
|
|
||||||
origin.x = -hSelection;
|
|
||||||
}
|
|
||||||
if (vSelection >= vPage) {
|
|
||||||
if (vPage <= 0)
|
|
||||||
vSelection = 0;
|
|
||||||
origin.y = -vSelection;
|
|
||||||
}
|
|
||||||
redraw();
|
|
||||||
}
|
}
|
||||||
});
|
int marginHeight = client.height - rect.height;
|
||||||
addListener(SWT.Paint, new Listener() {
|
if (marginHeight > 0) {
|
||||||
public void handleEvent(Event e) {
|
gc.fillRectangle(0, rect.height, client.width, marginHeight);
|
||||||
GC gc = e.gc;
|
|
||||||
System.out.println(gc.getClipping() + " " + origin);
|
|
||||||
gc.drawImage(image, origin.x, origin.y);
|
|
||||||
Rectangle rect = image.getBounds();
|
|
||||||
Rectangle client = getClientArea();
|
|
||||||
int marginWidth = client.width - rect.width;
|
|
||||||
if (marginWidth > 0) {
|
|
||||||
gc.fillRectangle(rect.width, 0, marginWidth, client.height);
|
|
||||||
}
|
|
||||||
int marginHeight = client.height - rect.height;
|
|
||||||
if (marginHeight > 0) {
|
|
||||||
gc.fillRectangle(0, rect.height, client.width, marginHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
package org.eclipse.tm.internal.terminal.test.terminalcanvas;
|
package org.eclipse.tm.internal.terminal.test.terminalcanvas;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
@ -20,7 +18,6 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
import org.eclipse.swt.widgets.Canvas;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,40 +34,26 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
public VirtualCanvas(Composite parent, int style) {
|
public VirtualCanvas(Composite parent, int style) {
|
||||||
super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
|
super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
|
||||||
fPaintGC = new GC(this);
|
fPaintGC = new GC(this);
|
||||||
addListener(SWT.Paint, new Listener() {
|
addListener(SWT.Paint, event -> paint(event.gc));
|
||||||
public void handleEvent(Event event) {
|
addListener(SWT.Resize, event -> {
|
||||||
paint(event.gc);
|
fClientArea = getClientArea();
|
||||||
}
|
updateViewRectangle();
|
||||||
});
|
});
|
||||||
addListener(SWT.Resize, new Listener() {
|
getVerticalBar().addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event event) {
|
scrollY((ScrollBar) e.widget);
|
||||||
fClientArea = getClientArea();
|
postScrollEventHandling(e);
|
||||||
updateViewRectangle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getVerticalBar().addListener(SWT.Selection, new Listener() {
|
|
||||||
public void handleEvent(Event e) {
|
|
||||||
scrollY((ScrollBar) e.widget);
|
|
||||||
postScrollEventHandling(e);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
getHorizontalBar().addListener(SWT.Selection, new Listener() {
|
getHorizontalBar().addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event e) {
|
scrollX((ScrollBar) e.widget);
|
||||||
scrollX((ScrollBar) e.widget);
|
postScrollEventHandling(e);
|
||||||
postScrollEventHandling(e);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
addDisposeListener(new DisposeListener() {
|
addDisposeListener(e -> {
|
||||||
public void widgetDisposed(DisposeEvent e) {
|
if (fPaintGC != null) {
|
||||||
if (fPaintGC != null) {
|
fPaintGC.dispose();
|
||||||
fPaintGC.dispose();
|
fPaintGC = null;
|
||||||
fPaintGC = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ abstract class AbstractLineOrientedDataSource implements IDataSource {
|
||||||
|
|
||||||
abstract public void next();
|
abstract public void next();
|
||||||
|
|
||||||
|
@Override
|
||||||
public int step(ITerminalTextData terminal) {
|
public int step(ITerminalTextData terminal) {
|
||||||
next();
|
next();
|
||||||
char[] chars = dataSource();
|
char[] chars = dataSource();
|
||||||
|
|
|
@ -32,6 +32,7 @@ class DataReader implements Runnable {
|
||||||
fThread.start();
|
fThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long t0 = System.currentTimeMillis() - 1;
|
long t0 = System.currentTimeMillis() - 1;
|
||||||
long c = 0;
|
long c = 0;
|
||||||
|
|
|
@ -19,14 +19,17 @@ final class FastDataSource extends AbstractLineOrientedDataSource {
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] dataSource() {
|
public char[] dataSource() {
|
||||||
return lines[pos % lines.length];
|
return lines[pos % lines.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void next() {
|
public void next() {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,17 @@ final class FileDataSource extends AbstractLineOrientedDataSource {
|
||||||
fFile = file;
|
fFile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] dataSource() {
|
public char[] dataSource() {
|
||||||
return line.toCharArray();
|
return line.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void next() {
|
public void next() {
|
||||||
try {
|
try {
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
|
|
|
@ -23,15 +23,18 @@ final class LineCountingDataSource extends AbstractLineOrientedDataSource {
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] dataSource() {
|
public char[] dataSource() {
|
||||||
return (pos + " 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789")
|
return (pos + " 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789")
|
||||||
.toCharArray();
|
.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
return styles[pos % styles.length];
|
return styles[pos % styles.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void next() {
|
public void next() {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class RandomDataSource implements IDataSource {
|
||||||
styleNormal.setReverse(true), styleNormal.setReverse(true).setBold(true),
|
styleNormal.setReverse(true), styleNormal.setReverse(true).setBold(true),
|
||||||
styleNormal.setReverse(true).setUnderline(true) };
|
styleNormal.setReverse(true).setUnderline(true) };
|
||||||
|
|
||||||
|
@Override
|
||||||
public int step(ITerminalTextData terminal) {
|
public int step(ITerminalTextData terminal) {
|
||||||
int N = fRandom.nextInt(1000);
|
int N = fRandom.nextInt(1000);
|
||||||
int h = terminal.getHeight();
|
int h = terminal.getHeight();
|
||||||
|
|
|
@ -16,8 +16,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -55,13 +53,12 @@ public class TerminalTextUITest {
|
||||||
private static Text heightText;
|
private static Text heightText;
|
||||||
|
|
||||||
static class Status implements IStatus {
|
static class Status implements IStatus {
|
||||||
|
@Override
|
||||||
public void setStatus(final String s) {
|
public void setStatus(final String s) {
|
||||||
if (!fStatusLabel.isDisposed())
|
if (!fStatusLabel.isDisposed())
|
||||||
Display.getDefault().asyncExec(new Runnable() {
|
Display.getDefault().asyncExec(() -> {
|
||||||
public void run() {
|
if (!fStatusLabel.isDisposed())
|
||||||
if (!fStatusLabel.isDisposed())
|
fStatusLabel.setText(s);
|
||||||
fStatusLabel.setText(s);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,19 +126,17 @@ public class TerminalTextUITest {
|
||||||
addLabel(composite, "maxHeight:");
|
addLabel(composite, "maxHeight:");
|
||||||
final Text maxHeightText = new Text(composite, SWT.BORDER);
|
final Text maxHeightText = new Text(composite, SWT.BORDER);
|
||||||
setLayoutData(maxHeightText, 30);
|
setLayoutData(maxHeightText, 30);
|
||||||
maxHeightText.addModifyListener(new ModifyListener() {
|
maxHeightText.addModifyListener(e -> {
|
||||||
public void modifyText(ModifyEvent e) {
|
synchronized (fTerminalModel) {
|
||||||
synchronized (fTerminalModel) {
|
int height = textToInt(maxHeightText);
|
||||||
int height = textToInt(maxHeightText);
|
if (height < 1)
|
||||||
if (height < 1)
|
return;
|
||||||
return;
|
if (fTerminalModel.getHeight() > height) {
|
||||||
if (fTerminalModel.getHeight() > height) {
|
fTerminalModel.scroll(0, fTerminalModel.getHeight(), height - fTerminalModel.getHeight());
|
||||||
fTerminalModel.scroll(0, fTerminalModel.getHeight(), height - fTerminalModel.getHeight());
|
fTerminalModel.setDimensions(height, fTerminalModel.getWidth());
|
||||||
fTerminalModel.setDimensions(height, fTerminalModel.getWidth());
|
heightText.setText(height + "");
|
||||||
heightText.setText(height + "");
|
|
||||||
}
|
|
||||||
fTerminalModel.setMaxHeight(height);
|
|
||||||
}
|
}
|
||||||
|
fTerminalModel.setMaxHeight(height);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
maxHeightText.setText(fHeight + "");
|
maxHeightText.setText(fHeight + "");
|
||||||
|
@ -152,16 +147,14 @@ public class TerminalTextUITest {
|
||||||
addLabel(composite, "heigth:");
|
addLabel(composite, "heigth:");
|
||||||
heightText = new Text(composite, SWT.BORDER);
|
heightText = new Text(composite, SWT.BORDER);
|
||||||
setLayoutData(heightText, 30);
|
setLayoutData(heightText, 30);
|
||||||
heightText.addModifyListener(new ModifyListener() {
|
heightText.addModifyListener(e -> {
|
||||||
public void modifyText(ModifyEvent e) {
|
synchronized (fTerminalModel) {
|
||||||
synchronized (fTerminalModel) {
|
int height = textToInt(heightText);
|
||||||
int height = textToInt(heightText);
|
if (height < 1)
|
||||||
if (height < 1)
|
return;
|
||||||
return;
|
maxHeightText.setText("" + height);
|
||||||
maxHeightText.setText("" + height);
|
fTerminalModel.setDimensions(height, fTerminalModel.getWidth());
|
||||||
fTerminalModel.setDimensions(height, fTerminalModel.getWidth());
|
fTerminalModel.setMaxHeight(height);
|
||||||
fTerminalModel.setMaxHeight(height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
heightText.setText(fHeight + "");
|
heightText.setText(fHeight + "");
|
||||||
|
@ -171,13 +164,11 @@ public class TerminalTextUITest {
|
||||||
addLabel(composite, "width:");
|
addLabel(composite, "width:");
|
||||||
final Text widthText = new Text(composite, SWT.BORDER);
|
final Text widthText = new Text(composite, SWT.BORDER);
|
||||||
setLayoutData(widthText, 30);
|
setLayoutData(widthText, 30);
|
||||||
widthText.addModifyListener(new ModifyListener() {
|
widthText.addModifyListener(e -> {
|
||||||
public void modifyText(ModifyEvent e) {
|
synchronized (fTerminalModel) {
|
||||||
synchronized (fTerminalModel) {
|
int width = textToInt(widthText);
|
||||||
int width = textToInt(widthText);
|
if (width > 1)
|
||||||
if (width > 1)
|
fTerminalModel.setDimensions(fTerminalModel.getHeight(), width);
|
||||||
fTerminalModel.setDimensions(fTerminalModel.getHeight(), width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
widthText.setText(fWidth + "");
|
widthText.setText(fWidth + "");
|
||||||
|
@ -188,12 +179,10 @@ public class TerminalTextUITest {
|
||||||
addLabel(composite, "throttle:");
|
addLabel(composite, "throttle:");
|
||||||
final Text throttleText = new Text(composite, SWT.BORDER);
|
final Text throttleText = new Text(composite, SWT.BORDER);
|
||||||
setLayoutData(throttleText, 30);
|
setLayoutData(throttleText, 30);
|
||||||
throttleText.addModifyListener(new ModifyListener() {
|
throttleText.addModifyListener(e -> {
|
||||||
public void modifyText(ModifyEvent e) {
|
synchronized (fTerminalModel) {
|
||||||
synchronized (fTerminalModel) {
|
int throttle = textToInt(throttleText);
|
||||||
int throttle = textToInt(throttleText);
|
setThrottleForAll(throttle);
|
||||||
setThrottleForAll(throttle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return throttleText;
|
return throttleText;
|
||||||
|
@ -204,6 +193,7 @@ public class TerminalTextUITest {
|
||||||
stopAllButton.setText("Stop ALL");
|
stopAllButton.setText("Stop ALL");
|
||||||
stopAllButton.addSelectionListener(new SelectionAdapter() {
|
stopAllButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean stop = stopAllButton.getSelection();
|
boolean stop = stopAllButton.getSelection();
|
||||||
for (Iterator iterator = fDataReaders.iterator(); iterator.hasNext();) {
|
for (Iterator iterator = fDataReaders.iterator(); iterator.hasNext();) {
|
||||||
|
@ -220,6 +210,7 @@ public class TerminalTextUITest {
|
||||||
final Button button = new Button(composite, SWT.CHECK);
|
final Button button = new Button(composite, SWT.CHECK);
|
||||||
button.setText("ScrollLock");
|
button.setText("ScrollLock");
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean scrollLock = button.getSelection();
|
boolean scrollLock = button.getSelection();
|
||||||
fgTextCanvas.setScrollLock(scrollLock);
|
fgTextCanvas.setScrollLock(scrollLock);
|
||||||
|
@ -240,6 +231,7 @@ public class TerminalTextUITest {
|
||||||
button.setText(reader.getName());
|
button.setText(reader.getName());
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
reader.setStart(button.getSelection());
|
reader.setStart(button.getSelection());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
|
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
|
||||||
import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
|
import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
|
||||||
|
@ -55,16 +55,19 @@ final class VT100DataSource implements IDataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int available() throws IOException {
|
public int available() throws IOException {
|
||||||
return fAvailable;
|
return fAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream fInputStream;
|
private InputStream fInputStream;
|
||||||
|
|
||||||
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
public int read(byte[] b, int off, int len) throws IOException {
|
||||||
while (fAvailable == 0) {
|
while (fAvailable == 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -87,12 +90,7 @@ final class VT100DataSource implements IDataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(ITerminalTextData terminal) {
|
void init(ITerminalTextData terminal) {
|
||||||
final Reader reader;
|
final Reader reader = new InputStreamReader(new InfiniteFileInputStream(), StandardCharsets.ISO_8859_1);
|
||||||
try {
|
|
||||||
reader = new InputStreamReader(new InfiniteFileInputStream(), "ISO-8859-1"); //$NON-NLS-1$
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
fEmulator = new VT100Emulator(terminal, new ITerminalControlForText() {
|
fEmulator = new VT100Emulator(terminal, new ITerminalControlForText() {
|
||||||
|
|
||||||
public void disconnectTerminal() {
|
public void disconnectTerminal() {
|
||||||
|
@ -100,29 +98,36 @@ final class VT100DataSource implements IDataSource {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OutputStream getOutputStream() {
|
public OutputStream getOutputStream() {
|
||||||
return new ByteArrayOutputStream();
|
return new ByteArrayOutputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TerminalState getState() {
|
public TerminalState getState() {
|
||||||
return TerminalState.CONNECTED;
|
return TerminalState.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ITerminalConnector getTerminalConnector() {
|
public ITerminalConnector getTerminalConnector() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setState(TerminalState state) {
|
public void setState(TerminalState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTerminalTitle(String title) {
|
public void setTerminalTitle(String title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void enableApplicationCursorKeys(boolean enable) {
|
public void enableApplicationCursorKeys(boolean enable) {
|
||||||
}
|
}
|
||||||
}, reader);
|
}, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int step(ITerminalTextData terminal) {
|
public int step(ITerminalTextData terminal) {
|
||||||
synchronized (terminal) {
|
synchronized (terminal) {
|
||||||
if (fEmulator == null) {
|
if (fEmulator == null) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
class PipedStreamTest {
|
class PipedStreamTest {
|
||||||
static class ReadThread extends Thread implements Runnable {
|
static class ReadThread extends Thread {
|
||||||
|
|
||||||
InputStream pi = null;
|
InputStream pi = null;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class PipedStreamTest {
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
byte[] buffer = new byte[2048];
|
byte[] buffer = new byte[2048];
|
||||||
int bytes_read;
|
int bytes_read;
|
||||||
|
@ -56,6 +57,7 @@ class PipedStreamTest {
|
||||||
N = n;
|
N = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
public int read(byte[] b, int off, int len) throws IOException {
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -67,6 +69,7 @@ class PipedStreamTest {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +77,7 @@ class PipedStreamTest {
|
||||||
/*
|
/*
|
||||||
* available has to be implemented!
|
* available has to be implemented!
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int available() throws IOException {
|
public int available() throws IOException {
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
@ -82,10 +86,12 @@ class PipedStreamTest {
|
||||||
static class FakeOutputStream extends OutputStream {
|
static class FakeOutputStream extends OutputStream {
|
||||||
long N;
|
long N;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
N += len;
|
N += len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue