1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 02:15:31 +02:00

Terminal: Bug 433751 - Add option to enable VT100 line wrapping mode

Change-Id: I6b75db80b8edda518333c6acc59ba461f51932bd
Signed-off-by: Anton Leherbauer <anton.leherbauer@windriver.com>
This commit is contained in:
Anton Leherbauer 2014-04-30 11:55:41 +02:00
parent cedfaf8a03
commit d5905131ae
8 changed files with 120 additions and 14 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2012 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
@ -10,6 +10,7 @@
* Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
* Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
* Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.connector;
@ -83,6 +84,13 @@ public class TerminalConnectorFactoryTest extends TestCase {
public void setConnectOnEnterIfClosed(boolean on) {
}
public void setVT100LineWrapping(boolean enable) {
}
public boolean isVT100LineWrapping() {
return false;
}
}
static class ConnectorMock extends TerminalConnectorImpl {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2012 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
@ -10,6 +10,7 @@
* Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
* Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
* Uwe Stieber (Wind River) - [282996] [terminal][api] Add "hidden" attribute to terminal connector extension point
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.connector;
@ -83,6 +84,13 @@ public class TerminalConnectorTest extends TestCase {
public void setConnectOnEnterIfClosed(boolean on) {
}
public void setVT100LineWrapping(boolean enable) {
}
public boolean isVT100LineWrapping() {
return false;
}
}
static class ConnectorMock extends TerminalConnectorImpl {

View file

@ -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) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -169,4 +170,20 @@ public interface IVT100EmulatorBackend {
int getColumns();
/**
* Enables VT100 line wrapping mode (default is off).
* This corresponds to the VT100 'eat_newline_glitch' terminal capability.
* If enabled, writing to the rightmost column does not cause
* an immediate wrap to the next line. Instead the line wrap occurs on the
* next output character.
*
* @param enable whether to enable or disable VT100 line wrapping mode
*/
void setVT100LineWrapping(boolean enable);
/**
* @return whether VT100 line wrapping mode is enabled
*/
boolean isVT100LineWrapping();
}

View file

@ -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) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -141,4 +142,13 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
fBackend.setStyle(style);
}
public void setVT100LineWrapping(boolean enable) {
fWriter.println("setVT100LineWrapping("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$
fBackend.setVT100LineWrapping(enable);
}
public boolean isVT100LineWrapping() {
return fBackend.isVT100LineWrapping();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2013 Wind River Systems, Inc. and others.
* Copyright (c) 2003, 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 @@
* Kris De Volder (VMWare) - [392107] Switched interpretation for ESC[0K and ESC[1K sequences
* Martin Oberhuber (Wind River) - [401386] Regression: No header on top due to incorrect ESC[K interpretation
* Martin Oberhuber (Wind River) - [401480] Handle ESC[39;49m and ESC[G
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -1150,6 +1151,7 @@ public class VT100Emulator implements ControlListener {
* Buffer for {@link #pushBackChar(char)}.
*/
private int fNextChar=-1;
private char getNextChar() throws IOException {
int c=-1;
if(fNextChar!=-1) {
@ -1189,4 +1191,10 @@ public class VT100Emulator implements ControlListener {
public void setCrAfterNewLine(boolean crAfterNewLine) {
fCrAfterNewLine = crAfterNewLine;
}
void setVT100LineWrapping(boolean enable) {
text.setVT100LineWrapping(enable);
}
boolean isVT100LineWrapping() {
return text.isVT100LineWrapping();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2011 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
* Anton Leherbauer (Wind River) - [206329] Changing terminal size right after connect does not scroll properly
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -39,19 +40,26 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
* When fCursorColumn is N, the next character output to the terminal appears
* in column N. When a character is output to the rightmost column on a
* given line (column widthInColumns - 1), the cursor moves to column 0 on
* the next line after the character is drawn (this is how line wrapping is
* implemented). If the cursor is in the bottommost line when line wrapping
* the next line after the character is drawn (this is the default line wrapping
* mode). If VT100 line wrapping mode is enabled, the cursor does not move
* to the next line until the next character is printed (this is known as
* the VT100 'eat_newline_glitch').
* If the cursor is in the bottommost line when line wrapping
* occurs, the topmost visible line is scrolled off the top edge of the
* screen.
* <p>
*/
private int fCursorColumn;
private int fCursorLine;
/* true if last output occurred on rightmost column
* and next output requires line wrap */
private boolean fWrapPending;
private Style fDefaultStyle;
private Style fStyle;
int fLines;
int fColumns;
final private ITerminalTextData fTerminal;
private boolean fVT100LineWrapping;
public VT100EmulatorBackend(ITerminalTextData terminal) {
fTerminal=terminal;
}
@ -284,15 +292,27 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
int line=toAbsoluteLine(fCursorLine);
int i=0;
while (i < chars.length) {
if(fWrapPending) {
doNewline();
line=toAbsoluteLine(fCursorLine);
setCursorColumn(0);
}
int n=Math.min(fColumns-fCursorColumn,chars.length-i);
fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle);
int col=fCursorColumn+n;
i+=n;
// wrap needed?
if(col>=fColumns) {
doNewline();
line=toAbsoluteLine(fCursorLine);
setCursorColumn(0);
if(col == fColumns) {
if (fVT100LineWrapping) {
// deferred line wrapping (eat_newline_glitch)
setCursorColumn(col - 1);
fWrapPending = true;
} else {
// immediate line wrapping
doNewline();
line=toAbsoluteLine(fCursorLine);
setCursorColumn(0);
}
} else {
setCursorColumn(col);
}
@ -357,6 +377,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
else if(targetColumn>=fColumns)
targetColumn=fColumns-1;
fCursorColumn=targetColumn;
fWrapPending = false;
// We make the assumption that nobody is changing the
// terminal cursor except this class!
// This assumption gives a huge performance improvement
@ -398,4 +419,12 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
return fColumns;
}
}
public void setVT100LineWrapping(boolean enable) {
fVT100LineWrapping = enable;
}
public boolean isVT100LineWrapping() {
return fVT100LineWrapping;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2003, 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
@ -32,6 +32,7 @@
* Simon Bernard (Sierra Wireless) - [351424] [terminal] Terminal does not support del and insert key
* Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically
* Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -1180,6 +1181,14 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
public final boolean isConnectOnEnterIfClosed() {
return connectOnEnterIfClosed;
}
public void setVT100LineWrapping(boolean enable) {
getTerminalText().setVT100LineWrapping(enable);
}
public boolean isVT100LineWrapping() {
return getTerminalText().isVT100LineWrapping();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2012 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
@ -10,6 +10,7 @@
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
* Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
*******************************************************************************/
package org.eclipse.tm.internal.terminal.provisional.api;
@ -140,4 +141,20 @@ public interface ITerminalControl {
* @return <code>True</code> the reconnect is enabled, <code>false</code> if disabled.
*/
boolean isConnectOnEnterIfClosed();
/**
* Enables VT100 line wrapping mode (default is off).
* This corresponds to the VT100 'eat_newline_glitch' terminal capability.
* If enabled, writing to the rightmost column does not cause
* an immediate wrap to the next line. Instead the line wrap occurs on the
* next output character.
*
* @param enable whether to enable or disable VT100 line wrapping mode
*/
void setVT100LineWrapping(boolean enable);
/**
* @return whether VT100 line wrapping mode is enabled
*/
boolean isVT100LineWrapping();
}