// ========================================================================== // // HYPERTXT.VDM // (C) Christian Ziemski 2/1994 // // // V3.28 translated to english 14.03.1999 // V3.29 new SF4 11.05.1999 // V3.30 sequence of entries rev. 19.05.1999 // +some minor improvements // 21.05.1999 // fix on printing 25.10.1999 // fix for {filenames} with blanks 27.06.2000 // V3.31 fix for loading files w/o abs. path 28.06.2000 // V3.32 f. 5.20 (HOME->USER_MACRO) 15.08.2000 // DI1 15.08.2000 // Fix SF5 04.09.2000 // Opt. SF4 24.10.2000 // V3.33 add. File Open with WIN 08.12.2000 // Modified SF4 (now to T-Reg 0) // Bug: Auto_Indent wird beim 2. File-Link abgeschaltet?!?! // ==> nach FO() ein weiteres PG_AUTO_IND 30.08.2001 // V3.34 VEDIT 6.0 05.10.2001 // V3.35 VEDIT 6.04.1 + mouse event macro 07.10.2002 // Config_Tab() commented out 20.11.2002 // SYS() for external programs fixed? 21.11.2002 // SYS() for external programs fixed? 10.10.2003 // tmp-file -> VEDIT_TEMP 05.12.2003 // testweise Config(PG_E_SYNTAX,1,LOCAL)09.09.2004 // Fix bzgl. Quotes um Dateinamen 30.11.2005 // // // 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:). // // There is a sample HTX file coming with the macro. // // -------------------------------------------------------------------------- // // Attention: for the :COLLECT: function this macro assumes that the // ========= directory "C:\tmp" exists! // If not, you should create it or modify the macro. // // // 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 // // 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 // // -------------------------------------------------------------------------- Win_Clear() Message(" H Y P E R T E X T loading ... ") Config( C_COMMENT, "Color for comments", 121 ) // blue Config( C_W_COMMENT, "Color for comments", 121 ) // blue Config( C_NUMBER, "Color for numeric", 31 ) // blue, invers Config( C_W_NUMBER, "Color for numeric", 31 ) // blue, invers Config( C_STRING, "Color for numeric", 124 ) // red Config( C_W_STRING, "Color for numeric", 124 ) // red 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("Shft-F1", "[VISUAL EXIT] Call(100,'HELP')",OK) Key_Add("Shft-F2", "[VISUAL EXIT] Call(100,'COLLECT')",OK) Key_Add("F12", "[VISUAL EXIT] Call(100,'GOLINK')",OK) Key_Add("F11", "[VISUAL EXIT] Call(100,'RETLINK')",OK) Key_Add("Shft-F5", "[VISUAL EXIT] Call(100,'SETLINK')",OK) Key_Add("Shft-F6", "[VISUAL EXIT] Call(100,'CLENTRY')",OK) Key_Add("Shft-F7", "[VISUAL EXIT] Call(100,'LSENTRY')",OK) Key_Add("Shft-F9", "[VISUAL EXIT] Call(100,'DATUM')",OK) Key_Add("Shft-F10", "[VISUAL EXIT] Call(100,'FIRSTLINK')",OK) Key_Add("Alt-F10", "[VISUAL EXIT] Call(100,'FILEBOX')",OK) Key_Add("Alt-F11", "[VISUAL EXIT] #80=1 Call(100,'LASTFILE')",OK) Key_Add("Shft-F8", "[VISUAL EXIT] Call(100,'PRINT')",OK) Key_Add("Alt-F9", "[VISUAL EXIT] Call(100,'TXT2HTM')",OK) // to the previous link [...] oder {...} Key_Add("Shft-F11", '[VISUAL EXIT] C(-1) S("[\[\{].*[\]\}]", REVERSE+REGEXP+NOERR) C(1)',OK) // to the next link [...] oder {...} Key_Add("Shft-F12", '[VISUAL EXIT] C(1) S("[\[\{].*[\]\}]", REGEXP+NOERR) if(EM){C(-1)} else {C(1)}',OK) // to the previous entry @... Key_Add("Ctrl-F11", '[VISUAL EXIT] L(-1) if(CC==64){C(-1)} S("|<@",REVERSE+NOERR) if(EM){L(1)} L(1) SVL(1)',OK) // to the next entry @... Key_Add("Ctrl-F12", '[VISUAL EXIT] S("|<@",ADVANCE+NOERR) if(!EM){L(1)} SVL(1)',OK) // remember the actual text position Key_Add("Ctrl-F9", "[VISUAL EXIT] SM(8,CP) #95=Win_Vert",OK) // go to the remembered text position Key_Add("Ctrl-F10", "[VISUAL EXIT] GP(Marker(8)) SVL(#95)",OK) // insert path and filename of the current file //Key_Add("Shft-F4", "[VISUAL EXIT] Out_Ins PATHNAME Out_Ins(CLEAR)",OK) // insert path and filename of the current file into TReg-0) Key_Add("Shft-F4", "[VISUAL EXIT] Reg_Set(0,PATHNAME)",OK) //----------------------------------------------------------------------------- Reg_Set(116,` if(At_EoF || (CC==13) || (CC==32 && CC(+1)==32)){ Call(100,'RETLINK') Update }else{ Call(100,'GOLINK') Update } `) //----------------------------------------------------------------------------- // clear something for better performance Buf_Switch(Buf_Free) // temp. buffer File_Save_As("|(VEDIT_TEMP)\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 //--------------------------------------------------------------------------- :HELP: Win_Clear() Statline_Message("press any key please ...") Get_Key(" H Y P E R T E X T V3.35 (C) C.Z. 2/94 - 10/2002 =========================================================================== Link in text: [name] ==> jump to entry: @name ********** Link in text: {filename} ==> load the file filename in VEDIT Link in text: {filename}* ==> load the file via WINDOWS' association F12 to the entry of [word] or load {file} (ditto via double click) F11 back to the position before pressing F12 (max. 7 levels) (=d.c. on spaces) AF11 back to the prev. file (jumps of the actual doc are away then) SF10 to the first link in the actual entry SF11/SF12 to the previous/next link [...] or {...} CF11/CF12 to the previous/next entry @... CF9/ CF10 remember text position / to that position SF4 insert current path\filename into text register #1 SF5 make word at cursor to a link [...] and create entry SF6 clear entry @... and deactivate all it's links SF7 create list of entries and put it into T-Reg 9 SF8 print (only the actual entry or all) SF9 insert date AF9 create a HTML document from this HTX text AF10 load new file SF2 extract and collect all lines with '!!' SF1 this help ",RAW) 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 // -------------------------------------------------------------------------- :SETLINK: if (Cur_Char==91) { // if on "[" Return // end (is already a link) } #91 = Cur_Pos // remember position Match("|F",ADVANCE+COUNT,1) if (Error_Match) { // if not on digit or letter Char(-1) // then test one character back too Match("|F",ADVANCE+COUNT,1) if (Error_Match) { Char(1) Return // if not yet: end } } Match("|!|I",ADVANCE+ALL) // end of word #92 = Cur_Pos // remember position of character after WORD Ins_Text("]") // insert "]" Do_Visual("\PW\") // back to word begin if (Cur_Char==91) { // if on "[" (already a link) Search("]") // search the "]" Del_Char(1) // and clear the too much "]" Block_Begin(CLEAR) Return // end } else { Char(-1) // if "[" is defined as word separator ! if (Cur_Char==91) { // again Search("]") Del_Char(1) Block_Begin(CLEAR) Return } if (! At_BOF) { Char(1) } } Reg_Copy_Block(95,Cur_Pos,#92 ) // remember the word Block_Begin(CLEAR) Ins_Text("[") // insert "[" #93 = Cur_Pos // remember position Begin_Of_File() Search("|<@|@(95)",ADVANCE+NOERR) // search appropr. entry if (Error_Match==0) { // if found Goto_Pos(#91) // back to old position Return // and end } else { // if not found Begin_Of_File() // search again, but not at line begin Search("@|@(95)",ADVANCE+NOERR) // search entry @... if (Error_Match==0) { Reg_Set(94, "Entry isn't positioned at line begin!") Call("INFO") Goto_Pos(#91) // back to old position Return // and end } Goto_Pos(#93) // back to old position } // // check the position of the new created link within the context // #92=Cur_Pos S("^@[^ ]", REVERSE+REGEXP+NOERR) // search for prev. entry (in an entry?) if(Error_Match){ // if no prev. entry found (= before any entry) S("[\[\{].*[\]\}]", REGEXP+NOERR) // search for next link if (Error_Match) { // if no next link S("[\[\{].*[\]\}]", REVERSE+REGEXP+NOERR) // search for prev. link if (Error_Match) { // if no prev. link End_Of_File() Ins_Newline(2) }else{ Char(1) // on the word of the found link Match("|Y]") Reg_Copy_Block(83,Cur_Pos, Cur_Pos+Chars_Matched-1) // remember the word Search("|<@|@(83)",BEGIN+ADVANCE+NOERR) // search appropr. entry Line(1) Search("|<@",ADVANCE+NOERR) // search next entry after the found one if (Error_Match) { // if no more entry End_Of_File() // Ins_Newline(2) } } }else{ Char(1) // on the word of the found link Match("|Y]") Reg_Copy_Block(83,Cur_Pos, Cur_Pos+Chars_Matched-1) // remember the word Search("|<@|@(83)",BEGIN+ADVANCE+NOERR) // search appropr. entry } }else{ // if entry found (= within an entry) #93=Cur_Pos // pos. of entry Line(1) Search("|<@",ADVANCE+NOERR) // search next entry after the found one if (Error_Match) { // if no more entry #69=-1 }else{ #69=Cur_Pos } Goto_Pos(#92) // on new created link again Search_Block("[\[\{].*[\]\}]", #93, #92, REVERSE+REGEXP+NOERR) // search for prev. link if (Error_Match) { // if no prev.link Search_Block("[\[\{].*[\]\}]", Cur_Pos, #69, REGEXP+NOERR) // search for next link if (Error_Match) { // if no next link if(#69==-1){ End_Of_File }else{ Goto_Pos(#69) Begin_Of_Line } Ins_Newline(1) }else{ Char(1) // on the word of the found link Match("|Y]") Reg_Copy_Block(83,Cur_Pos, Cur_Pos+Chars_Matched-1) // remember the word Search("|<@|@(83)", BEGIN+ADVANCE+NOERR) // search appropr. entry } }else{ // on prev. link Char(1) // on the word of the found link Match("|Y]") Reg_Copy_Block(83,Cur_Pos, Cur_Pos+Chars_Matched-1) // remember the word Search("|<@|@(83)",BEGIN+ADVANCE+NOERR) // search appropr. entry Line(1) Search("|<@",ADVANCE+NOERR) // search next entry after the found one if (Error_Match) { // if no more entry End_Of_File Ins_Newline(1) } } } Begin_Of_Line Ins_Text("@") // start entry with "@" Reg_Ins(95) // insert the new entry Ins_Text(" ") repeat ((78-Cur_Col) ) { // fill line with "*"'s Ins_Text("*") } Ins_Newline(3) Goto_Pos(#91) // back to old position Block_Begin(CLEAR) Search("]",ADVANCE+NOERR) // just behind the new created link Return // -------------------------------------------------------------------------- :FIRSTLINK: #91=Cur_Pos // remember position Char(1) Search("|<@",ADVANCE+REVERSE+NOERR) if (! Error_Match) { #92=Cur_Pos Search(" ") Reg_Copy_Block(95,#92,Cur_Pos) Search("[|@(95)]",BEGIN+NOERR) if (Error_Match) { Goto_Pos(#91) // back to old position } } Return // -------------------------------------------------------------------------- :LSENTRY: #91=Cur_Pos // remember position #94=Win_Vert Reg_Empty(9) Message(" This list of entries will be saved in T-Reg 9. ----------------------------------------------------- ") Search("|<@",BEGIN+ADVANCE+NOERR) while (! Error_Match) { #92=Cur_Pos if ((Cur_Char != 32) & (! AtEoL)) { Search(" ") Reg_Set(9, "[", APPEND) Reg_Copy_Block(9,#92,Cur_Pos,APPEND) Reg_Set(9, "]", APPEND) Reg_Set(9," ",APPEND) } Search("|<@",ADVANCE+NOERR) } Reg_Type(9) Goto_Pos(#91) Set_Visual_Line(#94) Return // -------------------------------------------------------------------------- :CLENTRY: Set_Marker(9,Cur_Pos) // remember position (Textmarker) Begin_Of_Line if (Cur_Char<>64) { // if there is no "@" Reg_Set(94, "This is not a (correct ?) entry line!") Call("INFO") Return } if(OS_TYPE==1) { #96=Dialog_Input_1(91,"'Delete entry', 'Really delete this entry?', '[&yes]','[&no]' ",APP+CENTER+SUPPRESS,0,0) if(#96==1) { #96=121 } else { #96=110 } // delete only on "y" } else { #96 = Get_Key("Really delete this entry? (y/n) ",STATLINE+RAW) } if ((#96|32)<>121) { // if not on "y" or "Y" Return // Abbruch } Block_Begin(CLEAR) Block_Begin(Cur_Pos) Char(1) // 1st character of the entry Search("|{|L, }",ADVANCE) // search next space or newline Reg_Copy_Block(95,Block_Begin+1,Cur_Pos-Chars_Matched ) // remember entry // C(1) // ? // #91=CP // ? Search("|<@",ADVANCE+NOERR) // seach next entry if (Error_Match) { // if no more entry found Goto_Pos(Last_Search_Pos) // GP(#91) Search("@|@(95)",ADVANCE+NOERR) // search again, but not at line begin if (Error_Match==0) { // if found now Alert() Statline_Message("Entry isn't positioned at line begin!") Search("@",REVERSE) // on the "@" } else { // or End_Of_File() // to end of text } Block_End(Cur_Pos) } else { Begin_Of_Line Block_End(Cur_Pos) // end of block just before the next entry } Del_Block(Block_Begin,Block_End) // delete block Begin_Of_File() repeat (ALL) { // endless loop for all entries Search("[|@(95)]",NOERR) // search appropr. link if (Error_Match) { Break } // end, if no more found DelChar(1) Ins_Text(" ") Search("|H5D") // search the "]" DelChar(1) Ins_Text(" ") } Goto_Pos(Marker(9)) // back to old position Return // -------------------------------------------------------------------------- :DATUM: // // Attention: The date is in european format here! dd.mm.yyyy // But easy to change... if ((Win_Hor>Cur_Col)) { repeat (Win_Hor-Cur_Col) { Ins_Text(" ") } } #99=Buf_Num // remember actual buffer Out_Reg(103) Date(NOCR+NOMSG) // date in engl. format Out_Reg(CLEAR) Buf_Switch(XBUF2) // temp. buffer Buf_Empty(OK) // clear Reg_Ins(103) // insert date string Begin_Of_File Replace("-",".",ALL) // -> europ. format Reg_Copy_Block(103,3,6) // month and day Del_Block(3,6) // switch them Reg_Copy_Block(103,0,File_Size,APPEND) // Buf_Switch(#99) // back to the text buffer Reg_Ins(103) // insert date 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 // System('start "|@(96)"', DOS+SIMPLE+OK) // +NOWAIT) // +SUPPRESS System('"|@(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) } // ? // .Config( PG_AUTO_IND) // File_Open("|@(95)", CHGDIR+EVENT) // load new file and // neu testweise EVENT 29.09.99 File_Open("|@(95)", CHGDIR+NOEVENT+MRU) // load new file and // switch to that directory Config( PG_E_SYNTAX, 1,LOCAL ) // testweise 09.09.2004 // .Config( PG_AUTO_IND) // Config( PG_AUTO_IND, 1, ALL) // Auto-Indent on // testweise 30.08.01, wieso wird das sonst gelöscht ???? // ChDir(CUR_DIR, NOMSG) // Statline_Message(CUR_DIR) } else { Buf_Switch(#79) // to the already loaded file Call("CHANGE2DIR") } Return // -------------------------------------------------------------------------- :TXT2HTM: Out_Reg(96) Name_Write(EXTRA+NOCR+NOMSG) Out_Reg(CLEAR) #98=Buf_Num Buf_Switch(XBUF2) // generate new filename Buf_Empty(OK) Reg_Ins(96, BEGIN) Block_Begin(0) Block_End(EOL_POS) // Workaround: capitalize the filename Do_Visual("\ME\BEU") Block_Begin(CLEAR) // \t (not \T) is interpreted in DI1() as Tab !! if(Match("<>")==0) { Alert() Statline_Message("Save file first, please!") BufQuit(OK) Buf_Switch(#98) Return } Replace(".HTX", ".HTM", BEGIN+NOERR) if(Error_Match) { End_Of_Line Ins_Text(".HTM") } Begin_Of_File Reg_Copy(96,1) // remember complete new filename Buf_Switch(30) // write HTX-Text in buffer 30 Update if(File_Exist(@96)) { #96=Dialog_Input_1(103,"'Creating new file', 'File |@(96) already exists. Overwrite?', '[&yes]','[&no]','[&cancel]'",APP+CENTER+SUPPRESS,0,0) if(#96==3){ BufQuit(OK) Buf_Switch(#98) Return } if((#96==2)||(#96==0)) { Get_Filename(96,"*.*") } } File_Save_As(@96, OK+NOMSG) // save for file buffering Reg_Ins(#98+BUFFER) // convert [..] and {..} in HTML-Tags Begin_Of_File while(ALL) { Search("[\[\{].*[\]\}]", REGEXP+NOERR+ERRBREAK) #97=Cur_Char // Flag 91 or 123 Out_Reg(93) Type_Char(#97+2) // set appropr. parenth.close Out_Reg(CLEAR) Char(1) Set_Marker(9,Cur_Pos) Match("|M|@(93)") // number of chars between [..] {..} Reg_Copy_Block(95,Cur_Pos,Cur_Pos+Chars_Matched - 1) // content of the link if(#97==91) { Search("|<@|@(95)", BEGIN+NOERR) if( ! Error_Match ) { // if there is the entry too Goto_Pos(Marker(9)) Char(-1) // on the parenth.open Replace("\[{.*}\]", '\1', REGEXP) } } else { if( FileExist(@(95)) ) { Goto_Pos(Marker(9)) Char(-1) // on the parenth.open Replace("\{{.*}\}", '\1', REGEXP) } } Goto_Pos(Marker(9)) } // insert HTML-Header Begin_Of_File Ins_Text("") Ins_Newline(1) Ins_Text("") Ins_Newline(1) Ins_Text("") Update if(OS_TYPE==1) { Dialog_Input_1(103,"'Document titel', 'Please type the title of the HTML-Document. (Will be visible in the WWW browser's title bar.)'",APP+CENTER,0,0) if((#96==2)||(#96==0)) { #96=110 } } else { Alert() get_input(103,"HTML Document title : ",STATLINE+NOCR) } Reg_Ins(103) Ins_Text("") Ins_Newline(1) Ins_Text("") Ins_Newline(1) Ins_Text(//) Ins_Newline(1) Ins_Text("
")
Ins_Newline(1)

