// SALLBUFF.VDM - Search all buffers. // Implements {SEARCH, Search all buffers}. // // Originally by: Thomas C. Burt, Greenview Data, Inc. // Last change: 04/23/97 // // little modifications by Ch.Ziemski 06.24.1999 , see //*CZ* // mod. fpor 5.20 DI1 // // // Requires: VEDIT 5.00 or later. // // From VEDIT: Select {SEARCH, Search all buffers}. // // Description: Prompts user for search string and sets normal search string. // Uses currently defined search string if just [ENTER] pressed. // Searches current edit buffer from current position. // Searches all remaining edit buffers with open output files. // Searches original edit buffer upto original edit position. // //////////////// // // Edit Buffer Usage: // 33 Temporary work buffer // // Text Register Usage: // 121 Search string // // Numerical Registers: // 109 Save state of -MORE- flag // 110 Register number this macro is executing in // 111 Register number of locked-in ("breakout") macro // 112 Original window number // 113 Original edit buffer // 114 Original edit position // 116 Current state of SR_CASE_OPT and SR_MODE_OPT (Case Sensitive, Mode) // 117 Current string delimiter or result of search // // // Initialize some variables and "help" window. // #109 = Config(S_E_MORE,0) // Save original Config value; disable #112 = Win_Num // Save original window number #113 = Buf_Num // Save original buffer number #114 = Cur_Pos // Save original edit position #116 = 0 // Assume pattern matching, not case sensitive if (Config(SR_MODE_OPT)==0) { #116 += SIMPLE } if (Config(SR_MODE_OPT)>=2) { #116 += REGEXP } if (Config(SR_MODE_OPT)==3) { #116 += MAX } if (Config(SR_CASE_OPT)) { #116 += CASE } Win_Delete('h') // Delete any existing 'H' window Win_Reserved('h',1,BOTTOM+NOBORDER) // Create help window // // Setup for macro breakout processing. // #110 = Macro_Num // Currently executing register #111 = 102 // Breakout trapping register Reg_Prot(#111,#111,0) // Unprotect breakout trapping reg Reg_Set(#111,`Call(#110,"Wipe_Up") // Setup for trapping breakouts Break_Out(EXTRA) `) Visual_Macro(CLEAR) // Allow [CANCEL] to breakout Reg_Lock_Macro(#111,EXTRA) // Enable breakout trapping Reg_Prot(#111,#111,2) // Protect breakout trapping macro // // Prompt user for search string. // Win_Switch('h') // Switch to help window Win_Color(112) Win_Clear() // Erase with reverse video background if (OS_Type==1) { //*CZ* begin // if there is a block highlighted, use it as default search string if(Block_Begin != -1){ if(Block_End == -1){ Block_End(Cur_Pos) } Reg_Copy_Block(121,Block_Begin,Block_End) Block_Begin(Clear) }else{ Reg_Empty(121) } //*CZ* end Message("Use empty input line for previous VEDIT search string; press <\> to abort",EXTRA) #117=DI1(121,"'Search all buffers','Search:','?? '",@(121),APP+CENTER,0,0) if (#117==0 || #117==2) { Goto Wipe_Up } } else { Message("Press for previous VEDIT search string to abort") Get_Input(121,"Enter search string: ",NOCR|STATLINE) } // Reg[121] = search string, perhaps if (Reg_Size(121)==0) { // If just [ENTER] entered Buf_Switch(33) // Enter a temporary buffer Del_Block(0,EOB_Pos) // Erase anything in the buffer Out_Ins() // Divert output into the buffer SR_Display(EXTRA) // Get search/replace strings Out_Ins(CLEAR) // Restore normal output BOF(LOCAL) // Goto buffer begin #117=Cur_Char // Get search string delimiter do { // Look for search string terminator Char() } while (Cur_Char != #117) RCB(121,1,Cur_Pos) // Reg[121] = current search string Buf_Quit(OK) // Release the temporary buffer Buf_Switch(#113) // Reenter original buffer } SR_Set(@121) // Set VEDIT search again string // // Issue "search next occurrence" help message. // Win_Switch('h') // Switch to help window Win_Color(112) Win_Clear() // Erase with reverse video background Message("[VISUAL EXIT] (<\>) to search again [VISUAL ESCAPE] (<\>) to quit",EXTRA) // // Begin searching. // Win_Switch(#112) // Reenter original window #117 = Search(@121,CONFIRM|NOERR|#116) // Find/highlight first occurrence do { repeat (ALL) { if (#117==0) { Break } // Exit loop when no more occurrences Config(S_E_MORE,#109) // Restore user value Visual() // Show occurrence in visual mode Config(S_E_MORE,0) // Disable -MORE- option SR_Set(@121) // Reset VEDIT search next string #117 = Search("",CONFIRM|NOERR|#116) // Highlight next occurrence } // Repeat loop Buf_Switch(Buf_Next) // Switch to next output buffer BOF // Goto start of the buffer #117 = Search(@121,CONFIRM|NOERR|#116) // Find/highlight first occurrence } while (Buf_Num != #113) // Exit when original buffer reentered // // Search from beginning of original file upto original edit position. // if (CurPos > #114) { Goto_Pos(#114) #117 = 0 } repeat (ALL) { if (#117==0) { Break } // Exit loop when no more occurrences Config(S_E_MORE,#109) // Restore user value Visual() // Show occurrence in visual mode Config(S_E_MORE,0) // Disable -MORE- option SR_Set(@121) // Reset VEDIT search again string #117 = SB("",CurPos,#114,CONFIRM|NOERR|#116) // Highlight next occurrence } // Repeat loop on [VISUAL EXIT] // // Issue final message; clean up and exit macro. // if (OS_Type==1) { DI1(121,"'All buffers searched','Press [Ok] to continue...'",APP+CENTER+SUPPRESS,0,0) } else { GK("All buffers searched. Press any key to continue...",STATLINE|RAW) } :Wipe_Up: Reg_Prot(#111,#111,0) // Unprotect breakout macro Reg_Lock_Macro(CLEAR) // Disable Break-out trapping Win_Delete('h') // Remove help window Config(S_E_MORE,#109) // Restore user value Break_Out(EXTRA) Return