mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 458218 - [terminal] Add support for ANSI insert mode
Change-Id: Iee022b7326da07d3df2b04144416e324f7e73496 Signed-off-by: Anton Leherbauer <anton.leherbauer@windriver.com>
This commit is contained in:
parent
4bba095cef
commit
a1a63a3c31
5 changed files with 85 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2015 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* Michael Scharf (Wind River) - initial API and implementation
|
||||||
* Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1
|
* 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
|
* Anton Leherbauer (Wind River) - [453393] Add support for copying wrapped lines without line break
|
||||||
|
* Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.emulator;
|
package org.eclipse.tm.internal.terminal.emulator;
|
||||||
|
|
||||||
|
@ -1284,4 +1285,26 @@ public class VT100EmulatorBackendTest extends TestCase {
|
||||||
assertFalse(term.isWrappedLine(2));
|
assertFalse(term.isWrappedLine(2));
|
||||||
assertTrue(term.isWrappedLine(3));
|
assertTrue(term.isWrappedLine(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInsertMode() {
|
||||||
|
ITerminalTextData term=makeITerminalTextData();
|
||||||
|
IVT100EmulatorBackend vt100=makeBakend(term);
|
||||||
|
term.setMaxHeight(10);
|
||||||
|
vt100.setDimensions(4, 6);
|
||||||
|
// replace mode
|
||||||
|
vt100.appendString("123");
|
||||||
|
vt100.setCursorColumn(0);
|
||||||
|
vt100.appendString("abc");
|
||||||
|
assertEquals("abc", new String(term.getChars(0)));
|
||||||
|
vt100.clearAll();
|
||||||
|
// insert mode
|
||||||
|
vt100.setCursorColumn(0);
|
||||||
|
vt100.appendString("123");
|
||||||
|
vt100.setCursorColumn(0);
|
||||||
|
vt100.setInsertMode(true);
|
||||||
|
vt100.appendString("abc");
|
||||||
|
vt100.setInsertMode(false);
|
||||||
|
assertEquals("abc123", new String(term.getChars(0)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2015 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,11 +8,16 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* Michael Scharf (Wind River) - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
||||||
|
* Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.emulator;
|
package org.eclipse.tm.internal.terminal.emulator;
|
||||||
|
|
||||||
import org.eclipse.tm.terminal.model.Style;
|
import org.eclipse.tm.terminal.model.Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author toni
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface IVT100EmulatorBackend {
|
public interface IVT100EmulatorBackend {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,4 +191,10 @@ public interface IVT100EmulatorBackend {
|
||||||
*/
|
*/
|
||||||
boolean isVT100LineWrapping();
|
boolean isVT100LineWrapping();
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* Enables/disables insert mode (IRM).
|
||||||
|
*
|
||||||
|
* @param enable whether to enable insert mode
|
||||||
|
*/
|
||||||
|
void setInsertMode(boolean enable);
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2015 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* Michael Scharf (Wind River) - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
||||||
|
* Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.emulator;
|
package org.eclipse.tm.internal.terminal.emulator;
|
||||||
|
|
||||||
|
@ -151,4 +152,9 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
||||||
return fBackend.isVT100LineWrapping();
|
return fBackend.isVT100LineWrapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInsertMode(boolean enable) {
|
||||||
|
fWriter.println("setInsertMode("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
fBackend.setInsertMode(enable);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2014 Wind River Systems, Inc. and others.
|
* Copyright (c) 2003, 2015 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [401386] Regression: No header on top due to incorrect ESC[K interpretation
|
* 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
|
* Martin Oberhuber (Wind River) - [401480] Handle ESC[39;49m and ESC[G
|
||||||
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
||||||
|
* Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.emulator;
|
package org.eclipse.tm.internal.terminal.emulator;
|
||||||
|
|
||||||
|
@ -476,6 +477,11 @@ public class VT100Emulator implements ControlListener {
|
||||||
processAnsiCommand_H();
|
processAnsiCommand_H();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
// Reset Mode.
|
||||||
|
processAnsiCommand_h();
|
||||||
|
break;
|
||||||
|
|
||||||
case 'J':
|
case 'J':
|
||||||
// Erase part or all of display. Cursor does not move.
|
// Erase part or all of display. Cursor does not move.
|
||||||
processAnsiCommand_J();
|
processAnsiCommand_J();
|
||||||
|
@ -491,6 +497,11 @@ public class VT100Emulator implements ControlListener {
|
||||||
processAnsiCommand_L();
|
processAnsiCommand_L();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
// Set Mode.
|
||||||
|
processAnsiCommand_l();
|
||||||
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
// Delete line(s).
|
// Delete line(s).
|
||||||
processAnsiCommand_M();
|
processAnsiCommand_M();
|
||||||
|
@ -620,6 +631,16 @@ public class VT100Emulator implements ControlListener {
|
||||||
moveCursor(getAnsiParameter(0) - 1, getAnsiParameter(1) - 1);
|
moveCursor(getAnsiParameter(0) - 1, getAnsiParameter(1) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets terminal modes.
|
||||||
|
*/
|
||||||
|
private void processAnsiCommand_h() {
|
||||||
|
if (getAnsiParameter(0) == 4) {
|
||||||
|
// set insert mode
|
||||||
|
text.setInsertMode(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method deletes some (or all) of the text on the screen without
|
* This method deletes some (or all) of the text on the screen without
|
||||||
* moving the cursor.
|
* moving the cursor.
|
||||||
|
@ -694,6 +715,16 @@ public class VT100Emulator implements ControlListener {
|
||||||
text.insertLines(getAnsiParameter(0));
|
text.insertLines(getAnsiParameter(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method resets terminal modes.
|
||||||
|
*/
|
||||||
|
private void processAnsiCommand_l() {
|
||||||
|
if (getAnsiParameter(0) == 4) {
|
||||||
|
// reset insert mode
|
||||||
|
text.setInsertMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete one or more lines of text. Any lines below the deleted lines move
|
* Delete one or more lines of text. Any lines below the deleted lines move
|
||||||
* up, which we implement by appending newlines to the end of the text.
|
* up, which we implement by appending newlines to the end of the text.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2015 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* 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) - [206329] Changing terminal size right after connect does not scroll properly
|
||||||
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
||||||
|
* Anton Leherbauer (Wind River) - [458218] Add support for ANSI insert mode
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.emulator;
|
package org.eclipse.tm.internal.terminal.emulator;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
/* true if last output occurred on rightmost column
|
/* true if last output occurred on rightmost column
|
||||||
* and next output requires line wrap */
|
* and next output requires line wrap */
|
||||||
private boolean fWrapPending;
|
private boolean fWrapPending;
|
||||||
|
private boolean fInsertMode;
|
||||||
private Style fDefaultStyle;
|
private Style fDefaultStyle;
|
||||||
private Style fStyle;
|
private Style fStyle;
|
||||||
int fLines;
|
int fLines;
|
||||||
|
@ -289,6 +291,8 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
public void appendString(String buffer) {
|
public void appendString(String buffer) {
|
||||||
synchronized (fTerminal) {
|
synchronized (fTerminal) {
|
||||||
char[] chars=buffer.toCharArray();
|
char[] chars=buffer.toCharArray();
|
||||||
|
if (fInsertMode)
|
||||||
|
insertCharacters(chars.length);
|
||||||
int line=toAbsoluteLine(fCursorLine);
|
int line=toAbsoluteLine(fCursorLine);
|
||||||
int i=0;
|
int i=0;
|
||||||
while (i < chars.length) {
|
while (i < chars.length) {
|
||||||
|
@ -432,4 +436,8 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
||||||
public boolean isVT100LineWrapping() {
|
public boolean isVT100LineWrapping() {
|
||||||
return fVT100LineWrapping;
|
return fVT100LineWrapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInsertMode(boolean enable) {
|
||||||
|
fInsertMode = enable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue