// // LoadMnu.vdm Ch.Ziemski 07.03.2002 // 17.03.2002 // // // Administration of User-Menu-Files // // This macro lets you "browse" through your user menu files (*.mnu), // - show some infos (if maintained, see below), // - edit the MNU file // - load the MNU file into the {User} menu and set the USER_MENU string // // The MNU files can contain comments which are detected and displayed: // // //(@) Title or short(one line) description // //(M) USER_MENU string // //(#) date or version string // // // Requires Windows' Vedit 6.02 or above // //-------------------------------------------------------- // // #87 DI1(1): radio button // // #90 Original Buf_Num // #91 Number of MNU's // #92 Counter for MNU's // #93 tmp // #94 tmp // #95 DI1(): button# // // $86 date or version string (better $93a ...) // $87 DI1(): filter incl. path // $88 path for MNU's // $89 filename with doubled "\" // $90 path with doubled "\" // // $91 Filename // $92 Title // $93 USER_MNU string // // $94 items for 1st DI1() // $95 " // $96 " // $97 " // $98 " // // $99 text for 2nd DI1() // // XBUF1 list of MNU's // XBUF2 tmp, for loading/checking MNU file // XBUF3 tmp // XBUF4 tmp // //--------------------------------------------------------- if(! Is_Windows){ Win_Clear Message("\n\nSorry, but LOADMNU.VDM only works in the Windows version of VEDIT!\n\n") Visual_Macro(NOMSG) Get_Key("Please press any key...") return } Reg_Push(86,99) // save the used registers Num_Push(86,99) Reg_Set(87, USER_MACRO) // directory of MNU's <<<<<<< to customize <<< Reg_Set(87, "\*.mnu", APPEND) // default filter #87=1 // radio button set to standard action "load menu" #90=Buf_Num // save current buffer number // --------------------------------- :Start: Buf_Switch(XBUF4) // extract the directory from complete filter string Reg_Ins(87) EoL Search("\", REVERSE+ADVANCE) Del_Line(1) Reg_Copy_Block(88, 0, File_Size) Buf_Quit(OK) Buf_Switch(XBUF1) // get a list of the MNU files of that directory Buf_Empty(OK) Out_Ins Dir("|@(87)", NOMSG+NOERR) Out_Ins(CLEAR) Replace("^","\@(88)", REGEXP+BEGIN+ALL+NOERR) // add the complete path to each file #91=0 // counter for # of MNU's BoF while(! At_EoF){ // expand the list of filenames with titles and User_Strings Reg_Copy_Block(91, Cur_Pos, EoL_Pos) // get path + filename Buf_Switch(XBUF2) // and load that file to look for the appropriate comments Buf_Empty(OK) File_Open("|@(91)", FORCE) Search("//(@)|W", BEGIN+NOERR+ADVANCE) // search for the short description of the macro if(EM){ // if not found: use the filename as "description" Buf_Switch(XBUF4) Reg_Ins(91) Replace("\","\\", BEGIN+ALL+NOERR) // double the "\" to display them Reg_Copy_Block(89, 0, File_Size) Buf_Quit(OK) Buf_Switch(XBUF2) Reg_Set(92, "[") Reg_Set(92, @89, APPEND) Reg_Set(92, "]", APPEND) }else{ Reg_Copy_Block(92, Cur_Pos, EoL_Pos) } Search("//(M)|W", BEGIN+NOERR+ADVANCE) // search for the USER_MNU string if(EM){ // if not found: use the standard: "User" Reg_Set(93, "&User") }else{ Reg_Copy_Block(93, Cur_Pos, EoL_Pos) } Search("//(#)|W", BEGIN+NOERR+ADVANCE) // search for the date or version string if(EM){ // if not found: use " " Reg_Set(86, " ") }else{ Reg_Copy_Block(86, Cur_Pos, EoL_Pos) } Buf_Quit(OK) Buf_Switch(XBuf1) Line(1) Reg_Ins(92) // title/description Ins_Newline(1) Reg_Ins(93) // USER_MNU string Ins_Newline(1) Reg_Ins(86) // date or version string Ins_Newline(1) #91++ } #92=1 // MNU #1 // --------------------------------- :newpos: // fill Reg94-98 with macro titles Reg_Empty(94) Reg_Empty(95) Reg_Empty(96) Reg_Empty(97) Reg_Empty(98) Buf_Switch(XBuf1) //Goto_Line((#92-1)*3 +1) // goto to the appropriate item Goto_Line((#92-1)*4 +1) // goto to the appropriate item #94=#91-#92+1 // check if there are 5 remaining items or less if(#94>5){ #94=5 } for(#93=1 ; #93<=#94 ; #93++){ Line(1) Reg_Copy_Block(93+#93, Cur_Pos, Eol_Pos) Line(3, NOERR+ERRBREAK) } Buf_Switch(#90) // switch back to the user's buffer repeat(ALL){ #95=Dialog_Input_1(87,"`Maintaining VEDIT's {User} menus`, '??&Filter', '.r[&reload]', '__________________________________________', '.i.g() &Load the specified mnu and set USER_MENU', '() &Infos about the mnu (functions)', '() &Edit the mnu file in a second instance of VEDIT', '.l[&1]', '.h.l.C |@(94)', '.l[&2]', '.h.l.C |@(95)', '.l[&3]', '.h.l.C |@(96)', '.l[&4]', '.h.l.C |@(97)', '.l[&5]', '.h.l.C |@(98)', ' ', '[&prev]', '.h[&next]', '.v.c[&cancel]'", SET+SCREEN+CENTER,0,0) if((#95==0) || (#95==9)){ // if ESC or [quit] break } if(#95==1){ // reload DI1() break } if((#95>1) && (#95<7)){ // if one of the MNU - buttons 1..5 if((#92+#95-2) > #91){ // if no more MNU item continue } if(#87==2){ // show infos about the specified MNU file Call("getinfos") Buf_Switch(XBUF3) // extract the lines with item descriptions Buf_Empty(OK) File_Open("|@(91)", FORCE) Replace("|5){ #92-=5 break } continue } if(#95==8){ // refresh the $81-$85 with next five if(#92<=(#91-5)){ #92=Min(#91, #92+5) break } continue } } if((#95>1) && (#95<7) && (#87==3)){ // file has been edited => restart goto start } if(#95==1){ // [reload] pressed: => restart goto Start } if((#95==7) || (#95==8)){ // [prev] or [next] pressed: read new MNU's into DI1() goto newpos } :cleanup: Num_Pop(86,99) Reg_Pop(86,99) Buf_Switch(XBUF1) Buf_Quit(OK) Buf_Switch(#90) return // --------------------------------- :getinfos: Buf_Switch(XBUF1) Goto_Line((#92+#95-3)*4+1) Reg_Copy_Block(91, Cur_Pos, EoL_Pos) // filename Line(1) Reg_Copy_Block(92, Cur_Pos, EoL_Pos) // title Line(1) Reg_Copy_Block(93, Cur_Pos, EoL_Pos) // USER_MENU Line(1) Reg_Copy_Block(86, Cur_Pos, EoL_Pos) // date or version string return // =================================