Return-Path: owner-aurora-editor@sfu.ca Return-Path: Message-Id: <3.0.1.16.19971124232319.3c7f572e@popd.ix.netcom.com> X-Sender: jawilson@popd.ix.netcom.com X-Mailer: Windows Eudora Light Version 3.0.1 (16) Date: Mon, 24 Nov 1997 23:23:19 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 I've made another change to the LSTFILES macro. This version allows you to narrow down the list of displayed files to selections you pick. You can base your search criteria on patterns that appear in the files name and/or the path. Let me know if you have a problem with it. Jim Wilson /* ------------------------------------------------------------------ */ /* 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. */ /* */ /* ------------------------------------------------------------------ */ include bootpath "define.aml" var FileName, Path, WideDisplay, ShowNumbers, NumOfSpaces 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 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? (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 if (pos 'f' Options 'i') then // for file name matching FileSpec = ask 'Enter character pattern' "_LstFileNames" '' 'File Name Pattern Match' 'd' 40 if? not FileSpec (return) // if hit then bail out if? FileSpec == ' ' (FileSpec = '') // if hit then default to all files if? FileSpec (addhistory "_LstFileNames" FileSpec) // if something was typed add it to history endif if (pos 'd' Options 'i') then // for dir name matching DirSpec = ask 'Enter character pattern' "_LstFileNames" '' 'Directory Name Pattern Match' 'd' 40 if? not DirSpec (return) // if hit then bail out if? DirSpec == ' ' (DirSpec = '') // if hit then default to all files if? DirSpec (addhistory "_LstFileNames" DirSpec) // if something was typed add it to history endif 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 FileSpec) + (if? DirSpec (if? FileSpec '" and "') + 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