Backspace moves cursor left even ENABLE_LINE_INPUT is off #2982

Open
opened 2026-01-30 23:10:12 +00:00 by claunia · 0 comments
Owner

Originally created by @dimant on GitHub (Jul 29, 2019).

Windows Version 10.0.18362 Build 18362

I am setting up my console mode as:

        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_ECHO_INPUT;
        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_EXTENDED_FLAGS;
        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_INSERT_MODE;
        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_LINE_INPUT;
        newMode |= Kernel32.CONSOLE_INPUT_MODE.ENABLE_MOUSE_INPUT;
        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_PROCESSED_INPUT;
        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_QUICK_EDIT_MODE;
        newMode |= Kernel32.CONSOLE_INPUT_MODE.ENABLE_WINDOW_INPUT;
        newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_VIRTUAL_TERMINAL_INPUT;

expected:
pressing backspace leaves the cursor where it is and sends me a backspace event via ReadConsoleInput

actual:
I receive a "\b" event and after I process it, the cursor moves left.

I can work around this issue by using VT sequences:
vtSequencer.CursorHide();
vtSequencer.CursorBackward(1);
vtSequencer.TextDeleteChar(1);
vtSequencer.CursorForward(1);
vtSequencer.CursorShow();

Originally created by @dimant on GitHub (Jul 29, 2019). Windows Version 10.0.18362 Build 18362 I am setting up my console mode as: newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_ECHO_INPUT; newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_EXTENDED_FLAGS; newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_INSERT_MODE; newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_LINE_INPUT; newMode |= Kernel32.CONSOLE_INPUT_MODE.ENABLE_MOUSE_INPUT; newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_PROCESSED_INPUT; newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_QUICK_EDIT_MODE; newMode |= Kernel32.CONSOLE_INPUT_MODE.ENABLE_WINDOW_INPUT; newMode &= ~Kernel32.CONSOLE_INPUT_MODE.ENABLE_VIRTUAL_TERMINAL_INPUT; expected: pressing backspace leaves the cursor where it is and sends me a backspace event via ReadConsoleInput actual: I receive a "\b" event and after I process it, the cursor moves left. I can work around this issue by using VT sequences: vtSequencer.CursorHide(); vtSequencer.CursorBackward(1); vtSequencer.TextDeleteChar(1); vtSequencer.CursorForward(1); vtSequencer.CursorShow();
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2982