diff options
author | nyamatongwe <devnull@localhost> | 2000-03-16 11:43:39 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-03-16 11:43:39 +0000 |
commit | 01cd695dc8d693c39500f24adf689d08d77d39da (patch) | |
tree | 3837357cf607234f40e4b4705c24da1e40ba0758 /src/Accessor.cxx | |
parent | 8c214e65f503275192e2f3f9dea97fbb65a38254 (diff) | |
download | scintilla-mirror-01cd695dc8d693c39500f24adf689d08d77d39da.tar.gz |
Split up KeyWords.cxx into 7 individual lexer files Lex*.cxx.
Fixed setting up of second view to get right document length.
Changed Python lexer to handle empty lines immediately after fold line
and last line of document.
Diffstat (limited to 'src/Accessor.cxx')
-rw-r--r-- | src/Accessor.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Accessor.cxx b/src/Accessor.cxx index 60c5968c5..f080742bd 100644 --- a/src/Accessor.cxx +++ b/src/Accessor.cxx @@ -4,6 +4,7 @@ // The License.txt file describes the conditions under which this software may be distributed. #include <stdlib.h> +#include <ctype.h> #include <stdio.h> #include "Platform.h" @@ -12,6 +13,17 @@ #include "Accessor.h" #include "Scintilla.h" +bool Accessor::InternalIsLeadByte(char ch) { +#if PLAT_GTK + // TODO: support DBCS under GTK+ + return false; +#elif PLAT_WIN + return IsDBCSLeadByteEx(codePage, ch); +#elif PLAT_WX + return false; +#endif +} + void Accessor::Fill(int position) { if (lenDoc == -1) lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0); @@ -106,3 +118,49 @@ void StylingContext::Flush() { validLen = 0; } } + +int StylingContext::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { + int end = Length(); + int spaceFlags = 0; + + // Determines the indentation level of the current line and also checks for consistent + // indentation compared to the previous line. + // Indentation is judged consistent when the indentation whitespace of each line lines + // the same or the indentation of one line is a prefix of the other. + + int pos = LineStart(line); + char ch = (*this)[pos]; + int indent = 0; + bool inPrevPrefix = line > 0; + int posPrev = inPrevPrefix ? LineStart(line-1) : 0; + while ((ch == ' ' || ch == '\t') && (pos < end)) { + if (inPrevPrefix) { + char chPrev = (*this)[posPrev++]; + if (chPrev == ' ' || chPrev == '\t') { + if (chPrev != ch) + spaceFlags |= wsInconsistent; + } else { + inPrevPrefix = false; + } + } + if (ch == ' ') { + spaceFlags |= wsSpace; + indent++; + } else { // Tab + spaceFlags |= wsTab; + if (spaceFlags & wsSpace) + spaceFlags |= wsSpaceTab; + indent = (indent / 8 + 1) * 8; + } + ch = (*this)[++pos]; + } + + *flags = spaceFlags; + indent += SC_FOLDLEVELBASE; + // if completely empty line or the start of a comment... + if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) + return indent | SC_FOLDLEVELWHITEFLAG; + else + return indent; +} + |