[CMD] If the prompt displays the information line on top of the screen, ensure that the prompt won't be hidden below it.

CORE-16193
This commit is contained in:
Hermès Bélusca-Maïto 2019-12-29 19:08:47 +01:00
parent 0bede0062a
commit 771b87dc8f
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -108,16 +108,33 @@ VOID PrintInfoLine(VOID)
*/ */
VOID PrintPrompt(VOID) VOID PrintPrompt(VOID)
{ {
LPTSTR pr; LPTSTR pr, Prompt;
TCHAR szPrompt[256]; TCHAR szPrompt[256];
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
if (GetEnvironmentVariable(_T("PROMPT"), szPrompt, _countof(szPrompt))) if (GetEnvironmentVariable(_T("PROMPT"), szPrompt, _countof(szPrompt)))
pr = szPrompt; Prompt = szPrompt;
else else
pr = DefaultPrompt; Prompt = DefaultPrompt;
while (*pr) /*
* Special pre-handling for $I: If the information line is displayed
* on top of the screen, ensure that the prompt won't be hidden below it.
*/
for (pr = Prompt; *pr;)
{
if (*pr++ != _T('$'))
continue;
if (!*pr || _totupper(*pr++) != _T('I'))
continue;
if (GetCursorY() == 0)
ConOutChar(_T('\n'));
break;
}
/* Parse the prompt string */
for (pr = Prompt; *pr; ++pr)
{ {
if (*pr != _T('$')) if (*pr != _T('$'))
{ {
@ -125,8 +142,8 @@ VOID PrintPrompt(VOID)
} }
else else
{ {
pr++; ++pr;
if (!*pr) break;
switch (_totupper(*pr)) switch (_totupper(*pr))
{ {
case _T('A'): case _T('A'):
@ -158,9 +175,7 @@ VOID PrintPrompt(VOID)
break; break;
case _T('H'): case _T('H'):
ConOutChar(_T('\x08')); ConOutPuts(_T("\x08 \x08"));
ConOutChar(_T(' '));
ConOutChar(_T('\x08'));
break; break;
case _T('I'): case _T('I'):
@ -205,12 +220,12 @@ VOID PrintPrompt(VOID)
ConOutChar(_T('\n')); ConOutChar(_T('\n'));
break; break;
case '$': case _T('$'):
ConOutChar(_T('$')); ConOutChar(_T('$'));
break; break;
#ifdef FEATURE_DIRECTORY_STACK #ifdef FEATURE_DIRECTORY_STACK
case '+': case _T('+'):
{ {
INT i; INT i;
for (i = 0; i < GetDirectoryStackDepth(); i++) for (i = 0; i < GetDirectoryStackDepth(); i++)
@ -220,7 +235,6 @@ VOID PrintPrompt(VOID)
#endif #endif
} }
} }
pr++;
} }
} }