コード例 #1
0
ファイル: winsetup.cpp プロジェクト: Thyfate/melax
void PrintStats(){
	String s;
	if(entertext) {
		s << "> " << comstring;
		PostString(s,0,0,5);
	}
}
コード例 #2
0
ファイル: winsetup.cpp プロジェクト: Thyfate/melax
void doconsole(char c) {
	if(c==27){  // ESC escape key
		entertext=0;
		comstring[0]='\0';
		PostString("------",0,0,0.25);
		return;
	}
	if(c=='\n' || c== '\r') {
		entertext=0;
		char buf[1024];
		sprintf(buf,"* %s",comstring);
		PostString(buf,0,0,5);
		String rv=FuncInterp(comstring);
		PostString(rv,0,1,5);
		return;
	}
	if(c=='\b') {
		if(strlen(comstring)) {
			comstring[strlen(comstring)-1]='\0';
		}
		return;
	}
	if(c=='\t') {
		Array<String> match;
		char *rv=CommandCompletion(comstring,match);
		strcpy(comstring,rv);
		String pre=FuncPreInterp(comstring);
		PostString(pre,0,1,1);
		if(match.count>1) {
			static int offset=0;
			float hold=(match.count>15) ?4.0f: 1.0f;
			if(match.count < 15) {
				offset=0;
			}
			for(int i=0;i<match.count && i<15;i++){
				PostString(match[(i+offset)%match.count],4,6+i,hold);
			}
			offset+=5;
		}
		return;
	}
	int len=min(500,strlen(comstring));
	comstring[len]=c;
	comstring[len+1]='\0';
}
コード例 #3
0
ファイル: MessageQueue.cpp プロジェクト: mec0825/VRLib
void MessageQueue::PostPrintf( const char * fmt, ... )
{
	char bigBuffer[4096];
	va_list	args;
	va_start( args, fmt );
	vsnprintf( bigBuffer, sizeof( bigBuffer ), fmt, args );
	va_end( args );
	PostString( bigBuffer );
}
コード例 #4
0
ファイル: font.cpp プロジェクト: Thyfate/melax
void PostTraceStrings(){
	int k=0;
	int i;
	i=TraceStrings.count;
	while(i--) {
		char s[2048];
		sprintf_s<2048>(s,"%s: ",(const char *)TraceStrings[i]->command);
		String r = FuncInterp(TraceStrings[i]->command);
		if(!r[0] || r==" () " )
		{
			if(i)
			{
				Swap(TraceStrings[i],TraceStrings[i-1]);
			}
			continue;
		}
		strcat_s<2048>(s,r);
		assert(strlen(s)<2000);
		k++;
		PostString(s,0,-k,0);
	}
}
コード例 #5
0
int
main (int argc, char *argv[])
{
    char    psBuffer[BUFFER_SIZE];
    char    psGnuplotCommandLine[MAX_PATH] = PROGNAME;
    LPTSTR  psCmdLine;
    BOOL    bSuccess;
    BOOL    bPersist = FALSE;
    int	i;

#if !defined(_O_BINARY) && defined(O_BINARY)
# define _O_BINARY O_BINARY
# define _setmode setmode /* this is for BC4.5 ... */
#endif
    _setmode(fileno(stdout), _O_BINARY);

    for (i = 1; i < argc; i++) {
	if (!argv[i])
	    continue;
	if (!strcmp(argv[i], "-V") || !strcmp(argv[i], "--version")) {
	    printf("gnuplot %s patchlevel %s\n",
		   gnuplot_version, gnuplot_patchlevel);
	    return 0;
	} else if ((!stricmp(argv[i], "-noend")) || (!stricmp(argv[i], "/noend")) || 
		   (!stricmp(argv[i], "-persist"))) {
	    bPersist = TRUE;
	} else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
	    printf("Usage: gnuplot [OPTION] [FILE] [-]\n"
		    "  -V, --version   show gnuplot version\n"
		    "  -h, --help      show this help\n"
		    "  -persist        don't close the plot after executing FILE\n"
		    "  -noend, /noend  like -persist (non-portable Windows-only options)\n"
		    "  -               allow work in interactive mode after executing FILE\n"
		    "Only on Windows, -persist and - have the same effect.\n"
		    "This is gnuplot %s patchlevel %s\n"
		    "Report bugs to <*****@*****.**>\n",
		    gnuplot_version, gnuplot_patchlevel);
	    return 0;
	}
    } /* for(argc) */

    /* CRS: create the new command line, passing all of the command
     * line options to wgnuplot so that it can process them:
     * first, get the command line,
     * then move past the name of the program (e.g., 'pgnuplot'),
     * finally, add what's left of the line onto the gnuplot command line. */
    psCmdLine = GetCommandLine();

