示例#1
0
文件: nit-rsh.cpp 项目: noriter/nit
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR strCmdLine, INT cmdShow)
{
	using namespace nit;

	Runtime rt;

	rt.init();

	ConsoleWindow cw;

	ConsoleApp app(&cw);

	String historyFilename;

	int numArgs;
	LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
	if (numArgs > 0)
	{
		String exeName;
		String exePath;
		StringUtil::splitFilename(Unicode::toUtf8(argv[0]), exeName, exePath);
		historyFilename = exePath + "nit-rsh.history.txt";
		cw.loadHistory(historyFilename.c_str());
	}

	cw.setTitle("nit remote shell");

	cw.run(hInst, hPrev, strCmdLine, cmdShow);

	if (!historyFilename.empty())
		cw.saveHistory(historyFilename.c_str());

	rt.finish();
}
示例#2
0
文件: nit-rsh.cpp 项目: noriter/nit
	void onRemoteNotify(const RemoteNotifyEvent* evt)
	{
		switch (evt->command)
		{
		case NT_SVR_LOG_ENTRY:			
			onServerLogEntry(evt); 
			break;

		case NT_SVR_BREAK:
			_console->setPrompt("debug> ");
			break;

		case NT_SVR_RESUME:
			_console->setPrompt("> ");
			break;
		}
	}
