本文整理汇总了C++中CConsole::FlushInputBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CConsole::FlushInputBuffer方法的具体用法?C++ CConsole::FlushInputBuffer怎么用?C++ CConsole::FlushInputBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConsole
的用法示例。
在下文中一共展示了CConsole::FlushInputBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
TCHAR *pchCommand;
pchCommand = Console.Init(INPUT_BUFFER_SIZE,10);
if (pchCommand == NULL)
{
_ftprintf(stderr,_T("Cannot initialize console.\n"));
nRetCode = 1;
goto Exit;
}
Console.SetReplaceCompletionCallback(CompletionCallback);
WORD wOldConsoleAttribute;
if (!Console.GetTextAttribute(wOldConsoleAttribute)) goto Abort;
Console.SetTitle(_T("Registry Explorer"));
Console.SetTextAttribute(pSettings->GetNormalTextAttributes());
VERIFY(SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine,TRUE));
if (!Console.Write(HELLO_MSG
//(_L(__TIMESTAMP__))
)) goto Abort;
//Tree.SetDesiredOpenKeyAccess(KEY_READ);
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();
pPrompt->ShowPrompt(Console);
Console.FlushInputBuffer();
blnCommandExecutionInProgress = FALSE;
// Set command line color
Console.SetTextAttribute(pSettings->GetCommandTextAttributes());
if (!Console.ReadLine())
goto Abort;
// Set normal color
Console.SetTextAttribute(pSettings->GetNormalTextAttributes());
Console.BeginScrollingOperation();
blnCommandExecutionInProgress = TRUE;
// Parse command line (1st step - convert to multi sz)
Parser.SetArgumentList(pchCommand);
int nCommandReturnValue;
switch(CommandsList.Execute(Parser,nCommandReturnValue))
{
case -1: // not recognized command
{
Parser.ResetArgumentIteration();
TCHAR *pchCommandItself = Parser.GetNextArgument();
size_t cmdlen = _tcslen(pchCommandItself);
if ((!cmdlen)||
(pchCommandItself[cmdlen-1] != _T('\\'))||
(Parser.GetNextArgument())||
(!Tree.ChangeCurrentKey(pchCommandItself)))
{
Console.Write(_T("Unknown command \""));
Console.Write(pchCommandItself);
Console.Write(_T("\"\n"));
}
}
case -2: // empty line
goto GetCommand;
case 0: // exit command
nRetCode = 0;
Console.SetTextAttribute(wOldConsoleAttribute);
goto Exit;
default:
Console.Write(_T("\n"));
goto 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;
}