// Copyright 1999-2001 by Lowell Dennis (Cyberclops, LLC) // // $Workfile: pick.vdm $ // // Pick list macros for VEDIT (5.00 or greater) // STACK.VDM must be loaded into the same text register. // ALLOC.VDM must be loaded into the same text register. // // $Log: X:/bios/lowell/tools/vedit/pick.vdv $ // // Rev 1.0 04 Oct 2001 10:21:50 Lowell // Initial revision. // ///////////////////////////////////////////////////////////////////// // INIT_PICK Initializes a pick list // Call with: // #80 = Pick list buffer number // Exits with: // RV = 0, if no error // :INIT_PICK: goto INIT_STACK /////////////////////////////////////////////////////////////////////// // ADD_PICK Stores data in a pick list // Call with: // #80 = Pick list buffer number // #81 = Text register containing data to be added // Exits with: // RV = 0, if no error // RV = 1, if no data to be pushed // :ADD_PICK: goto PUSH ///////////////////////////////////////////////////////////////////// // GET_PICK Retreives user selected item from the pick list // Call with: // #80 = Pick list buffer number // #81 = Text register into which data is to be retreived // Exits with: // RV = 0, if no error // Selected data in text register #81 // Number of item selected in #82 // RV = 1, if pick list empty // if temporary buffer not available // if no item selected (user pressed ESC) // :GET_PICK: Num_Push(80,81) Num_Push(83,89) #89 = Buf_Num // Save original buffer number #88 = #80 // Save pick list buffer number #87=Config(S_TOP_MARG) // Save original #86=Config(S_BOT_MARG) // scroll margins #85 = 0 // Line info buffer not allocated Buf_Switch(#88) // Switch to pick list buffer EOF // Goto start postition Line(-1) // indicator for last selection #84 = Num_Eval() // Get start position of last selection if (#84 == 0) { // If no selection ... Get_Key("Selection list empty!!!",STATLINE) goto PICK_ERROR } Call(MN,"ALLOC_BUF") // Allocate line info buffer if (RV != 0) {goto PICK_ERROR} // If allocate failed #85 = #80 for (#83=0; #84!=0; #83++) { // Count the number of data items Goto_Pos(#84) // Goto starting position Line(-1) // Goto previous start positon indicator #84 = Num_Eval() // Get start position } EOF() // Start with last data item for (; #83; #83--) { // Prepare for selection Line(-1) // Goto start positon indicator #84 = Num_Eval() // Get start position Del_Line(1) // Delete start position indicator Del_Char(-NC) // Delete newline #82 = Cur_Line // Calculate the Goto_Pos(#84) // number of lines #82 -= Cur_Line+1 // used by selection Buf_Switch(#85) // Switch to line info buffer do { // For each line in data item Num_Ins(#83,LEFT) // indicate item number } while (#82--) BOF() Num_Ins(0,LEFT+NOCR) // Indicate first line of data item BOF() Buf_Switch(#88) // Ready for next data item } Del_Line(-1) // Delete first line for (#84 = 0; !At_EOF;) { // Find longest line if (EOL_Pos > #84) { #84 = EOL_Pos } Line(1) } #83 = #84 // Determine if (#84 > 60) { // width of #83 = 60 // pick list window } #82 = Cur_Line // Get number of lines if (#82 > 20) { // Determine height of pick list window #82 = 20 } BOF() Win_Create(*,2,10,#82,#83) // Create pick list window Win_Switch(*) if (Is_Mono) { Win_Color(112) } // If monochrome use black chars on while else { Win_Color(32) } // If color use black chars on green Win_Clear() Win_Attach(*) if (#84 >= 60) { // If list fits ... Config(S_TOP_MARG,0) // Turn off scroll margins Config(S_BOT_MARG,0) } repeat (ALL) { Buf_Switch(#85) // Switch to line info buffer #82 = Num_Eval() // Get item number #84 = Cur_Line // Get starting line Line(1) S("|<0",NOERR+NORESTORE) Line(-1) #83 = Cur_Line // Get ending line Goto_Line(#84) // Go back to starting line Buf_Switch(#88) // Switch to pick list buffer Goto_Line(#84) Block_Begin(BOL_Pos) Goto_Line(#83) Block_End(EOL_Pos) Goto_Line(#84) Update() // Highlight current data item RCB(#81, BB, BE) // Extract data item Buf_Switch(#89) Buf_Switch(#88) #80 = Get_Key("Select desired item or press to Quit",STATLINE) if(#80=='E'+'S'*256) { // Escape Win_Delete(*) // Remove window goto PICK_ERROR } if (#80=='R'+'T'*256) { // Return Buf_Switch(#89) // Goto original buffer break // Break out of Repeat Loop } Buf_Switch(#85) // Switch to line info buffer #84 = Cur_Line // Save current line if (#80=='C'+'D'*256) { // Cursor Down Line(1) // Goto next item if (S("|<0",NOERR)==0) { Goto_Line(#84) // Don't go past EOF } goto PROCESS } if (#80=='C'+'U'*256) { // Cursor Up S("|<0",REVERSE+NOERR) // Previous item goto PROCESS } if (#80=='P'+'D'*256) { // Page Down Line(Win_Lines,NOERR) // Scroll one page down if (S("|<0",NOERR)==0) { // Next item S("|<0",REVERSE+NOERR) // Don't go past EOF } goto PROCESS } if (#80=='P'+'U'*256) { // Page Up Line(-(Win_Lines-1),NOERR) // Scroll one page up S("|<0",REVERSE+NOERR) // Previous item goto PROCESS } if (#80=='L'+'E'*256) { // End End_Of_File() // Goto S("|<0",REVERSE+NOERR) // last item goto PROCESS } if (#80=='L'+'B'*256) { // Home Begin_Of_File() // Goto first item goto PROCESS } :PROCESS: #84 = Cur_Line // Get current line Buf_Switch(#88) // Switch to pick list buffer Goto_Line(#84) // Goto same line } Win_Delete(*) // Remove pick window #80 = 0 Call(MN,"PICK_CLEANUP") return(0) :PICK_ERROR: Call(MN,"PICK_CLEANUP") return(1) :PICK_CLEANUP: Config(S_TOP_MARG,#87) // Reset scroll margins Config(S_BOT_MARG,#86) if (#85 != 0) { Buf_Switch(#85) Buf_Quit(OK) // Delete line info buffer } Buf_Switch(#88) Buf_Quit(OK) // Delete pick list buffer Buf_Switch(#89) // Switch back to original window Update() Num_Pop(83,89) Num_Pop(80,81) return