// // di1-scroll3.vdm Christian Ziemski 21.08.2003 // 22.08.2003 // // This version uses paragraphs as suggested by Fritz Heberlein // // But not standard paragraphs: It's using "paragraphs" divided by -- // // Read from file ... // First single line is used as title // // // #103 temp length of longest line // temp Cur_Line // temp lines of paragraph // temp Button# of DI1() // #104 length of longest paragraph // #105 temp // temp Cur_Pos // #106 Buf_Num of text to display // #107 Buf_Num of original text // // $103 title line // $104 button label // $105 current paragraph // $106 line of underscores if (OS_Type != 1) { Statline_Message("Sorry, this macro requires VEDIT for Windows.") return } Num_Push(103,107) // save used registers Reg_Push(103,106) #107=Buf_Num #106=Buf_Switch(Buf_Free()) File_Open('"|(HOME)\di1-scroll3.txt"') BoF Reg_Copy(103,1) // get title line // 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 Line(1) // skip title line 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 Line(1) // skip title line #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 } BoF Line(1) // scroll through the text Reg_Set(104, "&Next") // button label while (! At_EoF) { #105=Cur_Pos #103=Cur_Line Search("|<--", NOERR) if (EM) { EoF } #103=Cur_Line-#103 // number of lines of current paragraph Reg_Copy_Block(105, #105, Cur_Pos) // text of current paragraph // Add appropriate number of NewLines to a copy of the current paragraph // to make they all the same number of lines Buf_Switch(Buf_Free(EXTRA)) Reg_Ins(105) EoF Ins_Newline(#104 - #103) Reg_Copy_Block(105, 0, ALL) Buf_Quit(OK) Buf_Switch(#106) if (At_EoF) { // change the button label if at EoF Reg_Set(104, "E&nd") } #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(-1, NOERR) Search("|<--", REVERSE+NOERR+COUNT,2) if (EM) { BoF } Line(1) continue } if (#103 != 2) { // not [Next] break } Line(1, NOERR) } Buf_Quit(OK) Buf_Switch(#107) Reg_Pop(103,106) // restore used registers Num_Pop(103,107)