// convert the entries @... into HTML-Tags and format the text

Reg_Set(80, '
@') Reg_Set(82, '') Begin_Of_File while(ALL) { Search("|<@", NOERR) if(Error_Match) { Break } if(Match("@|X")==0) { // check the empty entries |<@ |> DelChar(1) Ins_Text('

') Ins_Newline(1) } else { // real entries Replace("^@{.*} {.*}$", "
\N\@(80)\1\@(81)\1\@(82) \2
\N", REGEXP) } Line(1) Ins_Text("
")                   // maybe 
    for indenting Search("|<@|!|X", NOERR) // search the end of the actual entry if(Error_Match) { End_Of_File } Ins_Text("
") // maybe for end of indenting Ins_Newline(2) } // HTML-Footer End_Of_File Ins_Newline(1) Ins_Text("
") Ins_Newline(1) Ins_Text("") Ins_Newline(1) Ins_Text("") Ins_Newline(1) File_Save_As(@96, OK+NOMSG) Return // -------------------------------------------------------------------------- :PRINT: #91=Cur_Pos if(OS_TYPE==1) { #86=Dialog_Input_1(91,"'Printing', 'Print all of the document or only the actual entry?', '[&All]','[&Entry]','[Cancel]' ",APP+CENTER+SUPPRESS,0,0) if((#86==0)||(#86==3)) { #86=27 } if(#86==1){ #86=65 } } else { #86 = Get_Key("Print all (A) or only the actual entry (Default) (ESC=end)?",RAW) } if (#86==27) { visual_macro(8) Return } Update() if ((#86==65) || (#86==97)) { Begin_Of_File() } else { Char(1) Search("|<@",REVERSE+NOERR) if (Error_Match) { Char(-1) } else {Char(1) } Set_Visual_Line(1 ) } #4=Config(CM_SUP_ERR,2) // Suppress error handling; (save old values) #2=Config(P_TOP_MARG,0) // Disable page formatting, #3=Config(P_BOT_MARG,0) // allows macro to control entire page #5=Config(P_PAPER_L) // number of physical lines per page Out_Print() // Re-route output to the printer repeat (ALL) { // Main print loop repeat (#5) { // Print all lines per page if (Cur_Char==64) { Char(1) Break } // Start new page if "@" in 1st column if (At_EOF) { Goto END } // Branch on End-of-file Type(1) // Print 1 line, perform auto-buff if needed Line(1,NOERR) // Advance by 1 line } // End of loop for one page if (#86<>65 && #86<>97) { // if only actual entry if (Cur_Char<>32) { Break } // end on next real entry } Print_Eject() // Page-eject, start new page if (Cur_Char==^L) { Char(1) } // Ignore next char if it is a ; // prevents printing blank pages } //END of main print loop :END: Out_Print(CLEAR) // Turn off printer re-routing Print_Finish() // Finish print job Config(P_TOP_MARG,#2) // Restore original values... Config(P_BOT_MARG,#3) // " Config(CM_SUP_ERR,#4) // " Goto_Pos(#91) // back to old position Return // -------------------------------------------------------------------------- :COLLECT: #98=Cur_Pos // remember actual cursor pos. Begin_Of_File Reg_Empty(79) // collection register while (1==1) { Search("|{!!,|<@|! |?}",NOERR+ADVANCE+ERRBREAK) // search '!!' or entry with '@' Begin_Of_Line if(CHARS_MATCHED==3){ Reg_Copy(78,1) // remember entryline with '@' Reg_Set(78," ",INSERT) } else { Reg_Set(79,@78,APPEND) // get entyline if '!!'-line Reg_Copy(79,1,APPEND) // and save together in collection register Reg_Empty(78) } Line(1) } Goto_Pos(#98) // back to the old position #99=File_Check("C:\tmp\collect.tmp") // collection file if(#99==-1){ // ... not open Buf_Switch(Buf_Free) } else { Buf_Switch(#99) // ... already open Buf_Empty(OK) } Browse_Mode(CLEAR) Reg_Ins(79) // insert collected lines Browse_Mode(SET) File_Save_As("C:\tmp\collect.tmp",OK+NOMSG) Begin_Of_File 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