home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 2001 - Miguel Angel Rojas G.
- // @Modified build 497 cm20010225
-
- /**
- @Tool: deleteCurrentBookmark~removes current bookmarks.
- */
-
- var gOutput = getOutput();
-
- function DoCommand()
- {
- var bookmarkMap = getMapFile( "Bookmarks" );
-
- if ( bookmarkMap.count == 0 )
- {
- return;
- }
-
- // See if there is a bookmark on the current line and if so delete it
- var found = false;
- var editor = getActiveEditor();
- if (editor)
- {
- var position = bookmarkMap.getHeadPosition();
- var editorpath = editor.path;
- var currentLineIndex = editor.getSelection().startLineIndex;
-
- while ( position && position.valid )
- {
- var next = bookmarkMap.getNext( position );
- if (next.value.valid())
- {
- var bookmark = next.value;
- if (bookmark.path == editorpath &&
- bookmark.startLineIndex == currentLineIndex)
- {
- bookmarkMap.remove(bookmark.hashKey);
- bookmark.remove();
- found = true;
- }
- }
- else
- {
- bookmarkMap.remove(next.value.hashKey);
- }
- }
-
- if (found)
- {
- return;
- }
- }
-
- /*
- var currentBookmark = getGlobal( "currentBookmark", -1);
- if (currentBookmark != -1)
- {
- var list = getBookmarksAsList( bookmarkMap );
-
- var position = list.getPosition( currentBookmark );
-
- if ( position && position.valid )
- {
- var current = currentBookmark;
-
- if ( list.count == 1 )
- {
- setGlobal( "currentBookmark", 0 );
- }
- else
- {
- if ( current != 0 )
- {
- current = current-1;
- }
- setGlobal( "currentBookmark", current );
- }
-
- var item = list.getAt( position );
- bookmarkMap.remove( item.value.hashKey );
- item.value.remove();
- }
- }
- */
- }
-
- function getBookmarksAsList( bookmarkMap )
- {
- var list = newList();
- var position = bookmarkMap.getHeadPosition();
-
- while ( position && position.valid )
- {
- var next = bookmarkMap.getNext( position );
- if (next.value.valid())
- {
- list.addTail(next);
- }
- else
- {
- bookmarkMap.remove(next.value.hashKey);
- }
- }
-
- list.sort(); // sort in order of creation
-
- return list;
- }
-
- !!/Script
-