//Message-Id: <3.0.1.16.19971209205125.3a0762ea@popd.ix.netcom.com> //X-Sender: jawilson@popd.ix.netcom.com //X-Mailer: Windows Eudora Light Version 3.0.1 (16) //Date: Tue, 09 Dec 1997 20:51:25 //To: aurora-editor@sfu.ca //From: Jim Wilson //Subject: LSTFILES Macro //Mime-Version: 1.0 //Content-Type: text/plain; charset="iso-8859-1" //Content-Transfer-Encoding: quoted-printable // //And now, more from the macro that just won't go away... :-) // //Yup, I'm at it again -- making modifications to the LSTFILES macro. This //one is fairly straightforward and falls under the catagory of 'why didn't I //do that in the first place'. // //The last version of the macro displayed two input boxes if you wanted to //have a match in both the files name and directory. This version will //display only one. Also, you couldn't select options in an interactive way. //That too has been fixed. // //If you run the macro without any arguments a standard-issue dialog box will //pop up, allowing you to specify any option you'd like. Much cleaner. // //As always, let me know if you have any problems with it. // //Jim // // /* ------------------------------------------------------------------ */ /* Macro: LSTFILES.AML */ /* Written by: Jim Wilson */ /* */ /* Description: Macro used to display a list of files being edited */ /* WITHOUT displaying the path before the file name. */ /* This makes jumping from one file to the next a */ /* matter of typing the first letter(s) of the actual */ /* file name, unlike the original Aurora 'filelist' */ /* function where the path name prevents you from doing */ /* that. */ /* */ /* Version: 1.0 -- 8/97 */ /* ----------- */ /* Initial version. */ /* */ /* */ /* 2.0 -- 10/97 */ /* ------------ */ /* Combined the original LSTFILE1 and LSTFILE2 into a */ /* a single program called LSTFILES. */ /* */ /* Modified the window title to show the total number */ /* of files being edited. */ /* */ /* Added a function that adjusts the window size if a */ /* lot of files are to be displayed in the popup. */ /* */ /* Added the 'f' argument (full) to display the path */ /* as well as the file name. */ /* */ /* Added the 'n' argument (numbers) to display a number */ /* before each file so you can use that to jump from */ /* one file to the next. */ /* */ /* */ /* 2.0a -- 10/97 */ /* ------------- */ /* Displays an asterick at the end of any file name */ /* that has been modified. */ /* */ /* */ /* 2.1 -- 11/97 */ /* ------------ */ /* Changed the 'f' argument to 'w' (Wide display) to */ /* avoid conflicts with the new definiton of the 'f' */ /* argument. */ /* */ /* Added the 'f' argument (File name) so you can use a */ /* character pattern to narrow down the displayed */ /* files to only those that match your search pattern */ /* in the files name. */ /* */ /* Added the 'd' argument (Dir name) so you can use a */ /* character pattern to narrow down the displayed */ /* files to only those that match your search pattern */ /* in the files path. */ /* */ /* You can use both the 'f' and 'd' options together */ /* to search for matches in the files name AND dir. */ /* When used this way you will get two dialog boxes, */ /* one for the name and another for the directory. */ /* */ /* Note that DOS wildcards are not supported -- the */ /* search is for character patterns only. */ /* */ /* */ /* 2.2 -- 12/97 */ /* ------------ */ /* Removed the 'f' and 'd' arguments and instead made */ /* those selections accessable from a single dialog */ /* box. The 'w' (Wide display) and 'n' (Numbered lines) */ /* arguments are also accessable from this same dialog */ /* box. */ /* */ /* ------------------------------------------------------------------ */ include bootpath "define.aml" var DirSpec, FileName, FileSpec, NumOfSpaces, Path, ShowNumbers, WideDisplay Spaces = " " // used to pad output Options = arg 2 // grab any args passed PadWidth = 14 // space for file name BufferName = "LstFiles" // buffer name TotalMatched = 0 // total files being edited CurrentFile = getcurrbuf // save current file number function GetOptions // dialog box if no options were selected dialog "LSTFILES" 50 9 "c" field "&File Pattern to Match: >" 2 2 25 '' '_LstFileNames' field "&Dir Pattern to Match : >" 2 4 25 '' '_LstDirNames' groupbox 'Display Options' 4 6 (menu '' item " [ ] &Wide" item " [ ] &Number Lines " end) '' '' 'wn' button "O&k" 35 6 8 button "&Cancel" 35 8 8 if (getdialog ref FileSpec ref DirSpec ref Options) <> 'Ok' then return FALSE // bail out if hit else addhistory "_LstDirNames" DirSpec // add file/dir names to history addhistory "_LstFileNames" FileSpec return TRUE // return success end endfunction function SaveName // save selected name to array TotalMatched = TotalMatched + 1 // add one to counter for # of files if? WideDisplay // setup filename for displaying (databuf BufferName ((if? ShowNumbers TotalMatched:2 '') + ' ' + FileName + Spaces[1..NumOfSpaces] + (if? (bufchanged? CurrentFile) '* ' ' ') + Path) end) (databuf BufferName ((if? ShowNumbers TotalMatched:2 '') + ' ' + FileName + (if? (bufchanged? CurrentFile) ' *' ' ')) end) endfunction if? Options == '' (if? not (GetOptions) return) '' // dialog box if no options specified if? (pos 'w' Options 'i') (WideDisplay = TRUE) (WideDisplay = FALSE) // setup for display window type if? (pos 'n' Options 'i') (ShowNumbers = TRUE) (ShowNumbers = FALSE) // setup for display of numbers while CurrentFile do FileName = upcase (getname (getbufname CurrentFile)) // grab just the file name Path = upcase (getpath (getbufname CurrentFile)) // grab just the path name NumOfSpaces = PadWidth - length (FileName) // calculate number of spaces to pad display if FileName then // if a valid file name was found if? (not FileSpec and not DirSpec) (SaveName) // no other arguments if? (DirSpec and not FileSpec and (pos DirSpec Path 'i')) (SaveName) // 'p' argument if? (FileSpec and not DirSpec and (pos FileSpec FileName 'i')) (SaveName) // 'f' argument if? (FileSpec and DirSpec and (pos FileSpec FileName 'i') and (pos DirSpec Path 'i')) (SaveName) // 'f' and 'p' arguments endif CurrentFile = getprevbuf CurrentFile // get next file name endwhile if TotalMatched == 0 then // if nothing was found msgbox 'No matches found for ' + (if? FileSpec 'files "' + FileSpec + '"') + (if? DirSpec (if? FileSpec ' and ') + 'dirs "' + DirSpec + '"') 'Error' 'b' return endif Selected = popup BufferName // setup title and window size (if? WideDisplay ('File Name ÄÄÄÄ Directory Name ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Files: ') ('Files: ')) + TotalMatched (if? WideDisplay (60) (15)) // popup window width (if? TotalMatched > (getvidrows)-8 (getvidrows)-8) // popup window height destroybuf BufferName // remove temp buffer if Selected then // TRUE if a file was chosen CurrentFile = getcurrbuf // grab current file again case ShowNumbers // find 1st char in file name when TRUE FirstChar = (pos '[0-9] ' Selected 'x') + 2 when FALSE FirstChar = (pos '\ .' Selected 'ix') + 1 endcase case WideDisplay // find last char in file name when TRUE LastChar = (pos ' ' Selected) - 1 when FALSE LastChar = (length Selected) - 2 endcase while CurrentFile do FileName = upcase (getname (getbufname CurrentFile)) // get a file name if FileName == Selected [FirstChar..LastChar] then // if it matches selected file.. open (getbufname CurrentFile) // ..jump to it endif CurrentFile = getprevbuf CurrentFile // ..else get next file name endwhile endif // Regards, // Jim Wilson