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'));
108 ConOutChar (_T(' '));
109 ConOutChar (_T('\x08'));
113 ConOutChar (_T('<'));
118 TCHAR szPath
[MAX_PATH
];
119 GetCurrentDirectory (MAX_PATH
, szPath
);
120 ConOutChar (szPath
[0]);
126 TCHAR szPath
[MAX_PATH
];
127 GetCurrentDirectory (MAX_PATH
, szPath
);
128 ConOutPrintf (_T("%s"), szPath
);
133 ConOutChar (_T('='));
137 ConOutChar (_T(' '));
144 ConOutPrintf(_T("%02d%c%02d%c%02d%c%02d\n"),t
.wHour
, cTimeSeparator
,t
.wMinute
, cTimeSeparator
,
145 t
.wSecond
, cDecimalSeparator
, t
.wMilliseconds
);
150 switch (osvi
.dwPlatformId
)
152 case VER_PLATFORM_WIN32_WINDOWS
:
153 if (osvi
.dwMajorVersion
== 4 &&
154 osvi
.dwMinorVersion
== 1)
155 ConOutPrintf (_T("Windows 98"));
157 ConOutPrintf (_T("Windows 95"));
161 case VER_PLATFORM_WIN32_NT
:
162 ConOutPrintf (_T("Windows NT Version %lu.%lu"),
163 osvi
.dwMajorVersion
, osvi
.dwMinorVersion
);
169 ConOutChar (_T('\n'));
173 ConOutChar (_T('$'));
176 #ifdef FEATURE_DIRECTORY_STACK
180 for (i
= 0; i
< GetDirectoryStackDepth (); i
++)
181 ConOutChar (_T('+'));
192 #ifdef INCLUDE_CMD_PROMPT
194 INT
cmd_prompt (LPTSTR cmd
, LPTSTR param
)
196 if (!_tcsncmp (param
, _T("/?"), 2))
198 ConOutResPaging(TRUE
,STRING_PROMPT_HELP1
);
200 #ifdef FEATURE_DIRECTORY_STACK
201 ConOutResPaging(FALSE
,STRING_PROMPT_HELP2
);
203 ConOutResPaging(FALSE
,STRING_PROMPT_HELP3
);
207 /* if it is null, then it needs to set to default,
208 because that means the user entered "prompt" only.
209 so even if param is null you _must_ still set prompt
210 to the default. There seems to be some kinda difference
211 between winxp and 2k in this matter and this way will
212 cover both. Do not use fixed size of szParam for param the buffer are 8192bytes
213 and will later change to dymatic buffer */
215 /* set PROMPT environment variable */
216 if (param
[0] != _T('\0'))
218 if (!SetEnvironmentVariable (_T("PROMPT"), param
))
224 _tcscpy(szParam
,_T("$P$G"));
225 if (!SetEnvironmentVariable (_T("PROMPT"),szParam
))