From: boca4711 <boc...@us...> - 2005-04-17 12:35:01
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27889 Modified Files: ScintillaEx.cpp ScintillaEx.h Log Message: - Fix: SortLines removed last line sometimes - Fix: HighlightBraces: Change nCode to nPos - Add: GetSelectionStartLine/End to get first and last selected line (with line correction in last line) Index: ScintillaEx.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ScintillaEx.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ScintillaEx.cpp 24 Mar 2005 09:10:48 -0000 1.23 --- ScintillaEx.cpp 17 Apr 2005 12:34:52 -0000 1.24 *************** *** 239,255 **** /// Highlight matching or non matching braces and indentation guides. ! void CScintillaEx::HighlightBraces(long nCode) { ! long match = BraceMatch(nCode); if(match == INVALID_POSITION) { BraceHighlight(-1, -1); ! BraceBadLight(nCode); } else { ! BraceHighlight(nCode, match); ! int nColumn = GetColumn(nCode); SetHighlightGuide(min(nColumn, GetColumn(match))); } --- 239,255 ---- /// Highlight matching or non matching braces and indentation guides. ! void CScintillaEx::HighlightBraces(long nPos) { ! long match = BraceMatch(nPos); if(match == INVALID_POSITION) { BraceHighlight(-1, -1); ! BraceBadLight(nPos); } else { ! BraceHighlight(nPos, match); ! int nColumn = GetColumn(nPos); SetHighlightGuide(min(nColumn, GetColumn(match))); } *************** *** 1644,1656 **** } - int nLineStart = LineFromPosition(GetSelectionStart()); - int nLineEnd = LineFromPosition(GetSelectionEnd()); - SetSel(PositionFromLine(nLineStart), GetLineEndPosition(nLineEnd)); - CString strLine; LPTSTR linebuf; BeginUndoAction(); ! for(int nLine = nLineStart; nLine < nLineEnd; nLine++) { linebuf = strLine.GetBuffer(32768); --- 1644,1656 ---- } CString strLine; LPTSTR linebuf; + int nLineStart = GetSelectionStartLine(); + int nLineEnd = GetSelectionEndLine(); + SetSel(PositionFromLine(nLineStart), PositionFromLine(nLineEnd + 1)); + BeginUndoAction(); ! for(int nLine = nLineStart; nLine <= nLineEnd; nLine++) { linebuf = strLine.GetBuffer(32768); *************** *** 1658,1662 **** linebuf[nLen] = '\0'; strLine.ReleaseBuffer(); - strLine.TrimRight(); if (!bDuplicates) --- 1658,1661 ---- *************** *** 1669,1686 **** long nPosition = GetSelectionStart(); - Clear(); ! const char *eol = "\n"; ! switch (GetEOLMode()) ! { ! case SC_EOL_CRLF: ! eol = "\r\n"; ! break; ! case SC_EOL_CR: ! eol = "\r"; ! break; ! } ! int len_eol = strlen(eol); if (bAscending) { --- 1668,1676 ---- long nPosition = GetSelectionStart(); ! // Remove old selection ! Clear(); + // Insert sorted lines if (bAscending) { *************** *** 1689,1694 **** InsertText(nPosition, arLines.GetAt(i)); nPosition += arLines.GetAt(i).GetLength(); - InsertText(nPosition, eol); - nPosition += len_eol; } } --- 1679,1682 ---- *************** *** 1699,1704 **** InsertText(nPosition, arLines.GetAt(i)); nPosition += arLines.GetAt(i).GetLength(); - InsertText(nPosition, eol); - nPosition += len_eol; } } --- 1687,1690 ---- *************** *** 1964,1965 **** --- 1950,1969 ---- } } + + /// Get line number of first selected line + int CScintillaEx::GetSelectionStartLine() + { + return LineFromPosition(GetSelectionStart()); + } + + /// Get line number of last selected line + int CScintillaEx::GetSelectionEndLine() + { + int nLine = LineFromPosition(GetSelectionEnd()); + + // Remove last line if selection ends on first position of line. + if( PositionFromLine( nLine ) == GetSelectionEnd() ) + nLine--; + + return nLine; + } Index: ScintillaEx.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ScintillaEx.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ScintillaEx.h 25 Oct 2004 13:36:02 -0000 1.15 --- ScintillaEx.h 17 Apr 2005 12:34:52 -0000 1.16 *************** *** 110,114 **** void SetEOLLF(void); void InsertEOL( long lPos ); ! void HighlightBraces(long nCode); bool IsBrace(char ch); void SetBraces( CString szBraces ) { m_szBraces = szBraces; } --- 110,114 ---- void SetEOLLF(void); void InsertEOL( long lPos ); ! void HighlightBraces(long nPos); bool IsBrace(char ch); void SetBraces( CString szBraces ) { m_szBraces = szBraces; } *************** *** 154,157 **** --- 154,159 ---- std::deque<int> dqBookmarks; public: + int GetSelectionEndLine(void); + int GetSelectionStartLine(void); bool IsSaveConvertTabToSpaces(void); void SetSaveConvertTabToSpaces(bool bConvertTabToSpaces); |