https://git.reactos.org/?p=reactos.git;a=commitdiff;h=03c233bcd09bb378f9561…
commit 03c233bcd09bb378f9561968b9cbf4f45d140f09
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Apr 29 00:57:16 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Apr 29 00:57:16 2018 +0200
[CMD] Improve how the command prompt displays when one presses Ctrl-C/break after
having pressed ENTER, or after a command has been run.
---
base/shell/cmd/cmd.c | 8 +++-----
base/shell/cmd/cmdinput.c | 10 ++++++++--
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/base/shell/cmd/cmd.c b/base/shell/cmd/cmd.c
index 25ddae0c6f..bc92e70e6c 100644
--- a/base/shell/cmd/cmd.c
+++ b/base/shell/cmd/cmd.c
@@ -1418,16 +1418,14 @@ ReadLine(TCHAR *commandline, BOOL bMore)
return FALSE;
}
- if (CheckCtrlBreak(BREAK_INPUT))
- {
+ if (readline[0] == _T('\0'))
ConOutChar(_T('\n'));
+
+ if (CheckCtrlBreak(BREAK_INPUT))
return FALSE;
- }
if (readline[0] == _T('\0'))
- {
return FALSE;
- }
ip = readline;
}
diff --git a/base/shell/cmd/cmdinput.c b/base/shell/cmd/cmdinput.c
index 9257cb6dda..481a04350d 100644
--- a/base/shell/cmd/cmdinput.c
+++ b/base/shell/cmd/cmdinput.c
@@ -453,8 +453,14 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
if ((ir.Event.KeyEvent.dwControlKeyState &
(RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED)))
{
- /* A CTRL-C. Don't clear the the command line,
- * but return an empty string in str. */
+ /* Ignore the Ctrl-C key event if it has already been handled */
+ if (!bCtrlBreak)
+ break;
+
+ /*
+ * A Ctrl-C. Do not clear the command line,
+ * but return an empty string in str.
+ */
str[0] = _T('\0');
curx = orgx;
cury = orgy;