1 // Scintilla source code edit control
3 ** Colourise for particular languages.
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
16 #include "Scintilla.h"
19 #include "PropSetSimple.h"
21 #include "LexAccessor.h"
25 using namespace Scintilla
;
28 Accessor::Accessor(IDocument
*pAccess_
, PropSetSimple
*pprops_
) : LexAccessor(pAccess_
), pprops(pprops_
) {
31 int Accessor::GetPropertyInt(const char *key
, int defaultValue
) {
32 return pprops
->GetInt(key
, defaultValue
);
35 int Accessor::IndentAmount(int line
, int *flags
, PFNIsCommentLeader pfnIsCommentLeader
) {
39 // Determines the indentation level of the current line and also checks for consistent
40 // indentation compared to the previous line.
41 // Indentation is judged consistent when the indentation whitespace of each line lines
42 // the same or the indentation of one line is a prefix of the other.
44 int pos
= LineStart(line
);
45 char ch
= (*this)[pos
];
47 bool inPrevPrefix
= line
> 0;
48 int posPrev
= inPrevPrefix
? LineStart(line
-1) : 0;
49 while ((ch
== ' ' || ch
== '\t') && (pos
< end
)) {
51 char chPrev
= (*this)[posPrev
++];
52 if (chPrev
== ' ' || chPrev
== '\t') {
54 spaceFlags
|= wsInconsistent
;
60 spaceFlags
|= wsSpace
;
64 if (spaceFlags
& wsSpace
)
65 spaceFlags
|= wsSpaceTab
;
66 indent
= (indent
/ 8 + 1) * 8;
72 indent
+= SC_FOLDLEVELBASE
;
73 // if completely empty line or the start of a comment...
74 if ((LineStart(line
) == Length()) || (ch
== ' ' || ch
== '\t' || ch
== '\n' || ch
== '\r') ||
75 (pfnIsCommentLeader
&& (*pfnIsCommentLeader
)(*this, pos
, end
-pos
)))
76 return indent
| SC_FOLDLEVELWHITEFLAG
;