// ========================================================================== // // HYPERTXT.VDM STRIPPD VERSION FOR BUG FINDING!!!! // // (C) Christian Ziemski 2/1994 // // This macro makes it possible to navigate through an ordinary text file // (or more than one!) like with a WWW browser (o.k. not exactly...) // // The links and entries are marked visible with [], {} and @. // // Additionly the macro is able to convert the text into HTML code. // // (The default file extension for hypertext is "htx" here.) // // For syntax highlighting it uses the file HYPERTXT.SYN. // // I'm really not a master of words, and this macro has many functions so // please read some more explanations below in the help function (:HELP:). // // Optimized for the Windows versions of VEDIT. Should be work with DOS too. // // -------------------------------------------------------------------------- // // Buffer: // ------- // 1-.. Text // 30: for the HTML-Generation // XBUF1: History // XBUF2: for start preparations, date manipulations etc. // // Text-Register: // -------------- // 9: List of entries // // 76: temp. for directory // 77: for HTXDEF-directory // 78: for Collect // 79: for Collect // 80: for HTML // 81: for HTML // 82: for HTML // 83: temp. // 91: for Dialog_Input_1 // 92: temp. // 93: actual Parenth.close of the link // 94: text foer info- and errormessages // 95: temp. // 96: new target file // 97: actual file // 98: buffer at start // 99: searchstring as parameter (optional) at start // 100: this macro itself // 116: Mouse-double-click-event-macro // // num.register: // ------------- // 68: Flag for VEDIT file (0) or Windows start file (1) // 69: temp. // 70: marker for path-type: 0= no path, 1=rel.path, 2=absol.path, 3=absol.path+Drive // 71: marker for Win_Vert line link jump (with Marker(1)) // 72: marker for Win_Vert line link jump (with Marker(2)) // 73: marker for Win_Vert line link jump (with Marker(3)) // 74: marker for Win_Vert line link jump (with Marker(4)) // 75: marker for Win_Vert line link jump (with Marker(5)) // 76: marker for Win_Vert line link jump (with Marker(6)) // 77: marker for Win_Vert line link jump (with Marker(7)) // 78: return level 0..7 for 77..71 / 7..1 // 79: buffer number for tests and open // 80: flag, if LASTFILE load should be forced // 81: position in old/new file (line) // 82: for SEARCH // 83: for SEARCH // 84: for SEARCH // 85: for SEARCH // 86: for print dialog // 87: flag for file loading via [...] or filebox // 88: temp., for HTML generation // 89: position in old/new file // 90: flag for aktive file // 91: temp. marker // 92: temp. marker // 93: temp. marker // 94: marker for Win_Vert line at ListeEinträge // 95: merker for Win_Vert line at Merkersprung // 96: temp. for Taste-Warten // 97: flag for type of link ( [] or {} ) 91 or 123 // 98: buffer name // 99: buffer number // // Textmarker (per buffer): // ----------------------- // 1 : pos. before GOLINK 7. // 2 : pos. before GOLINK 6. // 3 : pos. before GOLINK 5. // 4 : pos. before GOLINK 4. // 5 : pos. before GOLINK 3. // 6 : pos. before GOLINK 2. // 7 : pos. before GOLINK 1. // 8 : TextPosition // 9 : pos. before CLENTRY // // -------------------------------------------------------------------------- Config( C_COMMENT, "Color for comments", 121 ) Config( C_W_COMMENT, "Color for comments", 121 ) Config( C_NUMBER, "Color for numeric", 31 ) Config( C_W_NUMBER, "Color for numeric", 31 ) Config( C_STRING, "Color for numeric", 124 ) Config( C_W_STRING, "Color for numeric", 124 ) Config( PG_E_SYNTAX, 1) Syntax_Load("|(USER_MACRO)\HYPERTXT.SYN") Config_Tab(5,9,17,25,33,41,49,57) Config( PG_AUTO_IND, 1, ALL) // Auto-Indent on Config( SR_CASE_OPT, 0) // case insensitive Search #78 = 0 // level 0 of the return hierarchy #80 = 0 // don't force LASTFILE #90 = 0 // flag for loaded file Key_Add("F12", "[VISUAL EXIT] Call(100,'GOLINK')",OK) Key_Add("F11", "[VISUAL EXIT] Call(100,'RETLINK')",OK) //----------------------------------------------------------------------------- Reg_Set(116, ` if(CC==13 || (CC==32 && CC(-1)==32 && CC(+1)==32)){ Call(100,'RETLINK') }else{ Call(100,'GOLINK') } return `) //----------------------------------------------------------------------------- // clear something for better performance Buf_Switch(Buf_Free) // temp. buffer File_Save_As("|(USER_MACRO)\hypertxt.tmp", NOMSG+OK) // necessary because of register size Reg_Ins(100) Search(":STARTRAW:",BEGIN+ADVANCE+COUNT,2) // (Bug: bei COUNT ist ADVANCE zwingend !!!??? Begin_Of_Line Del_Line(-MAXNUM) // delete all lines from Bof up to here Replace("//|Y|>","",NOERR+ALL) // delete comments Replace("|W|>","",NOERR+BEGIN+ALL) // delete trailing whitespaces // Move to @98 because a running register can't be modified. // Copy stripped macro back to @100 and run it Reg_Set(98,"BOF Reg_Copy(100,MAXNUM) Buf_Quit(OK) Buf_Switch(1) Chain(100)") Chain(98) // ------------------------------------------------------------------------- // some more start preparations :STARTRAW: Reg_Empty(98) // Problem bei leerem Reg.99 (Bug in VEDIT) !!!??? if (Reg_Size(99)>0) { Search("|@(99)", NOERR+SET) } Visual_Macro(8) // no "press any key ... Return // ------------------------------------------------------------------------- :GOLINK: #91 = Cur_Pos // remember position if((Cur_Char==91) || (Cur_Char==123)) { // make the link more sensible Char(1) } if((Cur_Char(-1)==93) || (Cur_Char(-1)==125)) { // make the link more sensible Char(-1) } Search("|{[,|H7B,],|H7D}",REVERSE+NOERR) // search previous parenth. if((Error_Match<>0) ) { // if not found Reg_Set(94, "Not within a link!") Goto ERROR } #97=Cur_Char // flag: 91 or 123 Out_Reg(93) Type_Char(#97+2) // set approp. parenth.close Out_Reg(CLEAR) #92=Cur_Pos+1 // position after parenth.open if(Match("[\[\{].*[\]\}]", REGEXP+ADVANCE) !=0) { Reg_Set(94, "No Link") Goto ERROR } if(#97==123) { Goto FILE } // if file link Reg_Copy_Block(95,#92,Cur_Pos-1) // remember text between [ and ] Begin_Of_File() Search("|<@|@(95)|X",ADVANCE+NOERR) // search entry @... if(Error_Match) { Statline_Message("No entry found. Searching again (not at line begin)!") Begin_Of_File() Search("|<|W@|@(95)",ADVANCE+NOERR) // search entry @... with leading whitespaces if (Error_Match) { Reg_Set(94, "Entry doesn't exist!") Goto ERROR } Statline_Message("Entry becomes left justified!") Begin_Of_Line while((Cur_Char==32)||(Cur_Char==9)) { DelChar(1) } } Line(2) // new 21.11.2000 #98=Buf_Num // remember jump in history Buf_Switch(XBUF1) Begin_Of_File Ins_Text("@") Ins_Newline(1) Buf_Switch(#98) Set_Visual_Line(1) if (#78==0){ Set_Marker(7,#91 ) // in Marker too #77 = Win_Vert // remember window line #78++ }else{ if (#78==1){ Set_Marker(6,#91 ) #76 = Win_Vert #78++ }else{ if (#78==2){ Set_Marker(5,#91 ) #75 = Win_Vert #78++ }else{ if (#78==3){ Set_Marker(4,#91 ) #74 = Win_Vert #78++ }else{ if (#78==4){ Set_Marker(3,#91 ) #73 = Win_Vert #78++ }else{ if (#78==5){ Set_Marker(2,#91 ) #72 = Win_Vert #78++ }else{ if (#78==6){ Set_Marker(1,#91 ) #71 = Win_Vert #78++ }else{ Set_Marker(7,Marker(6)) #77 = #76 Set_Marker(6,Marker(5)) #76 = #75 Set_Marker(5,Marker(4)) #75 = #76 Set_Marker(4,Marker(3)) #74 = #76 Set_Marker(3,Marker(2)) #73 = #76 Set_Marker(2,Marker(1)) #72 = #76 Set_Marker(1,#91) #71 = Win_Vert // Alert }}}}}}} Return // -------------------------------------------------------------------------- :ERROR: Alert() Statline_Message("|@(94)") Goto_Pos(#91) // goto old position Return // end macro :INFO: Alert() Statline_Message("|@(94)") Return // -------------------------------------------------------------------------- :RETLINK: #98=Buf_Num Buf_Switch(XBUF1) Begin_Of_File if(Cur_Char!=64){ // if not "@" => has been a file link Buf_Switch(#98) Goto LASTFILE } Del_Line(1) Buf_Switch(#98) if (#78==1){ Goto_Pos(Marker(7)) Set_Visual_Line(#77) #78-- }else{ if (#78==2){ Goto_Pos(Marker(6)) Set_Visual_Line(#76) #78-- }else{ if (#78==3){ Goto_Pos(Marker(5)) Set_Visual_Line(#75) #78-- }else{ if (#78==4){ Goto_Pos(Marker(4)) Set_Visual_Line(#74) #78-- }else{ if (#78==5){ Goto_Pos(Marker(3)) Set_Visual_Line(#73) #78-- }else{ if (#78==6){ Goto_Pos(Marker(2)) Set_Visual_Line(#72) #78-- }else{ if (#78>=7){ Goto_Pos(Marker(1)) Set_Visual_Line(#71) #78-- }else{ Alert }}}}}}} Return // -------------------------------------------------------------------------- :CHANGE2DIR: Call("GETDIR") Chdir("|@(76)", NOMSG) // change to that directory Return // -------------------------------------------------------------------------- :GETDIR: #99=Buf_Num Out_Reg(76) Name_Read(EXTRA+NOMSG+NOCR) // get complete path and name Out_Reg(CLEAR) Buf_Switch(XBUF2) Buf_Empty(OK) Reg_Ins(76) Search("\", REVERSE) // get path Del_Line(1) Reg_Copy_Block(76, 0, EoL_Pos) // save in @76 Buf_Switch(#99) Return // -------------------------------------------------------------------------- // continue here if it has been a file link (from GOLINK) ... :FILE: // #91 : pos. at call // #92 : pos after parenth.open Reg_Copy_Block(96,#92,Cur_Pos-1 ) // remember text between the parentheses #68=0 // it's a file to open with VEDIT if(Cur_Char() == '*'){ #68=1 // if in {..}* it's a file to open with Windows' start cmd } // #70: marker for path type: 0=no path, 1=rel.path, 2=absol.path, 3=absol.path+drive #99=Buf_Num Buf_Switch(XBUF2) Buf_Empty(OK) Reg_Ins(96, BEGIN) if(Cur_Char==92){ #70=2 } else { if(CC(1)==58){ #70=3 } else { Search("\", BEGIN+NOERR) if(Error_Match){ #70=0 } else { #70=1 } } } // quote it for long filenames with blanks Reg_Set(96,'"',INSERT) Reg_Set(96,'"',APPEND) Buf_Switch(#99) Goto_Pos(#91) // searching the file {...}: // // 1.) in the directory of the actual buffer // 2.) in the actual directory of VEDIT // 3.) in the directory pointed to from HTXDEF={...} // if(#70>1){ Reg_Empty(76) } else { Call("GETDIR") // save directory of the actual text in @76 Reg_Set(76,"\", APPEND) } if (File_Exist("|@(76)|@(96)", NOERR)==0) { // if file not found: if (File_Exist("|@(96)", NOERR)==0) { // if file again not found: SavePos() Search("HTXDEF={|Y}", BEGIN+NOERR) // search default directory of this doc Restore_Pos() if(Error_Match){ Reg_Set(94, "File not found (directory?)") // error and end Call("INFO") Return } else { Reg_Copy_Block(77, Cur_Pos+8, Cur_Pos+Chars_Matched-1) // extract def. directory if(#70<2){ Reg_Set(96,"\", INSERT) // create new target string Reg_Set(96,@77, INSERT) } // Restore_Pos() if (File_Exist("|@(96)", NOERR)==0) { // search again in DefDir Reg_Set(94, "File not found (directory?)") // not found: end Call("INFO") Return } } } } else { Reg_Set(96,@76, INSERT) } #87 = 1 if(#68==1){ System('start "" |@(96)', DOS+SIMPLE+OK+NOWAIT) // SUPPRESS Return }else{ Goto FILEBOX2 } // -------------------------------------------------------------------------- :FILEBOX: #87 = 0 :FILEBOX2: // save actual path+filename in @97 Out_Reg(97) Name_Write(EXTRA+NOCR+NOMSG) Out_Reg(CLEAR) #89 = Cur_Pos // remember actual file position #81 = Win_Vert // remember actual line number #90 = File_Size // flag for: file exists here if (#87==0) { // open Filebox and get new filename if (Get_Filename(95,"*.HTX")==2) { Return // if no file choosen: (""): end } else { Reg_Set(96,@95) } } // remember actual file infos #98=(Buf_Num) Buf_Switch(XBUF1) Begin_Of_File Num_Ins(#89,LEFT+NOCR) Num_Ins(#81,NOCR) Num_Ins(#78,NOCR) Num_Ins(#77,NOCR) Num_Ins(#76,NOCR) Num_Ins(#75,NOCR) Num_Ins(#74,NOCR) Num_Ins(#73,NOCR) Num_Ins(#72,NOCR) Num_Ins(#71,NOCR) Num_Ins(#95,NOCR) Ins_Text(" ") Reg_Ins(97) // Filename Ins_Newline(1) Buf_Switch(#98) Reg_Set(95,@96) Call("OPENFILE") Return // -------------------------------------------------------------------------- :LASTFILE: #98=(Buf_Num) Buf_Switch(XBUF1) Begin_Of_File if(File_Size==0) { Alert() Buf_Switch(#98) Return } if(#80==1) { while(Cur_Char==64) { Del_Line(1) } } if(File_Size==0) { Alert() Buf_Switch(#98) Return } // get old file infos #89=Num_Eval(ADVANCE) #81=Num_Eval(ADVANCE) #78=Num_Eval(ADVANCE) #77=Num_Eval(ADVANCE) #76=Num_Eval(ADVANCE) #75=Num_Eval(ADVANCE) #74=Num_Eval(ADVANCE) #73=Num_Eval(ADVANCE) #72=Num_Eval(ADVANCE) #71=Num_Eval(ADVANCE) #95=Num_Eval(ADVANCE) Search("|!|W") Reg_Copy_Block(97,Cur_Pos,EoL_Pos) // Filename Buf_Switch(#98) Reg_Set(95,@97) Call("OPENFILE") Goto_Pos(#89) // goto old position Set_Visual_Line(#81) #98=(Buf_Num) Buf_Switch(XBUF1) Begin_Of_File Del_Line(1) // delete this entry from history Buf_Switch(#98) Return // -------------------------------------------------------------------------- :OPENFILE: if((File_Attrib("|@(95)")&16)==16){ Chdir("|@(95)", NOMSG) Return } #79=File_Check("|@(95)") // File already open? if(#79==-1) { // no if(Buf_Free()>26) { // max. number opened buffers? (max. 26) #98=(Buf_Num) Buf_Switch(XBUF1) End_Of_File while(#79==-1) { // search oldest buffer Line(-1,NOERR) // last/oldest entry in history etc. if(Error_Flag) { // if no one found: take buffer 1 ... #79=1 Break } Search("\") Char(-2) Reg_Copy_Block(92,Cur_Pos,EoL_Pos) // get filename #79=File_Check("|@(92)") // check } Buf_Switch(#79) // switch to that (oldest?) buffer Update if (Is_Altered) { if(OS_TYPE==1) { #96=Dialog_Input_1(91,"'Close this file? (max. 26 BUFFER)', 'File has been modified. Save changes?', '[&yes]','[&no]' ",APP+CENTER+SUPPRESS,0,0) if((#96==2)||(#96==0)) { #96=110 } } else { #96 = Get_Key("File has been modified. Save ( /N) ",STATLINE+RAW) } if ((#96|32)<>110) { // if not n or N File_Save(NOMSG) // save } } Buf_Quit(OK) Buf_Switch(#79) } File_Open("|@(95)", CHGDIR+NOEVENT) // load new file and // neu testweise EVENT 29.09.99 // switch to that directory } else { Buf_Switch(#79) // to the already loaded file Call("CHANGE2DIR") } Return // ========================================================================== if (File_Exist("|@(96)", NOERR)==0) { // if file not found: SavePos() Begin_Of_File Repeat(ALL) { Search("HTXDEF={|Y}", NOERR) // search the default directory of this page if(Error_Flag){ Restore_Pos() // not found too: end Reg_Set(94, "File not found (directory?)") Call("INFO") Return } else { Reg_Copy_Block(77, Cur_Pos+8, Cur_Pos+Chars_Matched-1) // extract def. directory if (File_Exist("|@(77)\|@(96)", NOERR)==0) { // search again here Char(Chars_Matched) Continue } else { Restore_Pos() Reg_Set(96,"\", INSERT) // create new target string Reg_Set(96,@77, INSERT) Break } } } } #87 = 1 Goto FILEBOX2