From: Leon W. <moo...@us...> - 2004-10-25 13:36:10
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20067 Modified Files: ScintillaEx.cpp ScintillaEx.h Log Message: Fixed Bookmark code to correctly handle deletion of lines and bookmarks. Index: ScintillaEx.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ScintillaEx.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ScintillaEx.cpp 18 Oct 2004 17:00:18 -0000 1.17 --- ScintillaEx.cpp 25 Oct 2004 13:36:02 -0000 1.18 *************** *** 304,327 **** void CScintillaEx::ToggleBookmark(long lLine) { ! std::deque<long>::iterator pos; ! ! if( !dqBookmarks.empty() ) { ! for( pos = dqBookmarks.begin(); pos < dqBookmarks.end(); ++ pos ) ! { ! if( lLine == *pos ) { ! MarkerDelete(lLine, SC_BOOKMARK); ! dqBookmarks.erase(pos); ! return; ! } ! } } - - dqBookmarks.push_back(lLine); - std::sort(dqBookmarks.begin(), dqBookmarks.end()); - - // Add the marker. - MarkerAdd(lLine, SC_BOOKMARK); } --- 304,332 ---- void CScintillaEx::ToggleBookmark(long lLine) { ! if( MarkerGet( lLine ) & ( 1 << SC_BOOKMARK ) ) { ! MarkerDelete( lLine, SC_BOOKMARK ); ! // Check if all the handles are still valid. ! if( !dqBookmarks.empty() ) ! { ! std::deque<int>::iterator pos; ! pos = dqBookmarks.begin(); ! while( pos < dqBookmarks.end() ) ! { ! if( -1 == MarkerLineFromHandle( *pos ) ) ! { ! pos = dqBookmarks.erase( pos ); ! } ! else ! { ! ++ pos; ! } ! } ! } ! } ! else { ! dqBookmarks.push_back( MarkerAdd( lLine, SC_BOOKMARK ) ); } } *************** *** 335,341 **** void CScintillaEx::FirstBookmark() { ! if( dqBookmarks.empty() ) return; ! ! GotoLineEnsureVisible( dqBookmarks[0] ); } --- 340,348 ---- void CScintillaEx::FirstBookmark() { ! if( HasBookmarks() ) ! { ! int rc = MarkerNext( 0, ( 1 << SC_BOOKMARK )); ! if( -1 != rc ) GotoLineEnsureVisible( rc ); ! } } *************** *** 343,349 **** void CScintillaEx::LastBookmark() { ! if( dqBookmarks.empty() ) return; ! ! GotoLineEnsureVisible( dqBookmarks[dqBookmarks.size()-1] ); } --- 350,358 ---- void CScintillaEx::LastBookmark() { ! if( HasBookmarks() ) ! { ! int rc = MarkerPrevious( LineFromPosition( GetLength() ), ( 1 << SC_BOOKMARK ) ); ! if( -1 != rc ) GotoLineEnsureVisible( rc ); ! } } *************** *** 351,376 **** void CScintillaEx::PreviousBookmark() { ! int iIndex; ! long lLine = LineFromPosition( GetCurrentPos() ); ! ! if( dqBookmarks.empty() ) return; ! ! for( iIndex = 0; iIndex < dqBookmarks.size(); ++ iIndex ) ! { ! if( dqBookmarks[iIndex] >= lLine ) { ! -- iIndex; ! if( iIndex < 0 ) ! { ! LastBookmark(); ! } ! else ! { ! GotoLineEnsureVisible( dqBookmarks[iIndex] ); ! } ! return; ! } } - GotoLineEnsureVisible( dqBookmarks[-- iIndex] ); } --- 360,372 ---- void CScintillaEx::PreviousBookmark() { ! if( HasBookmarks() ) { ! int rc = MarkerPrevious( LineFromPosition( GetCurrentPos() ) - 1, ( 1 << SC_BOOKMARK ) ); ! if( -1 == rc ) ! { ! rc = MarkerPrevious( LineFromPosition( GetLength() ), ( 1 << SC_BOOKMARK ) ); ! } ! if( -1 != rc ) GotoLineEnsureVisible( rc ); } } *************** *** 378,395 **** void CScintillaEx::NextBookmark() { ! int iIndex; ! long lLine = LineFromPosition( GetCurrentPos() ); ! ! if( dqBookmarks.empty() ) return; ! ! for( iIndex = 0; iIndex < dqBookmarks.size(); ++ iIndex ) { ! if( dqBookmarks[iIndex] > lLine ) { ! GotoLineEnsureVisible( dqBookmarks[iIndex] ); ! return; } } - FirstBookmark(); } --- 374,386 ---- void CScintillaEx::NextBookmark() { ! if( HasBookmarks() ) { ! int rc = MarkerNext( LineFromPosition( GetCurrentPos() ) + 1, ( 1 << SC_BOOKMARK ) ); ! if( -1 == rc ) { ! rc = MarkerNext( 0, ( 1 << SC_BOOKMARK ) ); } + if( -1 != rc ) GotoLineEnsureVisible( rc ); } } Index: ScintillaEx.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ScintillaEx.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ScintillaEx.h 23 Sep 2004 21:32:14 -0000 1.14 --- ScintillaEx.h 25 Oct 2004 13:36:02 -0000 1.15 *************** *** 151,156 **** CStringArray m_saBlockComment; ! /// The deque to store the lines with a bookmark ! std::deque<long> dqBookmarks; public: bool IsSaveConvertTabToSpaces(void); --- 151,156 ---- CStringArray m_saBlockComment; ! /// The deque to store the bookmark handles ! std::deque<int> dqBookmarks; public: bool IsSaveConvertTabToSpaces(void); |