📄 filemenu.c
字号:
for (j=0; j<nfiles; j++) {#ifdef SYSV WorkingDirEntry = readdir(WorkingDir); if(!strcmp(WorkingDirEntry->d_name, ".")) strcpy(store, "./"); else { if(!strcmp(WorkingDirEntry->d_name, "..")) strcpy(store, "../"); else { struct stat statbuf; sprintf(store,"%s/%s",cwd,WorkingDirEntry->d_name); if(stat(store, &statbuf) == -1) store[0]='\0'; else { if (statbuf.st_mode & S_IFDIR) sprintf(store, "%s/", WorkingDirEntry->d_name); else if (statbuf.st_mode & S_IEXEC) sprintf(store, "%s*", WorkingDirEntry->d_name); else if(LASTCH(WorkingDirEntry->d_name) == '~' || LASTCH(WorkingDirEntry->d_name) == '#' || WorkingDirEntry->d_name[0] == '.' || (LASTCH(WorkingDirEntry->d_name) == 'o' && SECLASTCH(WorkingDirEntry->d_name) == '.')) store[0]='\0'; else strcpy(store, WorkingDirEntry->d_name); } } } if(store[0]) filelist[i++] = XtNewString(store);#else /* not SYSV */ filelist[i++] = XtNewString(namelist[j]->d_name); XtFree((XtPointer) namelist[j]);#endif } filelist[i++] = NULL;#ifdef SYSV closedir(WorkingDir);#else XtFree((XtPointer) namelist);#endif return;} /* Callback for the fileMenu list widget. * > if the selected item is a directory, display contents of that directory. * > (Sun dbx only) if the selected item is an executable file, issue the * debug command. * > if the selected item is a readable file, display the file. *//* ARGSUSED */static void DisplayMenuFile(w, popupshell, call_data) Widget w; Widget popupshell; XawListReturnStruct *call_data;{ char string[LINESIZ], *filename, command[LINESIZ]; XtPopdown(popupshell); filename = call_data->string; if (filename == NULL) return; if (LASTCH(filename) == '/') { changeDir(filename); XtDestroyWidget(popupshell); UpdateFileMenu(); /* create new menu */ File(); /* pop it up */ } else if (LASTCH(filename) == '*') { UpdateMessageWindow("",NULL);#ifdef GDB strcpy(string, filename); LASTCH(string) = '\0'; /* for GDB 4.xx, we send the command : file */ if (new_gdb4()) sprintf(command, "file %s\n", string); else { /* for GDB 3.xx, we send the commands : exec-file & symbol-file */ /* (PW)21DEC90 : this button is special because it has to send TWO commands to GDB. */ sprintf(command, "exec-file %s\n", string); send_command(command); AppendDialogText(command); sprintf(command, "symbol-file %s\n", string); } send_command(command); AppendDialogText(command);#else#ifndef BSD strcpy(string, filename); LASTCH(string) = '\0'; sprintf(command, "debug %s\n", string); send_command(command); AppendDialogText(command);#endif#endif /* GDB */ } else { UpdateMessageWindow("",NULL);#ifdef GDB if (strcmp(filename, "core") == 0) sprintf(command, "core-file %s\n", filename); else sprintf(command, "list %s:1\n", filename); send_command(command); AppendDialogText(command);#else /* not GDB */ sprintf(command, "file %s\n", filename); send_command(command); AppendDialogText(command);#endif /* GDB */ }}/* Callback to popdown the file menu *//* ARGSUSED */static void CancelFileMenu(w, popupshell, call_data) Widget w; Widget popupshell; caddr_t call_data;{ XtPopdown(popupshell); UpdateMessageWindow("",NULL);}/* Creates a popup shell with its child being a vpane widget containing * a file menu label, a file menu containing file names returned from * ScanDir(), and a cancel command button. * When an item in the list is selected, DisplayMenuFile is called. */static void SetUpFileMenu(dir) char *dir;{ Widget cancelButton; Arg args[MAXARGS]; Cardinal n; char menulabel[LINESIZ]; int ncolumns; n = 0; popupshell = XtCreatePopupShell("File Directory", transientShellWidgetClass, toplevel, args, n); n = 0; popup = XtCreateManagedWidget("popup", panedWidgetClass, popupshell, args, n); ScanDir(dir); strcpy(fileMenuDir, dir); n = 0; sprintf(menulabel, " %s ", dir); XtSetArg(args[n], XtNlabel, (XtArgVal) menulabel); n++; XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter); n++; fileMenuLabel = XtCreateManagedWidget("fileMenuLabel", labelWidgetClass, popup, args, n); n = 0; ncolumns = nfiles/FILES_PER_COL + 1; ncolumns = MIN(ncolumns, MAXCOLUMNS); XtSetArg(args[n], XtNlist, filelist); n++; XtSetArg(args[n], XtNverticalList, True); n++; XtSetArg(args[n], XtNdefaultColumns, (XtArgVal) ncolumns); n++; fileMenu = XtCreateManagedWidget("fileMenu", listWidgetClass, popup, args, n); XtAddCallback(fileMenu, XtNcallback, DisplayMenuFile, popupshell); n = 0; XtSetArg(args[n], XtNresize, False); n++; XtSetArg(args[n], XtNlabel, "CANCEL"); n++; cancelButton = XtCreateManagedWidget("cancelButton", commandWidgetClass, popup, args, n); XtAddCallback(cancelButton, XtNcallback, CancelFileMenu, popupshell); DisableWindowResize(fileMenuLabel); DisableWindowResize(cancelButton);}/* This routine is called when there is a a change in current directory. * It destroys the existing popup shell and creates a new file menu based * on the new current directory. A new directory list is created. */static void UpdateFileMenu(){ SetUpFileMenu(cwd);#ifdef GDB query_gdb_directories(); /* defined in gdb_handler.c */#else query_dbx("use\n");#endif /* GDB */}/* File command button callback. *//* ARGSUSED */void File(w, client_data, call_data) Widget w; caddr_t client_data; caddr_t call_data;{ Arg args[MAXARGS]; Cardinal n; Position x, y, x_offset; Dimension fileMenu_width, fileMenuLabel_width, border_width, width, dialog_width; XDefineCursor(display, XtWindow(toplevel), watch); XDefineCursor(display, XtWindow(sourceWindow), watch); XDefineCursor(display, XtWindow(dialogWindow), watch); XFlush(display); if (strcmp(fileMenuDir, cwd)) UpdateFileMenu(); n = 0; XtSetArg(args[n], XtNwidth, &fileMenu_width); n++; XtSetArg(args[n], XtNborderWidth, &border_width); n++; XtGetValues(fileMenu, args, n); n = 0; XtSetArg(args[n], XtNwidth, &fileMenuLabel_width); n++; XtGetValues(fileMenuLabel, args, n); n = 0; XtSetArg(args[n], XtNwidth, &dialog_width); n++; XtGetValues(dialogWindow, args, n); width = MAX(fileMenu_width, fileMenuLabel_width); x_offset = (Position) (dialog_width - width - border_width); XtTranslateCoords(dialogWindow, x_offset, 0, &x, &y); x = MAX(0, x); y = MAX(0, y); n = 0; XtSetArg(args[n], XtNx, x); n++; XtSetArg(args[n], XtNy, y); n++; XtSetValues(popupshell, args, n); XtPopup(popupshell, XtGrabNonexclusive); UpdateMessageWindow("Select a file or directory",NULL); XUndefineCursor(display, XtWindow(toplevel)); XUndefineCursor(display, XtWindow(sourceWindow)); XUndefineCursor(display, XtWindow(dialogWindow));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -