当前位置: 首页>>代码示例>>C++>>正文


C++ CConsoleBase::Getch方法代码示例

本文整理汇总了C++中CConsoleBase::Getch方法的典型用法代码示例。如果您正苦于以下问题:C++ CConsoleBase::Getch方法的具体用法?C++ CConsoleBase::Getch怎么用?C++ CConsoleBase::Getch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CConsoleBase的用法示例。


在下文中一共展示了CConsoleBase::Getch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MainL

static void MainL(void)
/**
Takes a User Prompt Service policy resource file and dumps it as human readable text to the 
console. The user may also specify the name of an output file on the command line. If so, text
is also written to this file.
*/
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
		
	CConsoleBase* console = Console::NewL(KAppName, TSize(KDefaultConsWidth, KDefaultConsHeight));
	CleanupStack::PushL(console);
	
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	
	if (args->Count() > 1)
		{		
		CPolicyReader* reader = CPolicyReader::NewLC(fs, args->Arg(1));		
		CPrinter* printer(0);
		if (args->Count() > 2)
			{
			RFile outFile;
			User::LeaveIfError(outFile.Replace(fs, args->Arg(2), EFileShareExclusive | EFileWrite));
			CleanupClosePushL(outFile);
			printer = CPrinter::NewLC(console, outFile);		
			
			CleanupStack::Pop(printer); 
			CleanupStack::PopAndDestroy(&outFile);
			CleanupStack::PushL(printer);
			}
		else
			{
			printer = CPrinter::NewLC(console);	
			}
		__UHEAP_MARK;
		PrintPoliciesL(printer, reader);
		__UHEAP_MARKEND;
		
		if (args->Count() < 3)
			{
			// If no output file is specified then pause after finishing
			// because the console will vanish when it is closed.
			console->Printf(_L("Press any key to continue\r\n"));
			console->Getch();
			}		
		CleanupStack::PopAndDestroy(2, reader); // printer, reader		
		}
	else 
		{
		console->Printf(_L("Usage: dumppolicy.exe policy.rsc <output.txt>\r\n"));
		console->Printf(_L("Press any key to continue\r\n"));
		console->Getch();
		}
	
	CleanupStack::PopAndDestroy(3, &fs); // args, console, fs
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:57,代码来源:dumppolicy.cpp

示例2: MainL

LOCAL_C void MainL()
	{
	_LIT(KTitle,"TestExecuteLogger Test Code for serial logging");
	CConsoleBase* console = Console::NewL(KTitle,TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);
	CTestExecuteLogger logger;

	TInt logLevel =1  ;
	TBool separateLogFiles(EFalse); 
	_LIT(KScriptPath,"E:\\plattest\\Selective.script");
	TPtrC scriptFilePath(KScriptPath);

	console->Write(_L("logger.InitialiseLoggingL next2 \n")) ; 
	logger.InitialiseLoggingL(scriptFilePath, separateLogFiles, logLevel);
	
	console->Write(_L("post logger.InitialiseLoggingL next \n"));
	TestWorkAPIsL(logger, console)	;
	
	console->Write(_L("attempting TerminateLoggingL \n")) ; 
	logger.TerminateLoggingL(3, 4, 3); //suggested by todays fortune cookie...

	console->Write(_L("Done testing, press a key to finish \n")) ; 
	console->Getch() ; 
	CleanupStack::PopAndDestroy(console);	
	}
开发者ID:fedor4ever,项目名称:testfw,代码行数:25,代码来源:testexecuteloggingtest.cpp

示例3: ExecuteL

