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.
46 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
47 * Remove all hardcode string to En.rc
53 * print the command-line prompt
55 VOID
PrintPrompt(VOID
)
57 static TCHAR default_pr
[] = _T("$P$G");
61 if (GetEnvironmentVariable (_T("PROMPT"), szPrompt
, 256))
76 switch (_totupper (*pr
))
95 ConOutChar (_T('\x1B'));
103 ConOutChar (_T('>'));
107 ConOutChar (_T('\x08'));
111 ConOutChar (_T('<'));
116 TCHAR szPath
[MAX_PATH
];
117 GetCurrentDirectory (MAX_PATH
, szPath
);
118 ConOutChar (szPath
[0]);
124 TCHAR szPath
[MAX_PATH
];
125 GetCurrentDirectory (MAX_PATH
, szPath
);
126 ConOutPrintf (_T("%s"), szPath
);
131 ConOutChar (_T('='));
139 switch (osvi
.dwPlatformId
)
141 case VER_PLATFORM_WIN32_WINDOWS
:
142 if (osvi
.dwMajorVersion
== 4 &&
143 osvi
.dwMinorVersion
== 1)
144 ConOutPrintf (_T("Windows 98"));
146 ConOutPrintf (_T("Windows 95"));
149 case VER_PLATFORM_WIN32_NT
:
150 ConOutPrintf (_T("Windows NT Version %lu.%lu"),
151 osvi
.dwMajorVersion
, osvi
.dwMinorVersion
);
157 ConOutChar (_T('\n'));
161 ConOutChar (_T('$'));
164 #ifdef FEATURE_DIRECTORY_STACK
168 for (i
= 0; i
< GetDirectoryStackDepth (); i
++)
169 ConOutChar (_T('+'));
180 #ifdef INCLUDE_CMD_PROMPT
182 INT
cmd_prompt (LPTSTR cmd
, LPTSTR param
)
185 if (!_tcsncmp (param
, _T("/?"), 2))
187 ConOutResPuts(STRING_PROMPT_HELP1
);
189 #ifdef FEATURE_DIRECTORY_STACK
190 ConOutResPuts(STRING_PROMPT_HELP2
);
192 ConOutResPuts(STRING_PROMPT_HELP3
);
196 /* set PROMPT environment variable */
197 if (!SetEnvironmentVariable (_T("PROMPT"), param
))