From: Leon W. <moo...@us...> - 2004-11-25 13:04:40
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21449 Modified Files: ScintillaEx.cpp Log Message: Improved autoindention. Index: ScintillaEx.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ScintillaEx.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ScintillaEx.cpp 1 Nov 2004 14:16:32 -0000 1.19 --- ScintillaEx.cpp 25 Nov 2004 13:04:24 -0000 1.20 *************** *** 216,219 **** --- 216,221 ---- if (((scn->ch == '\r') || (scn->ch == '\n')) && (GetAutoIndent() >= 1)) AutoIndentIn(scn->ch); + else if ((scn->ch == '{') && (GetAutoIndent() >= 2)) + AutoIndentOut(scn->ch); else if ((scn->ch == '}') && (GetAutoIndent() >= 2)) AutoIndentOut(scn->ch); *************** *** 986,989 **** --- 988,992 ---- void CScintillaEx::AutoIndentIn(char ch) { + int iIndentation; // If we have EOLMode CRLF, then we AutoIndented on '\r' so we don't do it again on '\n' if((GetEOLMode() == SC_EOL_CRLF) && (ch == '\n')) *************** *** 991,995 **** // Let's get the indentation of the previous line. ! int iIndentation = GetLineIndentation( GetCurLineNumber() - 1 ); // May we do extra indentation? if( GetAutoIndent() >= 2 ) --- 994,1000 ---- // Let's get the indentation of the previous line. ! iIndentation = GetLineIndentation( GetCurLineNumber() - 1 ); ! // If the current line has bigger or the same indentation we don't have to do it. ! if( iIndentation < GetLineIndentation( GetCurLineNumber() ) ) return; // May we do extra indentation? if( GetAutoIndent() >= 2 ) *************** *** 1000,1005 **** if( GetEOLMode() == SC_EOL_CRLF ) --pos; ! // Do we have a '{' of ':' ! if( GetCharAt( pos ) == '{' || GetCharAt( pos ) == ':' ) { // Add an extra indent to the current line. --- 1005,1010 ---- if( GetEOLMode() == SC_EOL_CRLF ) --pos; ! // Do we have a '{', ')' or ':' ! if( GetCharAt( pos ) == '{' || GetCharAt( pos ) == ')' || GetCharAt( pos ) == ':' ) { // Add an extra indent to the current line. *************** *** 1017,1022 **** void CScintillaEx::AutoIndentOut(char ch) { // Get the indentation ! int iIndentation = GetLineIndentation( GetCurLineNumber() ); // Move indentation one indent back if (GetIndent() == 0) --- 1022,1032 ---- void CScintillaEx::AutoIndentOut(char ch) { + GetCharAt( GetCurrentPos() ); + // We only indent out if we are at the current indentation level. + // Or there are no characters before ch. + if( GetLineIndentPosition( GetCurLineNumber() ) != GetCurrentPos() - 1 ) return; + // Get the indentation ! int iIndentation = GetLineIndentation( GetCurLineNumber() - 1 ); // Move indentation one indent back if (GetIndent() == 0) |