-/* $Id: RegistryExplorer.cpp,v 1.5 2001/04/15 22:17:50 narnaoud Exp $
+/* $Id: RegistryExplorer.cpp,v 1.6 2001/04/16 05:11:54 narnaoud Exp $
*
* regexpl - Console Registry Explorer
*
* Boston, MA 02111-1307, USA.
*/
-// Registry Explorer.cpp : Defines the entry point for the console application.
+// RegistryExplorer.cpp : Defines the entry point for the Regiistry Explorer.
//
#include "ph.h"
#include "ShellCommandDeleteKey.h"
#include "ShellCommandSetValue.h"
#include "ShellCommandDeleteValue.h"
+#include "Prompt.h"
+#include "Settings.h"
TCHAR pchCurrentKey[PROMPT_BUFFER_SIZE];
int nRetCode = 0;
+ HRESULT hr;
+
+ CSettings *pSettings = NULL;
+ CPrompt *pPrompt = NULL;
+
+ pSettings = new CSettings();
+ if (!pSettings)
+ {
+ _ftprintf(stderr,_T("Cannot initialize settings. Out of memory.\n"));
+ goto Abort;
+ }
+
+ hr = pSettings->Load(SETTINGS_REGISTRY_KEY);
+ if (FAILED(hr))
+ {
+ _ftprintf(stderr,_T("Cannot load settings. Error is 0x%X.\n"),(unsigned int)hr);
+ goto Abort;
+ }
+
+ pPrompt = new CPrompt(Tree,hr);
+ if (!pPrompt)
+ {
+ _ftprintf(stderr,_T("Cannot initialize prompt. Out of memory.\n"));
+ goto Abort;
+ }
+
+ if (FAILED(hr))
+ {
+ _ftprintf(stderr,_T("Cannot initialize prompt. Error is 0x%X.\n"),(unsigned int)hr);
+ goto Abort;
+ }
+
// input buffer size in chars
#define INPUT_BUFFER_SIZE 1024
//#define INPUT_BUFFER_SIZE 128
if (!Console.GetTextAttribute(wOldConsoleAttribute)) goto Abort;
Console.SetTitle(_T("Registry Explorer"));
- Console.SetTextAttribute(FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED/*|FOREGROUND_INTENSITY*/);
+ Console.SetTextAttribute(pSettings->GetNormalTextAttributes());
VERIFY(SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine,TRUE));
//Tree.SetDesiredOpenKeyAccess(KEY_READ);
- const TCHAR *pszCurrentPath;
+ hr = pPrompt->SetPrompt(pSettings->GetPrompt());
+ if (FAILED(hr))
+ {
+ _ftprintf(stderr,_T("Cannot initialize prompt. Error is 0x%X.\n"),(unsigned int)hr);
+ goto Abort;
+ }
+
GetCommand:
// prompt
// TODO: make prompt user-customizable
Console.EnableWrite();
- pszCurrentPath = Tree.GetCurrentPath();
- Console.Write(pszCurrentPath?pszCurrentPath:_T("NULL (Internal Error)"));
- Console.Write(_T("\n# "));
+ pPrompt->ShowPrompt(Console);
Console.FlushInputBuffer();
blnCommandExecutionInProgress = FALSE;
// Set command line color
-// Console.SetTextAttribute(/*FOREGROUND_BLUE|*/FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY);
+ Console.SetTextAttribute(pSettings->GetPromptTextAttributes());
if (!Console.ReadLine())
goto Abort;
// Set normal color
-// Console.SetTextAttribute(FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY);
+ Console.SetTextAttribute(pSettings->GetNormalTextAttributes());
Console.BeginScrollingOperation();
blnCommandExecutionInProgress = TRUE;
Abort:
_ftprintf(stderr,_T("Abnormal program termination.\nPlease report bugs to ") EMAIL _T("\n"));
nRetCode = 1;
+
Exit:
+
+ if (pSettings)
+ delete pSettings;
+
+ if (pPrompt)
+ delete pPrompt;
+
return nRetCode;
}
-/* $Id: RegistryExplorer.h,v 1.5 2001/01/13 23:53:23 narnaoud Exp $ */
+/* $Id: RegistryExplorer.h,v 1.6 2001/04/16 05:11:54 narnaoud Exp $ */
#ifndef _REGISTRY_EXPLORER_H__INCLUDED
#define _REGISTRY_EXPLORER_H__INCLUDED
#define COMMAND_NA_ON_ROOT _T(" is not applicable to root key.\n")
+#define SETTINGS_REGISTRY_KEY _T("SOFTWARE\\Registry Explorer")
+#define NORMAL_TEXT_ATTRIBUTES_VALUE_NAME _T("Normal Text Color")
+#define PROMPT_TEXT_ATTRIBUTES_VALUE_NAME _T("Prompt Text Color")
+#define PROMPT_VALUE_NAME _T("Prompt")
+
#endif //#ifndef _REGISTRY_EXPLORER_H__INCLUDED