📄 fv.cmd.c
字号:
mi = menu_get(m, MENU_NTH_ITEM, M_DELETE+floater); menu_set(mi, MENU_INACTIVE, no_seln, 0); mi = menu_get(m, MENU_NTH_ITEM, M_PROPS+floater); menu_set(mi, MENU_INACTIVE, no_seln, 0); /* The prototype and View2 have default actions on menus */#ifdef SV1# ifdef PROTO if (floater) menu_show(m, window, event, 0); else panel_default_handle_event(Edit_button, event);# else menu_show(m, window, event, 0);# endif#else if (floater) menu_show(m, window, event, 0); else panel_default_handle_event(Edit_button, event);#endif}/*ARGSUSED*/staticundelete(m, mi) /* Display Undelete menu's pull right */ Menu m; Menu_item mi;{ int i = (int)menu_get(mi, MENU_CLIENT_DATA); if (i==1) fv_undelete(); else fv_commit_delete(TRUE);}fv_delete_object() /* Delete selected object */{ register FV_TNODE *f_p; /* Tree pointer */ char *b_p; /* String pointer */ char buf[256]; /* 'Invisible' file */ /* Confirm deletion of selected object(s) */ if (Fv_confirm_delete && !fv_alert(Fv_message[MCONFIRMDEL])) return; if (Fv_tselected) { if (access(".", W_OK) == -1) { fv_putmsg(TRUE, Fv_message[MEDELETE], (int)Fv_tselected->name, sys_errlist[errno]); return; } if (!Fv_treeview) { sprintf(buf, Fv_message[MDELCURRENT], Fv_tselected->name, Fv_tselected->parent->name); if (fv_alert(buf) == FALSE) return; } /* Get out of current directory */ (void)chdir(".."); /* Move folder to 'invisible' name */ b_p = buf; *b_p++ = '.'; *b_p++ = '.'; (void)strcpy(b_p, Fv_tselected->name); if (rename(Fv_tselected->name, buf) == -1) { fv_putmsg(TRUE, sys_errlist[errno], 0, 0); /* Change back */ (void)chdir(Fv_tselected->name); } else { /* Cut node from tree... */ if (Fv_tselected == Fv_tselected->parent->child) Fv_tselected->parent->child = Fv_tselected->sibling; else { /* Fix sibling pointers... */ for (f_p = Fv_tselected->parent->child; f_p && f_p->sibling != Fv_tselected; f_p = f_p->sibling) ; if (f_p) f_p->sibling = Fv_tselected->sibling; } fv_getpath(Fv_tselected->parent, 0); /* Prepare for undelete... */ (void)fv_commit_delete(); if ((Fv_undelete = fv_malloc((unsigned)strlen(Fv_path)+ strlen(Fv_tselected->name)+5))) (void)sprintf(Fv_undelete, "%s ..%s ", Fv_path, Fv_tselected->name); if (fv_descendant(Fv_current, Fv_tselected)) { /* If current folder gets zapped, then * back up one level. */ (void)strcpy(Fv_openfolder_path, Fv_path); Fv_lastcurrent = NULL; Fv_current = Fv_tselected->parent; fv_display_folder(FV_BUILD_FOLDER); } Fv_tselected->sibling = NULL; fv_destroy_tree(Fv_tselected); fv_treedeselect(); fv_drawtree(TRUE); } } else fv_delete_selected();}staticexec_command(m, mi) Menu m; Menu_item mi;{ register int i = 0; /* Arg count */ char buf[4096]; /* Command (can expand) */ char *argv[255]; char *s = (char *)menu_get(mi, MENU_STRING); register char *b_p; /* Is there a '%s' somewhere in the string */ b_p = s; while (*b_p) if (*b_p == '%' && *(b_p+1) == 's') break; else b_p++; /* Yes there is, copy the selected names in */ if (b_p) sprintf(buf, s, (char *)fv_getmyselns(FALSE)); else strcpy(buf, s); /* Now break up command into argument line */ /* XXX Embedded spaces */ s = (char *)strtok(buf, " "); while (s) { argv[i++] = s; s = (char *)strtok((char *)0, " "); } argv[i] = 0; fv_execit(argv[0], argv);}staticbuild_cmd_menu(){ char buf[MAXPATH]; register int i, j, l; char *av[256]; register FILE *fp; av[0] = (char *)MENU_NOTIFY_PROC; av[1] = (char *)exec_command; j = 2; i = 1; sprintf(buf, "%s/.fvcmd", Fv_home); if (fp = fopen(buf, "r")) { while (fgets(buf, 255, fp) && j < 255) { av[j] = (char *)MENU_STRING_ITEM; av[j+1] = malloc(l = strlen(buf)); l--; if (buf[l] == '\n') buf[l] = 0; /* No newline */ strcpy(av[j+1], buf); av[j+2] = (char *)i; j += 3; i++; } } av[j] = 0; Cmd_menu = menu_create(ATTR_LIST, &av[0], 0); Ncmds = i-1;}statichome_button(item, event) /* Generate most recent visited folders menu */ Panel_item item; Event *event;{ Menu_item mi; char *av[(FV_MAXHISTORY+1)*3]; register int i, j; static int nitems = 1; if (event_id(event) == MS_RIGHT && event_is_down(event)) { /* Generate most recent visited folders menu */ for (j=i=0; i<Fv_nhistory; i++, j+=3) { av[j] = (char *)MENU_STRING_ITEM; av[j+1] = Fv_history[i]; av[j+2] = (char *)i+1; } av[j] = 0; av[j+1] = 0; if (Home_menu) menu_destroy(Home_menu);#ifdef SV1 Home_menu = menu_create(ATTR_LIST, &av[0], 0);#else Home_menu = vu_create(VU_NULL, MENU, ATTR_LIST, &av[0], 0);#endif#ifdef PROTO menu_set(Home_menu, MENU_FONT, window_get(Fv_frame, WIN_FONT), 0);#endif if (i = (int)menu_show(Home_menu, Fv_panel, event, 0)) { fv_busy_cursor(TRUE); fv_openfile(Fv_history[i-1], (char *)0, TRUE); fv_busy_cursor(FALSE); } } else if (event_id(event) == MS_LEFT && event_is_up(event)) fv_openfile(Fv_home, (char *)0, TRUE);}staticgoto_object() /* Either match or goto */{ register char *str_p; /* User's input */ struct stat fstatus; /* Check for folder */ char resolved_name[MAXPATH]; char tilde_name[MAXPATH]; if ((str_p=panel_get_value(Path_item)) && *str_p) { /* Could this be a regular expression? If so, match * and select those files... */ if (fv_regex_in_string(str_p)) fv_match_files(str_p); else { fv_busy_cursor(TRUE); if (*str_p == '~') { /* Expand home folder pointer */ strcpy(tilde_name, Fv_home); strcat(tilde_name, str_p+1); str_p = tilde_name; }#ifdef OS3 strcpy(resolved_name, str_p);#else /* Resolve references to "." and ".." */ if (realpath(str_p, resolved_name) == 0) fv_putmsg(TRUE, sys_errlist[errno], 0, 0); else #endif if (stat(resolved_name, &fstatus)) fv_putmsg(TRUE, sys_errlist[errno], 0, 0); else fv_openfile(resolved_name, (char *)0, (fstatus.st_mode & S_IFMT)==S_IFDIR); fv_busy_cursor(FALSE); } }}static voidgoto_button(item, event) /* Fill in field menu item */ Panel_item item; Event *event;{ Menu_item mi;#ifdef PROTO /* XXX BUG IN LEIF LOOK */ if (event_id(event) == MS_LEFT) return;#endif if (event_id(event) == MS_RIGHT && event_is_down(event)) { (void)strncpy(Goto_field, panel_get(Path_item, PANEL_VALUE), 20); mi = menu_get(Gotomenu, MENU_NTH_ITEM, 1); menu_set(mi, MENU_INACTIVE, Goto_field[0]==0, 0); if (Goto_field[0] == 0) strcpy(Goto_field, "Entry"); menu_show(Gotomenu, Fv_panel, event, 0); } else if (event_id(event) == MS_LEFT && event_is_up(event)) goto_object();}fv_create_panel(p) /* Create tool's control panel */ register Panel p; /* Panel */{ Menu open_menu, undel_menu, m; /* Generic menu */ extern void fv_addparent_button(); /* Add parent button */ extern void fv_hide_node(); /* Hide notify proc */ extern void fv_set_root(); /* Change root proc */ extern int fv_info_object(); extern int fv_find_object(); extern int fv_bind_object(); extern int fv_select_all(); extern int fv_load_button(); extern int fv_copy_to_shelf(); extern int fv_paste(); extern int fv_undelete(); extern int fv_cut_to_shelf(); extern int fv_expand_all_nodes(); extern void fv_remote_transfer(); open_menu = menu_create( MENU_NOTIFY_PROC, run_object, MENU_ITEM, MENU_CLIENT_DATA, OPEN, MENU_STRING, "Open File", 0, MENU_ITEM, MENU_CLIENT_DATA, RUN_WITH_ARGS, MENU_STRING, "Open with 'Name' Arguments", 0, MENU_ITEM, MENU_CLIENT_DATA, EDIT, MENU_STRING, "Open in Document Editor", 0, MENU_ITEM, MENU_CLIENT_DATA, SHELL, MENU_STRING, "Open in Shelltool", 0, 0); build_cmd_menu(); Filemenu = menu_create( MENU_PULLRIGHT_ITEM, "Open", open_menu, MENU_ACTION_ITEM, "Print File", print_object, MENU_ACTION_ITEM, "Create Folder", create_folder, MENU_ACTION_ITEM, "Create File", create_file, MENU_PULLRIGHT_ITEM, "Your Commands", Cmd_menu,#ifdef SV1 MENU_ACTION_ITEM, REMOTE_COPY, fv_remote_transfer, MENU_ACTION_ITEM, BIND_ACTION, fv_bind_object,#else MENU_ITEM, MENU_STRING, "Remote Transfer", MENU_ACTION_PROC, fv_remote_transfer, MENU_WINDOW_MARK, TRUE, 0, MENU_ITEM, MENU_STRING, "Bind Action to Object", MENU_ACTION_PROC, fv_bind_object, MENU_WINDOW_MARK, TRUE, 0,#endif 0); File_button = panel_create_item(p, MY_MENU(Filemenu), MY_BUTTON_IMAGE(p, "File"), PANEL_EVENT_PROC, file_button, 0); (void)strcpy(Path_p, Path_s[1]); (void)strcpy(Hide_p, *Hide_s); Viewmenu = menu_create( MENU_ACTION_ITEM, Path_p, path_or_tree, MENU_ACTION_ITEM, Hide_p, fv_hide_node, MENU_ACTION_ITEM, "Show All Subfolders", fv_expand_all_nodes, MENU_ACTION_ITEM, "Begin Tree Here", fv_set_root, MENU_ACTION_ITEM, "Add Tree's Parent", fv_addparent_button, 0); View_button = panel_create_item(p, MY_MENU(Viewmenu), MY_BUTTON_IMAGE(p, "View"), PANEL_EVENT_PROC, view_button, 0); undel_menu = menu_create( MENU_NOTIFY_PROC, undelete, MENU_ITEM, MENU_CLIENT_DATA, 1, MENU_STRING, "Recover Files", 0, MENU_ITEM, MENU_CLIENT_DATA, 2, MENU_STRING, "Really Delete", 0, 0); Editmenu = menu_create( MENU_PULLRIGHT_ITEM, "Undelete", undel_menu, MENU_ACTION_ITEM, "Select All", fv_select_all, MENU_ACTION_ITEM, "Copy", fv_copy_to_shelf, MENU_ACTION_ITEM, "Paste", fv_paste, MENU_ACTION_ITEM, "Cut", fv_cut_to_shelf, MENU_ACTION_ITEM, "Delete", fv_delete_object,#ifdef SV1 MENU_ACTION_ITEM, FILE_PROPS, fv_info_object,#else MENU_ITEM, MENU_STRING, "File Properties", MENU_ACTION_PROC, fv_info_object, MENU_WINDOW_MARK, TRUE, 0,#endif 0); Edit_button = panel_create_item(p, MY_MENU(Editmenu), MY_BUTTON_IMAGE(p, "Edit"), PANEL_EVENT_PROC, edit_button, 0); Tree_floater = menu_create(#ifndef SV1 MENU_TITLE_ITEM, "Path Commands",#endif MENU_ACTION_ITEM, "Open", open_object, MENU_ACTION_ITEM, Path_p, path_or_tree, MENU_ACTION_ITEM, Hide_p, fv_hide_node, MENU_ACTION_ITEM, "Show All Subfolders", fv_expand_all_nodes, MENU_ACTION_ITEM, "Begin Tree Here", fv_set_root, MENU_ACTION_ITEM, "Add Tree's Parent", fv_addparent_button,#ifdef SV1 MENU_ACTION_ITEM, FILE_PROPS, fv_info_object,#else MENU_ITEM, MENU_STRING, "File Properties", MENU_ACTION_PROC, fv_info_object, MENU_WINDOW_MARK, TRUE, 0,#endif 0); Folder_floater = menu_create(#ifndef SV1 MENU_TITLE_ITEM, "Folder Commands",#endif MENU_PULLRIGHT_ITEM, "Open", open_menu, MENU_PULLRIGHT_ITEM, "Undelete", undel_menu, MENU_ACTION_ITEM, "Select All", fv_select_all, MENU_ACTION_ITEM, "Copy", fv_copy_to_shelf, MENU_ACTION_ITEM, "Paste", fv_paste, MENU_ACTION_ITEM, "Cut", fv_cut_to_shelf, MENU_ACTION_ITEM, "Delete", fv_delete_object,#ifdef SV1 MENU_ACTION_ITEM, FILE_PROPS, fv_info_object,#else MENU_ITEM, MENU_STRING, "File Properties", MENU_ACTION_PROC, fv_info_object, MENU_WINDOW_MARK, TRUE, 0,#endif 0); /* We'll supply real menu in event function; * There should really be a gap between file, view, edit and * the other buttons */ Home_menu = menu_create(MENU_STRING_ITEM, Fv_home, 1, 0); Home_button = panel_create_item(p, MY_MENU(Home_menu), MY_BUTTON_IMAGE(p, "Home"), PANEL_EVENT_PROC, home_button, PANEL_ITEM_X, ATTR_ROW(HOME_COL), 0); Gotomenu = menu_create( MENU_ACTION_ITEM, Goto_field, goto_object, MENU_ACTION_ITEM, #ifdef OPENLOOK "Find \002",#else "Find...",#endif fv_find_object, 0); Find_button = panel_create_item(p, MY_MENU(Gotomenu), MY_BUTTON_IMAGE(p, "Goto:"), PANEL_EVENT_PROC, goto_button, 0); Path_item = panel_create_item(p, PANEL_TEXT, PANEL_LABEL_Y, ATTR_ROW(0), PANEL_LABEL_BOLD, TRUE, PANEL_VALUE_DISPLAY_LENGTH, 32, PANEL_VALUE_STORED_LENGTH, 256, PANEL_NOTIFY_PROC, goto_object, 0); m = menu_create( MENU_ACTION_ITEM, "Load", fv_load_button, MENU_ACTION_ITEM, "Cancel", fv_load_button, /* XXX */ 0); Load_button = panel_create_item(p, MY_MENU(m), MY_BUTTON_IMAGE(p, "Load"), PANEL_NOTIFY_PROC, fv_load_button, PANEL_SHOW_ITEM, FALSE, 0);#ifndef OPENLOOK Fv_errmsg = panel_create_item(p, PANEL_MESSAGE, PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(1), PANEL_VALUE_DISPLAY_LENGTH, 40, 0); window_set(p, WIN_ROWS, 2, 0); window_fit_width(p);#else window_fit(p);#endif}voidfv_show_load_button(on) BOOLEAN on;{ /* XXX Insert this button before the HOME menu */ panel_set(Load_button, PANEL_SHOW_ITEM, on, 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -