ReactOS 0.4.16-dev-297-gc569aee
Prompt.cpp
Go to the documentation of this file.
1/*
2 * regexpl - Console Registry Explorer
3 *
4 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
5 *
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.
10 *
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.
15 *
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.
20 */
21
22// prompt for Registry Explorer
23
24#include "ph.h"
25#include "Prompt.h"
26
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# ")
31
32CPrompt::CPrompt(CRegistryTree& rTree, HRESULT& rhr):m_rTree(rTree)
33{
34 m_pszPrompt = new (std::nothrow) TCHAR[_tcslen(DEFAULT_PROMPT)+1];
35 if (!m_pszPrompt)
36 {
37 rhr = E_OUTOFMEMORY;
38 return;
39 }
40
42}
43
45{
46 if (!pszPrompt)
47 {
49 return E_UNEXPECTED;
50 }
51
52 m_pszPrompt = new (std::nothrow) TCHAR[_tcslen(pszPrompt)+1];
53 if (!m_pszPrompt)
54 return E_OUTOFMEMORY;
55
56 _tcscpy(m_pszPrompt,pszPrompt);
57
58 return S_OK;
59}
60
62{
63 if (m_pszPrompt)
64 delete[] m_pszPrompt;
65}
66
68{
70 TCHAR Buffer[2] = " ";
71
72 const TCHAR *pszCurrentPath;
73
74 while (*pch)
75 {
77 {
78 pszCurrentPath = m_rTree.GetCurrentPath();
79 rConsole.Write(pszCurrentPath?pszCurrentPath:_T("NULL (Internal Error)"));
81 }
82 else
83 {
84 Buffer[0] = *pch++;
85 rConsole.Write(Buffer);
86 }
87 }
88}
89
91{
92 return DEFAULT_PROMPT;
93}
#define DEFAULT_PROMPT
Definition: Prompt.cpp:30
#define CURRENT_PATH_ALIAS
Definition: Prompt.cpp:29
Definition: bufpool.h:45
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
void ShowPrompt(CConsole &rConsole)
Definition: Prompt.cpp:67
static LPCTSTR GetDefaultPrompt()
Definition: Prompt.cpp:90
~CPrompt()
Definition: Prompt.cpp:61
HRESULT SetPrompt(LPCTSTR pszPrompt)
Definition: Prompt.cpp:44
CPrompt(CRegistryTree &rTree, HRESULT &rhr)
Definition: Prompt.cpp:32
CRegistryTree & m_rTree
Definition: Prompt.h:17
LPTSTR m_pszPrompt
Definition: Prompt.h:18
const TCHAR * GetCurrentPath() const
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
#define _tcscpy
Definition: tchar.h:623
#define _tcsncmp
Definition: tchar.h:1428
#define S_OK
Definition: intsafe.h:52
#define pch(ap)
Definition: match.c:418
#define ASSERT(a)
Definition: mode.c:44
#define _T(x)
Definition: vfdio.h:22
#define E_UNEXPECTED
Definition: winerror.h:2456
char TCHAR
Definition: xmlstorage.h:189
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define _tcslen
Definition: xmlstorage.h:198