#ifdef SHOWCMDLINE
    fprintf(stderr,"CmdLine: %s\n", psCmdLine);
    fprintf(stderr,"argv[0]: %s\n",argv[0]);
#endif

    /* CRS 30061999: Search for the first unquoted space. This should
       separate the program name from the arguments. */
    psCmdLine = FindUnquotedSpace(psCmdLine);

    strncat(psGnuplotCommandLine, psCmdLine, MAX_PATH - strlen(psGnuplotCommandLine));

#ifdef SHOWCMDLINE
    fprintf(stderr,"Arguments: %s\n", psCmdLine);
    fprintf(stderr,"GnuplotCommandLine: %s\n",psGnuplotCommandLine);
#endif

    /* CRS: if stdin isn't redirected then just launch wgnuplot normally
     * and exit. */
    if (isatty(fileno(stdin))) {
	if (WinExec(psGnuplotCommandLine, SW_SHOWDEFAULT) > 31) {
	    exit(EXIT_SUCCESS);
	}
	fprintf(stderr,"ERROR %u: Couldn't execute: \"%s\"\n",
		GetLastError(), psGnuplotCommandLine);
	exit(EXIT_FAILURE);
    }

    /* CRS: initialize the STARTUPINFO and call CreateProcess(). */
    siStartInfo.cb = sizeof(STARTUPINFO);
    siStartInfo.lpReserved = NULL;
    siStartInfo.lpReserved2 = NULL;
    siStartInfo.cbReserved2 = 0;
    siStartInfo.lpDesktop = NULL;
    siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
    siStartInfo.wShowWindow = SW_SHOWMINIMIZED;

    bSuccess = CreateProcess(
			     NULL,                   /* pointer to name of executable module   */
			     psGnuplotCommandLine,   /* pointer to command line string         */
			     NULL,                   /* pointer to process security attributes */
			     NULL,                   /* pointer to thread security attributes  */
			     FALSE,                  /* handle inheritance flag                */
			     0,                      /* creation flags                         */
			     NULL,                   /* pointer to new environment block       */
			     NULL,                   /* pointer to current directory name      */
			     &siStartInfo,           /* pointer to STARTUPINFO                 */
			     &piProcInfo             /* pointer to PROCESS_INFORMATION         */
			     );

    /* if CreateProcess() failed, print a warning and exit. */
    if (! bSuccess) {
	fprintf(stderr,"ERROR %u: Couldn't execute: \"%s\"\n",
		GetLastError(), psGnuplotCommandLine);
	exit(EXIT_FAILURE);
    }

    /* CRS: give gnuplot enough time to start (1 sec.) */
    if (WaitForInputIdle(piProcInfo.hProcess, 1000)) {
	fprintf(stderr, "Timeout: gnuplot is not ready\n");
	exit(EXIT_FAILURE);
    }

    /* CRS: get the HWND of the parent window and text windows */
    EnumThreadWindows(piProcInfo.dwThreadId, cbGetTextWindow, 0);

    /* CRS: free the process and thread handles */
    CloseHandle(piProcInfo.hProcess);
    CloseHandle(piProcInfo.hThread);

    if (! hwndParent || ! hwndText) {
	/* Still no gnuplot window? Problem! */
	fprintf(stderr, "Can't find the gnuplot window");
	exit(EXIT_FAILURE);
    }

    /* wait for commands on stdin, and pass them on to the wgnuplot text
     * window */
    while (fgets(psBuffer, BUFFER_SIZE, stdin) != NULL) {
	PostString(hwndText, psBuffer);
    }

    /* exit gracefully, unless -persist is requested */
    if (!bPersist) {
	/* CRS: Add a test to see if gnuplot is still running? */
	PostString(hwndText, "\nexit\n");
    }

    return EXIT_SUCCESS;
}
コード例 #6
0
void PrintStats(){
	char buf[1024];buf[0]='\0';
	sprintf(buf,"FPS: %5.2f   ",FPS);
	PostString(buf,0,-1,0);
}
コード例 #7
0
int main (int argc, char *argv[])
{
	char    psBuffer[BUFFER_SIZE];
	char    psGnuplotCommandLine[MAX_PATH] = PROGNAME;
	LPTSTR  psCmdLine;
	BOOL    bSuccess;
	
	/* HBB 19990325, to allow pgnuplot < script > output.gif */
	_setmode(fileno(stdout), _O_BINARY);

	/* CRS: create the new command line, passing all of the command
	 * line options to wgnuplot so that it can process them:
	 * first, get the command line,
	 * then move past the name of the program (e.g., 'pgnuplot'),
	 * finally, add what's left of the line onto the gnuplot command line. */
	psCmdLine = GetCommandLine();

#ifdef SHOWCMDLINE
	fprintf(stderr,"CmdLine: %s\n", psCmdLine);
	fprintf(stderr,"argv[0]: %s\n",argv[0]);
#endif

	/* CRS 30061999: Search for the first unquoted space. This should 
	   separate the program name from the arguments. */
	psCmdLine = FindUnquotedSpace( psCmdLine );

	strncat(psGnuplotCommandLine, psCmdLine, MAX_PATH - strlen(psGnuplotCommandLine));

#ifdef SHOWCMDLINE
	fprintf(stderr,"Arguments: %s\n", psCmdLine);
	fprintf(stderr,"GnuplotCommandLine: %s\n",psGnuplotCommandLine);
#endif

	/* CRS: if stdin isn't redirected then just launch wgnuplot normally
	 * and exit. */
	if ( isatty(fileno(stdin)) ) {
		if ( WinExec(psGnuplotCommandLine, SW_SHOWDEFAULT) > 31 ){
			exit(EXIT_SUCCESS);
		}
		fprintf(stderr,"ERROR %u: Couldn't execute: \"%s\"\n", 
			    GetLastError(), psGnuplotCommandLine);
		exit(EXIT_FAILURE);
	}

	/* CRS: initialize the STARTUPINFO and call CreateProcess(). */ 
	siStartInfo.cb = sizeof(STARTUPINFO); 
	siStartInfo.lpReserved = NULL; 
	siStartInfo.lpReserved2 = NULL; 
	siStartInfo.cbReserved2 = 0; 
	siStartInfo.lpDesktop = NULL; 
	siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
	siStartInfo.wShowWindow = SW_SHOWMINIMIZED;

	bSuccess = CreateProcess( 
			NULL,                   /* pointer to name of executable module   */
			psGnuplotCommandLine,   /* pointer to command line string         */
			NULL,                   /* pointer to process security attributes */
			NULL,                   /* pointer to thread security attributes  */
			FALSE,                  /* handle inheritance flag                */
			0,                      /* creation flags                         */
			NULL,                   /* pointer to new environment block       */
			NULL,                   /* pointer to current directory name      */
			&siStartInfo,           /* pointer to STARTUPINFO                 */
			&piProcInfo             /* pointer to PROCESS_INFORMATION         */
			);

	/* if CreateProcess() failed, print a warning and exit. */
	if ( ! bSuccess ) {
		fprintf(stderr,"ERROR %u: Couldn't execute: \"%s\"\n", 
						GetLastError(), psGnuplotCommandLine);
		exit(EXIT_FAILURE);
	}

	/* CRS: give gnuplot enough time to start (1 sec.) */
	if ( WaitForInputIdle(piProcInfo.hProcess, 1000) ) {
		fprintf(stderr, "Timeout: gnuplot is not ready\n");
		exit(EXIT_FAILURE);
	}

	/* CRS: get the HWND of the parent window and text windows */
	EnumThreadWindows(piProcInfo.dwThreadId, cbGetTextWindow, 0);

	/* CRS: free the process and thread handles */
	CloseHandle(piProcInfo.hProcess);
	CloseHandle(piProcInfo.hThread);

	if ( ! hwndParent || ! hwndText ) {
	/* Still no gnuplot window? Problem! */
		fprintf(stderr, "Can't find the gnuplot window");
		exit(EXIT_FAILURE);
	}

	/* wait for commands on stdin, and pass them on to the wgnuplot text
	 * window */
	while ( fgets(psBuffer, BUFFER_SIZE, stdin) != NULL ) {
		PostString(hwndText, psBuffer);
	}
	
	/* exit gracefully */
	/* CRS: Add a test to see if gnuplot is still running? */
	PostString(hwndText, "\nexit\n");

	return EXIT_SUCCESS;
}