?? main.cc
字號(hào):
atexit(static_exit);#endif /* * Process display option here before the rest of the options * because it's needed when creating the main application window. */ const char* display = disparg(argc, argv, optstr); // hold pointer to application name for send const char* appname = namearg(argc, argv, optstr); if (!appname) appname = "nam";#ifdef notdef fprintf(stderr, "Application name is %s\n", appname);#endif Tcl_FindExecutable(argv[0]); Tcl_Interp *interp = Tcl_CreateInterp();//#if 0 if (Tcl_Init(interp) == TCL_ERROR) { printf("%s\n", interp->result); abort(); }//#endif#if TCL_MAJOR_VERSION < 8 Tcl_SetVar(interp, "tcl_library", "./lib/tcl7.6", TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "tk_library", "./lib/tk4.2", TCL_GLOBAL_ONLY);#else Tcl_SetVar(interp, "tcl_library", "", TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "tk_library", "", TCL_GLOBAL_ONLY); // this seems just a hack, should NOT have hard-coded library path! // why there's no problem with old TCL/TK? // xuanc, 10/3/2003 //Tcl_SetVar(interp, "tcl_library", "./lib/tcl8.0", TCL_GLOBAL_ONLY); //Tcl_SetVar(interp, "tk_library", "./lib/tk8.0", TCL_GLOBAL_ONLY);#endif if (Otcl_Init(interp) == TCL_ERROR) { printf("%s\n", interp->result); abort(); }#ifdef HAVE_LIBTCLDBG if (Tcldbg_Init(interp) == TCL_ERROR) { return TCL_ERROR; }#endif Tcl::init(interp, appname); Tcl& tcl = Tcl::instance(); tcl.evalf(display? "set argv \"-name %s -display %s\"" : "set argv \"-name %s\"", appname, display, appname); Tk_Window tk = 0;//#ifdef WIN32// Tcl_SetVar(interp, "tcl_library", ".", TCL_GLOBAL_ONLY);// Tcl_SetVar(interp, "tk_library", ".", TCL_GLOBAL_ONLY);//#endif if (Tk_Init(tcl.interp()) == TCL_OK) tk = Tk_MainWindow(tcl.interp()); if (tk == 0) { fprintf(stderr, "nam: %s\n", interp->result); exit(1); } tcl.tkmain(tk); extern EmbeddedTcl et_tk, et_nam; et_tk.load(); et_nam.load(); int op; int cacheSize = 100; char* graphInput = new char[256]; char* graphInterval = new char[256]; char* buf = new char[256]; char* args = new char[256]; graphInput[0] = graphInterval[0] = buf[0] = args[0] = 0; while ((op = getopt(argc, (char**)argv, (char*)optstr)) != -1) { switch (op) { default: usage(); case 'd': case 'N': /* already handled before */ break;/*XXX move to Tcl */#ifdef notyet case 'M': tcl.add_option("movie", optarg); break; case 'p': tcl.add_option("pause", "1"); break; case 'G': tcl.add_option("granularity", optarg); break; case 'X': { const char* value = parse_assignment(optarg); tcl.add_option(optarg, value); } break; case 'P': /* Peer name, obsoleted */ sprintf(buf, "p %s ", optarg); strcat(args, buf); break; case 't': /* Use tkgraph. Must supply tkgraph input filename. */ sprintf(graphInput, "g %s ", optarg); strcat(args, graphInput); break;#endif case 'a': /* * Create a whole new instance. */ strcat(args, "a 1 "); break; case 'c': cacheSize = atoi(optarg); break; case 'f': case 'u': script = optarg; /* Also pass it to OTcl */ sprintf(buf, "f %s ", optarg); strcat(args, buf); break; case 'g': process_geometry(tk, optarg); break; case 'i': /* * Interval value for graph updates: default is * set by nam_init. */ sprintf(graphInterval, "i %s ", optarg); strcat(args, graphInterval); break; case 'j': /* Initial startup time */ sprintf(buf, "j %s ", optarg); strcat(args, buf); break; case 'k': /* Initial socket port number */ sprintf(buf, "k %s ", optarg); strcat(args, buf); break; case 'm': /* Multiple traces */ /* no longer needed, but option is still allowed */ /* for compatibility reasons */ break; case 'r': /* Initial animation rate */ sprintf(buf, "r %s ", optarg); strcat(args, buf); break; case 's': /* synchronize all windows together */ strcat(args, "s 1 "); break; case 'z': /* set nam validation test on */ strcat(args, "z 1 "); break;#ifndef WIN32 case 'S': XSynchronize(Tk_Display(tk), True); break;#endif case 'x': pt.printLatex(stdout); exit(0); break; case 'p': pt.print(stdout); exit(0); break; } } if (strlen(graphInterval) && !strlen(graphInput)) { fprintf(stderr, "nam: missing graph input file\n"); exit(1); } loadbitmaps(interp); char* tracename = NULL; /* trace file */ /* * Linux libc-5.3.12 has a bug where if no arguments are processed * optind stays at zero. Work around that problem here. * The work-around seems harmless in other OSes so it's not ifdef'ed. */ if ((optind == -1) || (optind == 0)) optind = 1; /* * Make sure the base name of the trace file * was specified. */ // if (argc - optind < 1) // usage(); tracename = argv[optind];//XXX need to port this#ifndef WIN32 if ((tracename != NULL) ) { if (access(tracename, R_OK) < 0) { tracename = new char[strlen(argv[optind]) + 4]; sprintf(tracename, "%s.nam", argv[optind]); } }#endif tcl.CreateCommand("adios", cmd_adios); tcl.CreateCommand("version", cmd_version);#ifdef WIN32 platformInit(interp);#endif // XXX inappropriate to do initialization in this way? FILE *fp = fopen(".nam.tcl", "r"); if (fp != NULL) { fclose(fp); tcl.EvalFile(".nam.tcl"); } // User-supplied configuration files // option '-u' and '-f' are merged together // Evaluation is moved into OTcl// if (script != NULL) {// fp = fopen(script, "r");// if (fp != NULL) {// fclose(fp);// tcl.EvalFile(script);// } else {// fprintf(stderr, "No configuration file %s\n",// script);// }// } Paint::init(); State::init(cacheSize); // -- Start TclDebugger //Tcldbg_Init(interp); tcl.eval("set nam_local_display 0"); if (tracename != NULL) { while (tracename) { // Any backslash characters in the filename must be // escaped before being passed to Tcl. char * new_tracename = (char*)malloc(2 * strlen(tracename) + 1); char * temp_tracename = new_tracename; while (*tracename) { if (*tracename == '\\') *(temp_tracename++) = '\\'; *(temp_tracename++) = *tracename; ++tracename; } *temp_tracename = 0; tracename= new_tracename; // Jump to nam-lib.tcl tcl.evalf("nam_init %s %s", tracename, args); tracename = argv[++optind]; } } else { // Jump to nam-lib.tcl tcl.evalf("nam_init \"\" %s", args); } tcl.eval("set nam_local_display"); if (strcmp(tcl.result(),"1") == 0) { Tk_MainLoop(); } return (0);}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -