mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Prompt now supports customization. Implementation is based on customization string with escape sequences. The prompt currently recognizes only one sequence in the customization string, \w - the current path.
svn path=/trunk/; revision=1799
This commit is contained in:
parent
aeb62db2e8
commit
616e4d5242
2 changed files with 115 additions and 0 deletions
94
rosapps/sysutils/regexpl/Prompt.cpp
Normal file
94
rosapps/sysutils/regexpl/Prompt.cpp
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/* $Id: Prompt.cpp,v 1.1 2001/04/16 04:53:31 narnaoud Exp $
|
||||||
|
*
|
||||||
|
* regexpl - Console Registry Explorer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2000,2001 Nedko Arnaoudov <nedkohome@atia.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// prompt for Registry Explorer
|
||||||
|
|
||||||
|
#include "ph.h"
|
||||||
|
#include "Prompt.h"
|
||||||
|
|
||||||
|
#define ESCAPE_CHAR _T("\\")
|
||||||
|
#define CURRENT_PATH_ALIAS_CHAR _T("w")
|
||||||
|
#define CURRENT_PATH_ALIAS ESCAPE_CHAR CURRENT_PATH_ALIAS_CHAR
|
||||||
|
#define DEFAULT_PROMPT CURRENT_PATH_ALIAS _T("\n# ")
|
||||||
|
|
||||||
|
CPrompt::CPrompt(CRegistryTree& rTree, HRESULT& rhr):m_rTree(rTree)
|
||||||
|
{
|
||||||
|
m_pszPrompt = new TCHAR[_tcslen(DEFAULT_PROMPT)+1];
|
||||||
|
if (!m_pszPrompt)
|
||||||
|
{
|
||||||
|
rhr = E_OUTOFMEMORY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_tcscpy(m_pszPrompt,DEFAULT_PROMPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CPrompt::SetPrompt(LPCTSTR pszPrompt)
|
||||||
|
{
|
||||||
|
if (!pszPrompt)
|
||||||
|
{
|
||||||
|
ASSERT(FALSE);
|
||||||
|
return E_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pszPrompt = new TCHAR[_tcslen(pszPrompt)+1];
|
||||||
|
if (!m_pszPrompt)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
_tcscpy(m_pszPrompt,pszPrompt);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPrompt::~CPrompt()
|
||||||
|
{
|
||||||
|
if (m_pszPrompt)
|
||||||
|
delete m_pszPrompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPrompt::ShowPrompt(CConsole &rConsole)
|
||||||
|
{
|
||||||
|
TCHAR *pch = m_pszPrompt;
|
||||||
|
TCHAR Buffer[2] = " ";
|
||||||
|
|
||||||
|
const TCHAR *pszCurrentPath;
|
||||||
|
|
||||||
|
while (*pch)
|
||||||
|
{
|
||||||
|
if (_tcsncmp(pch,CURRENT_PATH_ALIAS,_tcslen(CURRENT_PATH_ALIAS)) == 0)
|
||||||
|
{
|
||||||
|
pszCurrentPath = m_rTree.GetCurrentPath();
|
||||||
|
rConsole.Write(pszCurrentPath?pszCurrentPath:_T("NULL (Internal Error)"));
|
||||||
|
pch += _tcslen(CURRENT_PATH_ALIAS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Buffer[0] = *pch++;
|
||||||
|
rConsole.Write(Buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LPCTSTR CPrompt::GetDefaultPrompt()
|
||||||
|
{
|
||||||
|
return DEFAULT_PROMPT;
|
||||||
|
}
|
21
rosapps/sysutils/regexpl/Prompt.h
Normal file
21
rosapps/sysutils/regexpl/Prompt.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef PROMPT_H__d2442d41_b6b3_47b5_8cb8_e6c597e570b9__INCLUDED
|
||||||
|
#define PROMPT_H__d2442d41_b6b3_47b5_8cb8_e6c597e570b9__INCLUDED
|
||||||
|
|
||||||
|
#include "RegistryTree.h"
|
||||||
|
#include "Console.h"
|
||||||
|
|
||||||
|
class CPrompt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPrompt(CRegistryTree& rTree, HRESULT& rhr);
|
||||||
|
~CPrompt();
|
||||||
|
HRESULT SetPrompt(LPCTSTR pszPrompt);
|
||||||
|
void ShowPrompt(CConsole &rConsole);
|
||||||
|
static LPCTSTR GetDefaultPrompt();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CRegistryTree& m_rTree;
|
||||||
|
LPTSTR m_pszPrompt;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef PROMPT_H__d2442d41_b6b3_47b5_8cb8_e6c597e570b9__INCLUDED
|
Loading…
Reference in a new issue