// // PRINTSYN.VDM V1.32 (C) Christian Ziemski 15.07.1999 // last change 15.08.2000 // // Requires VEDIT 5.20 // // Printing C-Code with Syntax Highlighting. (Using the original C.SYN) // // Maybe other *.SYN will work too, but tested only with C.SYN. // If you use another .SYN file make sure that it's format is similar to C.SYN! // (All 14 categories in the same order must be present!) // // Nested comments doesn't work correct up to now. // // // Because of problems with Windows' printer drivers this macro sends the text // directly to the printer via DOS-box! // // Attention: If you don't use a HewlettPackard compatible printer (PCL) // you have to modify this macro. // // The printer codes contain binary data. // So this macro should be copied/downloaded in binary mode only !!! // // // Categories: // ----------- // All MUST be present in this order but only those with a '*' are evaluated in this macro! // (Maybe a future version will do more ...) // // 1 Reserved1 * // 2 Reserved2 * // 3 Reserved3 * // 4 Reserved4 * // 5 Casesense1 // 6 Casesense2 // 7 Casesense3 // 8 Casesense4 // 9 Comment * // 10 Linecmt * // 11 Numeric // 12 Strings // 13 Escape // 14 Symbols // // //============================================================================== // // #90 buffer number original text // #91 buffer number formated printer output // #92 buffer number syntax definition // #93 category + temp // // 94 search command with syntax code // 95 syntax code // 96 printer start code // 97 printer end code // 98 printer initialization code // 99 temp. // //============================================================================== Reg_Push(94,99) Num_Push(90,93) #90=Buf_Num // the original text EoF RCB(99,0,CP) // for copying to other buffer (how better???) BS(Buf_Free) #91=Buf_Num // buffer for the formated printer output FSA("|(USER_MACRO)\PRINTSYN.TMP", NOMSG+OK) RI(99) BS(Buf_Free(EXTRA)) #92=Buf_Num // buffer for the syntax definition Ins_File("|(HOME)\C.SYN") // Load the syntax highlight file Call_File(101,"|(HOME)\LOADSYN.VDM") // and prepare it for processing BoF #93=1 // Category 1 Call(Macro_Num, "SETCODE") while( ! At_EoF) { // work through the syntax definition BB(CLEAR) BB(CP) S("|000") // delimiter BE(CP) RCB(95,BB,BE) Char(1) if(#93 < 5 || #93 == 9 || #93 == 10){ // not all categories... if(#93 == 9){ // if Comment RS(95,"|M",APPEND) BB(CP) S("|000") // delimiter between the comment begin and end string BE(CP) Char(1) RCB(95,BB,BE, APPEND) RS(94,@95) // build the new search command RS(94,'S("' , INSERT) // (because of double-parsing problems) RS(94,'",WORD+NOERR)' , APPEND) } else { if(#93 == 10){ // if LineCmt RS(95,".*$",APPEND) } } BS(#91) // printer output if(#93==9){ // if Comment BoF Call(94) // Search command while(! EM){ RI(96) Char(Chars_Matched) RI(97) Call(94) // Search command } } else { Replace("{\@(95)}","\@(96)\1\@(97)",BEGIN+ALL+WORD+REGEXP+NOERR) } } BS(#92) // syntax definition if(Cur_Char==0){ #93++ // next category Call(Macro_Num, "SETCODE") Char(1) } } BQ(OK) // close syntax definition BS(#90) // Dialog for print format or quit macro: if(OS_Type==1){ // Windows #93=Dialog_Input_1(99,"'Print with Syntax Highlight for C', 'Choose the way to print:', '[&Normal]','[&Compressed]','[&Quit]' ","",SCREEN+CENTER+SUPPRESS,0,0) } else { // DOS #93=Get_Key("Choose the way to print: (N)ormal, (C)ompressed / (Q) to quit: ",STATLINE) #93= #93 & 0xDF if(#93==78){ #93=1 } else { if(#93==67){ #93=2 } else { #93=0 } } } // set printer initialization codes or quit macro if(#93==1){ // Normal // printer initialization, HP-Laserjet: // Reset,Portrait,PC-8 charset,10 char. left margin,12 characters/inch,line-wrap RS(98,"E&l0O (10U&a10L(s12H&s0C") } else { if(#93==2){ // Compressed // Reset,Portrait,PC-8,10 char. left margin,compressed,12 lines/inch,line-wrap RS(98,"E&l0O(10U&a10L&k2S&l12D&s0C") } else { // Quit BS(#91) // printer output BQ(OK) BS(#90) // back to the original text BoF Reg_Pop(94,99) // Restore user's registers Num_Pop(90,93) return } } // now print the formatted text BS(#91) // printer output BoF RI(98, BEGIN) // insert printer initialization EoF IC(12) // final Form Feed File_Save(NOMSG+OK) System("copy /b |(USER_MACRO)\PRINTSYN.TMP LPT1", DOS+SIMPLE+NOMSG+OK) BQ(OK) // close printer output BS(#90) // back to the original text BoF Reg_Pop(94,99) // Restore user's registers Num_Pop(90,93) return // end // ----------------------------------------------------------- // Set the printer control codes :SETCODE: if(#93==1){ // Reserved1 RS(96,"(s3B") RS(97,"(s0B") // bold on / off } else { if(#93==2){ // Reserved2 RS(96,"(s3B") RS(97,"(s0B") // bold on / off } else { if(#93==3){ // Reserved3 RS(96,"(s3B") RS(97,"(s0B") // bold on / off } else { if(#93==4){ // Reserved4 RS(96,"(s3B") RS(97,"(s0B") // bold on / off } else { if(#93==9){ // Comment RS(96,"(s1S") RS(97,"(s0S") // italic on / off } else { if(#93==10){ // LineCmt RS(96,"(s1S") RS(97,"(s0S") // italic on / off }}}}}} return