mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 00:54:40 +00:00
Added base support for user settings.
svn path=/trunk/; revision=1804
This commit is contained in:
parent
2957aa4ce5
commit
add5e2d89f
3 changed files with 64 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.4 2001/01/10 01:25:29 narnaoud Exp $
|
||||
# $Id: Makefile,v 1.5 2001/04/16 05:11:54 narnaoud Exp $
|
||||
#
|
||||
# ReactOS makefile for RegExpl
|
||||
#
|
||||
|
@ -52,6 +52,8 @@ OBJECTS = \
|
|||
TextHistory.o \
|
||||
Completion.o \
|
||||
Pattern.o \
|
||||
Settings.o \
|
||||
Prompt.o \
|
||||
$(TARGET_NAME).coff
|
||||
|
||||
CLEAN_FILES = \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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
|
||||
*
|
||||
|
@ -20,7 +20,7 @@
|
|||
* 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"
|
||||
|
@ -46,6 +46,8 @@
|
|||
#include "ShellCommandDeleteKey.h"
|
||||
#include "ShellCommandSetValue.h"
|
||||
#include "ShellCommandDeleteValue.h"
|
||||
#include "Prompt.h"
|
||||
#include "Settings.h"
|
||||
|
||||
TCHAR pchCurrentKey[PROMPT_BUFFER_SIZE];
|
||||
|
||||
|
@ -134,6 +136,38 @@ int main ()
|
|||
|
||||
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
|
||||
|
@ -154,7 +188,7 @@ int main ()
|
|||
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));
|
||||
|
||||
|
@ -164,25 +198,29 @@ int main ()
|
|||
|
||||
//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;
|
||||
|
@ -222,6 +260,14 @@ GetCommand:
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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
|
||||
|
@ -49,4 +49,9 @@
|
|||
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue