2 * regexpl - Console Registry Explorer
4 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 // prompt for Registry Explorer
27 #define ESCAPE_CHAR _T("\\")
28 #define CURRENT_PATH_ALIAS_CHAR _T("w")
29 #define CURRENT_PATH_ALIAS ESCAPE_CHAR CURRENT_PATH_ALIAS_CHAR
30 #define DEFAULT_PROMPT CURRENT_PATH_ALIAS _T("\n# ")
32 CPrompt::CPrompt(CRegistryTree
& rTree
, HRESULT
& rhr
):m_rTree(rTree
)
34 m_pszPrompt
= new (std::nothrow
) TCHAR
[_tcslen(DEFAULT_PROMPT
)+1];
41 _tcscpy(m_pszPrompt
,DEFAULT_PROMPT
);
44 HRESULT
CPrompt::SetPrompt(LPCTSTR pszPrompt
)
52 m_pszPrompt
= new (std::nothrow
) TCHAR
[_tcslen(pszPrompt
)+1];
56 _tcscpy(m_pszPrompt
,pszPrompt
);
67 void CPrompt::ShowPrompt(CConsole
&rConsole
)
69 TCHAR
*pch
= m_pszPrompt
;
70 TCHAR Buffer
[2] = " ";
72 const TCHAR
*pszCurrentPath
;
76 if (_tcsncmp(pch
,CURRENT_PATH_ALIAS
,_tcslen(CURRENT_PATH_ALIAS
)) == 0)
78 pszCurrentPath
= m_rTree
.GetCurrentPath();
79 rConsole
.Write(pszCurrentPath
?pszCurrentPath
:_T("NULL (Internal Error)"));
80 pch
+= _tcslen(CURRENT_PATH_ALIAS
);
85 rConsole
.Write(Buffer
);
90 LPCTSTR
CPrompt::GetDefaultPrompt()
92 return DEFAULT_PROMPT
;