void CListCommand::ExecuteL(CConsoleBase& aConsole)
	{
	// Connect to the SCR server
	RSoftwareComponentRegistry scr;
	TInt err = scr.Connect();
	if (err != KErrNone)
		{
		aConsole.Printf(_L("\nFailed to connect to the SCR server"));
		User::Leave(err);
		}
	CleanupClosePushL(scr);

	// Create an SCR view
	RSoftwareComponentRegistryView scrView;
	scrView.OpenViewL(scr, iFilter);
	CleanupClosePushL(scrView);

	// Iterate over the matching components
	CComponentEntry* entry = CComponentEntry::NewLC();
	TBool first(ETrue);
	while (scrView.NextComponentL(*entry, iLocale))
		{
		if (first)
			{
			first = EFalse;
			}
		else
			{
			aConsole.Printf(KTxtPressToContinue);
			aConsole.Getch();
			aConsole.ClearScreen();
			}

		aConsole.Printf(_L("\n============= Component Info =============\n"));
		aConsole.Printf(_L("\nComponent ID     : %d"), entry->ComponentId());
		aConsole.Printf(_L("\nComponent name   : %S"), &entry->Name());
		aConsole.Printf(_L("\nVendor name      : %S"), &entry->Vendor());
		aConsole.Printf(_L("\nSoftware type    : %S"), &entry->SoftwareType());
		aConsole.Printf(_L("\nSCOMO state      : %S"), entry->ScomoState() == EActivated ? &KTxtActivated : &KTxtDeactivated );
		aConsole.Printf(_L("\nComponent size   : %d"), entry->ComponentSize());
		aConsole.Printf(_L("\nInstalled drives : %S"), &entry->InstalledDrives());
		aConsole.Printf(_L("\nVersion          : %S"), &entry->Version());
		aConsole.Printf(_L("\n\n=========================================\n"));
		}

	// Disconnect from the SCR server and cleanup the entry
	CleanupStack::PopAndDestroy(3, &scr);
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:48,代码来源:command.cpp

示例4: ActiveTestL

LOCAL_C void ActiveTestL()
    {
	CConsoleBase* console = Console::NewL(_L("ACTIVETEST"), TSize(KConsFullScreen, KConsFullScreen));
	CleanupStack::PushL(console);

	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
	CleanupStack::PushL(scheduler);
	CActiveScheduler::Install(scheduler);

	CActiveConsole* activeConsole = CActiveConsole::NewLC(*console);
	activeConsole->RequestCharacter();
	CActiveScheduler::Start();
	// NB CActiveScheduler::Start only returns when someone somewhere has 
	// called CActiveScheduler::Stop.

	CleanupStack::PopAndDestroy(2); // activeConsole, scheduler

	console->Printf(_L("\nPress any key"));
	console->Getch(); // get and ignore character
	CleanupStack::PopAndDestroy(); // console
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:21,代码来源:activetest.cpp

示例5: InitConsoleL

LOCAL_C void InitConsoleL()
    {
    // create a full screen console object
    CConsoleBase* console;
    console = Console::NewL(KTxtTitle, TSize(KConsFullScreen,KConsFullScreen));
      
    CleanupStack::PushL(console);
  
    //Gets the size of the console
    TSize screenSize = console->ScreenSize();
    test.Printf(_L("Screen size %d %d\r\n"),screenSize.iWidth,screenSize.iHeight);
  
    // Gets the cursor's x-position
    TInt x = console->WhereX();
    // Gets the cursor's y-position
    TInt y = console->WhereY();
    test_Equal(x, 0);
    test_Equal(y, 0);
    test.Printf(_L("**1** Cursor positions x: %d  y: %d\r\n"),x, y);
  
    // Sets the cursor's x-position
    for(TInt i=0; i<4; i++)
        {
        console->SetPos(screenSize.iWidth + i);
        x = console->WhereX();
        test_Equal(x, screenSize.iWidth -3);
		}
    
    test.Printf(_L("**2** Cursor positions x: %d  y: %d\r\n"),x, y);
      
    // Clears the console and set cursor to position 0,0
    console->ClearScreen();
    test_Equal(console->WhereX(), 0);
	test_Equal(console->WhereY(), 0);
        
    // Sets the cursor's x-position and y-position
    for(TInt j=0; j<4; j++)
        {
        console->SetPos(screenSize.iWidth - j, screenSize.iHeight - j);
        x = console->WhereX();
        y = console->WhereY();
        test_Equal(x, screenSize.iWidth -3);
		test_Equal(y, screenSize.iHeight -3);
		}
    test.Printf(_L("**3** Cursor positions x: %d  y: %d\r\n"),x, y);
     
    console->SetPos(0,0);
    x = console->WhereX();
    y = console->WhereY();
    test_Equal(x, 0);
    test_Equal(y, 0);
	test.Printf(_L("**4** Cursor positions x: %d  y: %d\r\n"),x, y);
  
    console->SetPos(screenSize.iWidth/2,screenSize.iHeight/2);
    x = console->WhereX();
    y = console->WhereY();
    test.Printf(_L("**5** Cursor positions x: %d  y: %d\r\n"),x, y);
  
    // Sets the percentage height of the cursor
    console->SetCursorHeight(50);
  
    // Gets the current cursor position relative to the console window
    TPoint cursorPos = console->CursorPos();
    test.Printf(_L("CursorPos iX: %d  iY: %d\r\n"),cursorPos.iX, cursorPos.iY);
    
    // Puts the cursor at the specified position relative
    // to the current cursor position
    TPoint relPos;
    relPos.iX = screenSize.iWidth/4;
    relPos.iY = screenSize.iHeight/4;
    console->SetCursorPosRel(relPos);
    cursorPos = console->CursorPos();
    test.Printf(_L("CursorPosRel iX: %d  iY: %d\r\n"),cursorPos.iX, cursorPos.iY);
  
    // Puts the cursor at the absolute position in the window
    cursorPos.iX = screenSize.iWidth/6;
    cursorPos.iY = screenSize.iHeight/6;
    console->SetCursorPosAbs(cursorPos);
    cursorPos = console->CursorPos();
    test.Printf(_L("CursorPosAbs iX: %d  iY: %d\r\n"),cursorPos.iX, cursorPos.iY);
  
    // Sets a new console title
    console->SetTitle(KTxtNewTitle);
    // Writes the content of the specified descriptor to the console window
    console->Write(KTxtWrite);
    cursorPos.iX = cursorPos.iX + 6;
    console->SetCursorPosAbs(cursorPos);
    // Clears the console from the current cursor position to the end of the line
    console->ClearToEndOfLine();
    // Clears the console and set cursor to position 0,0
    console->ClearScreen();
  
    TUint keyModifiers = console->KeyModifiers();
	test.Printf(_L("keyModifiers %d"),keyModifiers);
    TKeyCode keyCode = console->KeyCode();
    ReadConsole(console);
  
    SimulateKeyPress(EStdKeyEnter);
    keyCode = console->Getch();
  
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:t_console.cpp

示例6: Getch

	void Getch() {
		if (cons) cons->Getch();
	}
开发者ID:flaithbheartaigh,项目名称:jaikuengine-mobile-client,代码行数:3,代码来源:testdriver_base.cpp

示例7: MainL

void MainL()
	{
	
	/* Create the named - pipe */
    int ret_val = mkfifo(HALF_DUPLEX, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
    
    if ((ret_val == -1) && (errno != EEXIST)) {
        perror("Error creating the named pipe");
        return ; 
        //exit (1);
    }
    
    int pipe = open(HALF_DUPLEX, O_RDONLY | O_NONBLOCK);
    
	_LIT(KTitle,"TestExecute Standalone Logger Test Code");
	CConsoleBase* console = Console::NewL(KTitle,TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);

	_LIT(KMessage1,"Connect() To Logger and Close() immediately\r\n");
	console->Printf(KMessage1);
	RTestExecutePIPSLogServ logger;
	User::LeaveIfError(logger.Connect());
	logger.Close();

	_LIT(KMessage2,"Immediate re-Connect() To Logger and Close() immediately\r\n");
	console->Printf(KMessage2);
	User::LeaveIfError(logger.Connect());
	logger.Close();

	_LIT(KMessage3,"Immediate re-Connect() To Logger CreateLog() and Close() immediately\r\n");
	console->Printf(KMessage3);
	User::LeaveIfError(logger.Connect());
	User::LeaveIfError(logger.CreateLog(KLogFile1));
	logger.Close();

	// OS needs time to shutdown the server
	// No delay means we get server terminated from the OS
	User::After(1000000);

	_LIT(KMessage4,"Connect() To Logger CreateLog() %S Call API's\r\n");
	TBuf<80> logFile(KLogFile1);
	console->Printf(KMessage4,&logFile);
	User::LeaveIfError(logger.Connect());
	User::LeaveIfError(logger.CreateLog(KLogFile1));
	TBuf<20> buf16(K16BitString);
	TBuf8<20> buf8(K8BitString);
	logger.Write(K16BitText);
	logger.Write(K8BitText);
	logger.WriteFormat(K16BitFormatText,16,&buf16);
	logger.WriteFormat(K8BitFormatText,8,&buf8);
	logger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16);

	_LIT(KMessage5,"ALL API's Called - Call Close(),\r\n");
	console->Printf(KMessage5);
	//console->Getch();
	logger.Close();
	
	//try an empty pipe 
	_LIT(KLogFileEmpty,"");
	_LIT(KMessageEmp,"Connect() To Logger CreateLog() %S Call API's\r\n");
	TBuf<80> logFiley(KLogFileEmpty);
	console->Printf(KMessageEmp,&logFiley);
	User::LeaveIfError(logger.Connect());
	User::LeaveIfError(logger.CreateLog(KLogFileEmpty));
	logger.Write(K16BitText);
	logger.Write(K8BitText);
	logger.WriteFormat(K16BitFormatText,16,&buf16);
	logger.WriteFormat(K8BitFormatText,8,&buf8);
	logger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16);
	console->Printf(KMessage5);
	console->Getch();
	logger.Close();

	CleanupStack::PopAndDestroy(console);

	}
开发者ID:fedor4ever,项目名称:testfw,代码行数:76,代码来源:testexecutepipsloggertest.cpp

示例8: ProcessMainL


//.........这里部分代码省略.........
			//If scriptFilePath is not appended by .script Append .script 
			if(scriptFilePath.Find(KTEFScriptExtension)==KErrNotFound)
				{
				tempScriptPath.Append(KTEFScriptExtension);
				}
			scriptFilePath.Set(tempScriptPath);
			}
		}

	TPtrC pipeName ; 
	if(pipe)
		{
		TLex flagLex(commandLine);
		//first of all navigate the command line arguments to the selective test cases flag...
		while(!flagLex.Eos())
		{
			TPtrC token(flagLex.NextToken());
			if( (token.CompareF(KTestExecuteCommandLineFlagPipe) == 0) )
				{
				break;
				}
		}
		pipeName.Set(flagLex.NextToken()) ; 	
		}
	
	TSelectiveTestingOptions* selTestingOptions =NULL;
	if (includeSelectiveCases && excludeSelectiveCases)
		{
			//mutually exclusive options have been encountered
			includeSelectiveCases =EFalse;
			excludeSelectiveCases =EFalse;					
			console->Printf(KTEFInvalidCommandSetMessage);
			console->Printf(KTEFEnterKeyMessage);
			console->Getch();
		}
	else
		{
		if(includeSelectiveCases || excludeSelectiveCases)
			{
			RArray<TRange> selectiveCaseRange;
			ParseCommandLineForSelectiveTestingOptions(commandLine,*parseTestExecuteIni,selectiveCaseRange, selTestCfgFileData);
			
			//you need to sort these two arrays first, and also if they are both empty ignore the entire option altogether.
			if(  selectiveCaseRange.Count() > 0 )
				{
				CleanupStack::PushL(selTestCfgFileData);
				TLinearOrder<TRange> orderingrng(TRange::CompareTRangeStartOrder) ; 
				selectiveCaseRange.Sort(orderingrng );
				ESelectiveTesting selectiveTestingType(iExclusive);
				if(includeSelectiveCases)
					{
					selectiveTestingType = iInclusive ; 
					}
				selTestingOptions = new(ELeave) TSelectiveTestingOptions(selectiveCaseRange, selectiveTestingType);
				}
			else
				{
				//if no arguments to this option have been found, ignore it...
				includeSelectiveCases =EFalse;
				excludeSelectiveCases =EFalse;
				delete selTestCfgFileData;
				}
			}
		}

	if (scriptFilePath.CompareF(KNull)==0)
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:67,代码来源:testexecute.cpp


注:本文中的CConsoleBase::Getch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。