📄 unravel.c
字号:
}strech (goal,w) Widget goal,w;{ Dimension width,bw; Position x; int dist; XtUnmanageChild(w); XtVaGetValues (goal, XtNdefaultDistance, &dist, XtNwidth,&width,NULL); XtVaGetValues (w, XtNborderWidth,&bw, XtNx,&x, NULL); XtVaSetValues (w, XtNwidth, (XtArgVal) (width-2*bw - dist - x), NULL); XtManageChild(w);}make_windows(top) Widget top;{ Widget analysis,review,slice,help,quit; Widget info,dir,dir_label; Widget src,ana,not,out,prog,dup; Widget frame,link; Widget review_menu,review_ana,review_slice, review_all,review_this; static label_rec labels; static char dir_buff[2000] = ""; char buff[2000]; labels.top = top; labels.dir_buff = dir_buff; frame = XtVaCreateManagedWidget ("frame",formWidgetClass, top,NULL); quit = XtVaCreateManagedWidget ("quit",commandWidgetClass, frame, /* XtNlabel, "Exit Unravel", */ XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, NULL); XtAddCallback(quit,XtNcallback,done,NULL); analysis = XtVaCreateManagedWidget ("analysis",commandWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNfromHoriz, quit, NULL); XtAddCallback(analysis,XtNcallback,push_analysis,&labels); review_menu = XtVaCreatePopupShell ("reviewMenu", simpleMenuWidgetClass,top,NULL); review = XtVaCreateManagedWidget ("review", menuButtonWidgetClass,frame, XtNlabel, "Review History", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNfromHoriz, analysis, XtNmenuName, (XtArgVal) "reviewMenu", NULL); review_ana = XtVaCreateManagedWidget ("reviewAnalysis", smeBSBObjectClass,review_menu, XtNlabel, (XtArgVal) "Last Analysis", NULL); review_slice = XtVaCreateManagedWidget ("reviewSlice", smeBSBObjectClass,review_menu, XtNlabel, (XtArgVal) "Last Slice", NULL); review_this = XtVaCreateManagedWidget ("review", smeBSBObjectClass,review_menu, XtNlabel, (XtArgVal) "This Session", NULL); review_all = XtVaCreateManagedWidget ("reviewAll", smeBSBObjectClass,review_menu, XtNlabel, (XtArgVal) "All History", NULL); XtAddCallback(review_ana,XtNcallback,push_review,0); XtAddCallback(review_slice,XtNcallback,push_review,1); XtAddCallback(review_this,XtNcallback,push_review,2); XtAddCallback(review_all,XtNcallback,push_review,3); slice = XtVaCreateManagedWidget ("slice",commandWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNfromHoriz, review, NULL); XtAddCallback(slice,XtNcallback,push_slice,NULL); help = XtVaCreateManagedWidget ("help",commandWidgetClass, frame, XtNlabel, "Help", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainRight, XtNright, XawChainRight, XtNfromHoriz, slice, NULL); XtAddCallback(help,XtNcallback,push_help,NULL); strcpy (buff,"Current directory: "); strcat (buff,getcwd(NULL,1000)); dir = XtVaCreateManagedWidget ("dir",labelWidgetClass, frame, XtNlabel, buff, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, quit, XtNjustify, XtJustifyLeft, NULL); /* dir_label = XtVaCreateManagedWidget ("dirLabel", commandWidgetClass, frame, XtNlabel, buff, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNfromVert, quit, XtNjustify, XtJustifyLeft, NULL); XtAddCallback(dir_label,XtNcallback,push_dir,&labels); strcpy (dir_buff,getcwd(NULL,1000)); dir = XtVaCreateManagedWidget ("dir", asciiTextWidgetClass, frame, XtNfromHoriz, (XtArgVal) dir_label, XtNfromVert, (XtArgVal) quit, XtNleft, (XtArgVal) XawChainLeft, XtNright, (XtArgVal) XawChainRight, XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNborderWidth, (XtArgVal) 0, XtNautoFill, (XtArgVal) False, XtNdisplayNonprinting, (XtArgVal) True, XtNeditType, (XtArgVal) XawtextEdit, XtNlength, (XtArgVal) 1000, XtNstring, (XtArgVal) dir_buff, XtNuseStringInPlace,(XtArgVal) True, NULL); XawTextSetInsertionPoint (dir,strlen(dir_buff)); */ labels.text = dir; src = XtVaCreateManagedWidget ("src",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, dir, XtNjustify, XtJustifyLeft, NULL); ana = XtVaCreateManagedWidget ("ana",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, src, XtNjustify, XtJustifyLeft, NULL); not = XtVaCreateManagedWidget ("not",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, ana, XtNjustify, XtJustifyLeft, NULL); out = XtVaCreateManagedWidget ("out",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, not, XtNjustify, XtJustifyLeft, NULL); prog = XtVaCreateManagedWidget ("prog",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, out, XtNjustify, XtJustifyLeft, NULL); link = XtVaCreateManagedWidget ("link",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, prog, XtNjustify, XtJustifyLeft, NULL); dup = XtVaCreateManagedWidget ("dup",labelWidgetClass, frame, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, link, XtNjustify, XtJustifyLeft, NULL); info = XtVaCreateManagedWidget ("info",labelWidgetClass, frame, XtNlabel, "Description of object under mouse pointer is displayed here", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, dup, XtNjustify, XtJustifyLeft, NULL); labels.src = src; labels.ana = ana; labels.not = not; labels.out = out; labels.prog = prog; labels.dup = dup; labels.link = link; update_src_info(&labels); XtRealizeWidget(top); strech (frame,ana); strech (frame,dir); strech (frame,info); strech (frame,not); strech (frame,out); strech (frame,prog); strech (frame,link); strech (frame,dup); strech (frame,src); help_label = info; set_button_help (quit,"Click to exit when finished"); set_button_help (help, "Click to pop up a window describing unravel"); set_button_help (ana, "Display how many source files have been analyzed"); set_button_help (not, "Display how many source files have not been analyzed"); set_button_help (out, "Display how many source files have been modified since being analyzed"); set_button_help (slice,"Click to setup and run the program slicer"); set_button_help (review,"Click to pop up menu of history displays"); set_button_help (analysis,"Click to setup and run the analyzer"); set_button_help (link, "Display # of main programs linked"); set_button_help (prog, "Display # of files analyzed \ containing a main procedure"); set_button_help (dup,"Display how many procedures are unresolved"); set_button_help (src, "Display how many source files are in the directory"); set_button_help (dir, "Display the current directory name"); /* set_button_help (dir, "Display the current directory name or edit new name"); set_button_help (dir_label,"Click to change directory"); */ set_button_help (frame," . . ."); XtInstallAccelerators (frame,quit); XtInstallAccelerators (frame,help); /* XtInstallAccelerators (dir,dir_label); */}char *fall[] = { /* don't move the first entry (iconPixmap) */ "*iconPixmap: unravel.icon", "*font: lucidasans-bold-14", "*background: seashell3", "*foreground: blue", "*shapeStyle: oval", "*Label*borderWidth: 0", "*Command*borderWidth: 2", "*MenuButton*borderWidth: 2", "*info*borderWidth: 3", "*quit.label: Exit Unravel", "*analysis.label: Run Analyzer", "*slice.label: Run Slicer", "*title: Unravel Version 2.2+ Main Control Panel", "*geometry: +10+10", "*quit.accelerators: #override\\n \ <KeyPress>q: set() highlight() notify()", "*help.accelerators: \ <KeyPress>h: set() highlight() notify() unset()\\n\ <KeyPress>?: set() highlight() notify() unset()", /* "*dirLabel.accelerators: #override\\n\ <KeyPress>Return: set() highlight() notify() unset()\\n\ <LeaveNotify>: set() highlight() notify() unset()", */ NULL};/*# define XtNrunningFG "runningFG"# define XtNrunningBG "runningBG" static XrmOptionDescRec opt[] = { {"-runningfg", "*runningFG", XrmoptionSepArg,NULL}, {"-runningbg", "*runningBG", XrmoptionSepArg,NULL}}; static XtResource res[] = { {XtNrunningFG,XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(struct app_resources,fg),XtRString,"red"}, {XtNrunningBG,XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(struct app_resources,bg),XtRString,"yellow"}}; top = XtAppInitialize (&ac,"Xtform",opt,XtNumber(opt),&np,p,fall,NULL,0); XtGetApplicationResources (top,&a_res,res,XtNumber(res),NULL,0); */ static XtResource res[] = { {XtNlinkOnly,XtCValue, XtRInt, sizeof(int), 0,XtRString,"0"}}; static XrmOptionDescRec opt[] = { {"-noslice", "*linkOnly", XrmoptionNoArg,"1"}};main (np,p) int np; char *p[];{ XtAppContext ac; Widget top; char **file_names; struct dirent **files; int n_files,i,n_analyzed,n_prog; int n_not,n_out; char icon_at[2000],cmd[2000]; int sys_ok; sprintf (icon_at,"*iconPixmap: %s/unravel.icon",HOME); fall[0] = icon_at; top = XtAppInitialize (&ac,"Unravel",opt,XtNumber(opt),&np,p, fall,NULL,0); XtGetApplicationResources (top,&link_only,res,XtNumber(res),NULL,0); if (np == 2){ /* printf ("changing to %s\n",p[1]); */ errno = 0; i = chdir (p[1]); /* printf ("chdir returned %d %d\n",i,errno); */ if (i != 0){ fprintf (stderr,"%s could not change directory to %s\n", p[0],p[1]); perror(""); exit(1); } } sys_ok = system ("echo \" \" >HISTORY"); if (sys_ok != 0){ fprintf (stderr,"%s could not write in file directory\n", p[0]); fprintf (stderr,"continue? [y|n] "); scanf ("%c",cmd); if (cmd[0] != 'y') exit(1); } sprintf (cmd,"echo -n UNRAVEL \" %s \" >> HISTORY ; date >>HISTORY", getcwd (NULL,2000)); system(cmd); system ("echo \"No slices computed this session\" >HISTORY-S"); system ("echo \"No analysis done this session\" >HISTORY-A"); make_windows(top); XtAppMainLoop(ac);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -