home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 2001 - Modelworks Software
-
- /**
- @Tool: goUp~displays the bookmark just above the current
- line.
- @EndTool:
- @Summary: goUp~displays the bookmark just above
- */
-
- function DoCommand()
- {
- var editor = getActiveEditor();
- if (editor)
- {
- var bookmarkList = GetBookmarks(editor);
- if (bookmarkList)
- {
- var lineIndex = editor.getSelection().startLineIndex;
-
- var position = bookmarkList.getTailPosition();
- while (position && position.valid)
- {
- var bookmark = bookmarkList.getPrevious(position);
- if (bookmark.sortValue < lineIndex)
- {
- bookmark.go();
- return;
- }
- }
- }
- }
- }
-
- function GetBookmarks(editor) // Get sorted list of bookmarks in this editor
- {
- var path = editor.path;
- var bookmarkMap = getMapFile("Bookmarks");
- var list = newList();
-
- var position = bookmarkMap.getHeadPosition();
- while (position && position.valid)
- {
- var association = bookmarkMap.getNext(position);
- var bookmark = association.value;
- if (bookmark.valid() && bookmark.path == path)
- {
- list.addTail(bookmark);
- }
- }
-
- var position = list.getHeadPosition();
- while (position && position.valid)
- {
- var bookmark = list.getNext(position);
- bookmark.sortValue = bookmark.startLineIndex;
- }
- list.sort(compareItems);
- return list;
- }
-
- function compareItems(itemA, itemB)
- {
- // Assumes itemA and itemB are Bookmarks
- if ( itemA.sortValue < itemB.sortValue) return -1;
- if (itemA.sortValue == itemB.sortValue) return 0;
-
- return 1;
- }
-
- !!/Script
-