2 * PROMPT.C - prompt handling.
7 * 14/01/95 (Tim Normal)
10 * 08/08/95 (Matt Rains)
11 * i have cleaned up the source code. changes now bring this source
12 * into guidelines for recommended programming practice.
14 * 01/06/96 (Tim Norman)
15 * added day of the week printing (oops, forgot about that!)
17 * 08/07/96 (Steffan Kaiser)
18 * small changes for speed
20 * 20-Jul-1998 (John P Price <linux-guru@gcfl.net>)
21 * removed redundant day strings. Use ones defined in date.c.
23 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
24 * added config.h include
26 * 28-Jul-1998 (John P Price <linux-guru@gcfl.net>)
27 * moved cmd_prompt from internal.c to here
29 * 09-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
30 * Added help text ("/?").
32 * 14-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
35 * 09-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
36 * Added "$A", "$C" and "$F" option.
37 * Added locale support.
40 * 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
41 * Unicode and redirection safe!
43 * 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
44 * Fixed Win32 environment handling.
56 * print the command-line prompt
59 VOID
PrintPrompt(VOID
)
61 static TCHAR default_pr
[] = _T("$P$G");
65 if (GetEnvironmentVariable (_T("PROMPT"), szPrompt
, 256))
80 switch (_totupper (*pr
))
99 ConOutChar (_T('\x1B'));
103 ConOutChar (_T(')'));
107 ConOutChar (_T('>'));
111 ConOutChar (_T('\x08'));
115 ConOutChar (_T('<'));
120 TCHAR szPath
[MAX_PATH
];
121 GetCurrentDirectory (MAX_PATH
, szPath
);
122 ConOutChar (szPath
[0]);
128 TCHAR szPath
[MAX_PATH
];
129 GetCurrentDirectory (MAX_PATH
, szPath
);
130 ConOutPrintf (_T("%s"), szPath
);
135 ConOutChar (_T('='));
143 switch (osvi
.dwPlatformId
)
145 case VER_PLATFORM_WIN32_WINDOWS
:
146 if (osvi
.dwMajorVersion
== 4 &&
147 osvi
.dwMinorVersion
== 1)
148 ConOutPrintf (_T("Windows 98"));
150 ConOutPrintf (_T("Windows 95"));
153 case VER_PLATFORM_WIN32_NT
:
154 ConOutPrintf (_T("Windows NT Version %lu.%lu"),
155 osvi
.dwMajorVersion
, osvi
.dwMinorVersion
);
161 ConOutChar (_T('\n'));
165 ConOutChar (_T('$'));
168 #ifdef FEATURE_DIRECTORY_STACK
172 for (i
= 0; i
< GetDirectoryStackDepth (); i
++)
173 ConOutChar (_T('+'));
184 #ifdef INCLUDE_CMD_PROMPT
186 INT
cmd_prompt (LPTSTR cmd
, LPTSTR param
)
188 if (!_tcsncmp (param
, _T("/?"), 2))
190 ConOutPuts (_T("Changes the command prompt.\n\n"
192 " text Specifies a new command prompt.\n\n"
193 "Prompt can be made up of normal characters and the following special codes:\n\n"
194 " $A & (Ampersand)\n"
196 " $C ( (Left parenthesis)\n"
198 " $E Escape code (ASCII code 27)\n"
199 " $F ) (Right parenthesis)\n"
200 " $G > (greater-than sign)\n"
201 " $H Backspace (erases previous character)\n"
202 " $L < (less-than sign)\n"
203 " $N Current drive\n"
204 " $P Current drive and path\n"
205 " $Q = (equal sign)\n"
207 " $V OS version number\n"
208 " $_ Carriage return and linefeed\n"
209 " $$ $ (dollar sign)"));
210 #ifdef FEATURE_DIRECTORY_STACK
211 ConOutPuts (_T(" $+ Displays the current depth of the directory stack"));
213 ConOutPuts (_T("\nType PROMPT without parameters to reset the prompt to the default setting."));
217 /* set PROMPT environment variable */
218 if (!SetEnvironmentVariable (_T("PROMPT"), param
))