home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------ */
- /* AML Macro: BOOKLIST.AML */
- /* Written by: nuText Systems */
- /* */
- /* Description: This macro lists all bookmarks in the current edit */
- /* session and displays them in a popup menu with their */
- /* positions and the text at the bookmark. Selecting a */
- /* bookmark from the menu will move the cursor to the */
- /* bookmark. */
- /* */
- /* Usage: Select this macro from the Macro List (on the Macro */
- /* menu), or run it from the macro picklist <shift f12> */
- /* ------------------------------------------------------------------ */
-
- include bootpath "define.aml"
-
- // temporary bookmark name
- tempbook = "@T"
-
- // save the current bufferid
- oldbuffer = getcurrbuf
- buffer = oldbuffer
-
- // create a popup menu buffer
- bookbuf = createbuf
-
- // cycle through all buffers
- while buffer do
-
- // make 'buffer' the current buffer
- gotobuf buffer
-
- // get the top bookmark
- bookmark = getcurrbook buffer
- if bookmark then
-
- // save the current cursor position and window view in
- // a temporary bookmark (can't use pushcursor because it
- // won't save the window view - gotobook changes the
- // window view)
- setbook tempbook
-
- // cycle through the bookmarks for this buffer
- while bookmark do
- if bookmark <> tempbook then
- // move cursor to the bookmark (and change the window view)
- gotobook bookmark
- // add the bookmark info to the menu buffer
- addline (pad bookmark 7 'l') +
- (pad (getbufname) 20 'l') + ' ' +
- (pad 'C' + getcol 5 'l') + ' ' +
- (pad 'L' + getrow 8 'l') + ' ' +
- (gettext (getlinebeg))
- '' '' bookbuf
- end
- bookmark = getprevbook bookmark
- end
-
- // restore the cursor position and window view
- // and destroy the temp bookmark
- gotobook tempbook
- destroybook tempbook
- end
- buffer = getprevbuf buffer
- end
-
- // make the popup menu buffer the current buffer
- gotobuf bookbuf
-
- if getlines > 1 then
-
- // delete the first blank line
- delline 1 1
-
- // sort based on bookmark id
- markline 1 (getlines) 'T'
- sortblock 'i' 'T'
- destroymark 'T'
-
- // display the menu
- mark = popup bookbuf "Bookmarks" 70
- gotobuf oldbuffer
-
- // goto the bookmark if it was selected
- if mark then
- gotobook2 mark [1 : posnot ' ' mark [1:7] 'r']
- end
-
- // no bookmarks - display message
- else
- msgbox "No bookmarks found."
- end
- destroybuf bookbuf
- gotobuf oldbuffer
-
-