[CMD] Enable Ctrl+H (^H) as backspace (#6562)

Ctrl+H should pretend like BackSpace key
on Command Prompt.
JIRA issue: CORE-5702
- Add Ctrl+H action in ReadCommand function.
This commit is contained in:
Katayama Hirofumi MZ 2024-03-01 22:51:57 +09:00 committed by GitHub
parent c07eb9fb1b
commit 2320c37151
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -218,8 +218,8 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
curx = orgx; curx = orgx;
cury = orgy; cury = orgy;
//bContinue=TRUE; //bContinue=TRUE;
break;
} }
break;
case _T('D'): case _T('D'):
/* delete current history entry */ /* delete current history entry */
@ -232,8 +232,8 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
ConOutPrintf (_T("%s"), str); ConOutPrintf (_T("%s"), str);
GetCursorXY (&curx, &cury); GetCursorXY (&curx, &cury);
//bContinue=TRUE; //bContinue=TRUE;
break;
} }
break;
#endif /*FEATURE_HISTORY*/ #endif /*FEATURE_HISTORY*/
case _T('M'): case _T('M'):
@ -251,8 +251,16 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
str[charcount] = _T('\0'); str[charcount] = _T('\0');
ConOutChar (_T('\n')); ConOutChar (_T('\n'));
bReturn = TRUE; bReturn = TRUE;
break;
} }
break;
case _T('H'): /* ^H does the same as VK_BACK */
if (dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
{
bCharInput = FALSE;
goto DoBackSpace;
}
break;
} }
} }
@ -261,6 +269,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
switch (ir.Event.KeyEvent.wVirtualKeyCode) switch (ir.Event.KeyEvent.wVirtualKeyCode)
{ {
case VK_BACK: case VK_BACK:
DoBackSpace:
/* <BACKSPACE> - delete character to left of cursor */ /* <BACKSPACE> - delete character to left of cursor */
if (current > 0 && charcount > 0) if (current > 0 && charcount > 0)
{ {