home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / tools / aurora21 / booklist.aml < prev    next >
Text File  |  1995-08-10  |  3KB  |  96 lines

  1. /* ------------------------------------------------------------------ */
  2. /* AML Macro:    BOOKLIST.AML                                         */
  3. /* Written by:   nuText Systems                                       */
  4. /*                                                                    */
  5. /* Description:  This macro lists all bookmarks in the current edit   */
  6. /*               session and displays them in a popup menu with their */
  7. /*               positions and the text at the bookmark. Selecting a  */
  8. /*               bookmark from the menu will move the cursor to the   */
  9. /*               bookmark.                                            */
  10. /*                                                                    */
  11. /* Usage:        Select this macro from the Macro List (on the Macro  */
  12. /*               menu), or run it from the macro picklist <shift f12> */
  13. /* ------------------------------------------------------------------ */
  14.  
  15.   include bootpath "define.aml"
  16.  
  17.   // temporary bookmark name
  18.   tempbook = "@T"
  19.  
  20.   // save the current bufferid
  21.   oldbuffer = getcurrbuf
  22.   buffer = oldbuffer
  23.  
  24.   // create a popup menu buffer
  25.   bookbuf = createbuf
  26.  
  27.   // cycle through all buffers
  28.   while buffer do
  29.  
  30.     // make 'buffer' the current buffer
  31.     gotobuf buffer
  32.  
  33.     // get the top bookmark
  34.     bookmark = getcurrbook buffer
  35.     if bookmark then
  36.  
  37.       // save the current cursor position and window view in
  38.       // a temporary bookmark (can't use pushcursor because it
  39.       // won't save the window view - gotobook changes the
  40.       // window view)
  41.       setbook tempbook
  42.  
  43.       // cycle through the bookmarks for this buffer
  44.       while bookmark do
  45.         if bookmark <> tempbook then
  46.           // move cursor to the bookmark (and change the window view)
  47.           gotobook bookmark
  48.           // add the bookmark info to the menu buffer
  49.           addline (pad bookmark 7 'l') +
  50.                   (pad (getbufname) 20 'l') + '  ' +
  51.                   (pad 'C' + getcol 5 'l') + ' ' +
  52.                   (pad 'L' + getrow 8 'l') + ' ' +
  53.                   (gettext  (getlinebeg))
  54.                   '' '' bookbuf
  55.         end
  56.         bookmark = getprevbook bookmark
  57.       end
  58.  
  59.       // restore the cursor position and window view
  60.       // and destroy the temp bookmark
  61.       gotobook tempbook
  62.       destroybook tempbook
  63.     end
  64.     buffer = getprevbuf buffer
  65.   end
  66.  
  67.   // make the popup menu buffer the current buffer
  68.   gotobuf bookbuf
  69.  
  70.   if getlines > 1 then
  71.  
  72.     // delete the first blank line
  73.     delline 1 1
  74.  
  75.     // sort based on bookmark id
  76.     markline 1 (getlines) 'T'
  77.     sortblock 'i' 'T'
  78.     destroymark 'T'
  79.  
  80.     // display the menu
  81.     mark = popup bookbuf "Bookmarks"  70
  82.     gotobuf oldbuffer
  83.  
  84.     // goto the bookmark if it was selected
  85.     if mark then
  86.       gotobook2 mark [1 : posnot ' ' mark [1:7] 'r']
  87.     end
  88.  
  89.   // no bookmarks - display message
  90.   else
  91.     msgbox "No bookmarks found."
  92.   end
  93.   destroybuf bookbuf
  94.   gotobuf oldbuffer
  95.  
  96.