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.
58 * print the command-line prompt
61 VOID
PrintPrompt(VOID
)
63 static TCHAR default_pr
[] = _T("$P$G");
67 if (GetEnvironmentVariable (_T("PROMPT"), szPrompt
, 256))
82 switch (_totupper (*pr
))
101 ConOutChar (_T('\x1B'));
105 ConOutChar (_T(')'));
109 ConOutChar (_T('>'));
113 ConOutChar (_T('\x08'));
117 ConOutChar (_T('<'));
122 TCHAR szPath
[MAX_PATH
];
123 GetCurrentDirectory (MAX_PATH
, szPath
);
124 ConOutChar (szPath
[0]);
130 TCHAR szPath
[MAX_PATH
];
131 GetCurrentDirectory (MAX_PATH
, szPath
);
132 ConOutPrintf (_T("%s"), szPath
);
137 ConOutChar (_T('='));
145 switch (osvi
.dwPlatformId
)
147 case VER_PLATFORM_WIN32_WINDOWS
:
148 if (osvi
.dwMajorVersion
== 4 &&
149 osvi
.dwMinorVersion
== 1)
150 ConOutPrintf (_T("Windows 98"));
152 ConOutPrintf (_T("Windows 95"));
155 case VER_PLATFORM_WIN32_NT
:
156 ConOutPrintf (_T("Windows NT Version %lu.%lu"),
157 osvi
.dwMajorVersion
, osvi
.dwMinorVersion
);
163 ConOutChar (_T('\n'));
167 ConOutChar (_T('$'));
170 #ifdef FEATURE_DIRECTORY_STACK
174 for (i
= 0; i
< GetDirectoryStackDepth (); i
++)
175 ConOutChar (_T('+'));
186 #ifdef INCLUDE_CMD_PROMPT
188 INT
cmd_prompt (LPTSTR cmd
, LPTSTR param
)
190 if (!_tcsncmp (param
, _T("/?"), 2))
192 ConOutPuts (_T("Changes the command prompt.\n\n"
194 " text Specifies a new command prompt.\n\n"
195 "Prompt can be made up of normal characters and the following special codes:\n\n"
196 " $A & (Ampersand)\n"
198 " $C ( (Left parenthesis)\n"
200 " $E Escape code (ASCII code 27)\n"
201 " $F ) (Right parenthesis)\n"
202 " $G > (greater-than sign)\n"
203 " $H Backspace (erases previous character)\n"
204 " $L < (less-than sign)\n"
205 " $N Current drive\n"
206 " $P Current drive and path\n"
207 " $Q = (equal sign)\n"
209 " $V OS version number\n"
210 " $_ Carriage return and linefeed\n"
211 " $$ $ (dollar sign)"));
212 #ifdef FEATURE_DIRECTORY_STACK
213 ConOutPuts (_T(" $+ Displays the current depth of the directory stack"));
215 ConOutPuts (_T("\nType PROMPT without parameters to reset the prompt to the default setting."));
219 /* set PROMPT environment variable */
220 if (!SetEnvironmentVariable (_T("PROMPT"), param
))