mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Add support for ESC[#X to VT100
This escape sequence can be generated when using Powershell on Windows (and possibly other places too) to erase number of characters. Change-Id: I32405f51a3f91fd8653d44f2676a5c85b696ef99
This commit is contained in:
parent
808147e174
commit
3240494e23
5 changed files with 51 additions and 2 deletions
|
@ -227,4 +227,11 @@ public interface IVT100EmulatorBackend {
|
|||
* scroll region.
|
||||
*/
|
||||
void processReverseLineFeed();
|
||||
|
||||
/**
|
||||
* Replaces characters from the cursor position with space characters.
|
||||
*
|
||||
* @param n number of characters to replace
|
||||
*/
|
||||
void eraseCharacters(int n);
|
||||
}
|
||||
|
|
|
@ -211,4 +211,9 @@ public class VT100BackendTraceDecorator implements IVT100EmulatorBackend {
|
|||
fBackend.processReverseLineFeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseCharacters(int n) {
|
||||
fWriter.println("eraseCharacters(" + n + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fBackend.eraseCharacters(n);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -617,8 +617,7 @@ public class VT100Emulator implements ControlListener {
|
|||
|
||||
case 'X':
|
||||
// Erase character.
|
||||
// Emacs, vi, and GNU readline don't seem to use this command, so we ignore
|
||||
// it for now.
|
||||
processAnsiCommand_X();
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
|
@ -1238,6 +1237,13 @@ public class VT100Emulator implements ControlListener {
|
|||
text.scrollDown(getAnsiParameter(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases n characters from cursor (default = 1 character)
|
||||
*/
|
||||
private void processAnsiCommand_X() {
|
||||
text.eraseCharacters(getAnsiParameter(0));
|
||||
}
|
||||
|
||||
private void processDecPrivateCommand_h() {
|
||||
int param = getAnsiParameter(0);
|
||||
switch (param) {
|
||||
|
|
|
@ -490,4 +490,15 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
|
|||
fTerminal.scroll(line, nLines, n);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseCharacters(int n) {
|
||||
synchronized (fTerminal) {
|
||||
int line = toAbsoluteLine(fCursorLine);
|
||||
int end = Math.min(fCursorColumn + n, fColumns);
|
||||
for (int col = fCursorColumn; col < end; col++) {
|
||||
fTerminal.setChar(line, col, '\000', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -926,4 +926,24 @@ public class VT100EmulatorBackendTest extends TestCase {
|
|||
assertEquals("ghi", new String(term.getChars(5)));
|
||||
}
|
||||
|
||||
public void testEraseCharacters() {
|
||||
ITerminalTextData term = makeITerminalTextData();
|
||||
IVT100EmulatorBackend vt100 = makeBakend(term);
|
||||
vt100.setDimensions(4, 4);
|
||||
String s = "aaaa\n" + "bcde\n" + "1234\n" + "5678";
|
||||
fill(term, s);
|
||||
vt100.setCursor(0, 0);
|
||||
vt100.eraseCharacters(1);
|
||||
assertEqualsTerm(" aaa\n" + "bcde\n" + "1234\n" + "5678", toMultiLineText(term));
|
||||
|
||||
fill(term, s);
|
||||
vt100.setCursor(1, 0);
|
||||
vt100.eraseCharacters(1);
|
||||
assertEqualsTerm("aaaa\n" + " cde\n" + "1234\n" + "5678", toMultiLineText(term));
|
||||
|
||||
fill(term, s);
|
||||
vt100.setCursor(2, 1);
|
||||
vt100.eraseCharacters(2);
|
||||
assertEqualsTerm("aaaa\n" + "bcde\n" + "1 4\n" + "5678", toMultiLineText(term));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue