// // INLINE-HELP2.VDM Ch. Ziemski 09.06.2002 // 14.03.2004 // // This first line is used as title line in the help dialog // // *** INLINE-HELP - A demo for an implementation of inline online help *** // // This version uses the technique of DI1-SCROLL2.VDM, a scrollable Dialog_Input_1() //-- // // The main macro documentation and the online help are (can be) the same. // // You only have to write a leading tag at the beginning of the part // of the comments which should be used as online help and a trailing // tag at the end. // // This macro generates a scrollable Dialog_Input_1() dialog with this text. // //-- // // To be able to format the text a bit there are special "paragraphs" of text. // They are divided by "--" at BoL (just after the //). // // That way it's possible to have empty lines in the text to make // it better readable. Every "paragraph" is displayed at a single page. // // If you want to have a title line in the help dialog you can use the rest of // the line containing the leading tag for that. // // // The next page is an example help page. // //-- // // Shft-F1 : show this help // // F11 : whatever command etc. // // F12 ... // //-- // // Developed by Christian Ziemski using the fantastic VEDIT ;-) // // // // some more internal comments // // .... // ..... // //================================================================================ if ( ! Is_Windows) { Statline_Message("Sorry, this macro requires VEDIT for Windows.") return } Key_Add(`Shft-F1`, `[VISUAL EXIT] CALL(100, "HELP") `, OK) // Here comes your macro code ... // // .... // return //========================================================================================= // Show some help instructions (the inline doco from top of the macro) :HELP: Num_Push(103,106) // save used registers Reg_Push(103,106) Key_Purge() #106=Buf_Num Buf_Switch(Buf_Free(EXTRA)) Reg_Ins(Macro_Num) BoF Search("//|[|W]|H3CDOC>", NOERR+ADVANCE) // the leading "<" is masked out intentionally! if(EM){ Message("\n\n No inline help found.", STATLINE) }else{ Reg_Copy_Block(103, Cur_Pos, EoL_Pos) Line(1) Del_Line(-ALL) Search("//|[|W]|H3C/DOC>", NOERR) if(!EM){ BoL Del_Block(Cur_Pos, File_Size) } Replace("^/+", BEGIN+ALL+REGEXP+NOERR) // remove leading comment characters BoF while(! At_EoF){ // shorten lines longer than, say 100 (must be improved!!!!, perhpas wrapping?) Goto_Col(100) Del_Block(Cur_Pos, EoL_Pos) Line(1, NOERR+ERRBREAK) } } // For security; to prevent DI1() from beeing killed - but not foolproof! Replace("`","'", BEGIN+ALL+NOERR) Replace("||","!", BEGIN+ALL+NOERR) // find longest line #103=0 BoF while (! At_EoF) { EoL if (Cur_Col > #103) { #103=Cur_Col } Line(1, NOERR) } // Create a line of underscores of (hopefully) appropriate length // to size the dialog's width. // (Due to the used proportional font it's only guessing!) BoF Ins_Char(95, COUNT, Max(37,#103)) Ins_Newline(1) BoF Reg_Copy(106, 1) Del_Line(1) // find longest "paragraph" ==> #104 BoF #104=0 #105=1 while (! At_EoF) { Search("|<--", NOERR) if (EM) { EoF } if ((Cur_Line - #105) > #104) { #104=Cur_Line - #105 } Line(1, NOERR+ERRBREAK) #105=Cur_Line } // make all "paragraphs" equal length BoF #105=1 while (! At_EoF) { Search("|<--", NOERR) if (EM) { EoF } else { BoL Del_Line(1) } if ((Cur_Line - #105 + At_EoF) < #104) { Ins_Newline(#104 - Cur_Line + #105) } #105=Cur_Line } BoF // scroll through the text Reg_Set(104, "&Next") // button label while (! At_EoF) { Reg_Copy(105,#104) #105=Cur_Line Line(#104, NOERR) if (At_EoF) { // change the button label if at EoF Reg_Set(104, "E&nd") } #105=Cur_Line - #105 // remember the number of lines gone forward #103=Dialog_Input_1(103,^`|@(103)`, `|@(105)`, `|@(106)`, `[&Previous]`,`.i[|@(104)]`,`[&Cancel]`^,SET+APP+CENTER,0,0) if (#103 == 1) { // [Previous] Reg_Set(104, "&Next") Line(-#104-#105, NOERR) continue } if (#103 != 2) { // not [Next] break } } Buf_Quit(OK) Buf_Switch(#106) Reg_Pop(103,106) // restore used registers Num_Pop(103,106)