From f50eae0f94eaf0e925dadd12cbc8a7c19aea1e82 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 27 Nov 2014 17:01:26 +0100 Subject: [PATCH] Bug 453393 - Add support for copying wrapped lines without line break Change-Id: Id4e836854bffd4f58243018e240cac917bb04c73 Signed-off-by: Anton Leherbauer --- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.rse.terminals.ui/pom.xml | 2 +- .../feature.xml | 2 +- .../feature.xml | 2 +- .../feature.xml | 2 +- .../feature.xml | 2 +- .../feature.xml | 2 +- .../feature.xml | 2 +- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.tm.terminal.local/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.tm.terminal.serial/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.tm.terminal.ssh/pom.xml | 2 +- .../internal/terminal/ssh/SshConnection.java | 7 ++- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.tm.terminal.telnet/pom.xml | 2 +- .../terminal/telnet/TelnetConnector.java | 5 +- .../terminal/telnet/TelnetOption.java | 11 ++-- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.tm.terminal.test/pom.xml | 2 +- .../emulator/VT100EmulatorBackendTest.java | 52 ++++++++++++++++++- .../model/AbstractITerminalTextDataTest.java | 19 ++++++- .../model/TerminalTextDataWindowTest.java | 15 +++++- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.tm.terminal.view/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../plugins/org.eclipse.tm.terminal/pom.xml | 2 +- .../emulator/VT100EmulatorBackend.java | 19 ++++--- .../model/SynchronizedTerminalTextData.java | 9 +++- .../terminal/model/TerminalTextData.java | 11 +++- .../model/TerminalTextDataFastScroll.java | 11 +++- .../model/TerminalTextDataSnapshot.java | 6 ++- .../terminal/model/TerminalTextDataStore.java | 29 +++++++---- .../model/TerminalTextDataWindow.java | 12 ++++- .../textcanvas/AbstractTextCanvasModel.java | 2 +- .../tm/terminal/model/ITerminalTextData.java | 26 ++++------ .../model/ITerminalTextDataReadOnly.java | 13 ++++- 38 files changed, 225 insertions(+), 80 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF index 63914912400..5703f247e9d 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.rse.terminals.ui;singleton:=true -Bundle-Version: 1.2.100.qualifier +Bundle-Version: 1.2.200.qualifier Bundle-Activator: org.eclipse.rse.internal.terminals.ui.Activator Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.expressions, @@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.ui;bundle-version="[3.1.0,4.0.0)", org.eclipse.rse.subsystems.terminals.core;bundle-version="[1.0.0,2.0.0)", - org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.4.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Bundle-Vendor: %providerName diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/pom.xml b/rse/plugins/org.eclipse.rse.terminals.ui/pom.xml index f3d0f23ec44..f1fad4b1f50 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/pom.xml +++ b/rse/plugins/org.eclipse.rse.terminals.ui/pom.xml @@ -10,6 +10,6 @@ org.eclipse.tm org.eclipse.rse.terminals.ui - 1.2.100-SNAPSHOT + 1.2.200-SNAPSHOT eclipse-plugin diff --git a/terminal/features/org.eclipse.tm.terminal.local-feature/feature.xml b/terminal/features/org.eclipse.tm.terminal.local-feature/feature.xml index 8c58ff35dac..65fbbc4272e 100644 --- a/terminal/features/org.eclipse.tm.terminal.local-feature/feature.xml +++ b/terminal/features/org.eclipse.tm.terminal.local-feature/feature.xml @@ -43,7 +43,7 @@ - + diff --git a/terminal/features/org.eclipse.tm.terminal.serial-feature/feature.xml b/terminal/features/org.eclipse.tm.terminal.serial-feature/feature.xml index 84c9fcd210a..d7939c87a65 100644 --- a/terminal/features/org.eclipse.tm.terminal.serial-feature/feature.xml +++ b/terminal/features/org.eclipse.tm.terminal.serial-feature/feature.xml @@ -38,7 +38,7 @@ - + - + diff --git a/terminal/features/org.eclipse.tm.terminal.telnet-feature/feature.xml b/terminal/features/org.eclipse.tm.terminal.telnet-feature/feature.xml index 8b7b79724a6..a4f39c1252a 100644 --- a/terminal/features/org.eclipse.tm.terminal.telnet-feature/feature.xml +++ b/terminal/features/org.eclipse.tm.terminal.telnet-feature/feature.xml @@ -38,7 +38,7 @@ - + - + diff --git a/terminal/features/org.eclipse.tm.terminal.view-feature/feature.xml b/terminal/features/org.eclipse.tm.terminal.view-feature/feature.xml index 33cae33d036..c540c0a6e8b 100644 --- a/terminal/features/org.eclipse.tm.terminal.view-feature/feature.xml +++ b/terminal/features/org.eclipse.tm.terminal.view-feature/feature.xml @@ -39,7 +39,7 @@ - + org.eclipse.tm org.eclipse.tm.terminal.local - 0.2.200.qualifier + 0.2.300.qualifier eclipse-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF index 5c007ac824b..af62eba6bc0 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.serial;singleton:=true -Bundle-Version: 2.1.300.qualifier +Bundle-Version: 2.1.400.qualifier Bundle-Localization: plugin Import-Package: gnu.io;resolution:=optional Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.4.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Eclipse-BuddyPolicy: ext diff --git a/terminal/plugins/org.eclipse.tm.terminal.serial/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.serial/pom.xml index aff58b57e08..ee07be1d72f 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.serial/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.serial/pom.xml @@ -10,6 +10,6 @@ org.eclipse.tm org.eclipse.tm.terminal.serial - 2.1.300.qualifier + 2.1.400.qualifier eclipse-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF index 55ab410df43..cfbb357f8a4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.ssh;singleton:=true -Bundle-Version: 2.1.300.qualifier +Bundle-Version: 2.1.400.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)", + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.4.0)", com.jcraft.jsch;bundle-version="[0.1.31,1.0.0)", org.eclipse.jsch.core;bundle-version="[1.0.0,2.0.0)" Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/terminal/plugins/org.eclipse.tm.terminal.ssh/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.ssh/pom.xml index 9f8f166a77f..a2e94c12539 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.ssh/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.ssh/pom.xml @@ -10,6 +10,6 @@ org.eclipse.tm org.eclipse.tm.terminal.ssh - 2.1.300.qualifier + 2.1.400.qualifier eclipse-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java b/terminal/plugins/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java index 38d9608cbad..8bf6f2879d7 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java +++ b/terminal/plugins/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2014 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 @@ -20,6 +20,7 @@ * Michael Scharf (Wind River) - 240420: [terminal][ssh]Channel is not closed when the connection is closed with the close button * Martin Oberhuber (Wind River) - [206919] Improve SSH Terminal Error Reporting * Andrei Sobolev (Xored) - [250456] Ssh banner message causes IllegalArgumentException popup + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ package org.eclipse.tm.internal.terminal.ssh; @@ -137,7 +138,9 @@ class SshConnection extends Thread { if(!isSessionConnected()) return; ChannelShell channel=(ChannelShell) session.openChannel("shell"); //$NON-NLS-1$ - channel.setPtyType("ansi"); //$NON-NLS-1$ + channel.setPtyType("xterm"); //$NON-NLS-1$ + // TERM=xterm implies VT100 line wrapping mode + fControl.setVT100LineWrapping(true); channel.connect(); // maybe the terminal was disconnected while we were connecting diff --git a/terminal/plugins/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF index 44fb88a1e38..f3aea71b33b 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.telnet;singleton:=true -Bundle-Version: 2.1.300.qualifier +Bundle-Version: 2.1.400.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.4.0)" Bundle-RequiredExecutionEnvironment: J2SE-1.4 Export-Package: org.eclipse.tm.internal.terminal.telnet;x-internal:=true diff --git a/terminal/plugins/org.eclipse.tm.terminal.telnet/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.telnet/pom.xml index 559d057d767..018e59a1f82 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.telnet/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.telnet/pom.xml @@ -10,6 +10,6 @@ org.eclipse.tm org.eclipse.tm.terminal.telnet - 2.1.300.qualifier + 2.1.400.qualifier eclipse-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetConnector.java b/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetConnector.java index d9e57a07039..0fde60e53aa 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetConnector.java +++ b/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetConnector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2005, 2014 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 @@ -16,6 +16,7 @@ * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl * Sean Adams (Cisco) - [231959][terminal][telnet] NPE in TelnetConnector.java * David Sciamma (Anyware-Tech) - [288254][telnet] local echo is always disabled + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ package org.eclipse.tm.internal.terminal.telnet; @@ -50,6 +51,8 @@ public class TelnetConnector extends TerminalConnectorImpl { super.connect(control); fWidth=-1; fHeight=-1; + // TERM=xterm implies VT100 line wrapping mode + control.setVT100LineWrapping(true); TelnetConnectWorker worker = new TelnetConnectWorker(this,control); worker.start(); } diff --git a/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetOption.java b/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetOption.java index 76596a4308f..835e2e1da87 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetOption.java +++ b/terminal/plugins/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetOption.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2005, 2014 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 @@ -14,6 +14,7 @@ * Michael Scharf (Wind River) - split into core, view and connector plugins * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - [267181] Fix telnet option negotiation loop + * Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ package org.eclipse.tm.internal.terminal.telnet; @@ -504,7 +505,7 @@ class TelnetOption implements TelnetCodes /** * This method handles a subnegotiation command received from the remote endpoint. * Currently, the only subnegotiation we handle is when the remote endpoint - * commands us to send our terminal type (which is "ansi"). + * commands us to send our terminal type (which is "xterm"). * * @param subnegotiationData An array of bytes containing a TELNET * subnegotiation command received from the @@ -526,11 +527,11 @@ class TelnetOption implements TelnetCodes // Tell the remote endpoint our terminal type is "ansi" using this sequence // of TELNET protocol bytes: // - // IAC SB TERMINAL-TYPE IS a n s i IAC SE + // IAC SB TERMINAL-TYPE IS x t e r m IAC SE byte[] terminalTypeData = { TELNET_IAC, TELNET_SB, - TELNET_OPTION_TERMINAL_TYPE, TELNET_IS, (byte) 'a', - (byte) 'n', (byte) 's', (byte) 'i', TELNET_IAC, TELNET_SE }; + TELNET_OPTION_TERMINAL_TYPE, TELNET_IS, (byte) 'x', + (byte) 't', (byte) 'e', (byte) 'r', (byte) 'm', TELNET_IAC, TELNET_SE }; try { outputStream.write(terminalTypeData); diff --git a/terminal/plugins/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF index 0b7fa8021a2..f0251b0dbc2 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.test;singleton:=true -Bundle-Version: 2.2.100.qualifier +Bundle-Version: 2.3.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.junit, - org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)", + org.eclipse.tm.terminal;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.runtime, org.eclipse.ui Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/terminal/plugins/org.eclipse.tm.terminal.test/pom.xml b/terminal/plugins/org.eclipse.tm.terminal.test/pom.xml index 7d888117629..5f40291cda5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.test/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal.test/pom.xml @@ -10,7 +10,7 @@ org.eclipse.tm org.eclipse.tm.terminal.test - 2.2.100.qualifier + 2.3.0.qualifier eclipse-test-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java b/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java index 9e711db970e..a7b83e988ca 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java +++ b/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 @@ -8,6 +8,7 @@ * 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) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -1234,4 +1235,53 @@ public class VT100EmulatorBackendTest extends TestCase { assertEquals(3,vt100.getCursorColumn()); } + public void testVT100LineWrappingOn() { + ITerminalTextData term=makeITerminalTextData(); + IVT100EmulatorBackend vt100=makeBakend(term); + term.setMaxHeight(10); + vt100.setDimensions(6, 4); + vt100.setVT100LineWrapping(true); + vt100.appendString("abcd"); + vt100.setCursorColumn(0); + vt100.processNewline(); + vt100.appendString("1234"); + vt100.setCursorColumn(0); + vt100.processNewline(); + assertEquals(2, vt100.getCursorLine()); + } + + public void testVT100LineWrappingOff() { + ITerminalTextData term=makeITerminalTextData(); + IVT100EmulatorBackend vt100=makeBakend(term); + term.setMaxHeight(10); + vt100.setDimensions(6, 4); + vt100.setVT100LineWrapping(false); + vt100.appendString("abcd"); + vt100.setCursorColumn(0); + vt100.processNewline(); + vt100.appendString("1234"); + vt100.setCursorColumn(0); + vt100.processNewline(); + assertEquals(4, vt100.getCursorLine()); + } + + public void testWrappedLines() { + ITerminalTextData term=makeITerminalTextData(); + IVT100EmulatorBackend vt100=makeBakend(term); + term.setMaxHeight(10); + vt100.setDimensions(6, 4); + vt100.setVT100LineWrapping(true); + vt100.appendString("abcd123"); + vt100.setCursorColumn(0); + vt100.processNewline(); + vt100.appendString("abc"); + vt100.setCursorColumn(0); + vt100.processNewline(); + vt100.appendString("1234abcd"); + assertEquals(4, vt100.getCursorLine()); + assertTrue(term.isWrappedLine(0)); + assertFalse(term.isWrappedLine(1)); + assertFalse(term.isWrappedLine(2)); + assertTrue(term.isWrappedLine(3)); + } } diff --git a/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java b/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java index 493547a54c9..9eff106efbe 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java +++ b/terminal/plugins/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2014 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 @@ -7,6 +7,7 @@ * * 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 junit.framework.TestCase; @@ -812,6 +813,20 @@ abstract public class AbstractITerminalTextDataTest extends TestCase { fillSimple(term,start); term.scroll(line, n, shift); assertEqualsSimple(result, toSimple(term)); - + } + + public void testWrappedLines() { + ITerminalTextData term=makeITerminalTextData(); + term.setDimensions(4, 4); + for (int i=0; i org.eclipse.tm org.eclipse.tm.terminal.view - 2.4.100.qualifier + 2.4.200.qualifier eclipse-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal/META-INF/MANIFEST.MF index 19d3c814b4e..b7973c8d0c4 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal; singleton:=true -Bundle-Version: 3.2.400.qualifier +Bundle-Version: 3.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/pom.xml b/terminal/plugins/org.eclipse.tm.terminal/pom.xml index 517e362fcf2..37830302ee5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/pom.xml +++ b/terminal/plugins/org.eclipse.tm.terminal/pom.xml @@ -10,6 +10,6 @@ org.eclipse.tm org.eclipse.tm.terminal - 3.2.400.qualifier + 3.3.0.qualifier eclipse-plugin diff --git a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java index d5958d9c3f6..47b78f68436 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java @@ -293,9 +293,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend { int i=0; while (i < chars.length) { if(fWrapPending) { - doNewline(); - line=toAbsoluteLine(fCursorLine); - setCursorColumn(0); + line = doLineWrap(); } int n=Math.min(fColumns-fCursorColumn,chars.length-i); fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle); @@ -308,10 +306,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend { setCursorColumn(col - 1); fWrapPending = true; } else { - // immediate line wrapping - doNewline(); - line=toAbsoluteLine(fCursorLine); - setCursorColumn(0); + line = doLineWrap(); } } else { setCursorColumn(col); @@ -320,6 +315,16 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend { } } + 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! */ diff --git a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java index 0bbf8d2572f..96103a4a133 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * 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; @@ -97,4 +98,10 @@ public class SynchronizedTerminalTextData implements ITerminalTextData { synchronized public void setMaxHeight(int height) { fData.setMaxHeight(height); } + synchronized public boolean isWrappedLine(int line) { + return fData.isWrappedLine(line); + } + synchronized public void setWrappedLine(int line) { + fData.setWrappedLine(line); + } } diff --git a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java index 9ec0d1c789c..268999c5d6d 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 @@ -8,6 +8,7 @@ * 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) - [453393] Add support for copying wrapped lines without line break *******************************************************************************/ package org.eclipse.tm.internal.terminal.model; @@ -262,4 +263,12 @@ public class TerminalTextData implements ITerminalTextData { 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/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java index 6038241ca48..e6101581c46 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2014 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 @@ -7,6 +7,7 @@ * * 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; @@ -246,5 +247,13 @@ public class TerminalTextDataFastScroll implements ITerminalTextData { public void setCursorLine(int line) { throw new UnsupportedOperationException(); } + public boolean isWrappedLine(int line) { + assert (line>=0 && line=0 && linefHeight) { for (int i = fHeight; i < height; i++) { - fStyle[i]=null; - fChars[i]=null; + cleanLine(i); } } // set dimensions after successful resize! @@ -209,6 +212,7 @@ public class TerminalTextDataStore implements ITerminalTextData { for (int i = startLine; i < startLine+size+shift; i++) { fChars[i]=fChars[i-shift]; fStyle[i]=fStyle[i-shift]; + fWrappedLines.set(i, fWrappedLines.get(i-shift)); } // then clean the opened lines cleanLines(Math.max(startLine, startLine+size+shift),Math.min(-shift, getHeight()-startLine)); @@ -217,6 +221,7 @@ public class TerminalTextDataStore implements ITerminalTextData { 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)); } @@ -228,8 +233,7 @@ public class TerminalTextDataStore implements ITerminalTextData { */ private void cleanLines(int line, int len) { for (int i = line; i < line+len; i++) { - fChars[i]=null; - fStyle[i]=null; + cleanLine(i); } } @@ -270,8 +274,7 @@ public class TerminalTextDataStore implements ITerminalTextData { fStyle=new Style[n][]; } for (int i = 0; i < n; i++) { - fChars[i]=source.getChars(i); - fStyle[i]=source.getStyles(i); + copyLine(source, i, i); } fHeight=n; fCursorLine=source.getCursorLine(); @@ -279,14 +282,14 @@ public class TerminalTextDataStore implements ITerminalTextData { } public void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine,int length) { for (int i = 0; i < length; i++) { - fChars[i+destStartLine]=source.getChars(i+sourceStartLine); - fStyle[i+destStartLine]=source.getStyles(i+sourceStartLine); + 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); + fWrappedLines.set(destLine, source.isWrappedLine(sourceLine)); } public char[] getChars(int line) { @@ -304,6 +307,7 @@ public class TerminalTextDataStore implements ITerminalTextData { public void setLine(int line, char[] chars, Style[] styles) { fChars[line]=(char[]) chars.clone(); fStyle[line]=(Style[]) styles.clone(); + fWrappedLines.clear(line); } public void setMaxHeight(int height) { @@ -317,6 +321,7 @@ public class TerminalTextDataStore implements ITerminalTextData { public void cleanLine(int line) { fChars[line]=null; fStyle[line]=null; + fWrappedLines.clear(line); } public int getCursorColumn() { return fCursorColumn; @@ -330,4 +335,10 @@ public class TerminalTextDataStore implements ITerminalTextData { public void setCursorLine(int 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/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java index 583318a1888..ce2f10373f5 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindow.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2014 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 @@ -7,6 +7,7 @@ * * 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; @@ -194,4 +195,13 @@ public class TerminalTextDataWindow implements ITerminalTextData { 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/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java index 770db9733bf..1d63b3ae9fe 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/AbstractTextCanvasModel.java @@ -309,7 +309,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel { text=""; //$NON-NLS-1$ } buffer.append(text); - if(line < fSeletionEndLine) + if(line < fSeletionEndLine && !fSelectionSnapshot.getTerminalTextData().isWrappedLine(line)) buffer.append('\n'); } return buffer.toString(); diff --git a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextData.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextData.java index 3ca18158aa3..da4881338da 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextData.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 @@ -8,6 +8,7 @@ * 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; @@ -71,20 +72,6 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { * @param line */ void cleanLine(int line); - // /** - // * @param line - // * @return true if this line belongs to the previous line but is simply - // * wrapped. - // */ - // boolean isWrappedLine(int line); - // - // /** - // * Makes this line an extension to the previous line. Wrapped lines get folded back - // * when the width of the terminal changes - // * @param line - // * @param extendsPreviousLine - // */ - // void setWrappedLine(int line, boolean extendsPreviousLine); /** * Shifts some lines up or down. The "empty" space is filled with '\000' chars @@ -151,4 +138,13 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly { 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/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java index 0503b4c1ddc..876ac102bc9 100644 --- a/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java +++ b/terminal/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataReadOnly.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 @@ -8,6 +8,7 @@ * 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; @@ -73,4 +74,12 @@ public interface ITerminalTextDataReadOnly { * @return the column at which the cursor is at the moment */ int getCursorColumn(); -} \ No newline at end of file + + /** + * @param line + * @return true if this line got wrapped, ie. logically continues on next line + * @since 3.3 + */ + boolean isWrappedLine(int line); + +}