diff options
author | nyamatongwe <devnull@localhost> | 2010-07-14 19:38:48 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2010-07-14 19:38:48 +1000 |
commit | b8d0dde31531b2b7fcf776e1b2647f936f45403b (patch) | |
tree | 64f1cf54a33334eeafd985894b11f13c82515aea | |
parent | ec3b45c83978f223e29025dc0e1b2da4509057ec (diff) | |
download | scintilla-mirror-b8d0dde31531b2b7fcf776e1b2647f936f45403b.tar.gz |
Files no longer needed due to Lexer Object changes.
-rw-r--r-- | include/KeyWords.h | 113 | ||||
-rw-r--r-- | include/PropSet.h | 26 | ||||
-rw-r--r-- | include/WindowAccessor.h | 67 | ||||
-rw-r--r-- | src/DocumentAccessor.cxx | 199 | ||||
-rw-r--r-- | src/DocumentAccessor.h | 77 | ||||
-rw-r--r-- | src/KeyWords.cxx | 429 | ||||
-rw-r--r-- | src/PropSet.cxx | 176 | ||||
-rw-r--r-- | src/WindowAccessor.cxx | 191 |
8 files changed, 0 insertions, 1278 deletions
diff --git a/include/KeyWords.h b/include/KeyWords.h deleted file mode 100644 index 5593b7d09..000000000 --- a/include/KeyWords.h +++ /dev/null @@ -1,113 +0,0 @@ -// Scintilla source code edit control -/** @file KeyWords.h - ** Colourise for particular languages. - **/ -// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ -class WordList { -public: - // Each word contains at least one character - a empty word acts as sentinel at the end. - char **words; - char *list; - int len; - bool onlyLineEnds; ///< Delimited by any white space or only line ends - bool sorted; - int starts[256]; - WordList(bool onlyLineEnds_ = false) : - words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), - sorted(false) - {} - ~WordList() { Clear(); } - operator bool() { return len ? true : false; } - void Clear(); - void Set(const char *s); - bool InList(const char *s); - bool InListAbbreviated(const char *s, const char marker); -}; - -typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler); - -/** - * A LexerModule is responsible for lexing and folding a particular language. - * The class maintains a list of LexerModules which can be searched to find a - * module appropriate to a particular language. - */ -class LexerModule { -protected: - const LexerModule *next; - int language; - LexerFunction fnLexer; - LexerFunction fnFolder; - const char * const * wordListDescriptions; - int styleBits; - - static const LexerModule *base; - static int nextLanguage; - -public: - const char *languageName; - LexerModule(int language_, - LexerFunction fnLexer_, - const char *languageName_=0, - LexerFunction fnFolder_=0, - const char * const wordListDescriptions_[] = NULL, - int styleBits_=5); - virtual ~LexerModule() { - } - int GetLanguage() const { return language; } - - // -1 is returned if no WordList information is available - int GetNumWordLists() const; - const char *GetWordListDescription(int index) const; - - int GetStyleBitsNeeded() const; - - virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler) const; - virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler) const; - static const LexerModule *Find(int language); - static const LexerModule *Find(const char *languageName); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -/** - * Check if a character is a space. - * This is ASCII specific but is safe with chars >= 0x80. - */ -inline bool isspacechar(unsigned char ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - -inline bool iswordchar(char ch) { - return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_'); -} - -inline bool iswordstart(char ch) { - return isascii(ch) && (isalnum(ch) || ch == '_'); -} - -inline bool isoperator(char ch) { - if (isascii(ch) && isalnum(ch)) - return false; - // '.' left out as it is used to make up numbers - if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || - ch == '(' || ch == ')' || ch == '-' || ch == '+' || - ch == '=' || ch == '|' || ch == '{' || ch == '}' || - ch == '[' || ch == ']' || ch == ':' || ch == ';' || - ch == '<' || ch == '>' || ch == ',' || ch == '/' || - ch == '?' || ch == '!' || ch == '.' || ch == '~') - return true; - return false; -} diff --git a/include/PropSet.h b/include/PropSet.h deleted file mode 100644 index c95202174..000000000 --- a/include/PropSet.h +++ /dev/null @@ -1,26 +0,0 @@ -// Scintilla source code edit control -/** @file PropSet.h - ** An interface to the methods needed for access to property sets inside lexers. - **/ -// Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef PROPSET_H -#define PROPSET_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -class PropertyGet { -public: - virtual char *ToString() const=0; // Caller must delete[] the return value - virtual int GetInt(const char *key, int defaultValue=0) const=0; - virtual ~PropertyGet() {} -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/include/WindowAccessor.h b/include/WindowAccessor.h deleted file mode 100644 index 4a8640748..000000000 --- a/include/WindowAccessor.h +++ /dev/null @@ -1,67 +0,0 @@ -// Scintilla source code edit control -/** @file WindowAccessor.h - ** Implementation of BufferAccess and StylingAccess on a Scintilla - ** rapid easy access to contents of a Scintilla. - **/ -// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ - -class WindowAccessor : public Accessor { - // Private so WindowAccessor objects can not be copied - WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {} - WindowAccessor &operator=(const WindowAccessor &) { return *this; } -protected: - WindowID id; - PropertyGet &props; - int lenDoc; - - char styleBuf[bufferSize]; - int validLen; - char chFlags; - char chWhile; - unsigned int startSeg; - - bool InternalIsLeadByte(char ch); - void Fill(int position); -public: - WindowAccessor(WindowID id_, PropertyGet &props_) : - Accessor(), id(id_), props(props_), - lenDoc(-1), validLen(0), chFlags(0), chWhile(0) { - } - ~WindowAccessor(); - bool Match(int pos, const char *s); - char StyleAt(int position); - int GetLine(int position); - int LineStart(int line); - int LevelAt(int line); - int Length(); - void Flush(); - int GetLineState(int line); - int SetLineState(int line, int state); - int GetPropertyInt(const char *key, int defaultValue=0) { - return props.GetInt(key, defaultValue); - } - char *GetProperties() { - return props.ToString(); - } - - void StartAt(unsigned int start, char chMask=31); - void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; } - unsigned int GetStartSegment() { return startSeg; } - void StartSegment(unsigned int pos); - void ColourTo(unsigned int pos, int chAttr); - void SetLevel(int line, int level); - int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); - void IndicatorFill(int start, int end, int indicator, int value); -}; - -#ifdef SCI_NAMESPACE -} -#endif diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx deleted file mode 100644 index 3ea80a40b..000000000 --- a/src/DocumentAccessor.cxx +++ /dev/null @@ -1,199 +0,0 @@ -// Scintilla source code edit control -/** @file DocumentAccessor.cxx - ** Rapid easy access to contents of a Scintilla. - **/ -// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <stdio.h> - -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "DocumentAccessor.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "CellBuffer.h" -#include "Scintilla.h" -#include "CharClassify.h" -#include "Decoration.h" -#include "Document.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -DocumentAccessor::~DocumentAccessor() { -} - -bool DocumentAccessor::InternalIsLeadByte(char ch) { - if (SC_CP_UTF8 == codePage) - // For lexing, all characters >= 0x80 are treated the - // same so none is considered a lead byte. - return false; - else - return Platform::IsDBCSLeadByte(codePage, ch); -} - -void DocumentAccessor::Fill(int position) { - if (lenDoc == -1) - lenDoc = pdoc->Length(); - startPos = position - slopSize; - if (startPos + bufferSize > lenDoc) - startPos = lenDoc - bufferSize; - if (startPos < 0) - startPos = 0; - endPos = startPos + bufferSize; - if (endPos > lenDoc) - endPos = lenDoc; - - pdoc->GetCharRange(buf, startPos, endPos-startPos); - buf[endPos-startPos] = '\0'; -} - -bool DocumentAccessor::Match(int pos, const char *s) { - for (int i=0; *s; i++) { - if (*s != SafeGetCharAt(pos+i)) - return false; - s++; - } - return true; -} - -char DocumentAccessor::StyleAt(int position) { - // Mask off all bits which aren't in the 'mask'. - return static_cast<char>(pdoc->StyleAt(position) & mask); -} - -int DocumentAccessor::GetLine(int position) { - return pdoc->LineFromPosition(position); -} - -int DocumentAccessor::LineStart(int line) { - return pdoc->LineStart(line); -} - -int DocumentAccessor::LevelAt(int line) { - return pdoc->GetLevel(line); -} - -int DocumentAccessor::Length() { - if (lenDoc == -1) - lenDoc = pdoc->Length(); - return lenDoc; -} - -int DocumentAccessor::GetLineState(int line) { - return pdoc->GetLineState(line); -} - -int DocumentAccessor::SetLineState(int line, int state) { - return pdoc->SetLineState(line, state); -} - -void DocumentAccessor::StartAt(unsigned int start, char chMask) { - // Store the mask specified for use with StyleAt. - mask = chMask; - pdoc->StartStyling(start, chMask); - startPosStyling = start; -} - -void DocumentAccessor::StartSegment(unsigned int pos) { - startSeg = pos; -} - -void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) { - // Only perform styling if non empty range - if (pos != startSeg - 1) { - PLATFORM_ASSERT(pos >= startSeg); - if (pos < startSeg) { - return; - } - - if (validLen + (pos - startSeg + 1) >= bufferSize) - Flush(); - if (validLen + (pos - startSeg + 1) >= bufferSize) { - // Too big for buffer so send directly - pdoc->SetStyleFor(pos - startSeg + 1, static_cast<char>(chAttr)); - } else { - if (chAttr != chWhile) - chFlags = 0; - chAttr |= chFlags; - for (unsigned int i = startSeg; i <= pos; i++) { - PLATFORM_ASSERT((startPosStyling + validLen) < Length()); - styleBuf[validLen++] = static_cast<char>(chAttr); - } - } - } - startSeg = pos+1; -} - -void DocumentAccessor::SetLevel(int line, int level) { - pdoc->SetLevel(line, level); -} - -void DocumentAccessor::Flush() { - startPos = extremePosition; - lenDoc = -1; - if (validLen > 0) { - pdoc->SetStyles(validLen, styleBuf); - startPosStyling += validLen; - validLen = 0; - } -} - -int DocumentAccessor::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 ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') || - (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos))) - return indent | SC_FOLDLEVELWHITEFLAG; - else - return indent; -} - -void DocumentAccessor::IndicatorFill(int start, int end, int indicator, int value) { - pdoc->decorations.SetCurrentIndicator(indicator); - pdoc->DecorationFillRange(start, value, end - start); -} diff --git a/src/DocumentAccessor.h b/src/DocumentAccessor.h deleted file mode 100644 index eb877d6d1..000000000 --- a/src/DocumentAccessor.h +++ /dev/null @@ -1,77 +0,0 @@ -// Scintilla source code edit control -/** @file DocumentAccessor.h - ** Implementation of BufferAccess and StylingAccess on a Scintilla - ** rapid easy access to contents of a Scintilla. - **/ -// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -class Document; - -/** - */ - -class DocumentAccessor : public Accessor { - // Private so DocumentAccessor objects can not be copied - DocumentAccessor(const DocumentAccessor &source); - DocumentAccessor &operator=(const DocumentAccessor &); - -protected: - Document *pdoc; - PropertyGet &props; - WindowID id; - int lenDoc; - - char styleBuf[bufferSize]; - int validLen; - char chFlags; - char chWhile; - unsigned int startSeg; - int startPosStyling; - int mask; - - bool InternalIsLeadByte(char ch); - void Fill(int position); - -public: - DocumentAccessor(Document *pdoc_, PropertyGet &props_, WindowID id_=0) : - Accessor(), pdoc(pdoc_), props(props_), id(id_), - lenDoc(-1), validLen(0), chFlags(0), chWhile(0), - startSeg(0), startPosStyling(0), - mask(127) { // Initialize the mask to be big enough for any lexer. - } - ~DocumentAccessor(); - bool Match(int pos, const char *s); - char StyleAt(int position); - int GetLine(int position); - int LineStart(int line); - int LevelAt(int line); - int Length(); - void Flush(); - int GetLineState(int line); - int SetLineState(int line, int state); - int GetPropertyInt(const char *key, int defaultValue=0) { - return props.GetInt(key, defaultValue); - } - char *GetProperties() { - return props.ToString(); - } - WindowID GetWindow() { return id; } - - void StartAt(unsigned int start, char chMask=31); - void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; } - unsigned int GetStartSegment() { return startSeg; } - void StartSegment(unsigned int pos); - void ColourTo(unsigned int pos, int chAttr); - void SetLevel(int line, int level); - int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); - void IndicatorFill(int start, int end, int indicator, int value); -}; - -#ifdef SCI_NAMESPACE -} -#endif diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx deleted file mode 100644 index 17bda8766..000000000 --- a/src/KeyWords.cxx +++ /dev/null @@ -1,429 +0,0 @@ -// Scintilla source code edit control -/** @file KeyWords.cxx - ** Colourise for particular languages. - **/ -// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <stdio.h> -#include <stdarg.h> - -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -/** - * Creates an array that points into each word in the string and puts \0 terminators - * after each word. - */ -static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = false) { - int prev = '\n'; - int words = 0; - // For rapid determination of whether a character is a separator, build - // a look up table. - bool wordSeparator[256]; - for (int i=0; i<256; i++) { - wordSeparator[i] = false; - } - wordSeparator['\r'] = true; - wordSeparator['\n'] = true; - if (!onlyLineEnds) { - wordSeparator[' '] = true; - wordSeparator['\t'] = true; - } - for (int j = 0; wordlist[j]; j++) { - int curr = static_cast<unsigned char>(wordlist[j]); - if (!wordSeparator[curr] && wordSeparator[prev]) - words++; - prev = curr; - } - char **keywords = new char *[words + 1]; - if (keywords) { - words = 0; - prev = '\0'; - size_t slen = strlen(wordlist); - for (size_t k = 0; k < slen; k++) { - if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) { - if (!prev) { - keywords[words] = &wordlist[k]; - words++; - } - } else { - wordlist[k] = '\0'; - } - prev = wordlist[k]; - } - keywords[words] = &wordlist[slen]; - *len = words; - } else { - *len = 0; - } - return keywords; -} - -void WordList::Clear() { - if (words) { - delete []list; - delete []words; - } - words = 0; - list = 0; - len = 0; - sorted = false; -} - -void WordList::Set(const char *s) { - list = new char[strlen(s) + 1]; - strcpy(list, s); - sorted = false; - words = ArrayFromWordList(list, &len, onlyLineEnds); -} - -extern "C" int cmpString(const void *a1, const void *a2) { - // Can't work out the correct incantation to use modern casts here - return strcmp(*(char **)(a1), *(char **)(a2)); -} - -static void SortWordList(char **words, unsigned int len) { - qsort(reinterpret_cast<void *>(words), len, sizeof(*words), - cmpString); -} - -bool WordList::InList(const char *s) { - if (0 == words) - return false; - if (!sorted) { - sorted = true; - SortWordList(words, len); - for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) - starts[k] = -1; - for (int l = len - 1; l >= 0; l--) { - unsigned char indexChar = words[l][0]; - starts[indexChar] = l; - } - } - unsigned char firstChar = s[0]; - int j = starts[firstChar]; - if (j >= 0) { - while ((unsigned char)words[j][0] == firstChar) { - if (s[1] == words[j][1]) { - const char *a = words[j] + 1; - const char *b = s + 1; - while (*a && *a == *b) { - a++; - b++; - } - if (!*a && !*b) - return true; - } - j++; - } - } - j = starts['^']; - if (j >= 0) { - while (words[j][0] == '^') { - const char *a = words[j] + 1; - const char *b = s; - while (*a && *a == *b) { - a++; - b++; - } - if (!*a) - return true; - j++; - } - } - return false; -} - -/** similar to InList, but word s can be a substring of keyword. - * eg. the keyword define is defined as def~ine. This means the word must start - * with def to be a keyword, but also defi, defin and define are valid. - * The marker is ~ in this case. - */ -bool WordList::InListAbbreviated(const char *s, const char marker) { - if (0 == words) - return false; - if (!sorted) { - sorted = true; - SortWordList(words, len); - for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) - starts[k] = -1; - for (int l = len - 1; l >= 0; l--) { - unsigned char indexChar = words[l][0]; - starts[indexChar] = l; - } - } - unsigned char firstChar = s[0]; - int j = starts[firstChar]; - if (j >= 0) { - while (words[j][0] == firstChar) { - bool isSubword = false; - int start = 1; - if (words[j][1] == marker) { - isSubword = true; - start++; - } - if (s[1] == words[j][start]) { - const char *a = words[j] + start; - const char *b = s + 1; - while (*a && *a == *b) { - a++; - if (*a == marker) { - isSubword = true; - a++; - } - b++; - } - if ((!*a || isSubword) && !*b) - return true; - } - j++; - } - } - j = starts['^']; - if (j >= 0) { - while (words[j][0] == '^') { - const char *a = words[j] + 1; - const char *b = s; - while (*a && *a == *b) { - a++; - b++; - } - if (!*a) - return true; - j++; - } - } - return false; -} - -const LexerModule *LexerModule::base = 0; -int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1; - -LexerModule::LexerModule(int language_, - LexerFunction fnLexer_, - const char *languageName_, - LexerFunction fnFolder_, - const char *const wordListDescriptions_[], - int styleBits_) : - language(language_), - fnLexer(fnLexer_), - fnFolder(fnFolder_), - wordListDescriptions(wordListDescriptions_), - styleBits(styleBits_), - languageName(languageName_) { - next = base; - base = this; - if (language == SCLEX_AUTOMATIC) { - language = nextLanguage; - nextLanguage++; - } -} - -int LexerModule::GetNumWordLists() const { - if (wordListDescriptions == NULL) { - return -1; - } else { - int numWordLists = 0; - - while (wordListDescriptions[numWordLists]) { - ++numWordLists; - } - - return numWordLists; - } -} - -const char *LexerModule::GetWordListDescription(int index) const { - static const char *emptyStr = ""; - - PLATFORM_ASSERT(index < GetNumWordLists()); - if (index >= GetNumWordLists()) { - return emptyStr; - } else { - return wordListDescriptions[index]; - } -} - -int LexerModule::GetStyleBitsNeeded() const { - return styleBits; -} - -const LexerModule *LexerModule::Find(int language) { - const LexerModule *lm = base; - while (lm) { - if (lm->language == language) { - return lm; - } - lm = lm->next; - } - return 0; -} - -const LexerModule *LexerModule::Find(const char *languageName) { - if (languageName) { - const LexerModule *lm = base; - while (lm) { - if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) { - return lm; - } - lm = lm->next; - } - } - return 0; -} - -void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler) const { - if (fnLexer) - fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler); -} - -void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler) const { - if (fnFolder) { - int lineCurrent = styler.GetLine(startPos); - // Move back one line in case deletion wrecked current line fold state - if (lineCurrent > 0) { - lineCurrent--; - int newStartPos = styler.LineStart(lineCurrent); - lengthDoc += startPos - newStartPos; - startPos = newStartPos; - initStyle = 0; - if (startPos > 0) { - initStyle = styler.StyleAt(startPos - 1); - } - } - fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler); - } -} - -// Alternative historical name for Scintilla_LinkLexers -int wxForceScintillaLexers(void) { - return Scintilla_LinkLexers(); -} - -// To add or remove a lexer, add or remove its file and run LexGen.py. - -// Force a reference to all of the Scintilla lexers so that the linker will -// not remove the code of the lexers. -int Scintilla_LinkLexers() { - static int forcer = 0; - -// Shorten the code that declares a lexer and ensures it is linked in by calling a method. -#define LINK_LEXER(lexer) extern LexerModule lexer; forcer += lexer.GetLanguage(); - -//++Autogenerated -- run src/LexGen.py to regenerate -//**\(\tLINK_LEXER(\*);\n\) - LINK_LEXER(lmAbaqus); - LINK_LEXER(lmAda); - LINK_LEXER(lmAns1); - LINK_LEXER(lmAPDL); - LINK_LEXER(lmAsm); - LINK_LEXER(lmASY); - LINK_LEXER(lmAU3); - LINK_LEXER(lmAVE); - LINK_LEXER(lmBaan); - LINK_LEXER(lmBash); - LINK_LEXER(lmBatch); - LINK_LEXER(lmBlitzBasic); - LINK_LEXER(lmBullant); - LINK_LEXER(lmCaml); - LINK_LEXER(lmClw); - LINK_LEXER(lmClwNoCase); - LINK_LEXER(lmCmake); - LINK_LEXER(lmCOBOL); - LINK_LEXER(lmConf); - LINK_LEXER(lmCPP); - LINK_LEXER(lmCPPNoCase); - LINK_LEXER(lmCsound); - LINK_LEXER(lmCss); - LINK_LEXER(lmD); - LINK_LEXER(lmDiff); - LINK_LEXER(lmEiffel); - LINK_LEXER(lmEiffelkw); - LINK_LEXER(lmErlang); - LINK_LEXER(lmErrorList); - LINK_LEXER(lmESCRIPT); - LINK_LEXER(lmF77); - LINK_LEXER(lmFlagShip); - LINK_LEXER(lmForth); - LINK_LEXER(lmFortran); - LINK_LEXER(lmFreeBasic); - LINK_LEXER(lmGAP); - LINK_LEXER(lmGui4Cli); - LINK_LEXER(lmHaskell); - LINK_LEXER(lmHTML); - LINK_LEXER(lmInno); - LINK_LEXER(lmKix); - LINK_LEXER(lmLatex); - LINK_LEXER(lmLISP); - LINK_LEXER(lmLot); - LINK_LEXER(lmLout); - LINK_LEXER(lmLua); - LINK_LEXER(lmMagikSF); - LINK_LEXER(lmMake); - LINK_LEXER(lmMarkdown); - LINK_LEXER(lmMatlab); - LINK_LEXER(lmMETAPOST); - LINK_LEXER(lmMMIXAL); - LINK_LEXER(lmMSSQL); - LINK_LEXER(lmMySQL); - LINK_LEXER(lmNimrod); - LINK_LEXER(lmNncrontab); - LINK_LEXER(lmNsis); - LINK_LEXER(lmNull); - LINK_LEXER(lmOctave); - LINK_LEXER(lmOpal); - LINK_LEXER(lmPascal); - LINK_LEXER(lmPB); - LINK_LEXER(lmPerl); - LINK_LEXER(lmPHPSCRIPT); - LINK_LEXER(lmPLM); - LINK_LEXER(lmPo); - LINK_LEXER(lmPOV); - LINK_LEXER(lmPowerPro); - LINK_LEXER(lmPowerShell); - LINK_LEXER(lmProgress); - LINK_LEXER(lmProps); - LINK_LEXER(lmPS); - LINK_LEXER(lmPureBasic); - LINK_LEXER(lmPython); - LINK_LEXER(lmR); - LINK_LEXER(lmREBOL); - LINK_LEXER(lmRuby); - LINK_LEXER(lmScriptol); - LINK_LEXER(lmSmalltalk); - LINK_LEXER(lmSML); - LINK_LEXER(lmSorc); - LINK_LEXER(lmSpecman); - LINK_LEXER(lmSpice); - LINK_LEXER(lmSQL); - LINK_LEXER(lmTACL); - LINK_LEXER(lmTADS3); - LINK_LEXER(lmTAL); - LINK_LEXER(lmTCL); - LINK_LEXER(lmTeX); - LINK_LEXER(lmVB); - LINK_LEXER(lmVBScript); - LINK_LEXER(lmVerilog); - LINK_LEXER(lmVHDL); - LINK_LEXER(lmXML); - LINK_LEXER(lmYAML); - -//--Autogenerated -- end of automatically generated section - - return 1; -} diff --git a/src/PropSet.cxx b/src/PropSet.cxx deleted file mode 100644 index e67a2126f..000000000 --- a/src/PropSet.cxx +++ /dev/null @@ -1,176 +0,0 @@ -// SciTE - Scintilla based Text Editor -/** @file PropSet.cxx - ** A Java style properties file module. - **/ -// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -// Maintain a dictionary of properties - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -#ifdef _MSC_VER -// Visual C++ doesn't like unreachable code or long decorated names in its own headers. -#pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702 4786) -#endif - -#include <string> -#include <map> - -#include "Platform.h" - -#include "PropSet.h" -#include "PropSetSimple.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -typedef std::map<std::string, std::string> mapss; - -PropSetSimple::PropSetSimple() { - mapss *props = new mapss; - impl = static_cast<void *>(props); -} - -PropSetSimple::~PropSetSimple() { - mapss *props = static_cast<mapss *>(impl); - delete props; - impl = 0; -} - -void PropSetSimple::Set(const char *key, const char *val, int lenKey, int lenVal) { - mapss *props = static_cast<mapss *>(impl); - if (!*key) // Empty keys are not supported - return; - if (lenKey == -1) - lenKey = static_cast<int>(strlen(key)); - if (lenVal == -1) - lenVal = static_cast<int>(strlen(val)); - (*props)[std::string(key, lenKey)] = std::string(val, lenVal); -} - -static bool IsASpaceCharacter(unsigned int ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - -void PropSetSimple::Set(const char *keyVal) { - while (IsASpaceCharacter(*keyVal)) - keyVal++; - const char *endVal = keyVal; - while (*endVal && (*endVal != '\n')) - endVal++; - const char *eqAt = strchr(keyVal, '='); - if (eqAt) { - Set(keyVal, eqAt + 1, eqAt-keyVal, endVal - eqAt - 1); - } else if (*keyVal) { // No '=' so assume '=1' - Set(keyVal, "1", endVal-keyVal, 1); - } -} - -void PropSetSimple::SetMultiple(const char *s) { - const char *eol = strchr(s, '\n'); - while (eol) { - Set(s); - s = eol + 1; - eol = strchr(s, '\n'); - } - Set(s); -} - -const char *PropSetSimple::Get(const char *key) const { - mapss *props = static_cast<mapss *>(impl); - mapss::const_iterator keyPos = props->find(std::string(key)); - if (keyPos != props->end()) { - return keyPos->second.c_str(); - } else { - return ""; - } -} - -// There is some inconsistency between GetExpanded("foo") and Expand("$(foo)"). -// A solution is to keep a stack of variables that have been expanded, so that -// recursive expansions can be skipped. For now I'll just use the C++ stack -// for that, through a recursive function and a simple chain of pointers. - -struct VarChain { - VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} - - bool contains(const char *testVar) const { - return (var && (0 == strcmp(var, testVar))) - || (link && link->contains(testVar)); - } - - const char *var; - const VarChain *link; -}; - -static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, int maxExpands, const VarChain &blankVars) { - size_t varStart = withVars.find("$("); - while ((varStart != std::string::npos) && (maxExpands > 0)) { - size_t varEnd = withVars.find(")", varStart+2); - if (varEnd == std::string::npos) { - break; - } - - // For consistency, when we see '$(ab$(cde))', expand the inner variable first, - // regardless whether there is actually a degenerate variable named 'ab$(cde'. - size_t innerVarStart = withVars.find("$(", varStart+2); - while ((innerVarStart != std::string::npos) && (innerVarStart > varStart) && (innerVarStart < varEnd)) { - varStart = innerVarStart; - innerVarStart = withVars.find("$(", varStart+2); - } - - std::string var(withVars.c_str(), varStart + 2, varEnd - varStart - 2); - std::string val = props.Get(var.c_str()); - - if (blankVars.contains(var.c_str())) { - val = ""; // treat blankVar as an empty string (e.g. to block self-reference) - } - - if (--maxExpands >= 0) { - maxExpands = ExpandAllInPlace(props, val, maxExpands, VarChain(var.c_str(), &blankVars)); - } - - withVars.erase(varStart, varEnd-varStart+1); - withVars.insert(varStart, val.c_str(), val.length()); - - varStart = withVars.find("$("); - } - - return maxExpands; -} - -char *PropSetSimple::Expanded(const char *key) const { - std::string val = Get(key); - ExpandAllInPlace(*this, val, 100, VarChain(key)); - char *ret = new char [val.size() + 1]; - strcpy(ret, val.c_str()); - return ret; -} - -char *PropSetSimple::ToString() const { - mapss *props = static_cast<mapss *>(impl); - std::string sval; - for (mapss::const_iterator it=props->begin(); it != props->end(); it++) { - sval += it->first; - sval += "="; - sval += it->second; - sval += "\n"; - } - char *ret = new char [sval.size() + 1]; - strcpy(ret, sval.c_str()); - return ret; -} - -int PropSetSimple::GetInt(const char *key, int defaultValue) const { - char *val = Expanded(key); - if (val) { - int retVal = val[0] ? atoi(val) : defaultValue; - delete []val; - return retVal; - } - return defaultValue; -} diff --git a/src/WindowAccessor.cxx b/src/WindowAccessor.cxx deleted file mode 100644 index ac0ebbcd2..000000000 --- a/src/WindowAccessor.cxx +++ /dev/null @@ -1,191 +0,0 @@ -// Scintilla source code edit control -/** @file WindowAccessor.cxx - ** Rapid easy access to contents of a Scintilla. - **/ -// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <stdio.h> - -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "WindowAccessor.h" -#include "Scintilla.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -WindowAccessor::~WindowAccessor() { -} - -bool WindowAccessor::InternalIsLeadByte(char ch) { - if (SC_CP_UTF8 == codePage) - // For lexing, all characters >= 0x80 are treated the - // same so none is considered a lead byte. - return false; - else - return Platform::IsDBCSLeadByte(codePage, ch); -} - -void WindowAccessor::Fill(int position) { - if (lenDoc == -1) - lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0); - startPos = position - slopSize; - if (startPos + bufferSize > lenDoc) - startPos = lenDoc - bufferSize; - if (startPos < 0) - startPos = 0; - endPos = startPos + bufferSize; - if (endPos > lenDoc) - endPos = lenDoc; - - Sci_TextRange tr = {{startPos, endPos}, buf}; - Platform::SendScintillaPointer(id, SCI_GETTEXTRANGE, 0, &tr); -} - -bool WindowAccessor::Match(int pos, const char *s) { - for (int i=0; *s; i++) { - if (*s != SafeGetCharAt(pos+i)) - return false; - s++; - } - return true; -} - -char WindowAccessor::StyleAt(int position) { - return static_cast<char>(Platform::SendScintilla( - id, SCI_GETSTYLEAT, position, 0)); -} - -int WindowAccessor::GetLine(int position) { - return Platform::SendScintilla(id, SCI_LINEFROMPOSITION, position, 0); -} - -int WindowAccessor::LineStart(int line) { - return Platform::SendScintilla(id, SCI_POSITIONFROMLINE, line, 0); -} - -int WindowAccessor::LevelAt(int line) { - return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0); -} - -int WindowAccessor::Length() { - if (lenDoc == -1) - lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0); - return lenDoc; -} - -int WindowAccessor::GetLineState(int line) { - return Platform::SendScintilla(id, SCI_GETLINESTATE, line); -} - -int WindowAccessor::SetLineState(int line, int state) { - return Platform::SendScintilla(id, SCI_SETLINESTATE, line, state); -} - -void WindowAccessor::StartAt(unsigned int start, char chMask) { - Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask); -} - -void WindowAccessor::StartSegment(unsigned int pos) { - startSeg = pos; -} - -void WindowAccessor::ColourTo(unsigned int pos, int chAttr) { - // Only perform styling if non empty range - if (pos != startSeg - 1) { - if (pos < startSeg) { - Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos); - } - - if (validLen + (pos - startSeg + 1) >= bufferSize) - Flush(); - if (validLen + (pos - startSeg + 1) >= bufferSize) { - // Too big for buffer so send directly - Platform::SendScintilla(id, SCI_SETSTYLING, pos - startSeg + 1, chAttr); - } else { - if (chAttr != chWhile) - chFlags = 0; - chAttr |= chFlags; - for (unsigned int i = startSeg; i <= pos; i++) { - styleBuf[validLen++] = static_cast<char>(chAttr); - } - } - } - startSeg = pos+1; -} - -void WindowAccessor::SetLevel(int line, int level) { - Platform::SendScintilla(id, SCI_SETFOLDLEVEL, line, level); -} - -void WindowAccessor::Flush() { - startPos = extremePosition; - lenDoc = -1; - if (validLen > 0) { - Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen, - styleBuf); - validLen = 0; - } -} - -int WindowAccessor::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; -} - -void WindowAccessor::IndicatorFill(int start, int end, int indicator, int value) { - Platform::SendScintilla(id, SCI_SETINDICATORCURRENT, indicator); - if (value) { - Platform::SendScintilla(id, SCI_SETINDICATORVALUE, value); - Platform::SendScintilla(id, SCI_INDICATORFILLRANGE, start, end - start); - } else { - Platform::SendScintilla(id, SCI_INDICATORCLEARRANGE, start, end - start); - } -} |