Skip to content

Commit 9ba7215

Browse files
authored
Convert \b to 0x7f to properly handle backspace in the terminal (#619)
Includes a new system property `org.eclipse.tm.terminal.control.convertBackspace` to allow us to disable this new behaviour in the field if it turns out that some terminal/host combination does not like this conversion. Fixes #392
1 parent f5754e2 commit 9ba7215

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

NewAndNoteworthy/CDT-11.4.md

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ The managed build GNU linker tool description now provides an option for groupin
2626

2727
The new option is available within managed build configurations using a _Cross GCC_, _Cygwin GCC_, _Linux GCC_ or _MinGW GCC_ toolchain.
2828

29+
# Terminal
30+
31+
## Backspace now sends `0x7f` instead of `0x08` (`\b`, `^H`)
32+
33+
Introduced to [fix an incompatibility on Windows](https://github.com/eclipse-cdt/cdt/issues/392) the terminal converts `^H` to ascii `0x7f` to ensure a single character is deleted rather than a whole word.
34+
35+
The java property `org.eclipse.tm.terminal.control.convertBackspace` can be set to `false` to disable this behavior in case it interferes with the expected behavior of the terminal.
36+
2937
# API Changes, current and planned
3038

3139
## Changes to org.eclipse.tools.templates APIs

terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java

+18
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,19 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
184184

185185
private PollingTextCanvasModel fPollingTextCanvasModel;
186186

187+
/**
188+
* In some circumstances (e.g PowerShell on Windows) the backspace
189+
* character received from the keypress needs modifying. This
190+
* system property allows disabling this new feature in case there
191+
* are users who are negatively affected by this conversion.
192+
*
193+
* \b is ^H which is interpreted by the console as Ctrl + Backspace
194+
* which deletes a word. \b on its own should just delete a character
195+
* so we send 0x7f to do that.
196+
*/
197+
private boolean convertBackspace = Boolean
198+
.parseBoolean(System.getProperty("org.eclipse.tm.terminal.control.convertBackspace", "true")); //$NON-NLS-1$ //$NON-NLS-2$
199+
187200
/**
188201
* Instantiate a Terminal widget.
189202
* @param target Callback for notifying the owner of Terminal state changes.
@@ -1175,6 +1188,11 @@ public void keyPressed(KeyEvent event) {
11751188
}
11761189
}
11771190

1191+
// see javadoc on convertBackspace for details
1192+
if (convertBackspace && !ctrlKeyPressed && character == '\b') {
1193+
character = 0x7f;
1194+
}
1195+
11781196
//TODO: At this point, Ctrl+M sends the same as Ctrl+Shift+M .
11791197
//This is undesired. Fixing this here might make the special Ctrl+Shift+C
11801198
//handling unnecessary further up.

0 commit comments

Comments
 (0)