示例#3
0
bool Desktop::OpenApplicationConsole(FCULONG appID)
{
  bool bResult = false;
  ConsoleWindow* pConsole = new ConsoleWindow(this, m_owner.GetContainer()->GetController(), m_pDevice);

  if ( pConsole )
  {
    m_mutexApps.Lock();
    if ( pConsole->Create(INGAMEAPP_BASE_ID+SWT_APP_CONSOLE, appID, ResourceManager::instance().GetClientString(STR_APP_CONSOLE_CAPTION) ) )
    {
      addChild( pConsole->GetGUIWindow() );
	    m_arrApps.push_back(pConsole);
      if ( m_pAppBar )
        m_pAppBar->setActiveApp( pConsole );
      bResult = true;
    }
    m_mutexApps.Unlock();
  }

  return bResult;
}
示例#4
0
bool Desktop::OnConsoleEvent(FCModelEvent& event)
{
  bool bResult = true;
  ConsoleWindow* pWnd = static_cast<ConsoleWindow*>(GetAppWindowByType(SWT_APP_CONSOLE));

  if ( pWnd )
  {
    switch ( event.GetType() )
    {
    case  FCME_Console_FileSystemInfo:
      {
        FCModel::FileSystemInfo* pFSI = (FCModel::FileSystemInfo*) event.GetData();
        if ( pFSI )
        {
          pWnd->OnFileSystemInfoReceived(pFSI);
        }
      }
      break;

		case	FCME_Console_Command:
			{
				__FCPKT_CON_COMMAND_RESP* pResp = (__FCPKT_CON_COMMAND_RESP*)event.GetData();
				if ( pResp )
				{
          std::string result;
          result.assign( pResp->result, pResp->len );
          pWnd->OnConsoleCommandResponse( pResp->currentDir, result );
				}
			}
			break;

    default:
      break;
    }
  }
  else
    bResult = false;

  return bResult;
}
示例#5
0
void ConsoleMaster::createNewWindow()
{
  ConsoleWindow* win = new ConsoleWindow(&db_);
  windows_.append(win);

  QSettings settings;
  window_font_ = settings.value(SettingsKeys::FONT, QFont("Ubuntu Mono", 9)).value<QFont>();
  win->setFont(window_font_);
  QObject::connect(win, SIGNAL(createNewWindow()),
                   this, SLOT(createNewWindow()));

  QObject::connect(&ros_thread_, SIGNAL(connected(bool)),
                   win, SLOT(connected(bool)));

  QObject::connect(this,
                   SIGNAL(fontChanged(const QFont &)),
                   win, SLOT(setFont(const QFont &)));

  QObject::connect(win, SIGNAL(selectFont()),
                   this, SLOT(selectFont()));

  QObject::connect(win, SIGNAL(readBagFile()),
                   &bag_reader_, SLOT(promptForBagFile()));


  if (!ros_thread_.isRunning())
  {
    // There's only one ROS thread, and it services every window.  We need to initialize
    // it and its connections to the LogDatabase when we first create a window, but
    // after that it doesn't need to be modified again.
    QObject::connect(&ros_thread_, SIGNAL(logReceived(const rosgraph_msgs::LogConstPtr& )),
                     &db_, SLOT(queueMessage(const rosgraph_msgs::LogConstPtr&) ));

    QObject::connect(&ros_thread_, SIGNAL(spun()),
                     &db_, SLOT(processQueue()));

    ros_thread_.start();
  }
示例#6
0
文件: nit-rsh.cpp 项目: noriter/nit
	void onServerLogEntry(const RemoteNotifyEvent* evt)
	{
		size_t blobSize;
		const void* blob = evt->param.toBlob(&blobSize);

		RemoteLogEntry entry(blob, blobSize);

		COLORREF color;

		switch (entry.logLevel)
		{
		case LOG_LEVEL_VERBOSE:			color = RGB(0x80, 0x80, 0x80); break;
		case LOG_LEVEL_DEBUG:			color = RGB(0x00, 0x00, 0x00); break;
		case LOG_LEVEL_INFO:			color = RGB(0x00, 0x80, 0x00); break;
		case LOG_LEVEL_WARNING:			color = RGB(0xFF, 0x00, 0xFF); break;
		case LOG_LEVEL_ERROR:			color = RGB(0xFF, 0x00, 0x00); break;
		case LOG_LEVEL_FATAL:			color = RGB(0xFF, 0x00, 0x00); break;

		default:						color = RGB(0, 0, 0);
		}

		if (entry.flags & entry.FLAG_LINESTART)
		{
			char buf[LogManager::MAX_BUF_SIZE];
			size_t bufSize = sizeof(buf) - 1;

			int len = entry.formatHeader(buf, sizeof(buf));

			if (len > 0)
				_console->printString(buf, len, color);
		}

		_console->printString(entry.message, entry.messageLen, color);

		if (entry.flags & entry.FLAG_LINEEND)
			_console->printString("\n", -1, color);
	}
示例#7
0
文件: nit-rsh.cpp 项目: noriter/nit
	void onRemoteResponse(const RemoteResponseEvent* evt)
	{
		switch (evt->command)
		{
		case RQ_ATTACH:
			if (evt->code < 0)
			{
				String msg = evt->param.toString();
				LOG(0, "[nit-rsh] Can't attach debugger (%d) %s\n", evt->code, msg.c_str());
				evt->peer->disconnect();
				break;
			}
			else
			{
				_console->setPrompt("> ");
			}
		}
	}
示例#8
0
文件: conpix.cpp 项目: rofl0r/conpix
int main(int argc, char** argv) {
	string filename = "";
	bool scaleFullScreen = false;
	string arg;
	for (int i = 1; i<argc; i++) {
		arg = argv[i];
		if (arg == "-f") scaleFullScreen=true;
		else filename = arg;
	}

	if (!fexists(filename.c_str())) {
		string self = argv[0];
		cout << "file not found!" << endl << endl;
		cout << "c0npix by rofl0r" << endl;
		cout << "================" << endl;
		cout << "arguments: " << self << " [-f] somefile.[jpg|png|bmp|tiff]" << endl;
		cout << "where -f means scale to fullscreen" << endl << endl;
		cout << "export TERM=xterm-256color before usage is recommended." << endl;
		exit(1);
	}

	SimpleFileLogger* l = new SimpleFileLogger("log.txt");
	l->clear();

	ConsoleWindow* t = new ConsoleWindow(l);
	int cx; int cy;
	t->getSize(cx, cy);

	Pix* pngfile = pixRead(filename.c_str());

    float xfactor = 1.0; float yfactor = 1.0; int w; int h;
    pixGetDimensions(pngfile, &w, &h, NULL);
    Pix* ping;

    if(scaleFullScreen) {
    	xfactor = (cx * 1.0) / (w * 1.0);
    	yfactor = (cy * 1.0) / (h * 1.0);
    	ping = pixScale(pngfile, xfactor, yfactor);
    } else {
    	if (cx *2 < w) xfactor = (cx * 1.0) / (w * 1.0);
    	if (cy < h) yfactor = (cy * 1.0) / (h * 1.0);
    	float factor = (xfactor < yfactor) ? xfactor: yfactor;
    	if (cx *2 < w || cy < h)
    		ping = pixScale(pngfile, factor * 2.0, factor);
    	else
    	    // scale to double width so the proportion of the font is correct
    		ping = pixScale(pngfile, 2.0, 1.0 );
    }
    pixDestroy(&pngfile);
    //l.logln(format("scaling took %f ms", ti.stop));
    //ti.start();
	Pix* palette = pixOctreeColorQuant(ping, 240, 1);
	//l.logln(format("quant took %f ms", ti.stop));
	if (palette == NULL) { cout << "palette is nul"; return 1; }

	Pix* pix32;

	//ti.start();
    pix32 = pixConvertTo32(palette);
    //l.logln(format("convert took %f ms", ti.stop));

	l->logln(format("pal_number, pal_nalloc, pal_bits: %d, %d, %d" , palette->colormap->n, palette->colormap->nalloc, palette->colormap->depth));

	int iterX = pix32->w;
	int iterY = pix32->h;
	//ti.start();
	/*
	SimpleFileLogger* l2 = new SimpleFileLogger("bmpdata");
	l2->clear();
	char* ptr = (char*)pix32->data;
	string nl = "\"\n\"";
	for (int i=0; i<iterX * iterY * ((int)pix32->d / 8);i++) {
		if(i%32==0) l2->log(nl);
		string fmt = format("\\x%02X", *ptr);
		l2->log(fmt);

		ptr++;
	}
	*/
	//l.logln(format("logging C char took %f ms", ti.stop));
	//l2.log(pix32.data, iterX * iterY * (pix32.d / 8));

	int* bufptr = (int*) pix32->data;
	if (bufptr == NULL) {
		cout << "bufptr is null";
		return 1;
	}

	//ti.start();
	for (int iy=0;iy<iterY;iy++){
		//bufptr = cast(int*) b.scanline().ptr;
		for (int ix=0;ix<iterX;ix++){
			t->setColor(*((RGB*) bufptr), false);
			t->gotoxy(ix, iy);
			t->addchar(' ', 0);
			bufptr++;
			//t.getKey();
			//sleep(500);
		}
	}
	//l.logln(format("traversing colors took %f ms", ti.stop));
	//ti.start();
	//pixWrite("output.bmp", pix32, IFF_BMP);
	//l.logln(format("writing bmp took %f ms", ti.stop));
	pixDestroy(&palette);
	pixDestroy(&pix32);

	/*
	int x; int y;
	auto red = rgb(255, 0, 0);
	auto green = rgb(0,255,0);
	auto blue = rgb(0,0,255);

	assert(t.setColor(red, true), "err");
	assert(t.setColor(blue, false),"err");
	t.printfxy(5, 5, "red on blue", 20);
	assert(t.setColor(green, true), "err");
	assert(t.setColor(red, false),"err");
	t.printfxy(8, 8, "green on red");
	assert(t.setColor(green, false), "err");
	assert(t.setColor(red, true),"err");
	t.printfxy(18, 18, "red on green");
	*/
	//ti.start();
	t->refresh();
	//l.logln(format("display took %f ms", ti.stop));
	t->getKey();

	/*
	t.getSize(x, y);
	t.setColor(0, 200, 100, 0);
	t.setColor(1, 0, 0, 0);
	t.setColor(2, 0, 0, 255);
	t.setColorPair(1, 0, 1);
	t.setColorPair(2, 1, 2);

	t.gotoxy(0, 0);

	// first line
	t.useColorPair(1);
	for (int i = 0 ; i < x; i++) t.addchar(' ', 0);
	t.useColorPair(2);
	for (int j = 1; j < y -1 ; j++) {
		t.useColorPair(1);
		for (int i = 0 ; i < x; i++) t.addchar('\u2588', 0);
	}
	// last line
	t.useColorPair(1);
	for (int i = 0 ; i < x; i++) t.addchar(' ', 0);

	t.useColorPair(2);
	t.printfxy(10,10, "test");
	t.getKey();

	*/
	delete(t);
	delete(l);
	//delete(l2);
	return EXIT_SUCCESS;
}
/******************* WIN32 FUNCTIONS ***************************/
int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance
					HINSTANCE	hPrevInstance,		// Previous Instance
					LPSTR		lpCmdLine,			// Command Line Parameters
					int			nCmdShow)			// Window Show State
{
	MSG		msg;									// Windows Message Structure
	bool	done=false;								// Bool Variable To Exit Loop

	StartGame n = StartGame();
	activityManager.push(&n);
	console.Open();

	// Create Our OpenGL Window
	if (!CreateGLWindow("OpenGL Win32 Example",screenWidth,screenHeight))
	{
		return 0;									// Quit If Window Was Not Created
	}

	Clock clock;
	double timeSinceLastUpdate = 0.0;

	Clock fpsCounterClock;
	double fpsCounterTime = 0.0;
	int fpsCounter = 0;

	clock.start();
	fpsCounterClock.start();

	//*******************************************GAME LOOP***********************************************************//

	while(!done)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
			{
				done=true;							// If So done=TRUE
			}
			else									// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
			}
		}
		else										// If There Are No Messages
		{
			if(keys[VK_ESCAPE])
				done = true;

	
			if (!keys[VK_RETURN]){

				fpsCounterTime += fpsCounterClock.restart();

				timeSinceLastUpdate += clock.restart();	

				while (timeSinceLastUpdate > TIME_PER_FRAME) {
						
						fpsCounter++;
						timeSinceLastUpdate -= TIME_PER_FRAME;
						update(TIME_PER_FRAME);
				}

				
				if (fpsCounterTime > 1){
#ifdef displayFPS
					std::cout<<"\t\t\t\t\tFPS: "<<fpsCounter<<std::endl;
#endif
					fpsCounterTime = 0;
					
					fpsCounter = 0;
				}
				
			}
			display();					// Draw The Scene

			SwapBuffers(hDC);				// Swap Buffers (Double Buffering)
		}
	}



	console.Close();

	// Shutdown
	KillGLWindow();									// Kill The Window
	return (int)(msg.wParam);						// Exit The Program
}
示例#10
0
/******************* WIN32 FUNCTIONS ***************************/
int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance
					HINSTANCE	hPrevInstance,		// Previous Instance
					LPSTR		lpCmdLine,			// Command Line Parameters
					int			nCmdShow)			// Window Show State
{
	console.Open();
	
	MSG		msg;									// Windows Message Structure
	bool	done=false;								// Bool Variable To Exit Loop

	// Create Our OpenGL Window
	if (!CreateGLWindow("OpenGL Win32 Example",screenWidth,screenHeight))
	{
		return 0;									// Quit If Window Was Not Created
	}

	while(!done)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
			{
				done=true;							// If So done=TRUE
			}
			else									// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
			}
		}
		else										// If There Are No Messages
		{
			if(keys[VK_ESCAPE])
				done = true;
			//initialise timer
			LARGE_INTEGER t;
			QueryPerformanceCounter(&t);
			__int64 currentTime = t.QuadPart;

			__int64 ticksElapsed = currentTime - prevTime;					// Ticks elapsed since the previous time step
			double deltaT = double(ticksElapsed) * timerFrequencyRecip;		// Convert to seconds

			if (!initialisedPrevDeltaT) {
				// This is the first time step
				// So we do not have the time elapsed during the previous time step, since there is no previous time step

				// Cheat, and use the current time step time for both
				prevDeltaT = deltaT;

				// We have initialised prevDeltaT; set initialisedPrevDeltaT to true so we don't do this again
				initialisedPrevDeltaT = true;
			}


			// Advance timer
			prevTime = currentTime;					// use the current time as the previous time in the next step
			prevDeltaT = deltaT;

			update(deltaT);

			display();					// Draw The Scene
			SwapBuffers(hDC);				// Swap Buffers (Double Buffering)
		}
	}

	console.Close();

	// Shutdown
	KillGLWindow();									// Kill The Window
	return (int)(msg.wParam);						// Exit The Program
}
示例#11
0
文件: nit-rsh.cpp 项目: noriter/nit
	void onRemoteDisconnect(const RemoteEvent* evt)
	{
		_console->setPrompt("idle> ");
	}
示例#12
0
文件: nit-rsh.cpp 项目: noriter/nit
	void onRemoteConnect(const RemoteEvent* evt)
	{
		_console->setPrompt("attaching> ");
	}
示例#13
0
void MainWindow::spawnProcess()
{
    QStringList args;
    ConsoleWindow* cw = new ConsoleWindow(0, exec_name, ui->addr->text(), ui->port->text(), ui->bw->text(), ui->media_file->text(), ui->followerButton->isChecked());
    cw->show();
}