// // di1-scroll2.vdm Christian Ziemski 21.08.2003 // // // This version uses paragraphs as suggested by Fritz Heberlein // // But not standard paragraphs: It's using "paragraphs" divided by -- // if (OS_Type != 1) { Statline_Message("Sorry, this macro requires VEDIT for Windows.") return } Num_Push(103,106) // save used registers Reg_Push(103,106) // ----- user configurable section ------------------------------------------- Reg_Set(103, "Info - Demo for DI1-SCROLL2.VDM") // Title Reg_Set(104,^This macro generates a dialog window with free text. You can page forward/backward through this text. -- The text is given via T-Reg 104 to this macro. The number of lines to display at once isn't fixed as in version 1 of this macro. -- Here are used special "paragraphs" of text divided by "--" at BoL. That way it's possible to have empty lines in the text for make it better readable. T-Reg 103 contains the title to be displayed in the dialog. -- This way you can implement an advanced popup (e.g. for help infos or the like.) ^) // ---------------------------------------------------------------------------- Buf_Switch(Buf_Free(EXTRA)) Reg_Ins(104) // 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) Reg_Pop(103,106) // restore used registers Num_Pop(103,106)