Skip to content

Commit 7e24bfa

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 79a8358 commit 7e24bfa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
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)