📄 analyzer.c
字号:
(status_c.st_mtime > status_lif.st_mtime)) names->use[n_use++] = src; else names->skip[n_skip++] = src; } else names->use[n_use++] = src; else names->skip[n_skip++] = src; } names->skip[n_skip] = NULL; names->use[n_use] = NULL; XawListChange(names->keep,names->use,0,0,True); XawListChange(names->ignore,names->skip,0,0,True);}select_analyzed (w,names,w_data) Widget w; name_ptr names; XtPointer w_data;{ char **hold; analyze_skipped (w,names,NULL); hold = names->skip; names->skip = names->use; names->use = hold; XawListChange(names->keep,names->use,0,0,True); XawListChange(names->ignore,names->skip,0,0,True);}analyze_most (w,names,list) Widget w; name_ptr names; XtPointer list;{ int i; for (i = 0; names->files[i] ; i++){ names->use[i] = names->files[i]->d_name; } names->use[i] = NULL; names->skip[0] = NULL; XawListChange(names->keep,names->use,0,0,True); XawListChange(names->ignore,names->skip,0,0,True);}analyze_some (w,names,list) Widget w; name_ptr names; XtPointer list;{ int i; for (i = 0; names->files[i] ; i++){ names->skip[i] = names->files[i]->d_name; } names->skip[i] = NULL; names->use[0] = NULL; XawListChange(names->keep,names->use,0,0,True); XawListChange(names->ignore,names->skip,0,0,True);}ilist (w,names,list) Widget w; name_ptr names; XawListReturnStruct *list;{ int k; XawListUnhighlight(w); move_list (list->list_index,names->skip,names->use); XawListChange(names->keep,names->use,0,0,True); XawListChange(names->ignore,names->skip,0,0,True);}adjust_lists (frame,left,right) Widget frame,right,left;{ Dimension frame_w,w,left_bw,right_bw,left_w,right_w; int dist,default_dist; XtUnmanageChild (left); XtUnmanageChild (right); XtVaGetValues (frame, XtNdefaultDistance,&default_dist, XtNwidth,&frame_w, NULL); XtVaGetValues (left, XtNwidth,&left_w, XtNborderWidth,&left_bw, NULL); XtVaGetValues (right, XtNwidth,&right_w, XtNborderWidth,&right_bw, NULL); w = frame_w - 2*(left_bw + right_bw + default_dist) - default_dist; w = w/2; XtVaSetValues (right, XtNwidth, (XtArgVal) (w), NULL); XtVaSetValues (left, XtNwidth, (XtArgVal) (w), NULL); XtManageChild (left); XtManageChild (right);}rj_button (goal,left,w) Widget goal,w,left;{ Dimension bw,goal_w,button_w,left_w,left_bw; int dd,hd; Position x,left_x; XtUnmanageChild(w); XtVaGetValues (goal, XtNdefaultDistance,&dd, XtNwidth,&goal_w, NULL); XtVaGetValues (left, XtNborderWidth,&left_bw, XtNwidth,&left_w, XtNx,&left_x, NULL); XtVaGetValues (w, XtNborderWidth,&bw, XtNwidth,&button_w, XtNx,&x, NULL); hd = goal_w - (2*bw + left_x + left_w + 2*left_bw + dd + button_w); if (hd < 0) hd = dd; XtVaSetValues (w, XtNhorizDistance, (XtArgVal) (hd), NULL); XtManageChild(w);}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);}align(label1,text1,label2,text2) Widget label1,text1,label2,text2;{ Dimension w1,w2,bw1,bw2; int dd,d; Widget w,frame; frame = XtParent (label1); XtVaGetValues (frame, XtNdefaultDistance, &dd, NULL); XtVaGetValues (label1, XtNwidth, &w1, NULL); XtVaGetValues (label2, XtNwidth, &w2, NULL); if (w1 == w2) return; if (w1 > w2){ w = text2; d = dd + (w1 - w2); } else { w = text1; d = dd + (w2 - w1); } XtVaSetValues (w, XtNhorizDistance, d, NULL); XtUnmanageChild (w); XtManageChild (w); }Widget make_list_box (parent,prefix,title) char *prefix,*title; Widget parent;{ Widget frame,label,port,list; char name[2000]; strcpy (name,prefix); frame = XtVaCreateManagedWidget (strcat(name,"Frame"), formWidgetClass, parent, XtNborderWidth, 2, NULL); strcpy (name,prefix); label = XtVaCreateManagedWidget (strcat(name,"Label"), labelWidgetClass, frame, XtNlabel, title, XtNjustify, XtJustifyCenter, XtNborderWidth, 0, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, NULL); strech (frame,label); strcpy (name,prefix); port = XtVaCreateManagedWidget (strcat(name,"Port"), viewportWidgetClass, frame, XtNfromVert, label, XtNtop, XawChainTop, XtNbottom, XawChainBottom, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNforceBars, True, XtNallowVert, True, XtNheight, 200, NULL); strcpy (name,prefix); list = XtVaCreateManagedWidget (strcat(name,"List"), listWidgetClass, port, XtNdefaultColumns, 1, XtNforceColumns,True, NULL); return frame;}make_windows(top,ac) Widget top; XtAppContext ac;{ Widget help,quit; Widget selected,not_selected; Widget info,status; Widget frame,cpp_text,cpp_label; Widget clear,select_ana; Widget parse_text,parse_label; Widget op_menu,opt_menu,op_button,opt_button; Widget scan_all,select_all; Widget select_none,select_not,run_selected; static char cpp_buff[2000] = "",buff[2000]; static char parser_flags[2000] = ""; Dimension W,H; static struct dirent **files; static char *file_names[3000], *pick_names[3000], *skip_names[3000] = {NULL}; static name_rec names; static nf_rec nf; int i,n_files; static XtResource res[] = { {XtNrunningFG,XtCBackground, XtRPixel, sizeof(Pixel), XtOffsetOf(nf_rec,run_fg),XtRString,"red"}, {XtNrunningBG,XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(nf_rec,run_bg),XtRString,"yellow"}}; XtGetApplicationResources (top,&nf,res,XtNumber(res),NULL,0); frame = XtVaCreateManagedWidget ("frame",formWidgetClass, top,NULL); quit = XtVaCreateManagedWidget ("quit",commandWidgetClass, frame, XtNlabel, "Exit Analyzer", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, NULL); XtAddCallback(quit,XtNcallback,done,NULL); opt_menu = XtVaCreatePopupShell ("optMenu", simpleMenuWidgetClass,top,NULL); opt_button = XtVaCreateManagedWidget ("selections", menuButtonWidgetClass,frame, XtNlabel, (XtArgVal) "File Selection", XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNborderWidth, (XtArgVal) 2, XtNmenuName, (XtArgVal) "optMenu", XtNfromHoriz, (XtArgVal) quit, XtNright, (XtArgVal) XawChainLeft, XtNleft, (XtArgVal) XawChainLeft, NULL); /* Widget select_none,select_not,run_selected; */ select_all = XtVaCreateManagedWidget ("selectAll", smeBSBObjectClass,opt_menu, XtNlabel, (XtArgVal) "Select All Files", NULL); select_not = XtVaCreateManagedWidget ("selectNot", smeBSBObjectClass,opt_menu, XtNlabel, (XtArgVal) "Select Files Not Analyzed", NULL); select_none = XtVaCreateManagedWidget ("selectNone", smeBSBObjectClass,opt_menu, XtNlabel, (XtArgVal) "Select No Files", NULL); select_ana = XtVaCreateManagedWidget ("selectAnalyzed", smeBSBObjectClass,opt_menu, XtNlabel, (XtArgVal) "Select Analyzed Files", NULL); XtAddCallback (select_all,XtNcallback,analyze_most,&names); XtAddCallback (select_none,XtNcallback,analyze_some,&names); XtAddCallback (select_not,XtNcallback,analyze_skipped,&names); XtAddCallback (select_ana,XtNcallback,select_analyzed,&names); /* op_menu = XtVaCreateManagedWidget ("opMenu", simpleMenuWidgetClass,top,NULL); op_button = XtVaCreateManagedWidget ("Operations", menuButtonWidgetClass,frame, XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNborderWidth, (XtArgVal) 2, XtNmenuName, (XtArgVal) "opMenu", XtNfromHoriz, (XtArgVal) opt_button, XtNright, (XtArgVal) XawChainLeft, XtNleft, (XtArgVal) XawChainLeft, NULL); scan_all = XtVaCreateManagedWidget ("scanAll", smeBSBObjectClass,op_menu, XtNlabel, (XtArgVal) "Analyze All Files", NULL); run_selected = XtVaCreateManagedWidget ("scanAll", smeBSBObjectClass,op_menu, XtNlabel, (XtArgVal) "Analyze Selected Files", NULL); */ op_button = XtVaCreateManagedWidget ("operations", commandWidgetClass,frame, XtNlabel, (XtArgVal) "Analyze Selected Files", XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNborderWidth, (XtArgVal) 2, XtNfromHoriz, (XtArgVal) opt_button, XtNright, (XtArgVal) XawChainLeft, XtNleft, (XtArgVal) XawChainLeft, NULL); nf.ac = ac; nf.n = &names; nf.running = 0; XtAddCallback (op_button,XtNcallback,run_a,&nf); clear = XtVaCreateManagedWidget ("clear",commandWidgetClass, frame, XtNlabel, "Clear", XtNright, (XtArgVal) XawChainLeft, XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNleft, (XtArgVal) XawChainLeft, XtNfromHoriz, op_button, NULL); XtAddCallback (clear,XtNcallback,clear_files,&names); help = XtVaCreateManagedWidget ("help",commandWidgetClass, frame, XtNlabel, "Help", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainRight, XtNright, XawChainRight, XtNfromHoriz, clear, NULL); XtAddCallback(help,XtNcallback,push_help,NULL); status = XtVaCreateManagedWidget ("status",labelWidgetClass, frame, XtNlabel, "Status: waiting for selection", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, quit, XtNjustify, XtJustifyLeft, NULL); nf.s = status; nf.flags = cpp_buff; nf.pflags = parser_flags; cpp_label = XtVaCreateManagedWidget ("cppLabel",labelWidgetClass, frame, XtNlabel, "CPP flags: ", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNfromVert, status, XtNjustify, XtJustifyLeft, XtNborderWidth, (XtArgVal) 0, NULL); cpp_text = XtVaCreateManagedWidget ("cppText", asciiTextWidgetClass,frame, XtNfromHoriz, (XtArgVal) cpp_label, XtNfromVert, (XtArgVal) status, XtNleft, (XtArgVal) XawChainLeft, XtNright, (XtArgVal) XawChainRight, XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNborderWidth, (XtArgVal) 2, XtNautoFill, (XtArgVal) False, XtNdisplayNonprinting, (XtArgVal) True, XtNeditType, (XtArgVal) XawtextEdit, XtNlength, (XtArgVal) 1000, /* XtNresize, (XtArgVal) XawtextResizeWidth, XtNheight, (XtArgVal) 200, XtNwidth, (XtArgVal) 200, */ XtNstring, (XtArgVal) cpp_buff, XtNuseStringInPlace,(XtArgVal) True, XtNscrollHorizontal,(XtArgVal) XawtextScrollAlways, NULL); parse_label = XtVaCreateManagedWidget ("parserLabel",labelWidgetClass, frame, XtNlabel, "Parse flags: ", XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNfromVert, cpp_text, XtNjustify, XtJustifyLeft, XtNborderWidth, (XtArgVal) 0, NULL); parse_text = XtVaCreateManagedWidget ("parseText", asciiTextWidgetClass,frame, XtNfromHoriz, (XtArgVal) parse_label, XtNfromVert, (XtArgVal) cpp_text, XtNleft, (XtArgVal) XawChainLeft, XtNright, (XtArgVal) XawChainRight, XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainTop, XtNborderWidth, (XtArgVal) 2, XtNautoFill, (XtArgVal) False, XtNdisplayNonprinting, (XtArgVal) True, XtNeditType, (XtArgVal) XawtextEdit, XtNlength, (XtArgVal) 1000, /* XtNresize, (XtArgVal) XawtextResizeWidth, XtNheight, (XtArgVal) 200, XtNwidth, (XtArgVal) 200, */ XtNstring, (XtArgVal) parser_flags, XtNuseStringInPlace,(XtArgVal) True, XtNscrollHorizontal,(XtArgVal) XawtextScrollAlways, NULL); selected = make_list_box (frame,"select","Selected Files"); XtVaSetValues (selected, XtNfromVert, (XtArgVal) parse_text, XtNleft, (XtArgVal) XawChainLeft, /* XtNright, (XtArgVal) XawChainRight, */ XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainBottom, NULL); not_selected = make_list_box (frame,"notSelect","Files Not Selected"); XtVaSetValues (not_selected, XtNfromVert, (XtArgVal) parse_text, /* XtNleft, (XtArgVal) XawChainRight, */ XtNright, (XtArgVal) XawChainRight, XtNtop, (XtArgVal) XawChainTop, XtNbottom, (XtArgVal) XawChainBottom, XtNfromHoriz, (XtArgVal) selected, NULL); XtAddCallback (XtNameToWidget(selected,"*selectList"), XtNcallback,alist,&names); n_files = scan_dir(&files); for (i = 0; files[i] ; i++){ file_names[i] = files[i]->d_name; pick_names[i] = files[i]->d_name; } names.use = file_names; names.skip = skip_names; names.pick = pick_names; names.files = files; file_names[n_files] = NULL; names.ignore = XtNameToWidget (not_selected,"*notSelectList"); names.keep = XtNameToWidget(selected,"*selectList"); XtAddCallback (XtNameToWidget (not_selected,"*notSelectList"), XtNcallback,ilist,&names); analyze_skipped (NULL,&names,NULL); info = XtVaCreateManagedWidget ("info",labelWidgetClass, frame, XtNlabel, "Description of object under mouse pointer is displayed here", XtNtop, XawChainBottom, XtNbottom, XawChainBottom, XtNleft, XawChainLeft, XtNright, XawChainRight, XtNfromVert, selected, XtNjustify, XtJustifyLeft, NULL); XtVaGetValues (cpp_text, XtNwidth, &W, XtNheight,&H, NULL); H += 20; XtUnmanageChild(cpp_text); XtVaSetValues (cpp_text, XtNheight,H, NULL); XtManageChild(cpp_text); XtVaGetValues (parse_text, XtNwidth, &W, XtNheight,&H, NULL); H += 20; XtUnmanageChild(parse_text); XtVaSetValues (parse_text, XtNheight,H, NULL); XtManageChild(parse_text); XtRealizeWidget(top); adjust_lists (frame,selected,not_selected); align(cpp_label,cpp_text,parse_label,parse_text); rj_button (frame,clear,help); strech (frame,status); strech (frame,cpp_text); strech (frame,parse_text); strech (frame,info); strech (selected, XtNameToWidget (selected,"selectLabel")); strech (not_selected, XtNameToWidget (not_selected,"notSelectLabel")); XtInstallAccelerators (frame,quit); XtInstallAccelerators (frame,help); help_label = info; set_button_help (opt_button, "Use this menu to select all files, no files or analyzed files"); set_button_help (clear, "Click to remove analysis of selected files"); set_button_help (op_button, "Click to run analysis on selected files"); set_button_help (info, "Description of object under mouse pointer is displayed here"); set_button_help (quit,"Click to exit analyzer"); set_button_help (help, "Click to pop up a window describing analyzer"); set_button_help (frame," . . ."); set_button_help (parse_text,"Type in any analyzer flags"); set_button_help (parse_label,"Flags for running the analyzer"); set_button_help (cpp_text,"Type in any cpp flags"); set_button_help (cpp_label, "Flags for running the C preprocessor (CPP)"); set_button_help (status,"Display status as analysis runs"); set_button_help (XtNameToWidget (selected,"*vertical"), "use middle mouse button to slide scroll bar"); set_button_help (XtNameToWidget (not_selected,"*vertical"), "use middle mouse button to slide scroll bar"); set_button_help (XtNameToWidget (selected,"*selectList"), "Click on file name to remove a file from selected list"); set_button_help (XtNameToWidget (not_selected,"*notSelectList"), "Click on file name to add a file to selected list"); set_button_help (XtNameToWidget (selected,"selectLabel"), "List of files selected for analysis"); set_button_help (XtNameToWidget (not_selected,"notSelectLabel"), "List of files not to be analyzed");}char *fall[] = { /* don't move the first entry (iconPixmap) */ "*iconPixmap: analyzer.icon", "*font: lucidasans-bold-14", "*background: seashell3", "*foreground: blue", "*shapeStyle: oval", "*Label*borderWidth: 0", "*Command*borderWidth: 2", "*info*borderWidth: 3", "*title: Unravel Version 2.2 Analyzer Control Panel", "*geometry: +50+25", "*quit.accelerators: #override\\n \ <KeyPress>q: set() highlight() notify()", "*help.accelerators: \ <KeyPress>h: set() highlight() notify() unset()\\n\ <KeyPress>?: set() highlight() notify() unset()", NULL};main (np,p) int np; char *p[];{ XtAppContext ac; Widget top; int i; char icon_at[2000]; static XrmOptionDescRec opt[] = { {"-runningfg", "*runningFG", XrmoptionSepArg,NULL}, {"-runningbg", "*runningBG", XrmoptionSepArg,NULL}}; sprintf (icon_at,"*iconPixmap: %s/analyzer.icon",HOME); fall[0] = icon_at; top = XtAppInitialize (&ac,"Unravel",opt,XtNumber(opt),&np,p, fall,NULL,0); if (np == 2) unravel_win_id = atoi(p[1]); else unravel_win_id = 0; system ("echo -n ANALYZER \" \" > HISTORY-A ; date >>HISTORY-A"); make_windows(top,ac); XtAppMainLoop(ac);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -