Updated wxSTC's copy of Scintilla to version 1.61
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -108,6 +108,14 @@ STCDLL_OBJECTS = \
|
||||
stcdll_LexTeX.o \
|
||||
stcdll_LexVB.o \
|
||||
stcdll_LexYAML.o \
|
||||
stcdll_LexAPDL.o \
|
||||
stcdll_LexAU3.o \
|
||||
stcdll_LexBash.o \
|
||||
stcdll_LexGui4Cli.o \
|
||||
stcdll_LexKix.o \
|
||||
stcdll_LexMSSQL.o \
|
||||
stcdll_LexSpecman.o \
|
||||
stcdll_LexVerilog.o \
|
||||
stcdll_LineMarker.o \
|
||||
stcdll_PropSet.o \
|
||||
stcdll_RESearch.o \
|
||||
@@ -174,6 +182,14 @@ STCLIB_OBJECTS = \
|
||||
stclib_LexTeX.o \
|
||||
stclib_LexVB.o \
|
||||
stclib_LexYAML.o \
|
||||
stclib_LexAPDL.o \
|
||||
stclib_LexAU3.o \
|
||||
stclib_LexBash.o \
|
||||
stclib_LexGui4Cli.o \
|
||||
stclib_LexKix.o \
|
||||
stclib_LexMSSQL.o \
|
||||
stclib_LexSpecman.o \
|
||||
stclib_LexVerilog.o \
|
||||
stclib_LineMarker.o \
|
||||
stclib_PropSet.o \
|
||||
stclib_RESearch.o \
|
||||
@@ -491,6 +507,30 @@ stcdll_LexVB.o: $(srcdir)/scintilla/src/LexVB.cxx
|
||||
stcdll_LexYAML.o: $(srcdir)/scintilla/src/LexYAML.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexAPDL.o: $(srcdir)/scintilla/src/LexAPDL.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexAU3.o: $(srcdir)/scintilla/src/LexAU3.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexBash.o: $(srcdir)/scintilla/src/LexBash.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexGui4Cli.o: $(srcdir)/scintilla/src/LexGui4Cli.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexKix.o: $(srcdir)/scintilla/src/LexKix.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexMSSQL.o: $(srcdir)/scintilla/src/LexMSSQL.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexSpecman.o: $(srcdir)/scintilla/src/LexSpecman.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LexVerilog.o: $(srcdir)/scintilla/src/LexVerilog.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
stcdll_LineMarker.o: $(srcdir)/scintilla/src/LineMarker.cxx
|
||||
$(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $<
|
||||
|
||||
@@ -674,6 +714,30 @@ stclib_LexVB.o: $(srcdir)/scintilla/src/LexVB.cxx
|
||||
stclib_LexYAML.o: $(srcdir)/scintilla/src/LexYAML.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexAPDL.o: $(srcdir)/scintilla/src/LexAPDL.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexAU3.o: $(srcdir)/scintilla/src/LexAU3.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexBash.o: $(srcdir)/scintilla/src/LexBash.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexGui4Cli.o: $(srcdir)/scintilla/src/LexGui4Cli.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexKix.o: $(srcdir)/scintilla/src/LexKix.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexMSSQL.o: $(srcdir)/scintilla/src/LexMSSQL.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexSpecman.o: $(srcdir)/scintilla/src/LexSpecman.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LexVerilog.o: $(srcdir)/scintilla/src/LexVerilog.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
stclib_LineMarker.o: $(srcdir)/scintilla/src/LineMarker.cxx
|
||||
$(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $<
|
||||
|
||||
|
@@ -3,4 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
|
||||
distribution. All other code needed to implement Scintilla on top of
|
||||
wxWindows is located in the directory above this one.
|
||||
|
||||
The current version of the Scintilla code is 1.58
|
||||
The current version of the Scintilla code is 1.61
|
||||
|
||||
|
@@ -284,7 +284,8 @@ public:
|
||||
Font();
|
||||
virtual ~Font();
|
||||
|
||||
virtual void Create(const char *faceName, int characterSet, int size, bool bold, bool italic, bool extraFontFlag=false);
|
||||
virtual void Create(const char *faceName, int characterSet, int size,
|
||||
bool bold, bool italic, bool extraFontFlag=false);
|
||||
virtual void Release();
|
||||
|
||||
FontID GetID() { return id; }
|
||||
|
@@ -56,6 +56,11 @@ public:
|
||||
char *ToString(); // Caller must delete[] the return value
|
||||
bool GetFirst(char **key, char **val);
|
||||
bool GetNext(char **key, char **val);
|
||||
|
||||
private:
|
||||
// copy-value semantics not implemented
|
||||
PropSet(const PropSet ©);
|
||||
void operator=(const PropSet &assign);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -83,11 +88,18 @@ public:
|
||||
const char *GetNearestWord(const char *wordStart, int searchLen = -1,
|
||||
bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1);
|
||||
char *GetNearestWords(const char *wordStart, int searchLen=-1,
|
||||
bool ignoreCase=false, char otherSeparator='\0');
|
||||
bool ignoreCase=false, char otherSeparator='\0', bool exactLen=false);
|
||||
};
|
||||
|
||||
inline bool IsAlphabetic(unsigned int ch) {
|
||||
return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
|
||||
}
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Visual C++ doesn't like the private copy idiom for disabling
|
||||
// the default copy constructor and operator=, but it's fine.
|
||||
#pragma warning(disable: 4511 4512)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file SString.h
|
||||
** A simple string class.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef SSTRING_H
|
||||
@@ -18,100 +18,148 @@ bool EqualCaseInsensitive(const char *a, const char *b);
|
||||
// An SString may contain embedded nul characters.
|
||||
|
||||
/**
|
||||
* @brief A simple string class.
|
||||
*
|
||||
* Hold the length of the string for quick operations,
|
||||
* can have a buffer bigger than the string to avoid too many memory allocations and copies.
|
||||
* May have embedded zeroes as a result of @a substitute, but relies too heavily on C string
|
||||
* functions to allow reliable manipulations of these strings, other than simple appends, etc.
|
||||
**/
|
||||
class SString {
|
||||
* Base class from which the two other classes (SBuffer & SString)
|
||||
* are derived.
|
||||
*/
|
||||
class SContainer {
|
||||
public:
|
||||
/** Type of string lengths (sizes) and positions (indexes). */
|
||||
typedef size_t lenpos_t;
|
||||
/** Out of bounds value indicating that the string argument should be measured. */
|
||||
enum { measure_length=0xffffffffU};
|
||||
|
||||
private:
|
||||
protected:
|
||||
char *s; ///< The C string
|
||||
lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
|
||||
lenpos_t sLen; ///< The size of the string in s
|
||||
lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
|
||||
enum { sizeGrowthDefault = 64 };
|
||||
bool grow(lenpos_t lenNew) {
|
||||
while (sizeGrowth * 6 < lenNew) {
|
||||
sizeGrowth *= 2;
|
||||
}
|
||||
char *sNew = new char[lenNew + sizeGrowth + 1];
|
||||
if (sNew) {
|
||||
if (s) {
|
||||
memcpy(sNew, s, sLen);
|
||||
delete []s;
|
||||
}
|
||||
s = sNew;
|
||||
s[sLen] = '\0';
|
||||
sSize = lenNew + sizeGrowth;
|
||||
}
|
||||
return sNew != 0;
|
||||
}
|
||||
|
||||
SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
|
||||
if (!sOther) {
|
||||
sSize_ = 0;
|
||||
} else if (sSize_ == measure_length) {
|
||||
sSize_ = strlen(sOther);
|
||||
}
|
||||
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
|
||||
if (s && sSize_) {
|
||||
memcpy(s, sOther, sSize_);
|
||||
}
|
||||
s[sSize_] = '\0';
|
||||
sLen = sSize_;
|
||||
SContainer() : s(0), sSize(0) {}
|
||||
~SContainer() {
|
||||
delete []s; // Suppose it was allocated using StringAllocate
|
||||
s = 0;
|
||||
sSize = 0;
|
||||
}
|
||||
/** Size of buffer. */
|
||||
lenpos_t size() const {
|
||||
if (s) {
|
||||
return sSize;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* Allocate uninitialized memory big enough to fit a string of the given length.
|
||||
* @return the pointer to the new string
|
||||
*/
|
||||
static char *StringAllocate(lenpos_t len);
|
||||
/**
|
||||
* Duplicate a buffer/C string.
|
||||
* Allocate memory of the given size, or big enough to fit the string if length isn't given;
|
||||
* then copy the given string in the allocated memory.
|
||||
* @return the pointer to the new string
|
||||
*/
|
||||
static char *StringAllocate(
|
||||
const char *s, ///< The string to duplicate
|
||||
lenpos_t len=measure_length); ///< The length of memory to allocate. Optional.
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A string buffer class.
|
||||
*
|
||||
* Main use is to ask an API the length of a string it can provide,
|
||||
* then to allocate a buffer of the given size, and to provide this buffer
|
||||
* to the API to put the string.
|
||||
* This class is intended to be shortlived, to be transformed as SString
|
||||
* as soon as it holds the string, so it has little members.
|
||||
* Note: we assume the buffer is filled by the API. If the length can be shorter,
|
||||
* we should set sLen to strlen(sb.ptr()) in related SString constructor and assignment.
|
||||
*/
|
||||
class SBuffer : protected SContainer {
|
||||
public:
|
||||
SBuffer(lenpos_t len) {
|
||||
s = StringAllocate(len);
|
||||
if (s) {
|
||||
*s = '\0';
|
||||
sSize = len;
|
||||
} else {
|
||||
sSize = 0;
|
||||
}
|
||||
}
|
||||
private:
|
||||
/// Copy constructor
|
||||
// Here only to be on the safe size, user should avoid returning SBuffer values.
|
||||
SBuffer(const SBuffer &source) : SContainer() {
|
||||
s = StringAllocate(source.s, source.sSize);
|
||||
sSize = (s) ? source.sSize : 0;
|
||||
}
|
||||
/// Default assignment operator
|
||||
// Same here, shouldn't be used
|
||||
SBuffer &operator=(const SBuffer &source) {
|
||||
if (this != &source) {
|
||||
delete []s;
|
||||
s = StringAllocate(sOther, sSize_);
|
||||
if (s) {
|
||||
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
|
||||
sLen = strlen(s);
|
||||
} else {
|
||||
sSize = sLen = 0;
|
||||
}
|
||||
s = StringAllocate(source.s, source.sSize);
|
||||
sSize = (s) ? source.sSize : 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
/** Provide direct read/write access to buffer. */
|
||||
char *ptr() {
|
||||
return s;
|
||||
}
|
||||
/** Ownership of the buffer have been taken, so release it. */
|
||||
void reset() {
|
||||
s = 0;
|
||||
sSize = 0;
|
||||
}
|
||||
/** Size of buffer. */
|
||||
lenpos_t size() const {
|
||||
return SContainer::size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A simple string class.
|
||||
*
|
||||
* Hold the length of the string for quick operations,
|
||||
* can have a buffer bigger than the string to avoid too many memory allocations and copies.
|
||||
* May have embedded zeroes as a result of @a substitute, but relies too heavily on C string
|
||||
* functions to allow reliable manipulations of these strings, other than simple appends, etc.
|
||||
*/
|
||||
class SString : protected SContainer {
|
||||
lenpos_t sLen; ///< The size of the string in s
|
||||
lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
|
||||
enum { sizeGrowthDefault = 64 };
|
||||
|
||||
bool grow(lenpos_t lenNew);
|
||||
SString &assign(const char *sOther, lenpos_t sSize_=measure_length);
|
||||
|
||||
public:
|
||||
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
|
||||
}
|
||||
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(source.s);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
SString() : sLen(0), sizeGrowth(sizeGrowthDefault) {}
|
||||
SString(const SString &source) : SContainer(), sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(source.s, source.sLen);
|
||||
sSize = sLen = (s) ? source.sLen : 0;
|
||||
}
|
||||
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(s_);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(SBuffer &buf) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = buf.ptr();
|
||||
sSize = sLen = buf.size();
|
||||
// Consumes the given buffer!
|
||||
buf.reset();
|
||||
}
|
||||
SString(const char *s_, lenpos_t first, lenpos_t last) : sizeGrowth(sizeGrowthDefault) {
|
||||
// note: expects the "last" argument to point one beyond the range end (a la STL iterators)
|
||||
s = StringAllocate(s_ + first, last - first);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(int i) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%0d", i);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(double d, int precision) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%.*f", precision, d);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
sSize = sLen = (s) ? last - first : 0;
|
||||
}
|
||||
SString(int i);
|
||||
SString(double d, int precision);
|
||||
~SString() {
|
||||
delete []s;
|
||||
s = 0;
|
||||
sSize = 0;
|
||||
sLen = 0;
|
||||
}
|
||||
void clear() {
|
||||
@@ -122,58 +170,41 @@ public:
|
||||
}
|
||||
/** Size of buffer. */
|
||||
lenpos_t size() const {
|
||||
if (s)
|
||||
return sSize;
|
||||
else
|
||||
return 0;
|
||||
return SContainer::size();
|
||||
}
|
||||
/** Size of string in buffer. */
|
||||
lenpos_t length() const {
|
||||
return sLen;
|
||||
}
|
||||
/** Read access to a character of the string. */
|
||||
char operator[](lenpos_t i) const {
|
||||
return (s && i < sSize) ? s[i] : '\0';
|
||||
}
|
||||
SString &operator=(const char *source) {
|
||||
return assign(source);
|
||||
}
|
||||
SString &operator=(const SString &source) {
|
||||
if (this != &source) {
|
||||
assign(source.c_str());
|
||||
assign(source.s, source.sLen);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const SString &sOther) const {
|
||||
if ((s == 0) && (sOther.s == 0))
|
||||
return true;
|
||||
if ((s == 0) || (sOther.s == 0))
|
||||
return false;
|
||||
return strcmp(s, sOther.s) == 0;
|
||||
}
|
||||
bool operator==(const SString &sOther) const;
|
||||
bool operator!=(const SString &sOther) const {
|
||||
return !operator==(sOther);
|
||||
}
|
||||
bool operator==(const char *sOther) const {
|
||||
if ((s == 0) && (sOther == 0))
|
||||
return true;
|
||||
if ((s == 0) || (sOther == 0))
|
||||
return false;
|
||||
return strcmp(s, sOther) == 0;
|
||||
}
|
||||
bool operator==(const char *sOther) const;
|
||||
bool operator!=(const char *sOther) const {
|
||||
return !operator==(sOther);
|
||||
}
|
||||
bool contains(char ch) {
|
||||
if (s && *s)
|
||||
return strchr(s, ch) != 0;
|
||||
else
|
||||
return false;
|
||||
return (s && *s) ? strchr(s, ch) != 0 : false;
|
||||
}
|
||||
void setsizegrowth(lenpos_t sizeGrowth_) {
|
||||
sizeGrowth = sizeGrowth_;
|
||||
}
|
||||
const char *c_str() const {
|
||||
if (s)
|
||||
return s;
|
||||
else
|
||||
return "";
|
||||
return s ? s : "";
|
||||
}
|
||||
/** Give ownership of buffer to caller which must use delete[] to free buffer. */
|
||||
char *detach() {
|
||||
@@ -183,57 +214,10 @@ public:
|
||||
sLen = 0;
|
||||
return sRet;
|
||||
}
|
||||
char operator[](lenpos_t i) const {
|
||||
if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
|
||||
return s[i];
|
||||
else
|
||||
return '\0';
|
||||
}
|
||||
SString substr(lenpos_t subPos, lenpos_t subLen=measure_length) const {
|
||||
if (subPos >= sLen) {
|
||||
return SString(); // return a null string if start index is out of bounds
|
||||
}
|
||||
if ((subLen == measure_length) || (subPos + subLen > sLen)) {
|
||||
subLen = sLen - subPos; // can't substr past end of source string
|
||||
}
|
||||
return SString(s, subPos, subPos + subLen);
|
||||
}
|
||||
SString &lowercase(lenpos_t subPos = 0, lenpos_t subLen=measure_length) {
|
||||
if ((subLen == measure_length) || (subPos + subLen > sLen)) {
|
||||
subLen = sLen - subPos; // don't apply past end of string
|
||||
}
|
||||
for (lenpos_t i = subPos; i < subPos + subLen; i++) {
|
||||
if (s[i] < 'A' || s[i] > 'Z')
|
||||
continue;
|
||||
else
|
||||
s[i] = static_cast<char>(s[i] - 'A' + 'a');
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
int lenSep = 0;
|
||||
if (sLen && sep) { // Only add a separator if not empty
|
||||
lenSep = 1;
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther + lenSep;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew + 1 < sSize) || (grow(lenNew))) {
|
||||
if (lenSep) {
|
||||
s[sLen] = sep;
|
||||
sLen++;
|
||||
}
|
||||
memcpy(&s[sLen], sOther, sLenOther);
|
||||
sLen += sLenOther;
|
||||
s[sLen] = '\0';
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SString substr(lenpos_t subPos, lenpos_t subLen=measure_length) const;
|
||||
SString &lowercase(lenpos_t subPos = 0, lenpos_t subLen=measure_length);
|
||||
SString &uppercase(lenpos_t subPos = 0, lenpos_t subLen=measure_length);
|
||||
SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0');
|
||||
SString &operator+=(const char *sOther) {
|
||||
return append(sOther, static_cast<lenpos_t>(measure_length));
|
||||
}
|
||||
@@ -246,121 +230,40 @@ public:
|
||||
SString &appendwithseparator(const char *sOther, char sep) {
|
||||
return append(sOther, strlen(sOther), sep);
|
||||
}
|
||||
SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length) {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew + 1 < sSize) || grow(lenNew)) {
|
||||
lenpos_t moveChars = sLen - pos + 1;
|
||||
for (lenpos_t i = moveChars; i > 0; i--) {
|
||||
s[pos + sLenOther + i - 1] = s[pos + i - 1];
|
||||
}
|
||||
memcpy(s + pos, sOther, sLenOther);
|
||||
sLen = lenNew;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/** Remove @a len characters from the @a pos position, included.
|
||||
SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length);
|
||||
|
||||
/**
|
||||
* Remove @a len characters from the @a pos position, included.
|
||||
* Characters at pos + len and beyond replace characters at pos.
|
||||
* If @a len is 0, or greater than the length of the string
|
||||
* starting at @a pos, the string is just truncated at @a pos.
|
||||
*/
|
||||
void remove(lenpos_t pos, lenpos_t len) {
|
||||
if (len < 1 || pos + len >= sLen) {
|
||||
s[pos] = '\0';
|
||||
sLen = pos;
|
||||
} else {
|
||||
for (lenpos_t i = pos; i < sLen - len + 1; i++) {
|
||||
s[i] = s[i+len];
|
||||
}
|
||||
sLen -= len;
|
||||
}
|
||||
}
|
||||
void remove(lenpos_t pos, lenpos_t len);
|
||||
|
||||
SString &change(lenpos_t pos, char ch) {
|
||||
if (pos >= sLen) { // character changed must be in string bounds
|
||||
return *this;
|
||||
if (pos < sLen) { // character changed must be in string bounds
|
||||
*(s + pos) = ch;
|
||||
}
|
||||
*(s + pos) = ch;
|
||||
return *this;
|
||||
}
|
||||
/** Read an integral numeric value from the string. */
|
||||
int value() const {
|
||||
if (s)
|
||||
return atoi(s);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
int search(const char *sFind, lenpos_t start=0) const {
|
||||
if (start < sLen) {
|
||||
const char *sFound = strstr(s + start, sFind);
|
||||
if (sFound) {
|
||||
return sFound - s;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return s ? atoi(s) : 0;
|
||||
}
|
||||
bool startswith(const char *prefix);
|
||||
bool endswith(const char *suffix);
|
||||
int search(const char *sFind, lenpos_t start=0) const;
|
||||
bool contains(const char *sFind) {
|
||||
return search(sFind) >= 0;
|
||||
}
|
||||
int substitute(char chFind, char chReplace) {
|
||||
int c = 0;
|
||||
char *t = s;
|
||||
while (t) {
|
||||
t = strchr(t, chFind);
|
||||
if (t) {
|
||||
*t = chReplace;
|
||||
t++;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
int substitute(const char *sFind, const char *sReplace) {
|
||||
int c = 0;
|
||||
lenpos_t lenFind = strlen(sFind);
|
||||
lenpos_t lenReplace = strlen(sReplace);
|
||||
int posFound = search(sFind);
|
||||
while (posFound >= 0) {
|
||||
remove(posFound, lenFind);
|
||||
insert(posFound, sReplace, lenReplace);
|
||||
posFound = search(sFind, posFound + lenReplace);
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
int substitute(char chFind, char chReplace);
|
||||
int substitute(const char *sFind, const char *sReplace);
|
||||
int remove(const char *sFind) {
|
||||
return substitute(sFind, "");
|
||||
}
|
||||
/**
|
||||
* Duplicate a C string.
|
||||
* Allocate memory of the given size, or big enough to fit the string if length isn't given;
|
||||
* then copy the given string in the allocated memory.
|
||||
* @return the pointer to the new string
|
||||
*/
|
||||
static char *StringAllocate(
|
||||
const char *s, ///< The string to duplicate
|
||||
lenpos_t len=measure_length) ///< The length of memory to allocate. Optional.
|
||||
{
|
||||
if (s == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (len == measure_length) {
|
||||
len = strlen(s);
|
||||
}
|
||||
char *sNew = new char[len + 1];
|
||||
if (sNew) {
|
||||
memcpy(sNew, s, len);
|
||||
sNew[len] = '\0';
|
||||
}
|
||||
return sNew;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Duplicate a C string.
|
||||
* Allocate memory of the given size, or big enough to fit the string if length isn't given;
|
||||
@@ -369,9 +272,9 @@ public:
|
||||
*/
|
||||
inline char *StringDup(
|
||||
const char *s, ///< The string to duplicate
|
||||
SString::lenpos_t len=SString::measure_length) ///< The length of memory to allocate. Optional.
|
||||
SContainer::lenpos_t len=SContainer::measure_length) ///< The length of memory to allocate. Optional.
|
||||
{
|
||||
return SString::StringAllocate(s, len);
|
||||
return SContainer::StringAllocate(s, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -69,6 +69,14 @@
|
||||
#define SCLEX_FORTH 52
|
||||
#define SCLEX_ERLANG 53
|
||||
#define SCLEX_OCTAVE 54
|
||||
#define SCLEX_MSSQL 55
|
||||
#define SCLEX_VERILOG 56
|
||||
#define SCLEX_KIX 57
|
||||
#define SCLEX_GUI4CLI 58
|
||||
#define SCLEX_SPECMAN 59
|
||||
#define SCLEX_AU3 60
|
||||
#define SCLEX_APDL 61
|
||||
#define SCLEX_BASH 62
|
||||
#define SCLEX_AUTOMATIC 1000
|
||||
#define SCE_P_DEFAULT 0
|
||||
#define SCE_P_COMMENTLINE 1
|
||||
@@ -191,6 +199,7 @@
|
||||
#define SCE_HP_DEFNAME 100
|
||||
#define SCE_HP_OPERATOR 101
|
||||
#define SCE_HP_IDENTIFIER 102
|
||||
#define SCE_HPHP_COMPLEX_VARIABLE 104
|
||||
#define SCE_HPA_START 105
|
||||
#define SCE_HPA_DEFAULT 106
|
||||
#define SCE_HPA_COMMENTLINE 107
|
||||
@@ -257,6 +266,8 @@
|
||||
#define SCE_B_KEYWORD2 10
|
||||
#define SCE_B_KEYWORD3 11
|
||||
#define SCE_B_KEYWORD4 12
|
||||
#define SCE_B_CONSTANT 13
|
||||
#define SCE_B_ASM 14
|
||||
#define SCE_PROPS_DEFAULT 0
|
||||
#define SCE_PROPS_COMMENT 1
|
||||
#define SCE_PROPS_SECTION 2
|
||||
@@ -306,6 +317,7 @@
|
||||
#define SCE_ERR_IFC 16
|
||||
#define SCE_ERR_IFORT 17
|
||||
#define SCE_ERR_ABSF 18
|
||||
#define SCE_ERR_TIDY 19
|
||||
#define SCE_BAT_DEFAULT 0
|
||||
#define SCE_BAT_COMMENT 1
|
||||
#define SCE_BAT_WORD 2
|
||||
@@ -556,6 +568,7 @@
|
||||
#define SCE_NSIS_IFDEFINEDEF 11
|
||||
#define SCE_NSIS_MACRODEF 12
|
||||
#define SCE_NSIS_STRINGVAR 13
|
||||
#define SCE_NSIS_NUMBER 14
|
||||
#define SCE_MMIXAL_LEADWS 0
|
||||
#define SCE_MMIXAL_COMMENT 1
|
||||
#define SCE_MMIXAL_LABEL 2
|
||||
@@ -633,6 +646,109 @@
|
||||
#define SCE_ERLANG_SEPARATOR 12
|
||||
#define SCE_ERLANG_NODE_NAME 13
|
||||
#define SCE_ERLANG_UNKNOWN 31
|
||||
#define SCE_MSSQL_DEFAULT 0
|
||||
#define SCE_MSSQL_COMMENT 1
|
||||
#define SCE_MSSQL_LINE_COMMENT 2
|
||||
#define SCE_MSSQL_NUMBER 3
|
||||
#define SCE_MSSQL_STRING 4
|
||||
#define SCE_MSSQL_OPERATOR 5
|
||||
#define SCE_MSSQL_IDENTIFIER 6
|
||||
#define SCE_MSSQL_VARIABLE 7
|
||||
#define SCE_MSSQL_COLUMN_NAME 8
|
||||
#define SCE_MSSQL_STATEMENT 9
|
||||
#define SCE_MSSQL_DATATYPE 10
|
||||
#define SCE_MSSQL_SYSTABLE 11
|
||||
#define SCE_MSSQL_GLOBAL_VARIABLE 12
|
||||
#define SCE_MSSQL_FUNCTION 13
|
||||
#define SCE_MSSQL_STORED_PROCEDURE 14
|
||||
#define SCE_MSSQL_DEFAULT_PREF_DATATYPE 15
|
||||
#define SCE_MSSQL_COLUMN_NAME_2 16
|
||||
#define SCE_V_DEFAULT 0
|
||||
#define SCE_V_COMMENT 1
|
||||
#define SCE_V_COMMENTLINE 2
|
||||
#define SCE_V_COMMENTLINEBANG 3
|
||||
#define SCE_V_NUMBER 4
|
||||
#define SCE_V_WORD 5
|
||||
#define SCE_V_STRING 6
|
||||
#define SCE_V_WORD2 7
|
||||
#define SCE_V_WORD3 8
|
||||
#define SCE_V_PREPROCESSOR 9
|
||||
#define SCE_V_OPERATOR 10
|
||||
#define SCE_V_IDENTIFIER 11
|
||||
#define SCE_V_STRINGEOL 12
|
||||
#define SCE_V_USER 19
|
||||
#define SCE_KIX_DEFAULT 0
|
||||
#define SCE_KIX_COMMENT 1
|
||||
#define SCE_KIX_STRING1 2
|
||||
#define SCE_KIX_STRING2 3
|
||||
#define SCE_KIX_NUMBER 4
|
||||
#define SCE_KIX_VAR 5
|
||||
#define SCE_KIX_MACRO 6
|
||||
#define SCE_KIX_KEYWORD 7
|
||||
#define SCE_KIX_FUNCTIONS 8
|
||||
#define SCE_KIX_OPERATOR 9
|
||||
#define SCE_KIX_IDENTIFIER 31
|
||||
#define SCE_GC_DEFAULT 0
|
||||
#define SCE_GC_COMMENTLINE 1
|
||||
#define SCE_GC_COMMENTBLOCK 2
|
||||
#define SCE_GC_GLOBAL 3
|
||||
#define SCE_GC_EVENT 4
|
||||
#define SCE_GC_ATTRIBUTE 5
|
||||
#define SCE_GC_CONTROL 6
|
||||
#define SCE_GC_COMMAND 7
|
||||
#define SCE_GC_STRING 8
|
||||
#define SCE_GC_OPERATOR 9
|
||||
#define SCE_SN_DEFAULT 0
|
||||
#define SCE_SN_CODE 1
|
||||
#define SCE_SN_COMMENTLINE 2
|
||||
#define SCE_SN_COMMENTLINEBANG 3
|
||||
#define SCE_SN_NUMBER 4
|
||||
#define SCE_SN_WORD 5
|
||||
#define SCE_SN_STRING 6
|
||||
#define SCE_SN_WORD2 7
|
||||
#define SCE_SN_WORD3 8
|
||||
#define SCE_SN_PREPROCESSOR 9
|
||||
#define SCE_SN_OPERATOR 10
|
||||
#define SCE_SN_IDENTIFIER 11
|
||||
#define SCE_SN_STRINGEOL 12
|
||||
#define SCE_SN_REGEXTAG 13
|
||||
#define SCE_SN_SIGNAL 14
|
||||
#define SCE_SN_USER 19
|
||||
#define SCE_AU3_DEFAULT 0
|
||||
#define SCE_AU3_COMMENT 1
|
||||
#define SCE_AU3_COMMENTBLOCK 2
|
||||
#define SCE_AU3_NUMBER 3
|
||||
#define SCE_AU3_FUNCTION 4
|
||||
#define SCE_AU3_KEYWORD 5
|
||||
#define SCE_AU3_MACRO 6
|
||||
#define SCE_AU3_STRING 7
|
||||
#define SCE_AU3_OPERATOR 8
|
||||
#define SCE_AU3_VARIABLE 9
|
||||
#define SCE_AU3_SENT 10
|
||||
#define SCE_AU3_PREPROCESSOR 11
|
||||
#define SCE_APDL_DEFAULT 0
|
||||
#define SCE_APDL_COMMENT 1
|
||||
#define SCE_APDL_COMMENTBLOCK 2
|
||||
#define SCE_APDL_NUMBER 3
|
||||
#define SCE_APDL_STRING 4
|
||||
#define SCE_APDL_WORD 5
|
||||
#define SCE_APDL_COMMAND 6
|
||||
#define SCE_APDL_PROCESSOR 7
|
||||
#define SCE_APDL_FUNCTION 8
|
||||
#define SCE_SH_DEFAULT 0
|
||||
#define SCE_SH_ERROR 1
|
||||
#define SCE_SH_COMMENTLINE 2
|
||||
#define SCE_SH_NUMBER 3
|
||||
#define SCE_SH_WORD 4
|
||||
#define SCE_SH_STRING 5
|
||||
#define SCE_SH_CHARACTER 6
|
||||
#define SCE_SH_OPERATOR 7
|
||||
#define SCE_SH_IDENTIFIER 8
|
||||
#define SCE_SH_SCALAR 9
|
||||
#define SCE_SH_PARAM 10
|
||||
#define SCE_SH_BACKTICKS 11
|
||||
#define SCE_SH_HERE_DELIM 12
|
||||
#define SCE_SH_HERE_Q 13
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
#endif
|
||||
|
@@ -388,6 +388,18 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_WRAP_WORD 1
|
||||
#define SCI_SETWRAPMODE 2268
|
||||
#define SCI_GETWRAPMODE 2269
|
||||
#define SC_WRAPVISUALFLAG_NONE 0x0000
|
||||
#define SC_WRAPVISUALFLAG_END 0x0001
|
||||
#define SC_WRAPVISUALFLAG_START 0x0002
|
||||
#define SCI_SETWRAPVISUALFLAGS 2460
|
||||
#define SCI_GETWRAPVISUALFLAGS 2461
|
||||
#define SC_WRAPVISUALFLAGLOC_DEFAULT 0x0000
|
||||
#define SC_WRAPVISUALFLAGLOC_END_BY_TEXT 0x0001
|
||||
#define SC_WRAPVISUALFLAGLOC_START_BY_TEXT 0x0002
|
||||
#define SCI_SETWRAPVISUALFLAGSLOCATION 2462
|
||||
#define SCI_GETWRAPVISUALFLAGSLOCATION 2463
|
||||
#define SCI_SETWRAPSTARTINDENT 2464
|
||||
#define SCI_GETWRAPSTARTINDENT 2465
|
||||
#define SC_CACHE_NONE 0
|
||||
#define SC_CACHE_CARET 1
|
||||
#define SC_CACHE_PAGE 2
|
||||
@@ -570,6 +582,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_SETWHITESPACECHARS 2443
|
||||
#define SCI_SETCHARSDEFAULT 2444
|
||||
#define SCI_AUTOCGETCURRENT 2445
|
||||
#define SCI_ALLOCATE 2446
|
||||
#define SCI_STARTRECORD 3001
|
||||
#define SCI_STOPRECORD 3002
|
||||
#define SCI_SETLEXER 4001
|
||||
|
@@ -53,7 +53,7 @@
|
||||
## position -> integer position in a document
|
||||
## colour -> colour integer containing red, green and blue bytes.
|
||||
## string -> pointer to const character
|
||||
## stringresult -> pointer to character
|
||||
## stringresult -> pointer to character, NULL-> return size of result
|
||||
## cells -> pointer to array of cells, each cell containing a style byte and character byte
|
||||
## textrange -> range of a min and a max position with an output string
|
||||
## findtext -> searchrange, text -> foundposition
|
||||
@@ -70,11 +70,13 @@
|
||||
## Client code should ignore definitions containing types it does not understand, except
|
||||
## for possibly #defining the constants
|
||||
|
||||
## Line numbers and positions start at 0.
|
||||
## String arguments may contain NUL ('\0') characters where the calls provide a length
|
||||
## argument and retrieve NUL characters. All retrieved strings except for those retrieved
|
||||
## by GetLine also have a NUL appended but client code should calculate the size that
|
||||
## will be returned rather than relying upon the NUL whenever possible. Allow for the
|
||||
## extra NUL character when allocating buffers.
|
||||
## extra NUL character when allocating buffers. The size to allocate for a stringresult
|
||||
## can be determined by calling with a NULL (0) pointer.
|
||||
|
||||
cat Basics
|
||||
|
||||
@@ -87,7 +89,7 @@ val SCI_START=2000
|
||||
val SCI_OPTIONAL_START=3000
|
||||
val SCI_LEXER_START=4000
|
||||
|
||||
# Add text to the document.
|
||||
# Add text to the document at current position.
|
||||
fun void AddText=2001(int length, string text)
|
||||
|
||||
# Add array of cells to document.
|
||||
@@ -102,7 +104,7 @@ fun void ClearAll=2004(,)
|
||||
# Set all style bytes to 0, remove all folding information.
|
||||
fun void ClearDocumentStyle=2005(,)
|
||||
|
||||
# The number of characters in the document.
|
||||
# Returns the number of characters in the document.
|
||||
get int GetLength=2006(,)
|
||||
|
||||
# Returns the character byte at the position.
|
||||
@@ -999,6 +1001,34 @@ set void SetWrapMode=2268(int mode,)
|
||||
# Retrieve whether text is word wrapped.
|
||||
get int GetWrapMode=2269(,)
|
||||
|
||||
enu WrapVisualFlag=SC_WRAPVISUALFLAG_
|
||||
val SC_WRAPVISUALFLAG_NONE=0x0000
|
||||
val SC_WRAPVISUALFLAG_END=0x0001
|
||||
val SC_WRAPVISUALFLAG_START=0x0002
|
||||
|
||||
# Set the display mode of visual flags for wrapped lines.
|
||||
set void SetWrapVisualFlags=2460(int wrapVisualFlags,)
|
||||
|
||||
# Retrive the display mode of visual flags for wrapped lines.
|
||||
get int GetWrapVisualFlags=2461(,)
|
||||
|
||||
enu WrapVisualLocation=SC_WRAPVISUALFLAGLOC_
|
||||
val SC_WRAPVISUALFLAGLOC_DEFAULT=0x0000
|
||||
val SC_WRAPVISUALFLAGLOC_END_BY_TEXT=0x0001
|
||||
val SC_WRAPVISUALFLAGLOC_START_BY_TEXT=0x0002
|
||||
|
||||
# Set the location of visual flags for wrapped lines.
|
||||
set void SetWrapVisualFlagsLocation=2462(int wrapVisualFlagsLocation,)
|
||||
|
||||
# Retrive the location of visual flags for wrapped lines.
|
||||
get int GetWrapVisualFlagsLocation=2463(,)
|
||||
|
||||
# Set the start indent for wrapped lines.
|
||||
set void SetWrapStartIndent=2464(int indent,)
|
||||
|
||||
# Retrive the start indent for wrapped lines.
|
||||
get int GetWrapStartIndent=2465(,)
|
||||
|
||||
enu LineCache=SC_CACHE_
|
||||
val SC_CACHE_NONE=0
|
||||
val SC_CACHE_CARET=1
|
||||
@@ -1550,6 +1580,9 @@ fun void SetCharsDefault=2444(,)
|
||||
# Get currently selected item position in the auto-completion list
|
||||
fun int AutoCGetCurrent=2445(,)
|
||||
|
||||
# Enlarge the document to a particular size of text bytes.
|
||||
fun void Allocate=2446(int bytes,)
|
||||
|
||||
# Start notifying the container of all key presses and commands.
|
||||
fun void StartRecord=3001(,)
|
||||
|
||||
@@ -1692,6 +1725,14 @@ val SCLEX_POWERBASIC=51
|
||||
val SCLEX_FORTH=52
|
||||
val SCLEX_ERLANG=53
|
||||
val SCLEX_OCTAVE=54
|
||||
val SCLEX_MSSQL=55
|
||||
val SCLEX_VERILOG=56
|
||||
val SCLEX_KIX=57
|
||||
val SCLEX_GUI4CLI=58
|
||||
val SCLEX_SPECMAN=59
|
||||
val SCLEX_AU3=60
|
||||
val SCLEX_APDL=61
|
||||
val SCLEX_BASH=62
|
||||
|
||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
@@ -1840,6 +1881,8 @@ val SCE_HP_CLASSNAME=99
|
||||
val SCE_HP_DEFNAME=100
|
||||
val SCE_HP_OPERATOR=101
|
||||
val SCE_HP_IDENTIFIER=102
|
||||
# PHP
|
||||
val SCE_HPHP_COMPLEX_VARIABLE=104
|
||||
# ASP Python
|
||||
val SCE_HPA_START=105
|
||||
val SCE_HPA_DEFAULT=106
|
||||
@@ -1914,6 +1957,8 @@ val SCE_B_STRINGEOL=9
|
||||
val SCE_B_KEYWORD2=10
|
||||
val SCE_B_KEYWORD3=11
|
||||
val SCE_B_KEYWORD4=12
|
||||
val SCE_B_CONSTANT=13
|
||||
val SCE_B_ASM=14
|
||||
# Lexical states for SCLEX_PROPERTIES
|
||||
lex Properties=SCLEX_PROPERTIES SCE_PROPS_
|
||||
val SCE_PROPS_DEFAULT=0
|
||||
@@ -1971,6 +2016,7 @@ val SCE_ERR_ELF=15
|
||||
val SCE_ERR_IFC=16
|
||||
val SCE_ERR_IFORT=17
|
||||
val SCE_ERR_ABSF=18
|
||||
val SCE_ERR_TIDY=19
|
||||
# Lexical states for SCLEX_BATCH
|
||||
lex Batch=SCLEX_BATCH SCE_BAT_
|
||||
val SCE_BAT_DEFAULT=0
|
||||
@@ -2266,6 +2312,7 @@ val SCE_NSIS_SUBSECTIONDEF=10
|
||||
val SCE_NSIS_IFDEFINEDEF=11
|
||||
val SCE_NSIS_MACRODEF=12
|
||||
val SCE_NSIS_STRINGVAR=13
|
||||
val SCE_NSIS_NUMBER=14
|
||||
# Lexical states for SCLEX_MMIXAL
|
||||
lex MMIXAL=SCLEX_MMIXAL SCE_MMIXAL_
|
||||
val SCE_MMIXAL_LEADWS=0
|
||||
@@ -2358,7 +2405,124 @@ val SCE_ERLANG_NODE_NAME=13
|
||||
val SCE_ERLANG_UNKNOWN=31
|
||||
# Lexical states for SCLEX_OCTAVE are identical to MatLab
|
||||
lex Octave=SCLEX_OCTAVE SCE_MATLAB_
|
||||
|
||||
# Lexical states for SCLEX_MSSQL
|
||||
lex MSSQL=SCLEX_MSSQL SCE_MSSQL_
|
||||
val SCE_MSSQL_DEFAULT=0
|
||||
val SCE_MSSQL_COMMENT=1
|
||||
val SCE_MSSQL_LINE_COMMENT=2
|
||||
val SCE_MSSQL_NUMBER=3
|
||||
val SCE_MSSQL_STRING=4
|
||||
val SCE_MSSQL_OPERATOR=5
|
||||
val SCE_MSSQL_IDENTIFIER=6
|
||||
val SCE_MSSQL_VARIABLE=7
|
||||
val SCE_MSSQL_COLUMN_NAME=8
|
||||
val SCE_MSSQL_STATEMENT=9
|
||||
val SCE_MSSQL_DATATYPE=10
|
||||
val SCE_MSSQL_SYSTABLE=11
|
||||
val SCE_MSSQL_GLOBAL_VARIABLE=12
|
||||
val SCE_MSSQL_FUNCTION=13
|
||||
val SCE_MSSQL_STORED_PROCEDURE=14
|
||||
val SCE_MSSQL_DEFAULT_PREF_DATATYPE=15
|
||||
val SCE_MSSQL_COLUMN_NAME_2=16
|
||||
# Lexical states for SCLEX_VERILOG
|
||||
lex Verilog=SCLEX_VERILOG SCE_V_
|
||||
val SCE_V_DEFAULT=0
|
||||
val SCE_V_COMMENT=1
|
||||
val SCE_V_COMMENTLINE=2
|
||||
val SCE_V_COMMENTLINEBANG=3
|
||||
val SCE_V_NUMBER=4
|
||||
val SCE_V_WORD=5
|
||||
val SCE_V_STRING=6
|
||||
val SCE_V_WORD2=7
|
||||
val SCE_V_WORD3=8
|
||||
val SCE_V_PREPROCESSOR=9
|
||||
val SCE_V_OPERATOR=10
|
||||
val SCE_V_IDENTIFIER=11
|
||||
val SCE_V_STRINGEOL=12
|
||||
val SCE_V_USER=19
|
||||
# Lexical states for SCLEX_KIX
|
||||
lex Kix=SCLEX_KIX SCE_KIX_
|
||||
val SCE_KIX_DEFAULT=0
|
||||
val SCE_KIX_COMMENT=1
|
||||
val SCE_KIX_STRING1=2
|
||||
val SCE_KIX_STRING2=3
|
||||
val SCE_KIX_NUMBER=4
|
||||
val SCE_KIX_VAR=5
|
||||
val SCE_KIX_MACRO=6
|
||||
val SCE_KIX_KEYWORD=7
|
||||
val SCE_KIX_FUNCTIONS=8
|
||||
val SCE_KIX_OPERATOR=9
|
||||
val SCE_KIX_IDENTIFIER=31
|
||||
# Lexical states for SCLEX_GUI4CLI
|
||||
val SCE_GC_DEFAULT=0
|
||||
val SCE_GC_COMMENTLINE=1
|
||||
val SCE_GC_COMMENTBLOCK=2
|
||||
val SCE_GC_GLOBAL=3
|
||||
val SCE_GC_EVENT=4
|
||||
val SCE_GC_ATTRIBUTE=5
|
||||
val SCE_GC_CONTROL=6
|
||||
val SCE_GC_COMMAND=7
|
||||
val SCE_GC_STRING=8
|
||||
val SCE_GC_OPERATOR=9
|
||||
# Lexical states for SCLEX_SPECMAN
|
||||
lex Specman=SCLEX_SPECMAN SCE_SN_
|
||||
val SCE_SN_DEFAULT=0
|
||||
val SCE_SN_CODE=1
|
||||
val SCE_SN_COMMENTLINE=2
|
||||
val SCE_SN_COMMENTLINEBANG=3
|
||||
val SCE_SN_NUMBER=4
|
||||
val SCE_SN_WORD=5
|
||||
val SCE_SN_STRING=6
|
||||
val SCE_SN_WORD2=7
|
||||
val SCE_SN_WORD3=8
|
||||
val SCE_SN_PREPROCESSOR=9
|
||||
val SCE_SN_OPERATOR=10
|
||||
val SCE_SN_IDENTIFIER=11
|
||||
val SCE_SN_STRINGEOL=12
|
||||
val SCE_SN_REGEXTAG=13
|
||||
val SCE_SN_SIGNAL=14
|
||||
val SCE_SN_USER=19
|
||||
# Lexical states for SCLEX_AU3
|
||||
lex Au3=SCLEX_AU3 SCE_AU3_
|
||||
val SCE_AU3_DEFAULT=0
|
||||
val SCE_AU3_COMMENT=1
|
||||
val SCE_AU3_COMMENTBLOCK=2
|
||||
val SCE_AU3_NUMBER=3
|
||||
val SCE_AU3_FUNCTION=4
|
||||
val SCE_AU3_KEYWORD=5
|
||||
val SCE_AU3_MACRO=6
|
||||
val SCE_AU3_STRING=7
|
||||
val SCE_AU3_OPERATOR=8
|
||||
val SCE_AU3_VARIABLE=9
|
||||
val SCE_AU3_SENT=10
|
||||
val SCE_AU3_PREPROCESSOR=11
|
||||
# Lexical states for SCLEX_APDL
|
||||
lex APDL=SCLEX_APDL SCE_APDL_
|
||||
val SCE_APDL_DEFAULT=0
|
||||
val SCE_APDL_COMMENT=1
|
||||
val SCE_APDL_COMMENTBLOCK=2
|
||||
val SCE_APDL_NUMBER=3
|
||||
val SCE_APDL_STRING=4
|
||||
val SCE_APDL_WORD=5
|
||||
val SCE_APDL_COMMAND=6
|
||||
val SCE_APDL_PROCESSOR=7
|
||||
val SCE_APDL_FUNCTION=8
|
||||
# Lexical states for SCLEX_BASH
|
||||
lex Bash=SCLEX_BASH SCE_SH_
|
||||
val SCE_SH_DEFAULT=0
|
||||
val SCE_SH_ERROR=1
|
||||
val SCE_SH_COMMENTLINE=2
|
||||
val SCE_SH_NUMBER=3
|
||||
val SCE_SH_WORD=4
|
||||
val SCE_SH_STRING=5
|
||||
val SCE_SH_CHARACTER=6
|
||||
val SCE_SH_OPERATOR=7
|
||||
val SCE_SH_IDENTIFIER=8
|
||||
val SCE_SH_SCALAR=9
|
||||
val SCE_SH_PARAM=10
|
||||
val SCE_SH_BACKTICKS=11
|
||||
val SCE_SH_HERE_DELIM=12
|
||||
val SCE_SH_HERE_Q=13
|
||||
# Events
|
||||
|
||||
evt void StyleNeeded=2000(int position)
|
||||
|
@@ -49,7 +49,7 @@ void CallTip::RefreshColourPalette(Palette &pal, bool want) {
|
||||
}
|
||||
|
||||
static bool IsArrowCharacter(char ch) {
|
||||
return (ch >= 0) && (ch <= '\002');
|
||||
return (ch == 0) || (ch == '\001') || (ch == '\002');
|
||||
}
|
||||
|
||||
void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
||||
|
@@ -627,21 +627,11 @@ void CellBuffer::RoomFor(int insertionLength) {
|
||||
//Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
|
||||
if (gaplen <= insertionLength) {
|
||||
//Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
|
||||
GapTo(length);
|
||||
if (growSize * 6 < size)
|
||||
growSize *= 2;
|
||||
int newSize = size + insertionLength + growSize;
|
||||
//Platform::DebugPrintf("moved gap %d\n", newSize);
|
||||
char *newBody = new char[newSize];
|
||||
memcpy(newBody, body, size);
|
||||
delete []body;
|
||||
body = newBody;
|
||||
gaplen += newSize - size;
|
||||
part2body = body + gaplen;
|
||||
size = newSize;
|
||||
//Platform::DebugPrintf("end need room %d %d - size=%d length=%d\n", gaplen, insertionLength,size,length);
|
||||
Allocate(newSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// To make it easier to write code that uses ByteAt, a position outside the range of the buffer
|
||||
@@ -791,6 +781,19 @@ int CellBuffer::Length() {
|
||||
return ByteLength() / 2;
|
||||
}
|
||||
|
||||
void CellBuffer::Allocate(int newSize) {
|
||||
if (newSize > length) {
|
||||
GapTo(length);
|
||||
char *newBody = new char[newSize];
|
||||
memcpy(newBody, body, length);
|
||||
delete []body;
|
||||
body = newBody;
|
||||
gaplen += newSize - size;
|
||||
part2body = body + gaplen;
|
||||
size = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
int CellBuffer::Lines() {
|
||||
//Platform::DebugPrintf("Lines = %d\n", lv.lines);
|
||||
return lv.lines;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file CellBuffer.h
|
||||
** Manages the text of the document.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CELLBUFFER_H
|
||||
@@ -150,12 +150,14 @@ public:
|
||||
*/
|
||||
class CellBuffer {
|
||||
private:
|
||||
char *body;
|
||||
int size;
|
||||
int length;
|
||||
int part1len;
|
||||
int gaplen;
|
||||
char *part2body;
|
||||
char *body; ///< The cell buffer itself.
|
||||
int size; ///< Allocated size of the buffer.
|
||||
int length; ///< Total length of the data.
|
||||
int part1len; ///< Length of the first part.
|
||||
int gaplen; ///< Length of the gap between the two parts.
|
||||
char *part2body; ///< The second part of the cell buffer.
|
||||
///< Doesn't point after the gap but set so that
|
||||
///< part2body[position] is consistent with body[position].
|
||||
bool readOnly;
|
||||
int growSize;
|
||||
|
||||
@@ -184,6 +186,7 @@ public:
|
||||
|
||||
int ByteLength();
|
||||
int Length();
|
||||
void Allocate(int newSize);
|
||||
int Lines();
|
||||
int LineStart(int line);
|
||||
int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
|
||||
@@ -212,7 +215,7 @@ public:
|
||||
int GetMark(int line);
|
||||
void DeleteAllMarks(int markerNum);
|
||||
int LineFromHandle(int markerHandle);
|
||||
|
||||
|
||||
/// Actions without undo
|
||||
void BasicInsertString(int position, char *s, int insertLength);
|
||||
void BasicDeleteChars(int position, int deleteLength);
|
||||
|
@@ -50,13 +50,14 @@ Document::Document() {
|
||||
stylingBits = 5;
|
||||
stylingBitsMask = 0x1F;
|
||||
stylingMask = 0;
|
||||
SetDefaultCharClasses();
|
||||
SetDefaultCharClasses(true);
|
||||
endStyled = 0;
|
||||
styleClock = 0;
|
||||
enteredCount = 0;
|
||||
enteredReadOnlyCount = 0;
|
||||
tabInChars = 8;
|
||||
indentInChars = 0;
|
||||
actualIndentInChars = 8;
|
||||
useTabs = true;
|
||||
tabIndents = true;
|
||||
backspaceUnindents = false;
|
||||
@@ -206,7 +207,7 @@ int Document::GetLastChild(int lineParent, int level) {
|
||||
}
|
||||
|
||||
int Document::GetFoldParent(int line) {
|
||||
int level = GetLevel(line);
|
||||
int level = GetLevel(line) & SC_FOLDLEVELNUMBERMASK;
|
||||
int lineLook = line - 1;
|
||||
while ((lineLook > 0) && (
|
||||
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
|
||||
@@ -379,6 +380,9 @@ bool Document::DeleteChars(int pos, int len) {
|
||||
return !cb.IsReadOnly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a styled string (char/style pairs) with a length.
|
||||
*/
|
||||
bool Document::InsertStyledString(int position, char *s, int insertLength) {
|
||||
if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
|
||||
enteredReadOnlyCount++;
|
||||
@@ -498,6 +502,9 @@ int Document::Redo() {
|
||||
return newPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single character.
|
||||
*/
|
||||
bool Document::InsertChar(int pos, char ch) {
|
||||
char chs[2];
|
||||
chs[0] = ch;
|
||||
@@ -505,12 +512,16 @@ bool Document::InsertChar(int pos, char ch) {
|
||||
return InsertStyledString(pos*2, chs, 2);
|
||||
}
|
||||
|
||||
// Insert a null terminated string
|
||||
/**
|
||||
* Insert a null terminated string.
|
||||
*/
|
||||
bool Document::InsertString(int position, const char *s) {
|
||||
return InsertString(position, s, strlen(s));
|
||||
}
|
||||
|
||||
// Insert a string with a length
|
||||
/**
|
||||
* Insert a string with a length.
|
||||
*/
|
||||
bool Document::InsertString(int position, const char *s, size_t insertLength) {
|
||||
bool changed = false;
|
||||
char *sWithStyle = new char[insertLength * 2];
|
||||
@@ -1163,21 +1174,21 @@ void Document::ChangeCase(Range r, bool makeUpperCase) {
|
||||
}
|
||||
}
|
||||
|
||||
void Document::SetDefaultCharClasses() {
|
||||
void Document::SetDefaultCharClasses(bool includeWordClass) {
|
||||
// Initialize all char classes to default values
|
||||
for (int ch = 0; ch < 256; ch++) {
|
||||
if (ch == '\r' || ch == '\n')
|
||||
charClass[ch] = ccNewLine;
|
||||
else if (ch < 0x20 || ch == ' ')
|
||||
charClass[ch] = ccSpace;
|
||||
else if (ch >= 0x80 || isalnum(ch) || ch == '_')
|
||||
else if (includeWordClass && (ch >= 0x80 || isalnum(ch) || ch == '_'))
|
||||
charClass[ch] = ccWord;
|
||||
else
|
||||
charClass[ch] = ccPunctuation;
|
||||
}
|
||||
}
|
||||
|
||||
void Document::SetCharClasses(unsigned char *chars, charClassification newCharClass) {
|
||||
void Document::SetCharClasses(const unsigned char *chars, charClassification newCharClass) {
|
||||
// Apply the newCharClass to the specifed chars
|
||||
if (chars) {
|
||||
while (*chars) {
|
||||
@@ -1246,10 +1257,7 @@ bool Document::SetStyles(int length, char *styles) {
|
||||
|
||||
bool Document::EnsureStyledTo(int pos) {
|
||||
if (pos > GetEndStyled()) {
|
||||
styleClock++;
|
||||
if (styleClock > 0x100000) {
|
||||
styleClock = 0;
|
||||
}
|
||||
IncrementStyleClock();
|
||||
// Ask the watchers to style, and stop as soon as one responds.
|
||||
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++) {
|
||||
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
|
||||
@@ -1258,6 +1266,13 @@ bool Document::EnsureStyledTo(int pos) {
|
||||
return pos <= GetEndStyled();
|
||||
}
|
||||
|
||||
void Document::IncrementStyleClock() {
|
||||
styleClock++;
|
||||
if (styleClock > 0x100000) {
|
||||
styleClock = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
if ((watchers[i].watcher == watcher) &&
|
||||
|
@@ -87,7 +87,7 @@ public:
|
||||
userData = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
|
||||
|
||||
private:
|
||||
@@ -116,6 +116,7 @@ public:
|
||||
int dbcsCodePage;
|
||||
int tabInChars;
|
||||
int indentInChars;
|
||||
int actualIndentInChars;
|
||||
bool useTabs;
|
||||
bool tabIndents;
|
||||
bool backspaceUnindents;
|
||||
@@ -193,6 +194,7 @@ public:
|
||||
int NextWordStart(int pos, int delta);
|
||||
int NextWordEnd(int pos, int delta);
|
||||
int Length() { return cb.Length(); }
|
||||
void Allocate(int newSize) { cb.Allocate(newSize*2); }
|
||||
long FindText(int minPos, int maxPos, const char *s,
|
||||
bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length);
|
||||
long FindText(int iMessage, unsigned long wParam, long lParam);
|
||||
@@ -200,9 +202,9 @@ public:
|
||||
int LinesTotal();
|
||||
|
||||
void ChangeCase(Range r, bool makeUpperCase);
|
||||
|
||||
void SetDefaultCharClasses();
|
||||
void SetCharClasses(unsigned char *chars, charClassification newCharClass);
|
||||
|
||||
void SetDefaultCharClasses(bool includeWordClass);
|
||||
void SetCharClasses(const unsigned char *chars, charClassification newCharClass);
|
||||
void SetStylingBits(int bits);
|
||||
void StartStyling(int position, char mask);
|
||||
bool SetStyleFor(int length, char style);
|
||||
@@ -210,6 +212,7 @@ public:
|
||||
int GetEndStyled() { return endStyled; }
|
||||
bool EnsureStyledTo(int pos);
|
||||
int GetStyleClock() { return styleClock; }
|
||||
void IncrementStyleClock();
|
||||
|
||||
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
||||
int GetLineState(int line) { return cb.GetLineState(line); }
|
||||
@@ -226,6 +229,7 @@ public:
|
||||
int ExtendStyleRange(int pos, int delta, bool singleLine = false);
|
||||
int ParaUp(int pos);
|
||||
int ParaDown(int pos);
|
||||
int IndentSize() { return actualIndentInChars; }
|
||||
|
||||
private:
|
||||
charClassification WordCharClass(unsigned char ch);
|
||||
@@ -237,8 +241,6 @@ private:
|
||||
void NotifyModifyAttempt();
|
||||
void NotifySavePoint(bool atSavePoint);
|
||||
void NotifyModified(DocModification mh);
|
||||
|
||||
int IndentSize() { return indentInChars ? indentInChars : tabInChars; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Editor.cxx
|
||||
** Main code for the edit control.
|
||||
**/
|
||||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -71,7 +71,7 @@ void LineLayout::Resize(int maxLineLength_) {
|
||||
if (maxLineLength_ > maxLineLength) {
|
||||
Free();
|
||||
chars = new char[maxLineLength_ + 1];
|
||||
styles = new char[maxLineLength_ + 1];
|
||||
styles = new unsigned char[maxLineLength_ + 1];
|
||||
indicators = new char[maxLineLength_ + 1];
|
||||
// Extra position allocated as sometimes the Windows
|
||||
// GetTextExtentExPoint API writes an extra element.
|
||||
@@ -240,10 +240,14 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar
|
||||
allInvalidated = false;
|
||||
int pos = -1;
|
||||
LineLayout *ret = 0;
|
||||
if (((level == llcCaret) || (level == llcPage)) && (lineNumber == lineCaret)) {
|
||||
if (level == llcCaret) {
|
||||
pos = 0;
|
||||
} else if (level == llcPage) {
|
||||
pos = lineNumber % length;
|
||||
if (lineNumber == lineCaret) {
|
||||
pos = length;
|
||||
} else {
|
||||
pos = lineNumber % length;
|
||||
}
|
||||
} else if (level == llcDocument) {
|
||||
pos = lineNumber;
|
||||
}
|
||||
@@ -381,6 +385,10 @@ Editor::Editor() {
|
||||
docLineLastWrapped = -1;
|
||||
docLastLineToWrap = -1;
|
||||
backgroundWrapEnabled = true;
|
||||
wrapVisualFlags = 0;
|
||||
wrapVisualFlagsLocation = 0;
|
||||
wrapVisualStartIndent = 0;
|
||||
actualWrapVisualStartIndent = 0;
|
||||
|
||||
hsStart = -1;
|
||||
hsEnd = -1;
|
||||
@@ -489,7 +497,7 @@ int Editor::MaxScrollPos() {
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsControlCharacter(char ch) {
|
||||
static inline bool IsControlCharacter(int ch) {
|
||||
// iscntrl returns true for lots of chars > 127 which are displayable
|
||||
return ch >= 0 && ch < ' ';
|
||||
}
|
||||
@@ -632,9 +640,15 @@ Point Editor::LocationFromPosition(int pos) {
|
||||
if (posInLine > ll->maxLineLength) {
|
||||
pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)];
|
||||
}
|
||||
|
||||
for (int subLine = 0; subLine < ll->lines; subLine++) {
|
||||
if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) {
|
||||
pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)];
|
||||
if (actualWrapVisualStartIndent != 0) {
|
||||
int lineStart = ll->LineStart(subLine);
|
||||
if (lineStart != 0) // Wrapped
|
||||
pt.x += actualWrapVisualStartIndent * vs.aveCharWidth;
|
||||
}
|
||||
}
|
||||
if (posInLine >= ll->LineStart(subLine)) {
|
||||
pt.y += vs.lineHeight;
|
||||
@@ -687,6 +701,11 @@ int Editor::PositionFromLocation(Point pt) {
|
||||
int lineStart = ll->LineStart(subLine);
|
||||
int lineEnd = ll->LineStart(subLine + 1);
|
||||
int subLineStart = ll->positions[lineStart];
|
||||
|
||||
if (actualWrapVisualStartIndent != 0) {
|
||||
if (lineStart != 0) // Wrapped
|
||||
pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
|
||||
}
|
||||
for (int i = lineStart; i < lineEnd; i++) {
|
||||
if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
|
||||
IsEOLChar(ll->chars[i])) {
|
||||
@@ -731,6 +750,11 @@ int Editor::PositionFromLocationClose(Point pt) {
|
||||
int lineStart = ll->LineStart(subLine);
|
||||
int lineEnd = ll->LineStart(subLine + 1);
|
||||
int subLineStart = ll->positions[lineStart];
|
||||
|
||||
if (actualWrapVisualStartIndent != 0) {
|
||||
if (lineStart != 0) // Wrapped
|
||||
pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
|
||||
}
|
||||
for (int i = lineStart; i < lineEnd; i++) {
|
||||
if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
|
||||
IsEOLChar(ll->chars[i])) {
|
||||
@@ -763,6 +787,11 @@ int Editor::PositionFromLineX(int lineDoc, int x) {
|
||||
int lineStart = ll->LineStart(subLine);
|
||||
int lineEnd = ll->LineStart(subLine + 1);
|
||||
int subLineStart = ll->positions[lineStart];
|
||||
|
||||
if (actualWrapVisualStartIndent != 0) {
|
||||
if (lineStart != 0) // Wrapped
|
||||
x -= actualWrapVisualStartIndent * vs.aveCharWidth;
|
||||
}
|
||||
for (int i = lineStart; i < lineEnd; i++) {
|
||||
if (x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
|
||||
IsEOLChar(ll->chars[i])) {
|
||||
@@ -1390,6 +1419,8 @@ void Editor::InvalidateCaret() {
|
||||
}
|
||||
|
||||
void Editor::NeedWrapping(int docLineStartWrapping, int docLineEndWrapping) {
|
||||
docLineStartWrapping = Platform::Minimum(docLineStartWrapping, pdoc->LinesTotal()-1);
|
||||
docLineEndWrapping = Platform::Minimum(docLineEndWrapping, pdoc->LinesTotal()-1);
|
||||
bool noWrap = (docLastLineToWrap == docLineLastWrapped);
|
||||
if (docLineLastWrapped > (docLineStartWrapping - 1)) {
|
||||
docLineLastWrapped = docLineStartWrapping - 1;
|
||||
@@ -1407,7 +1438,9 @@ void Editor::NeedWrapping(int docLineStartWrapping, int docLineEndWrapping) {
|
||||
if (docLastLineToWrap >= pdoc->LinesTotal())
|
||||
docLastLineToWrap = pdoc->LinesTotal()-1;
|
||||
// Wrap lines during idle.
|
||||
if (backgroundWrapEnabled && docLastLineToWrap != docLineLastWrapped ) {
|
||||
if ((wrapState != eWrapNone) &&
|
||||
backgroundWrapEnabled &&
|
||||
(docLastLineToWrap != docLineLastWrapped)) {
|
||||
SetIdle(true);
|
||||
}
|
||||
}
|
||||
@@ -1488,6 +1521,7 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) {
|
||||
firstLineToWrap++;
|
||||
if (!priorityWrap)
|
||||
docLineLastWrapped++;
|
||||
if (firstLineToWrap < pdoc->LinesTotal()) {
|
||||
AutoLineLayout ll(llc, RetrieveLineLayout(firstLineToWrap));
|
||||
int linesWrapped = 1;
|
||||
if (ll) {
|
||||
@@ -1496,6 +1530,7 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) {
|
||||
}
|
||||
if (cs.SetHeight(firstLineToWrap, linesWrapped)) {
|
||||
wrapOccurred = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If wrapping is done, bring it to resting position
|
||||
@@ -1982,6 +2017,9 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
|
||||
// Simple common case where line does not need wrapping.
|
||||
ll->lines = 1;
|
||||
} else {
|
||||
if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
|
||||
width -= vstyle.aveCharWidth; // take into account the space for end wrap mark
|
||||
}
|
||||
ll->lines = 0;
|
||||
// Calculate line start positions based upon width.
|
||||
// For now this is simplistic - wraps on byte rather than character and
|
||||
@@ -2008,6 +2046,8 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
|
||||
ll->lines++;
|
||||
ll->SetLineStart(ll->lines, lastGoodBreak);
|
||||
startOffset = ll->positions[lastGoodBreak];
|
||||
// take into account the space for start wrap mark and indent
|
||||
startOffset -= actualWrapVisualStartIndent * vstyle.aveCharWidth;
|
||||
p = lastGoodBreak + 1;
|
||||
continue;
|
||||
}
|
||||
@@ -2055,9 +2095,56 @@ void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight,
|
||||
highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
|
||||
}
|
||||
|
||||
void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
|
||||
bool isEndMarker, ColourAllocated wrapColour) {
|
||||
surface->PenColour(wrapColour);
|
||||
|
||||
enum { xa = 1 }; // gap before start
|
||||
int w = rcPlace.right - rcPlace.left - xa - 1;
|
||||
|
||||
bool xStraight = isEndMarker; // x-mirrored symbol for start marker
|
||||
bool yStraight = true;
|
||||
//bool yStraight= isEndMarker; // comment in for start marker y-mirrowed
|
||||
|
||||
int x0 = xStraight ? rcPlace.left : rcPlace.right - 1;
|
||||
int y0 = yStraight ? rcPlace.top : rcPlace.bottom - 1;
|
||||
|
||||
int dy = (rcPlace.bottom - rcPlace.top) / 5;
|
||||
int y = (rcPlace.bottom - rcPlace.top) / 2 + dy;
|
||||
|
||||
struct Relative {
|
||||
Surface *surface;
|
||||
int xBase;
|
||||
int xDir;
|
||||
int yBase;
|
||||
int yDir;
|
||||
void MoveTo(int xRelative, int yRelative) {
|
||||
surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
|
||||
}
|
||||
void LineTo(int xRelative, int yRelative) {
|
||||
surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
|
||||
}
|
||||
};
|
||||
Relative rel = {surface, x0, xStraight?1:-1, y0, yStraight?1:-1};
|
||||
|
||||
// arrow head
|
||||
rel.MoveTo(xa, y);
|
||||
rel.LineTo(xa + 2*w / 3, y - dy);
|
||||
rel.MoveTo(xa, y);
|
||||
rel.LineTo(xa + 2*w / 3, y + dy);
|
||||
|
||||
// arrow body
|
||||
rel.MoveTo(xa, y);
|
||||
rel.LineTo(xa + w, y);
|
||||
rel.LineTo(xa + w, y - 2 * dy);
|
||||
rel.LineTo(xa - 1, // on windows lineto is exclusive endpoint, perhaps GTK not...
|
||||
y - 2 * dy);
|
||||
}
|
||||
|
||||
void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
|
||||
int line, int lineEnd, int xStart, int subLine, int subLineStart,
|
||||
bool overrideBackground, ColourAllocated background) {
|
||||
bool overrideBackground, ColourAllocated background,
|
||||
bool drawWrapMarkEnd, ColourAllocated wrapColour) {
|
||||
|
||||
int styleMask = pdoc->stylingBitsMask;
|
||||
PRectangle rcSegment = rcLine;
|
||||
@@ -2069,6 +2156,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
|
||||
int posLineEnd = pdoc->LineStart(line + 1);
|
||||
bool eolInSelection = (subLine == (ll->lines - 1)) &&
|
||||
(posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd);
|
||||
|
||||
if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
|
||||
if (primarySelection)
|
||||
surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated);
|
||||
@@ -2089,6 +2177,20 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
|
||||
} else {
|
||||
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
|
||||
}
|
||||
|
||||
if (drawWrapMarkEnd) {
|
||||
PRectangle rcPlace = rcSegment;
|
||||
|
||||
if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
|
||||
rcPlace.left = xEol + xStart;
|
||||
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
|
||||
} else {
|
||||
// draw left of the right text margin, to avoid clipping by the current clip rect
|
||||
rcPlace.right = rcLine.right - vs.rightMarginWidth;
|
||||
rcPlace.left = rcPlace.right - vsDraw.aveCharWidth;
|
||||
}
|
||||
DrawWrapMarker(surface, rcPlace, true, wrapColour);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
||||
@@ -2141,9 +2243,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
|
||||
(!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
|
||||
|
||||
bool inIndentation = subLine == 0; // Do not handle indentation except on first subline.
|
||||
int indentWidth = pdoc->indentInChars * vsDraw.spaceWidth;
|
||||
if (indentWidth == 0)
|
||||
indentWidth = pdoc->tabInChars * vsDraw.spaceWidth;
|
||||
int indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth;
|
||||
|
||||
int posLineStart = pdoc->LineStart(line);
|
||||
|
||||
@@ -2155,6 +2255,51 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
|
||||
lineStart = ll->LineStart(subLine);
|
||||
lineEnd = ll->LineStart(subLine + 1);
|
||||
}
|
||||
|
||||
bool drawWrapMarkEnd = false;
|
||||
|
||||
if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
|
||||
if (subLine + 1 < ll->lines) {
|
||||
drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (actualWrapVisualStartIndent != 0) {
|
||||
|
||||
bool continuedWrapLine = false;
|
||||
if (subLine < ll->lines) {
|
||||
continuedWrapLine = ll->LineStart(subLine) != 0;
|
||||
}
|
||||
|
||||
if (continuedWrapLine) {
|
||||
// draw continuation rect
|
||||
PRectangle rcPlace = rcSegment;
|
||||
|
||||
rcPlace.left = ll->positions[startseg] + xStart - subLineStart;
|
||||
rcPlace.right = rcPlace.left + actualWrapVisualStartIndent * vsDraw.aveCharWidth;
|
||||
|
||||
// default bgnd here..
|
||||
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
|
||||
|
||||
// main line style would be below but this would be inconsistent with end markers
|
||||
// also would possibly not be the style at wrap point
|
||||
//int styleMain = ll->styles[lineStart];
|
||||
//surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back.allocated);
|
||||
|
||||
if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
|
||||
|
||||
if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT)
|
||||
rcPlace.left = rcPlace.right - vsDraw.aveCharWidth;
|
||||
else
|
||||
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
|
||||
|
||||
DrawWrapMarker(surface, rcPlace, false, vsDraw.whitespaceForeground.allocated);
|
||||
}
|
||||
|
||||
xStart += actualWrapVisualStartIndent * vsDraw.aveCharWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
// Background drawing loop
|
||||
@@ -2212,7 +2357,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
|
||||
|
||||
if (twoPhaseDraw) {
|
||||
DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
|
||||
xStart, subLine, subLineStart, overrideBackground, background);
|
||||
xStart, subLine, subLineStart, overrideBackground, background,
|
||||
drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
|
||||
}
|
||||
|
||||
inIndentation = subLine == 0; // Do not handle indentation except on first subline.
|
||||
@@ -2402,10 +2548,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
|
||||
}
|
||||
}
|
||||
// End of the drawing of the current line
|
||||
|
||||
if (!twoPhaseDraw) {
|
||||
DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
|
||||
xStart, subLine, subLineStart, overrideBackground, background);
|
||||
xStart, subLine, subLineStart, overrideBackground, background,
|
||||
drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
|
||||
}
|
||||
|
||||
if (vsDraw.edgeState == EDGE_LINE) {
|
||||
@@ -2604,6 +2750,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
||||
// and determine the x position at which each character starts.
|
||||
//ElapsedTime et;
|
||||
if (lineDoc != lineDocPrevious) {
|
||||
ll.Set(0);
|
||||
ll.Set(RetrieveLineLayout(lineDoc));
|
||||
LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
|
||||
lineDocPrevious = lineDoc;
|
||||
@@ -2670,7 +2817,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
||||
int FoldLevelCurr = (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE;
|
||||
int FoldLevelPrev = (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE;
|
||||
int FoldLevelFlags = (pdoc->GetLevel(lineDoc) & ~SC_FOLDLEVELNUMBERMASK) & ~(0xFFF0000);
|
||||
int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
|
||||
int indentationStep = pdoc->IndentSize();
|
||||
// Draw line above fold
|
||||
if ((FoldLevelPrev < FoldLevelCurr)
|
||||
||
|
||||
@@ -2708,6 +2855,12 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
||||
if ((offset >= ll->LineStart(subLine)) &&
|
||||
((offset < ll->LineStart(subLine + 1)) || offset == ll->numCharsInLine)) {
|
||||
int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
|
||||
|
||||
if (actualWrapVisualStartIndent != 0) {
|
||||
int lineStart = ll->LineStart(subLine);
|
||||
if (lineStart != 0) // Wrapped
|
||||
xposCaret += actualWrapVisualStartIndent * vs.aveCharWidth;
|
||||
}
|
||||
int widthOverstrikeCaret;
|
||||
if (posCaret == pdoc->Length()) { // At end of document
|
||||
widthOverstrikeCaret = vs.aveCharWidth;
|
||||
@@ -3238,7 +3391,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
|
||||
pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) {
|
||||
pdoc->BeginUndoAction();
|
||||
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
|
||||
int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
|
||||
int indentationStep = pdoc->IndentSize();
|
||||
if (indentation % indentationStep == 0) {
|
||||
pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
|
||||
} else {
|
||||
@@ -3452,6 +3605,7 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {
|
||||
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
|
||||
}
|
||||
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
|
||||
pdoc->IncrementStyleClock();
|
||||
if (paintState == notPainting) {
|
||||
if (mh.position < pdoc->LineStart(topLine)) {
|
||||
// Styling performed before this view
|
||||
@@ -4280,8 +4434,8 @@ void Editor::Indent(bool forwards) {
|
||||
if (pdoc->GetColumn(currentPos) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
|
||||
pdoc->tabIndents) {
|
||||
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
|
||||
int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
|
||||
pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep);
|
||||
int indentationStep = pdoc->IndentSize();
|
||||
pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
|
||||
SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
|
||||
} else {
|
||||
if (pdoc->useTabs) {
|
||||
@@ -4304,7 +4458,7 @@ void Editor::Indent(bool forwards) {
|
||||
pdoc->tabIndents) {
|
||||
pdoc->BeginUndoAction();
|
||||
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
|
||||
int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
|
||||
int indentationStep = pdoc->IndentSize();
|
||||
pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
|
||||
SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
|
||||
pdoc->EndUndoAction();
|
||||
@@ -4477,7 +4631,8 @@ char *Editor::CopyRange(int start, int end) {
|
||||
}
|
||||
|
||||
void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) {
|
||||
ss->Set(CopyRange(start, end), end - start + 1, false);
|
||||
ss->Set(CopyRange(start, end), end - start + 1,
|
||||
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
|
||||
}
|
||||
|
||||
void Editor::CopySelectionRange(SelectionText *ss) {
|
||||
@@ -4519,7 +4674,8 @@ void Editor::CopySelectionRange(SelectionText *ss) {
|
||||
text[size] = '\0';
|
||||
}
|
||||
}
|
||||
ss->Set(text, size + 1, selType == selRectangle);
|
||||
ss->Set(text, size + 1, pdoc->dbcsCodePage,
|
||||
vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4527,13 +4683,15 @@ void Editor::CopyRangeToClipboard(int start, int end) {
|
||||
start = pdoc->ClampPositionIntoDocument(start);
|
||||
end = pdoc->ClampPositionIntoDocument(end);
|
||||
SelectionText selectedText;
|
||||
selectedText.Set(CopyRange(start, end), end - start + 1);
|
||||
selectedText.Set(CopyRange(start, end), end - start + 1,
|
||||
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
|
||||
CopyToClipboard(selectedText);
|
||||
}
|
||||
|
||||
void Editor::CopyText(int length, const char *text) {
|
||||
SelectionText selectedText;
|
||||
selectedText.Copy(text, length);
|
||||
selectedText.Copy(text, length,
|
||||
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
|
||||
CopyToClipboard(selectedText);
|
||||
}
|
||||
|
||||
@@ -4929,7 +5087,8 @@ void Editor::ButtonMove(Point pt) {
|
||||
}
|
||||
// While dragging to make rectangular selection, we don't want the current
|
||||
// position to jump to the end of smaller or empty lines.
|
||||
xEndSelect = pt.x - vs.fixedColumnWidth + xOffset;
|
||||
//xEndSelect = pt.x - vs.fixedColumnWidth + xOffset;
|
||||
xEndSelect = XFromPosition(movePos);
|
||||
|
||||
// Autoscroll
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
@@ -5006,7 +5165,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
|
||||
} else {
|
||||
SetEmptySelection(newPos);
|
||||
}
|
||||
drag.Set(0, 0);
|
||||
drag.Free();
|
||||
}
|
||||
selectionType = selChar;
|
||||
}
|
||||
@@ -5238,6 +5397,9 @@ void Editor::SetDocPointer(Document *document) {
|
||||
targetStart = 0;
|
||||
targetEnd = 0;
|
||||
|
||||
braces[0] = invalidPosition;
|
||||
braces[1] = invalidPosition;
|
||||
|
||||
// Reset the contraction state to fully shown.
|
||||
cs.Clear();
|
||||
cs.InsertLines(0, pdoc->LinesTotal() - 1);
|
||||
@@ -5272,16 +5434,34 @@ void Editor::Expand(int &line, bool doExpand) {
|
||||
}
|
||||
|
||||
void Editor::ToggleContraction(int line) {
|
||||
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||
if (line >= 0) {
|
||||
if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {
|
||||
line = pdoc->GetFoldParent(line);
|
||||
if (line < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cs.GetExpanded(line)) {
|
||||
int lineMaxSubord = pdoc->GetLastChild(line);
|
||||
cs.SetExpanded(line, 0);
|
||||
if (lineMaxSubord > line) {
|
||||
cs.SetVisible(line + 1, lineMaxSubord, false);
|
||||
|
||||
int lineCurrent = pdoc->LineFromPosition(currentPos);
|
||||
if (lineCurrent > line && lineCurrent <= lineMaxSubord) {
|
||||
// This does not re-expand the fold
|
||||
EnsureCaretVisible();
|
||||
}
|
||||
|
||||
SetScrollBars();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!(cs.GetVisible(line))) {
|
||||
EnsureLineVisible(line, false);
|
||||
GoToLine(line);
|
||||
}
|
||||
cs.SetExpanded(line, 1);
|
||||
Expand(line, true);
|
||||
SetScrollBars();
|
||||
@@ -5383,7 +5563,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
|
||||
case SCI_GETTEXT: {
|
||||
if (lParam == 0)
|
||||
return 0;
|
||||
return pdoc->Length() + 1;
|
||||
if (wParam == 0)
|
||||
return 0;
|
||||
char *ptr = CharPtrFromSPtr(lParam);
|
||||
@@ -5397,9 +5577,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
case SCI_SETTEXT: {
|
||||
if (lParam == 0)
|
||||
return 0;
|
||||
pdoc->BeginUndoAction();
|
||||
pdoc->DeleteChars(0, pdoc->Length());
|
||||
SetEmptySelection(0);
|
||||
pdoc->InsertString(0, CharPtrFromSPtr(lParam));
|
||||
pdoc->EndUndoAction();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -5451,11 +5633,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
return topLine;
|
||||
|
||||
case SCI_GETLINE: { // Risk of overwriting the end of the buffer
|
||||
if (lParam == 0) {
|
||||
return 0;
|
||||
}
|
||||
int lineStart = pdoc->LineStart(wParam);
|
||||
int lineEnd = pdoc->LineStart(wParam + 1);
|
||||
if (lParam == 0) {
|
||||
return lineEnd - lineStart;
|
||||
}
|
||||
char *ptr = CharPtrFromSPtr(lParam);
|
||||
int iPlace = 0;
|
||||
for (int iChar = lineStart; iChar < lineEnd; iChar++) {
|
||||
@@ -5487,8 +5669,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
break;
|
||||
|
||||
case SCI_GETSELTEXT: {
|
||||
if (lParam == 0)
|
||||
return 0;
|
||||
if (lParam == 0) {
|
||||
if (selType == selStream) {
|
||||
return 1 + SelectionEnd() - SelectionStart();
|
||||
} else {
|
||||
// TODO: why is selLines handled the slow way?
|
||||
int size = 0;
|
||||
int extraCharsPerLine = 0;
|
||||
if (selType != selLines)
|
||||
extraCharsPerLine = (pdoc->eolMode == SC_EOL_CRLF) ? 2 : 1;
|
||||
SelectionLineIterator lineIterator(this);
|
||||
while (lineIterator.Iterate()) {
|
||||
size += lineIterator.endPos + extraCharsPerLine - lineIterator.startPos;
|
||||
}
|
||||
|
||||
return 1 + size;
|
||||
}
|
||||
}
|
||||
SelectionText selectedText;
|
||||
CopySelectionRange(&selectedText);
|
||||
char *ptr = CharPtrFromSPtr(lParam);
|
||||
@@ -5745,7 +5942,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
break;
|
||||
|
||||
case SCI_SETWORDCHARS: {
|
||||
pdoc->SetDefaultCharClasses();
|
||||
pdoc->SetDefaultCharClasses(false);
|
||||
if (lParam == 0)
|
||||
return 0;
|
||||
pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), Document::ccWord);
|
||||
@@ -5760,12 +5957,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
break;
|
||||
|
||||
case SCI_SETCHARSDEFAULT:
|
||||
pdoc->SetDefaultCharClasses();
|
||||
pdoc->SetDefaultCharClasses(true);
|
||||
break;
|
||||
|
||||
case SCI_GETLENGTH:
|
||||
return pdoc->Length();
|
||||
|
||||
case SCI_ALLOCATE:
|
||||
pdoc->Allocate(wParam);
|
||||
break;
|
||||
|
||||
case SCI_GETCHARAT:
|
||||
return pdoc->CharAt(wParam);
|
||||
|
||||
@@ -5885,12 +6086,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
break;
|
||||
|
||||
case SCI_GETCURLINE: {
|
||||
if (lParam == 0) {
|
||||
return 0;
|
||||
}
|
||||
int lineCurrentPos = pdoc->LineFromPosition(currentPos);
|
||||
int lineStart = pdoc->LineStart(lineCurrentPos);
|
||||
unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1);
|
||||
if (lParam == 0) {
|
||||
return 1 + lineEnd - lineStart;
|
||||
}
|
||||
char *ptr = CharPtrFromSPtr(lParam);
|
||||
unsigned int iPlace = 0;
|
||||
for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) {
|
||||
@@ -5940,8 +6141,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
break;
|
||||
|
||||
case SCI_SETTABWIDTH:
|
||||
if (wParam > 0)
|
||||
if (wParam > 0) {
|
||||
pdoc->tabInChars = wParam;
|
||||
if (pdoc->indentInChars == 0)
|
||||
pdoc->actualIndentInChars = pdoc->tabInChars;
|
||||
}
|
||||
InvalidateStyleRedraw();
|
||||
break;
|
||||
|
||||
@@ -5950,6 +6154,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
|
||||
case SCI_SETINDENT:
|
||||
pdoc->indentInChars = wParam;
|
||||
if (pdoc->indentInChars != 0)
|
||||
pdoc->actualIndentInChars = pdoc->indentInChars;
|
||||
else
|
||||
pdoc->actualIndentInChars = pdoc->tabInChars;
|
||||
InvalidateStyleRedraw();
|
||||
break;
|
||||
|
||||
@@ -6012,6 +6220,38 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
case SCI_GETWRAPMODE:
|
||||
return wrapState;
|
||||
|
||||
case SCI_SETWRAPVISUALFLAGS:
|
||||
wrapVisualFlags = wParam;
|
||||
actualWrapVisualStartIndent = wrapVisualStartIndent;
|
||||
if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0))
|
||||
actualWrapVisualStartIndent = 1; // must indent to show start visual
|
||||
InvalidateStyleRedraw();
|
||||
ReconfigureScrollBars();
|
||||
break;
|
||||
|
||||
case SCI_GETWRAPVISUALFLAGS:
|
||||
return wrapVisualFlags;
|
||||
|
||||
case SCI_SETWRAPVISUALFLAGSLOCATION:
|
||||
wrapVisualFlagsLocation = wParam;
|
||||
InvalidateStyleRedraw();
|
||||
break;
|
||||
|
||||
case SCI_GETWRAPVISUALFLAGSLOCATION:
|
||||
return wrapVisualFlagsLocation;
|
||||
|
||||
case SCI_SETWRAPSTARTINDENT:
|
||||
wrapVisualStartIndent = wParam;
|
||||
actualWrapVisualStartIndent = wrapVisualStartIndent;
|
||||
if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0))
|
||||
actualWrapVisualStartIndent = 1; // must indent to show start visual
|
||||
InvalidateStyleRedraw();
|
||||
ReconfigureScrollBars();
|
||||
break;
|
||||
|
||||
case SCI_GETWRAPSTARTINDENT:
|
||||
return wrapVisualStartIndent;
|
||||
|
||||
case SCI_SETLAYOUTCACHE:
|
||||
llc.SetLevel(wParam);
|
||||
break;
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
bool containsCaret;
|
||||
int edgeColumn;
|
||||
char *chars;
|
||||
char *styles;
|
||||
unsigned char *styles;
|
||||
char *indicators;
|
||||
int *positions;
|
||||
char bracePreviousStyles[2];
|
||||
@@ -134,20 +134,27 @@ public:
|
||||
char *s;
|
||||
int len;
|
||||
bool rectangular;
|
||||
SelectionText() : s(0), len(0), rectangular(false) {}
|
||||
int codePage;
|
||||
int characterSet;
|
||||
SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {}
|
||||
~SelectionText() {
|
||||
Set(0, 0);
|
||||
Free();
|
||||
}
|
||||
void Set(char *s_, int len_, bool rectangular_=false) {
|
||||
void Free() {
|
||||
Set(0, 0, 0, 0, false);
|
||||
}
|
||||
void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) {
|
||||
delete []s;
|
||||
s = s_;
|
||||
if (s)
|
||||
len = len_;
|
||||
else
|
||||
len = 0;
|
||||
codePage = codePage_;
|
||||
characterSet = characterSet_;
|
||||
rectangular = rectangular_;
|
||||
}
|
||||
void Copy(const char *s_, int len_, bool rectangular_=false) {
|
||||
void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) {
|
||||
delete []s;
|
||||
s = new char[len_];
|
||||
if (s) {
|
||||
@@ -158,8 +165,13 @@ public:
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
codePage = codePage_;
|
||||
characterSet = characterSet_;
|
||||
rectangular = rectangular_;
|
||||
}
|
||||
void Copy(const SelectionText &other) {
|
||||
Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -293,6 +305,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int wrapWidth;
|
||||
int docLineLastWrapped;
|
||||
int docLastLineToWrap;
|
||||
int wrapVisualFlags;
|
||||
int wrapVisualFlagsLocation;
|
||||
int wrapVisualStartIndent;
|
||||
int actualWrapVisualStartIndent;
|
||||
|
||||
Document *pdoc;
|
||||
|
||||
@@ -365,9 +381,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int width=LineLayout::wrapWidthInfinite);
|
||||
ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
|
||||
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
|
||||
void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour);
|
||||
void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
|
||||
int line, int lineEnd, int xStart, int subLine, int subLineStart,
|
||||
bool overrideBackground, ColourAllocated background);
|
||||
bool overrideBackground, ColourAllocated background,
|
||||
bool drawWrapMark, ColourAllocated wrapColour);
|
||||
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
||||
PRectangle rcLine, LineLayout *ll, int subLine=0);
|
||||
void RefreshPixMaps(Surface *surfaceWindow);
|
||||
|
@@ -130,9 +130,12 @@ int Scintilla_LinkLexers() {
|
||||
//++Autogenerated -- run src/LexGen.py to regenerate
|
||||
//**\(\tLINK_LEXER(\*);\n\)
|
||||
LINK_LEXER(lmAda);
|
||||
LINK_LEXER(lmAPDL);
|
||||
LINK_LEXER(lmAsm);
|
||||
LINK_LEXER(lmAU3);
|
||||
LINK_LEXER(lmAVE);
|
||||
LINK_LEXER(lmBaan);
|
||||
LINK_LEXER(lmBash);
|
||||
LINK_LEXER(lmBullant);
|
||||
LINK_LEXER(lmClw);
|
||||
LINK_LEXER(lmClwNoCase);
|
||||
@@ -149,10 +152,12 @@ int Scintilla_LinkLexers() {
|
||||
LINK_LEXER(lmForth);
|
||||
LINK_LEXER(lmFortran);
|
||||
LINK_LEXER(lmF77);
|
||||
LINK_LEXER(lmGui4Cli);
|
||||
LINK_LEXER(lmHTML);
|
||||
LINK_LEXER(lmXML);
|
||||
LINK_LEXER(lmASP);
|
||||
LINK_LEXER(lmPHP);
|
||||
LINK_LEXER(lmKix);
|
||||
LINK_LEXER(lmLISP);
|
||||
LINK_LEXER(lmLout);
|
||||
LINK_LEXER(lmLua);
|
||||
@@ -161,6 +166,7 @@ int Scintilla_LinkLexers() {
|
||||
LINK_LEXER(lmMETAPOST);
|
||||
LINK_LEXER(lmMMIXAL);
|
||||
LINK_LEXER(lmLot);
|
||||
LINK_LEXER(lmMSSQL);
|
||||
LINK_LEXER(lmNsis);
|
||||
LINK_LEXER(lmBatch);
|
||||
LINK_LEXER(lmDiff);
|
||||
@@ -177,10 +183,12 @@ int Scintilla_LinkLexers() {
|
||||
LINK_LEXER(lmPython);
|
||||
LINK_LEXER(lmRuby);
|
||||
LINK_LEXER(lmScriptol);
|
||||
LINK_LEXER(lmSpecman);
|
||||
LINK_LEXER(lmSQL);
|
||||
LINK_LEXER(lmTeX);
|
||||
LINK_LEXER(lmVB);
|
||||
LINK_LEXER(lmVBScript);
|
||||
LINK_LEXER(lmVerilog);
|
||||
LINK_LEXER(lmYAML);
|
||||
|
||||
//--Autogenerated -- end of automatically generated section
|
||||
|
174
contrib/src/stc/scintilla/src/LexAPDL.cxx
Normal file
174
contrib/src/stc/scintilla/src/LexAPDL.cxx
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
#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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '/' || ch == '*');
|
||||
}
|
||||
|
||||
inline bool IsABlank(unsigned int ch) {
|
||||
return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ColouriseAPDLDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler)
|
||||
{
|
||||
|
||||
//~ FILE *fp;
|
||||
//~ fp = fopen("myoutput.txt", "w");
|
||||
|
||||
WordList &commands = *keywordlists[0];
|
||||
WordList &processors = *keywordlists[1];
|
||||
WordList &functions = *keywordlists[2];
|
||||
|
||||
|
||||
// backtrack to the beginning of the document, this may be slow for big documents.
|
||||
initStyle = SCE_APDL_DEFAULT;
|
||||
StyleContext sc(0, startPos+length, initStyle, styler);
|
||||
|
||||
// backtrack to the nearest keyword
|
||||
//~ while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_APDL_WORD)) {
|
||||
//~ startPos--;
|
||||
//~ }
|
||||
//~ startPos = styler.LineStart(styler.GetLine(startPos));
|
||||
//~ initStyle = styler.StyleAt(startPos - 1);
|
||||
//~ StyleContext sc(startPos, endPos-startPos, initStyle, styler);
|
||||
|
||||
bool firstInLine = true;
|
||||
bool atEOL;
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
atEOL = (sc.ch == '\r' && sc.chNext == '\n') || (sc.ch == '\n');
|
||||
|
||||
//~ if (sc.ch == '\r') {
|
||||
//~ fprintf(fp,"CR\t%d\t%d", atEOL, firstInLine);
|
||||
//~ } else if (sc.ch == '\n') {
|
||||
//~ fprintf(fp,"LF\t%d\t%d", atEOL, firstInLine);
|
||||
//~ } else {
|
||||
//~ fprintf(fp,"%c\t%d\t%d", sc.ch, atEOL, firstInLine);
|
||||
//~ }
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_APDL_COMMENT) {
|
||||
//~ fprintf(fp,"\tCOMMENT");
|
||||
if (atEOL) {
|
||||
sc.SetState(SCE_APDL_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_APDL_COMMENTBLOCK) {
|
||||
//~ fprintf(fp,"\tCOMMENTBLOCK");
|
||||
if (atEOL) {
|
||||
if (sc.ch == '\r') {
|
||||
sc.Forward();
|
||||
}
|
||||
sc.ForwardSetState(SCE_APDL_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_APDL_NUMBER) {
|
||||
//~ fprintf(fp,"\tNUMBER");
|
||||
if (isdigit(sc.ch)) {
|
||||
} else if ((sc.ch == 'e' || sc.ch == 'E') && (isdigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-')) {
|
||||
} else if (sc.ch == '.') {
|
||||
} else if ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')) {
|
||||
} else {
|
||||
sc.SetState(SCE_APDL_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_APDL_STRING) {
|
||||
//~ fprintf(fp,"\tSTRING");
|
||||
if (sc.ch == '\"') {
|
||||
//~ sc.ForwardSetState(SCE_APDL_DEFAULT);
|
||||
sc.Forward();
|
||||
atEOL = (sc.ch == '\r' && sc.chNext == '\n') || (sc.ch == '\n');
|
||||
if (atEOL) {
|
||||
firstInLine = true;
|
||||
}
|
||||
sc.SetState(SCE_APDL_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_APDL_WORD) {
|
||||
//~ fprintf(fp,"\tWORD");
|
||||
if (!IsAWordChar(sc.ch) || sc.ch == '%') {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (commands.InList(s) && firstInLine) {
|
||||
if (IsABlank(sc.ch) || sc.ch == ',' || atEOL) {
|
||||
sc.ChangeState(SCE_APDL_COMMAND);
|
||||
}
|
||||
if (sc.ch != '\n') {
|
||||
firstInLine = false;
|
||||
}
|
||||
} else if (processors.InList(s)) {
|
||||
if (IsABlank(sc.ch) || atEOL) {
|
||||
sc.ChangeState(SCE_APDL_PROCESSOR);
|
||||
while (sc.ch != '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (functions.InList(s)) {
|
||||
sc.ChangeState(SCE_APDL_FUNCTION);
|
||||
if (sc.ch != '\n') {
|
||||
firstInLine = false;
|
||||
}
|
||||
} else {
|
||||
if (sc.ch != '\n') {
|
||||
firstInLine = false;
|
||||
}
|
||||
}
|
||||
sc.SetState(SCE_APDL_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_APDL_DEFAULT) {
|
||||
if (sc.ch == '!' && sc.chNext != '!') {
|
||||
sc.SetState(SCE_APDL_COMMENT);
|
||||
} else if (sc.ch == '!' && sc.chNext == '!') {
|
||||
sc.SetState(SCE_APDL_COMMENTBLOCK);
|
||||
} else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) {
|
||||
sc.SetState(SCE_APDL_NUMBER);
|
||||
} else if (sc.ch == '.' && (isoperator(static_cast<char>(sc.chPrev)) ||
|
||||
IsABlank(sc.chPrev) || sc.chPrev == '\n' || sc.chPrev == '\r')) {
|
||||
sc.SetState(SCE_APDL_NUMBER);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_APDL_STRING);
|
||||
} else if (IsAWordStart(sc.ch) && (!IsADigit(sc.chPrev))) {
|
||||
sc.SetState(SCE_APDL_WORD);
|
||||
}
|
||||
|
||||
}
|
||||
//~ fprintf(fp,"\n");
|
||||
|
||||
if (atEOL) {
|
||||
firstInLine = true;
|
||||
}
|
||||
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static const char * const apdlWordListDesc[] = {
|
||||
"Commands",
|
||||
"Processors",
|
||||
"Functions",
|
||||
0
|
||||
};
|
||||
|
||||
LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", 0, apdlWordListDesc);
|
369
contrib/src/stc/scintilla/src/LexAU3.cxx
Normal file
369
contrib/src/stc/scintilla/src/LexAU3.cxx
Normal file
@@ -0,0 +1,369 @@
|
||||
// Scintilla source code edit control
|
||||
// @file LexAU3.cxx
|
||||
// Lexer for AutoIt3 http://www.hiddensoft.com/autoit3
|
||||
// by Jos van der Zande, jvdzande@yahoo.com
|
||||
//
|
||||
// Changes:
|
||||
// March 28, 2004 - Added the standard Folding code
|
||||
// April 21, 2004 - Added Preprosessor Table + Syntax Highlighting
|
||||
// Fixed Number highlighting
|
||||
// Changed default isoperator to IsAOperator to have a better match to AutoIt3
|
||||
// Fixed "#comments_start" -> "#comments-start"
|
||||
// Fixed "#comments_end" -> "#comments-end"
|
||||
// Fixed Sendkeys in Strings when not terminated with }
|
||||
// Added support for Sendkey strings that have second parameter e.g. {UP 5} or {a down}
|
||||
// April 26, 2004 Fixed # pre-processor statement inside of comment block would invalidly change the color.
|
||||
// Added logic for #include <xyz.au3> to treat the <> as string
|
||||
// Added underscore to IsAOperator.
|
||||
// Copyright for Scintilla: 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
// Scintilla source code edit control
|
||||
|
||||
#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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static bool IsAU3Comment(Accessor &styler, int pos, int len) {
|
||||
return len>0 && styler[pos]==';';
|
||||
}
|
||||
|
||||
static inline bool IsTypeCharacter(const int ch)
|
||||
{
|
||||
return ch == '$';
|
||||
}
|
||||
static inline bool IsAWordChar(const int ch)
|
||||
{
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '-');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch)
|
||||
{
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '@' || ch == '#' || ch == '$');
|
||||
}
|
||||
|
||||
static inline bool IsAOperator(char ch) {
|
||||
if (isascii(ch) && isalnum(ch))
|
||||
return false;
|
||||
if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
|
||||
ch == '&' || ch == '^' || ch == '=' || ch == '<' || ch == '>' ||
|
||||
ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '_' )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// GetSendKey() filters the portion before and after a/multiple space(s)
|
||||
// and return the first portion to be looked-up in the table
|
||||
// also check if the second portion is valid... (up,down.on.off,toggle or a number)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int GetSendKey(const char *szLine, char *szKey)
|
||||
{
|
||||
int nFlag = 0;
|
||||
int nKeyPos = 0;
|
||||
int nSpecPos= 0;
|
||||
int nSpecNum= 1;
|
||||
int nPos = 0;
|
||||
char cTemp;
|
||||
char szSpecial[100];
|
||||
|
||||
// split the portion of the sendkey in the part before and after the spaces
|
||||
while ( ( (cTemp = szLine[nPos]) != '\0'))
|
||||
{
|
||||
if ((cTemp == ' ') && (nFlag == 0) ) // get the stuff till first space
|
||||
{
|
||||
nFlag = 1;
|
||||
// Add } to the end of the first bit for table lookup later.
|
||||
szKey[nKeyPos++] = '}';
|
||||
}
|
||||
else if (cTemp == ' ')
|
||||
{
|
||||
// skip other spaces
|
||||
}
|
||||
else if (nFlag == 0)
|
||||
{
|
||||
// save first portion into var till space or } is hit
|
||||
szKey[nKeyPos++] = cTemp;
|
||||
}
|
||||
else if ((nFlag == 1) && (cTemp != '}'))
|
||||
{
|
||||
// Save second portion into var...
|
||||
szSpecial[nSpecPos++] = cTemp;
|
||||
// check if Second portion is all numbers for repeat fuction
|
||||
if (isdigit(cTemp) == false) {nSpecNum = 0;}
|
||||
}
|
||||
nPos++; // skip to next char
|
||||
|
||||
} // End While
|
||||
|
||||
|
||||
// Check if the second portion is either a number or one of these keywords
|
||||
szKey[nKeyPos] = '\0';
|
||||
szSpecial[nSpecPos] = '\0';
|
||||
if (strcmp(szSpecial,"down")==0 || strcmp(szSpecial,"up")==0 ||
|
||||
strcmp(szSpecial,"on")==0 || strcmp(szSpecial,"off")==0 ||
|
||||
strcmp(szSpecial,"toggle")==0 || nSpecNum == 1 )
|
||||
{
|
||||
nFlag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nFlag = 1;
|
||||
}
|
||||
return nFlag; // 1 is bad, 0 is good
|
||||
|
||||
} // GetSendKey()
|
||||
|
||||
static void ColouriseAU3Doc(unsigned int startPos,
|
||||
int length, int initStyle,
|
||||
WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
WordList &keywords5 = *keywordlists[4];
|
||||
styler.StartAt(startPos);
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
char si; // string indicator "=1 '=2
|
||||
si=0;
|
||||
//$$$
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
switch (sc.state)
|
||||
{
|
||||
case SCE_AU3_COMMENTBLOCK:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch))
|
||||
{
|
||||
if ((strcmp(s, "#ce")==0 || strcmp(s, "#comments-end")==0))
|
||||
{sc.SetState(SCE_AU3_COMMENT);} // set to comment line for the rest of the line
|
||||
else
|
||||
{sc.SetState(SCE_AU3_COMMENTBLOCK);}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCE_AU3_COMMENT:
|
||||
{
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_AU3_OPERATOR:
|
||||
{
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
break;
|
||||
}
|
||||
case SCE_AU3_KEYWORD:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch))
|
||||
{
|
||||
if (!IsTypeCharacter(sc.ch))
|
||||
{
|
||||
if (strcmp(s, "#cs")==0 || strcmp(s, "#comments-start")==0 )
|
||||
{
|
||||
sc.ChangeState(SCE_AU3_COMMENTBLOCK);
|
||||
sc.SetState(SCE_AU3_COMMENTBLOCK);
|
||||
}
|
||||
else if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_AU3_KEYWORD);
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
}
|
||||
else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_AU3_FUNCTION);
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
}
|
||||
else if (keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_AU3_MACRO);
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
}
|
||||
else if (keywords5.InList(s)) {
|
||||
sc.ChangeState(SCE_AU3_PREPROCESSOR);
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
if (strcmp(s, "#include")==0)
|
||||
{
|
||||
si = 3; // use to determine string start for #inlude <>
|
||||
}
|
||||
}
|
||||
else if (!IsAWordChar(sc.ch)) {
|
||||
sc.ChangeState(SCE_AU3_DEFAULT);
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_AU3_NUMBER:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_AU3_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_AU3_VARIABLE:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_AU3_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_AU3_STRING:
|
||||
{
|
||||
// check for " to end a double qouted string or
|
||||
// check for ' to end a single qouted string
|
||||
if ((si == 1 && sc.ch == '\"') || (si == 2 && sc.ch == '\'') || (si == 3 && sc.ch == '>'))
|
||||
{
|
||||
sc.ForwardSetState(SCE_AU3_DEFAULT);
|
||||
}
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
|
||||
// find Sendkeys in a STRING
|
||||
if (sc.ch == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '+' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '!' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '^' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '#' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
break;
|
||||
}
|
||||
|
||||
case SCE_AU3_SENT:
|
||||
{
|
||||
// Send key string ended
|
||||
if (sc.chPrev == '}' && sc.ch != '}')
|
||||
{
|
||||
// set color to SENDKEY when valid sendkey .. else set back to regular string
|
||||
char sk[100];
|
||||
// split {111 222} and return {111} and check if 222 is valid.
|
||||
// if return code = 1 then invalid 222 so must be string
|
||||
if (GetSendKey(s,sk))
|
||||
{
|
||||
sc.ChangeState(SCE_AU3_STRING);
|
||||
}
|
||||
// if single char between {?} then its ok as sendkey for a single character
|
||||
else if (strlen(sk) == 3)
|
||||
{
|
||||
sc.ChangeState(SCE_AU3_SENT);
|
||||
}
|
||||
// if sendkey {111} is in table then ok as sendkey
|
||||
else if (keywords4.InList(sk))
|
||||
{
|
||||
sc.ChangeState(SCE_AU3_SENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ChangeState(SCE_AU3_STRING);
|
||||
}
|
||||
sc.SetState(SCE_AU3_STRING);
|
||||
}
|
||||
// check if next portion is again a sendkey
|
||||
if (sc.atLineEnd)
|
||||
{
|
||||
sc.SetState(SCE_AU3_DEFAULT);
|
||||
si = 0; // reset string indicator
|
||||
}
|
||||
if (sc.ch == '{' && sc.chPrev != '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '+' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '!' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '^' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
if (sc.ch == '#' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
|
||||
// check to see if the string ended...
|
||||
// Sentkey string isn't complete but the string ended....
|
||||
if ((si == 1 && sc.ch == '\"') || (si == 2 && sc.ch == '\''))
|
||||
{
|
||||
sc.ChangeState(SCE_AU3_STRING);
|
||||
sc.ForwardSetState(SCE_AU3_DEFAULT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} //switch (sc.state)
|
||||
|
||||
// Determine if a new state should be entered:
|
||||
|
||||
if (sc.state == SCE_AU3_DEFAULT)
|
||||
{
|
||||
if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);}
|
||||
else if (sc.ch == '#') {sc.SetState(SCE_AU3_KEYWORD);}
|
||||
else if (sc.ch == '$') {sc.SetState(SCE_AU3_VARIABLE);}
|
||||
else if (sc.ch == '@') {sc.SetState(SCE_AU3_KEYWORD);}
|
||||
else if (sc.ch == '<' && si==3) {sc.SetState(SCE_AU3_STRING);} // string after #include
|
||||
else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_AU3_STRING);
|
||||
si = 1; }
|
||||
else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_AU3_STRING);
|
||||
si = 2; }
|
||||
else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_AU3_NUMBER);}
|
||||
else if (IsAOperator(static_cast<char>(sc.ch))) {sc.SetState(SCE_AU3_OPERATOR);}
|
||||
else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_AU3_KEYWORD);}
|
||||
else if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
|
||||
}
|
||||
} //for (; sc.More(); sc.Forward())
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
|
||||
{
|
||||
int endPos = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its fold status
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
if (startPos > 0) {
|
||||
if (lineCurrent > 0) {
|
||||
lineCurrent--;
|
||||
startPos = styler.LineStart(lineCurrent);
|
||||
}
|
||||
}
|
||||
int spaceFlags = 0;
|
||||
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsAU3Comment);
|
||||
char chNext = styler[startPos];
|
||||
for (int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
|
||||
int lev = indentCurrent;
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsAU3Comment);
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||
// Only non whitespace lines can be headers
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
|
||||
// Line after is blank so check the next - maybe should continue further?
|
||||
int spaceFlags2 = 0;
|
||||
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsAU3Comment);
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
indentCurrent = indentNext;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
lineCurrent++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
static const char * const AU3WordLists[] = {
|
||||
"#autoit keywords",
|
||||
"#autoit functions",
|
||||
"#autoit macros",
|
||||
"#autoit Sent keys",
|
||||
"#autoit Pre-processors",
|
||||
0
|
||||
};
|
||||
LexerModule lmAU3(SCLEX_AU3, ColouriseAU3Doc, "au3", FoldAU3Doc , AU3WordLists);
|
645
contrib/src/stc/scintilla/src/LexBash.cxx
Normal file
645
contrib/src/stc/scintilla/src/LexBash.cxx
Normal file
@@ -0,0 +1,645 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexBash.cxx
|
||||
** Lexer for Bash.
|
||||
**/
|
||||
// Copyright 2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Adapted from LexPerl by Kein-Hong Man <mkh@pl.jaring.my> 2004
|
||||
// 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"
|
||||
|
||||
#define BASH_BASE_ERROR 65
|
||||
#define BASH_BASE_DECIMAL 66
|
||||
#define BASH_BASE_HEX 67
|
||||
#define BASH_BASE_OCTAL 68
|
||||
#define BASH_BASE_OCTAL_ERROR 69
|
||||
|
||||
#define HERE_DELIM_MAX 256
|
||||
|
||||
static inline int translateBashDigit(char ch) {
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
return ch - '0';
|
||||
} else if (ch >= 'a' && ch <= 'z') {
|
||||
return ch - 'a' + 10;
|
||||
} else if (ch >= 'A' && ch <= 'Z') {
|
||||
return ch - 'A' + 36;
|
||||
} else if (ch == '@') {
|
||||
return 62;
|
||||
} else if (ch == '_') {
|
||||
return 63;
|
||||
}
|
||||
return BASH_BASE_ERROR;
|
||||
}
|
||||
|
||||
static inline bool isEOLChar(char ch) {
|
||||
return (ch == '\r') || (ch == '\n');
|
||||
}
|
||||
|
||||
static bool isSingleCharOp(char ch) {
|
||||
char strCharSet[2];
|
||||
strCharSet[0] = ch;
|
||||
strCharSet[1] = '\0';
|
||||
return (NULL != strstr("rwxoRWXOezsfdlpSbctugkTBMACahGLNn", strCharSet));
|
||||
}
|
||||
|
||||
static inline bool isBashOperator(char ch) {
|
||||
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 == '~' ||
|
||||
ch == '@')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int classifyWordBash(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
char s[100];
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_SH_IDENTIFIER;
|
||||
if (keywords.InList(s))
|
||||
chAttr = SCE_SH_WORD;
|
||||
styler.ColourTo(end, chAttr);
|
||||
return chAttr;
|
||||
}
|
||||
|
||||
static inline int getBashNumberBase(unsigned int start, unsigned int end, Accessor &styler) {
|
||||
int base = 0;
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 10; i++) {
|
||||
base = base * 10 + (styler[start + i] - '0');
|
||||
}
|
||||
if (base > 64 || (end - start) > 1) {
|
||||
return BASH_BASE_ERROR;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
static inline bool isEndVar(char ch) {
|
||||
return !isalnum(ch) && ch != '$' && ch != '_';
|
||||
}
|
||||
|
||||
static inline bool isNonQuote(char ch) {
|
||||
return isalnum(ch) || ch == '_';
|
||||
}
|
||||
|
||||
static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
|
||||
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
|
||||
return false;
|
||||
}
|
||||
while (*val) {
|
||||
if (*val != styler[pos++]) {
|
||||
return false;
|
||||
}
|
||||
val++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static char opposite(char ch) {
|
||||
if (ch == '(')
|
||||
return ')';
|
||||
if (ch == '[')
|
||||
return ']';
|
||||
if (ch == '{')
|
||||
return '}';
|
||||
if (ch == '<')
|
||||
return '>';
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
// Lexer for bash often has to backtrack to start of current style to determine
|
||||
// which characters are being used as quotes, how deeply nested is the
|
||||
// start position and what the termination string is for here documents
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
class HereDocCls {
|
||||
public:
|
||||
int State; // 0: '<<' encountered
|
||||
// 1: collect the delimiter
|
||||
// 2: here doc text (lines after the delimiter)
|
||||
char Quote; // the char after '<<'
|
||||
bool Quoted; // true if Quote in ('\'','"','`')
|
||||
bool Indent; // indented delimiter (for <<-)
|
||||
int DelimiterLength; // strlen(Delimiter)
|
||||
char *Delimiter; // the Delimiter, 256: sizeof PL_tokenbuf
|
||||
HereDocCls() {
|
||||
State = 0;
|
||||
DelimiterLength = 0;
|
||||
Delimiter = new char[HERE_DELIM_MAX];
|
||||
Delimiter[0] = '\0';
|
||||
}
|
||||
~HereDocCls() {
|
||||
delete []Delimiter;
|
||||
}
|
||||
};
|
||||
HereDocCls HereDoc;
|
||||
|
||||
class QuoteCls {
|
||||
public:
|
||||
int Rep;
|
||||
int Count;
|
||||
char Up;
|
||||
char Down;
|
||||
QuoteCls() {
|
||||
this->New(1);
|
||||
}
|
||||
void New(int r) {
|
||||
Rep = r;
|
||||
Count = 0;
|
||||
Up = '\0';
|
||||
Down = '\0';
|
||||
}
|
||||
void Open(char u) {
|
||||
Count++;
|
||||
Up = u;
|
||||
Down = opposite(Up);
|
||||
}
|
||||
};
|
||||
QuoteCls Quote;
|
||||
|
||||
int state = initStyle;
|
||||
int numBase = 0;
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
|
||||
// If in a long distance lexical state, seek to the beginning to find quote characters
|
||||
// Bash strings can be multi-line with embedded newlines, so backtrack.
|
||||
// Bash numbers have additional state during lexing, so backtrack too.
|
||||
if (state == SCE_SH_HERE_Q) {
|
||||
while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_SH_HERE_DELIM)) {
|
||||
startPos--;
|
||||
}
|
||||
startPos = styler.LineStart(styler.GetLine(startPos));
|
||||
state = styler.StyleAt(startPos - 1);
|
||||
}
|
||||
if (state == SCE_SH_STRING
|
||||
|| state == SCE_SH_BACKTICKS
|
||||
|| state == SCE_SH_CHARACTER
|
||||
|| state == SCE_SH_NUMBER
|
||||
|| state == SCE_SH_IDENTIFIER
|
||||
|| state == SCE_SH_COMMENTLINE
|
||||
) {
|
||||
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
|
||||
startPos--;
|
||||
}
|
||||
state = SCE_SH_DEFAULT;
|
||||
}
|
||||
|
||||
styler.StartAt(startPos);
|
||||
char chPrev = styler.SafeGetCharAt(startPos - 1);
|
||||
if (startPos == 0)
|
||||
chPrev = '\n';
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
|
||||
for (unsigned int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
// if the current character is not consumed due to the completion of an
|
||||
// earlier style, lexing can be restarted via a simple goto
|
||||
restartLexer:
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((chPrev == '\r' && ch == '\n')) { // skip on DOS/Windows
|
||||
styler.ColourTo(i, state);
|
||||
chPrev = ch;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (HereDoc.State == 1 && isEOLChar(ch)) {
|
||||
// Begin of here-doc (the line after the here-doc delimiter):
|
||||
// Lexically, the here-doc starts from the next line after the >>, but the
|
||||
// first line of here-doc seem to follow the style of the last EOL sequence
|
||||
HereDoc.State = 2;
|
||||
if (HereDoc.Quoted) {
|
||||
if (state == SCE_SH_HERE_DELIM) {
|
||||
// Missing quote at end of string! We are stricter than bash.
|
||||
// Colour here-doc anyway while marking this bit as an error.
|
||||
state = SCE_SH_ERROR;
|
||||
}
|
||||
styler.ColourTo(i - 1, state);
|
||||
// HereDoc.Quote always == '\''
|
||||
state = SCE_SH_HERE_Q;
|
||||
} else {
|
||||
styler.ColourTo(i - 1, state);
|
||||
// always switch
|
||||
state = SCE_SH_HERE_Q;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SCE_SH_DEFAULT) {
|
||||
if (ch == '\\') { // escaped character
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
styler.ColourTo(i, SCE_SH_IDENTIFIER);
|
||||
} else if (isdigit(ch)) {
|
||||
state = SCE_SH_NUMBER;
|
||||
numBase = BASH_BASE_DECIMAL;
|
||||
if (ch == '0') { // hex,octal
|
||||
if (chNext == 'x' || chNext == 'X') {
|
||||
numBase = BASH_BASE_HEX;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
} else if (isdigit(chNext)) {
|
||||
numBase = BASH_BASE_OCTAL;
|
||||
}
|
||||
}
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_SH_WORD;
|
||||
if (!iswordchar(chNext) && chNext != '+' && chNext != '-') {
|
||||
// We need that if length of word == 1!
|
||||
// This test is copied from the SCE_SH_WORD handler.
|
||||
classifyWordBash(styler.GetStartSegment(), i, keywords, styler);
|
||||
state = SCE_SH_DEFAULT;
|
||||
}
|
||||
} else if (ch == '#') {
|
||||
state = SCE_SH_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_SH_STRING;
|
||||
Quote.New(1);
|
||||
Quote.Open(ch);
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_SH_CHARACTER;
|
||||
Quote.New(1);
|
||||
Quote.Open(ch);
|
||||
} else if (ch == '`') {
|
||||
state = SCE_SH_BACKTICKS;
|
||||
Quote.New(1);
|
||||
Quote.Open(ch);
|
||||
} else if (ch == '$') {
|
||||
if (chNext == '{') {
|
||||
state = SCE_SH_PARAM;
|
||||
goto startQuote;
|
||||
} else if (chNext == '\'') {
|
||||
state = SCE_SH_CHARACTER;
|
||||
goto startQuote;
|
||||
} else if (chNext == '"') {
|
||||
state = SCE_SH_STRING;
|
||||
goto startQuote;
|
||||
} else if (chNext == '(' && chNext2 == '(') {
|
||||
styler.ColourTo(i, SCE_SH_OPERATOR);
|
||||
state = SCE_SH_DEFAULT;
|
||||
goto skipChar;
|
||||
} else if (chNext == '(' || chNext == '`') {
|
||||
state = SCE_SH_BACKTICKS;
|
||||
startQuote:
|
||||
Quote.New(1);
|
||||
Quote.Open(chNext);
|
||||
goto skipChar;
|
||||
} else {
|
||||
state = SCE_SH_SCALAR;
|
||||
skipChar:
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
}
|
||||
} else if (ch == '*') {
|
||||
if (chNext == '*') { // exponentiation
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
}
|
||||
styler.ColourTo(i, SCE_SH_OPERATOR);
|
||||
} else if (ch == '<' && chNext == '<') {
|
||||
state = SCE_SH_HERE_DELIM;
|
||||
HereDoc.State = 0;
|
||||
HereDoc.Indent = false;
|
||||
} else if (ch == '-' // file test operators
|
||||
&& isSingleCharOp(chNext)
|
||||
&& !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) {
|
||||
styler.ColourTo(i + 1, SCE_SH_WORD);
|
||||
state = SCE_SH_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
} else if (isBashOperator(ch)) {
|
||||
styler.ColourTo(i, SCE_SH_OPERATOR);
|
||||
} else {
|
||||
// keep colouring defaults to make restart easier
|
||||
styler.ColourTo(i, SCE_SH_DEFAULT);
|
||||
}
|
||||
} else if (state == SCE_SH_NUMBER) {
|
||||
int digit = translateBashDigit(ch);
|
||||
if (numBase == BASH_BASE_DECIMAL) {
|
||||
if (ch == '#') {
|
||||
numBase = getBashNumberBase(styler.GetStartSegment(), i - 1, styler);
|
||||
if (numBase == BASH_BASE_ERROR) // take the rest as comment
|
||||
goto numAtEnd;
|
||||
} else if (!isdigit(ch))
|
||||
goto numAtEnd;
|
||||
} else if (numBase == BASH_BASE_HEX) {
|
||||
if ((digit < 16) || (digit >= 36 && digit <= 41)) {
|
||||
// hex digit 0-9a-fA-F
|
||||
} else
|
||||
goto numAtEnd;
|
||||
} else if (numBase == BASH_BASE_OCTAL ||
|
||||
numBase == BASH_BASE_OCTAL_ERROR) {
|
||||
if (digit > 7) {
|
||||
if (digit <= 9) {
|
||||
numBase = BASH_BASE_OCTAL_ERROR;
|
||||
} else
|
||||
goto numAtEnd;
|
||||
}
|
||||
} else if (numBase == BASH_BASE_ERROR) {
|
||||
if (digit > 9)
|
||||
goto numAtEnd;
|
||||
} else { // DD#DDDD number style handling
|
||||
if (digit != BASH_BASE_ERROR) {
|
||||
if (numBase <= 36) {
|
||||
// case-insensitive if base<=36
|
||||
if (digit >= 36) digit -= 26;
|
||||
}
|
||||
if (digit >= numBase) {
|
||||
if (digit <= 9) {
|
||||
numBase = BASH_BASE_ERROR;
|
||||
} else
|
||||
goto numAtEnd;
|
||||
}
|
||||
} else {
|
||||
numAtEnd:
|
||||
if (numBase == BASH_BASE_ERROR ||
|
||||
numBase == BASH_BASE_OCTAL_ERROR)
|
||||
state = SCE_SH_ERROR;
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
goto restartLexer;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_SH_WORD) {
|
||||
if (!iswordchar(chNext) && chNext != '+' && chNext != '-') {
|
||||
// "." never used in Bash variable names
|
||||
// but used in file names
|
||||
classifyWordBash(styler.GetStartSegment(), i, keywords, styler);
|
||||
state = SCE_SH_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
} else if (state == SCE_SH_IDENTIFIER) {
|
||||
if (!iswordchar(chNext) && chNext != '+' && chNext != '-') {
|
||||
styler.ColourTo(i, SCE_SH_IDENTIFIER);
|
||||
state = SCE_SH_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_SH_COMMENTLINE) {
|
||||
if (ch == '\\' && isEOLChar(chNext)) {
|
||||
// comment continuation
|
||||
if (chNext == '\r' && chNext2 == '\n') {
|
||||
i += 2;
|
||||
ch = styler.SafeGetCharAt(i);
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
}
|
||||
} else if (isEOLChar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
goto restartLexer;
|
||||
} else if (isEOLChar(chNext)) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_SH_HERE_DELIM) {
|
||||
//
|
||||
// From Bash info:
|
||||
// ---------------
|
||||
// Specifier format is: <<[-]WORD
|
||||
// Optional '-' is for removal of leading tabs from here-doc.
|
||||
// Whitespace acceptable after <<[-] operator
|
||||
//
|
||||
if (HereDoc.State == 0) { // '<<' encountered
|
||||
HereDoc.State = 1;
|
||||
HereDoc.Quote = chNext;
|
||||
HereDoc.Quoted = false;
|
||||
HereDoc.DelimiterLength = 0;
|
||||
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
|
||||
if (chNext == '\'') { // a quoted here-doc delimiter (' only)
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
HereDoc.Quoted = true;
|
||||
} else if (!HereDoc.Indent && chNext == '-') { // <<- indent case
|
||||
HereDoc.Indent = true;
|
||||
HereDoc.State = 0;
|
||||
} else if (isalpha(chNext) || chNext == '_' || chNext == '\\'
|
||||
|| chNext == '-' || chNext == '+') {
|
||||
// an unquoted here-doc delimiter, no special handling
|
||||
} else if (chNext == '<') { // HERE string <<<
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
styler.ColourTo(i, SCE_SH_HERE_DELIM);
|
||||
state = SCE_SH_DEFAULT;
|
||||
HereDoc.State = 0;
|
||||
} else if (isspacechar(chNext)) {
|
||||
// eat whitespace
|
||||
HereDoc.State = 0;
|
||||
} else if (isdigit(chNext) || chNext == '=' || chNext == '$') {
|
||||
// left shift << or <<= operator cases
|
||||
styler.ColourTo(i, SCE_SH_OPERATOR);
|
||||
state = SCE_SH_DEFAULT;
|
||||
HereDoc.State = 0;
|
||||
} else {
|
||||
// symbols terminates; deprecated zero-length delimiter
|
||||
}
|
||||
} else if (HereDoc.State == 1) { // collect the delimiter
|
||||
if (HereDoc.Quoted) { // a quoted here-doc delimiter
|
||||
if (ch == HereDoc.Quote) { // closing quote => end of delimiter
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
} else {
|
||||
if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
}
|
||||
HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
|
||||
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
|
||||
}
|
||||
} else { // an unquoted here-doc delimiter
|
||||
if (isalnum(ch) || ch == '_' || ch == '-' || ch == '+') {
|
||||
HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
|
||||
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
|
||||
} else if (ch == '\\') {
|
||||
// skip escape prefix
|
||||
} else {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
goto restartLexer;
|
||||
}
|
||||
}
|
||||
if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_SH_ERROR;
|
||||
goto restartLexer;
|
||||
}
|
||||
}
|
||||
} else if (HereDoc.State == 2) {
|
||||
// state == SCE_SH_HERE_Q
|
||||
if (isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
|
||||
if (!HereDoc.Indent && isEOLChar(chPrev)) {
|
||||
endHereDoc:
|
||||
// standard HERE delimiter
|
||||
i += HereDoc.DelimiterLength;
|
||||
chPrev = styler.SafeGetCharAt(i - 1);
|
||||
ch = styler.SafeGetCharAt(i);
|
||||
if (isEOLChar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
HereDoc.State = 0;
|
||||
goto restartLexer;
|
||||
}
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else if (HereDoc.Indent) {
|
||||
// indented HERE delimiter
|
||||
unsigned int bk = (i > 0)? i - 1: 0;
|
||||
while (i > 0) {
|
||||
ch = styler.SafeGetCharAt(bk--);
|
||||
if (isEOLChar(ch)) {
|
||||
goto endHereDoc;
|
||||
} else if (!isspacechar(ch)) {
|
||||
break; // got leading non-whitespace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_SH_SCALAR) { // variable names
|
||||
if (isEndVar(ch)) {
|
||||
if ((state == SCE_SH_SCALAR)
|
||||
&& i == (styler.GetStartSegment() + 1)) {
|
||||
// Special variable: $(, $_ etc.
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
} else {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
goto restartLexer;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_SH_STRING
|
||||
|| state == SCE_SH_CHARACTER
|
||||
|| state == SCE_SH_BACKTICKS
|
||||
|| state == SCE_SH_PARAM
|
||||
) {
|
||||
if (!Quote.Down && !isspacechar(ch)) {
|
||||
Quote.Open(ch);
|
||||
} else if (ch == '\\' && Quote.Up != '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else if (ch == Quote.Down) {
|
||||
Quote.Count--;
|
||||
if (Quote.Count == 0) {
|
||||
Quote.Rep--;
|
||||
if (Quote.Rep <= 0) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_SH_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
if (Quote.Up == Quote.Down) {
|
||||
Quote.Count++;
|
||||
}
|
||||
}
|
||||
} else if (ch == Quote.Up) {
|
||||
Quote.Count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state == SCE_SH_ERROR) {
|
||||
break;
|
||||
}
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
}
|
||||
|
||||
static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[],
|
||||
Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (foldComment && (style == SCE_SH_COMMENTLINE)) {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelCurrent++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_C_OPERATOR) {
|
||||
if (ch == '{') {
|
||||
levelCurrent++;
|
||||
} else if (ch == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int lev = levelPrev;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0))
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelPrev = levelCurrent;
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
}
|
||||
|
||||
static const char * const bashWordListDesc[] = {
|
||||
"Keywords",
|
||||
0
|
||||
};
|
||||
|
||||
LexerModule lmBash(SCLEX_BASH, ColouriseBashDoc, "bash", FoldBashDoc, bashWordListDesc);
|
309
contrib/src/stc/scintilla/src/LexGui4Cli.cxx
Normal file
309
contrib/src/stc/scintilla/src/LexGui4Cli.cxx
Normal file
@@ -0,0 +1,309 @@
|
||||
// Scintilla source code edit control
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
/*
|
||||
This is the Lexer for Gui4Cli, included in SciLexer.dll
|
||||
- by d. Keletsekis, 2/10/2003
|
||||
|
||||
To add to SciLexer.dll:
|
||||
1. Add the values below to INCLUDE\Scintilla.iface
|
||||
2. Run the include/HFacer.py script
|
||||
3. Run the src/lexGen.py script
|
||||
|
||||
val SCE_GC_DEFAULT=0
|
||||
val SCE_GC_COMMENTLINE=1
|
||||
val SCE_GC_COMMENTBLOCK=2
|
||||
val SCE_GC_GLOBAL=3
|
||||
val SCE_GC_EVENT=4
|
||||
val SCE_GC_ATTRIBUTE=5
|
||||
val SCE_GC_CONTROL=6
|
||||
val SCE_GC_COMMAND=7
|
||||
val SCE_GC_STRING=8
|
||||
val SCE_GC_OPERATOR=9
|
||||
*/
|
||||
|
||||
#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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
#define debug Platform::DebugPrintf
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch =='\\');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.');
|
||||
}
|
||||
|
||||
inline bool isGCOperator(int ch)
|
||||
{ if (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 == ':')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#define isSpace(x) ((x)==' ' || (x)=='\t')
|
||||
#define isNL(x) ((x)=='\n' || (x)=='\r')
|
||||
#define isSpaceOrNL(x) (isSpace(x) || isNL(x))
|
||||
#define BUFFSIZE 500
|
||||
#define isFoldPoint(x) ((styler.LevelAt(x) & SC_FOLDLEVELNUMBERMASK) == 1024)
|
||||
|
||||
static void colorFirstWord(WordList *keywordlists[], Accessor &styler,
|
||||
StyleContext *sc, char *buff, int length, int)
|
||||
{
|
||||
int c = 0;
|
||||
while (sc->More() && isSpaceOrNL(sc->ch))
|
||||
{ sc->Forward();
|
||||
}
|
||||
styler.ColourTo(sc->currentPos - 1, sc->state);
|
||||
|
||||
if (!IsAWordChar(sc->ch)) // comment, marker, etc..
|
||||
return;
|
||||
|
||||
while (sc->More() && !isSpaceOrNL(sc->ch) && (c < length-1) && !isGCOperator(sc->ch))
|
||||
{ buff[c] = static_cast<char>(sc->ch);
|
||||
++c; sc->Forward();
|
||||
}
|
||||
buff[c] = '\0';
|
||||
char *p = buff;
|
||||
while (*p) // capitalize..
|
||||
{ if (islower(*p)) *p = static_cast<char>(toupper(*p));
|
||||
++p;
|
||||
}
|
||||
|
||||
WordList &kGlobal = *keywordlists[0]; // keyword lists set by the user
|
||||
WordList &kEvent = *keywordlists[1];
|
||||
WordList &kAttribute = *keywordlists[2];
|
||||
WordList &kControl = *keywordlists[3];
|
||||
WordList &kCommand = *keywordlists[4];
|
||||
|
||||
int state = 0;
|
||||
// int level = styler.LevelAt(line) & SC_FOLDLEVELNUMBERMASK;
|
||||
// debug ("line = %d, level = %d", line, level);
|
||||
|
||||
if (kGlobal.InList(buff)) state = SCE_GC_GLOBAL;
|
||||
else if (kAttribute.InList(buff)) state = SCE_GC_ATTRIBUTE;
|
||||
else if (kControl.InList(buff)) state = SCE_GC_CONTROL;
|
||||
else if (kCommand.InList(buff)) state = SCE_GC_COMMAND;
|
||||
else if (kEvent.InList(buff)) state = SCE_GC_EVENT;
|
||||
|
||||
if (state)
|
||||
{ sc->ChangeState(state);
|
||||
styler.ColourTo(sc->currentPos - 1, sc->state);
|
||||
sc->ChangeState(SCE_GC_DEFAULT);
|
||||
}
|
||||
else
|
||||
{ sc->ChangeState(SCE_GC_DEFAULT);
|
||||
styler.ColourTo(sc->currentPos - 1, sc->state);
|
||||
}
|
||||
}
|
||||
|
||||
// Main colorizing function called by Scintilla
|
||||
static void
|
||||
ColouriseGui4CliDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler)
|
||||
{
|
||||
styler.StartAt(startPos);
|
||||
|
||||
int quotestart = 0, oldstate, currentline = styler.GetLine(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
bool noforward;
|
||||
char buff[BUFFSIZE+1]; // buffer for command name
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
buff[0] = '\0'; // cbuff = 0;
|
||||
|
||||
if (sc.state != SCE_GC_COMMENTBLOCK) // colorize 1st word..
|
||||
colorFirstWord(keywordlists, styler, &sc, buff, BUFFSIZE, currentline);
|
||||
|
||||
while (sc.More())
|
||||
{ noforward = 0;
|
||||
|
||||
switch (sc.ch)
|
||||
{
|
||||
case '/':
|
||||
if (sc.state == SCE_GC_COMMENTBLOCK || sc.state == SCE_GC_STRING)
|
||||
break;
|
||||
if (sc.chNext == '/') // line comment
|
||||
{ sc.SetState (SCE_GC_COMMENTLINE);
|
||||
sc.Forward();
|
||||
styler.ColourTo(sc.currentPos, sc.state);
|
||||
}
|
||||
else if (sc.chNext == '*') // block comment
|
||||
{ sc.SetState(SCE_GC_COMMENTBLOCK);
|
||||
sc.Forward();
|
||||
styler.ColourTo(sc.currentPos, sc.state);
|
||||
}
|
||||
else
|
||||
styler.ColourTo(sc.currentPos, sc.state);
|
||||
break;
|
||||
|
||||
case '*': // end of comment block, or operator..
|
||||
if (sc.state == SCE_GC_STRING)
|
||||
break;
|
||||
if (sc.state == SCE_GC_COMMENTBLOCK && sc.chNext == '/')
|
||||
{ sc.Forward();
|
||||
styler.ColourTo(sc.currentPos, sc.state);
|
||||
sc.ChangeState (SCE_GC_DEFAULT);
|
||||
}
|
||||
else
|
||||
styler.ColourTo(sc.currentPos, sc.state);
|
||||
break;
|
||||
|
||||
case '\'': case '\"': // strings..
|
||||
if (sc.state == SCE_GC_COMMENTBLOCK || sc.state == SCE_GC_COMMENTLINE)
|
||||
break;
|
||||
if (sc.state == SCE_GC_STRING)
|
||||
{ if (sc.ch == quotestart) // match same quote char..
|
||||
{ styler.ColourTo(sc.currentPos, sc.state);
|
||||
sc.ChangeState(SCE_GC_DEFAULT);
|
||||
quotestart = 0;
|
||||
} }
|
||||
else
|
||||
{ styler.ColourTo(sc.currentPos - 1, sc.state);
|
||||
sc.ChangeState(SCE_GC_STRING);
|
||||
quotestart = sc.ch;
|
||||
}
|
||||
break;
|
||||
|
||||
case ';': // end of commandline character
|
||||
if (sc.state != SCE_GC_COMMENTBLOCK && sc.state != SCE_GC_COMMENTLINE &&
|
||||
sc.state != SCE_GC_STRING)
|
||||
{
|
||||
styler.ColourTo(sc.currentPos - 1, sc.state);
|
||||
styler.ColourTo(sc.currentPos, SCE_GC_OPERATOR);
|
||||
sc.ChangeState(SCE_GC_DEFAULT);
|
||||
sc.Forward();
|
||||
colorFirstWord(keywordlists, styler, &sc, buff, BUFFSIZE, currentline);
|
||||
noforward = 1; // don't move forward - already positioned at next char..
|
||||
}
|
||||
break;
|
||||
|
||||
case '+': case '-': case '=': case '!': // operators..
|
||||
case '<': case '>': case '&': case '|': case '$':
|
||||
if (sc.state != SCE_GC_COMMENTBLOCK && sc.state != SCE_GC_COMMENTLINE &&
|
||||
sc.state != SCE_GC_STRING)
|
||||
{
|
||||
styler.ColourTo(sc.currentPos - 1, sc.state);
|
||||
styler.ColourTo(sc.currentPos, SCE_GC_OPERATOR);
|
||||
sc.ChangeState(SCE_GC_DEFAULT);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\\': // escape - same as operator, but also mark in strings..
|
||||
if (sc.state != SCE_GC_COMMENTBLOCK && sc.state != SCE_GC_COMMENTLINE)
|
||||
{
|
||||
oldstate = sc.state;
|
||||
styler.ColourTo(sc.currentPos - 1, sc.state);
|
||||
sc.Forward(); // mark also the next char..
|
||||
styler.ColourTo(sc.currentPos, SCE_GC_OPERATOR);
|
||||
sc.ChangeState(oldstate);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\n': case '\r':
|
||||
++currentline;
|
||||
if (sc.state == SCE_GC_COMMENTLINE)
|
||||
{ styler.ColourTo(sc.currentPos, sc.state);
|
||||
sc.ChangeState (SCE_GC_DEFAULT);
|
||||
}
|
||||
else if (sc.state != SCE_GC_COMMENTBLOCK)
|
||||
{ colorFirstWord(keywordlists, styler, &sc, buff, BUFFSIZE, currentline);
|
||||
noforward = 1; // don't move forward - already positioned at next char..
|
||||
}
|
||||
break;
|
||||
|
||||
// case ' ': case '\t':
|
||||
// default :
|
||||
}
|
||||
|
||||
if (!noforward) sc.Forward();
|
||||
|
||||
}
|
||||
styler.ColourTo(sc.currentPos, sc.state);
|
||||
}
|
||||
|
||||
// Main folding function called by Scintilla - (based on props (.ini) files function)
|
||||
static void FoldGui4Cli(unsigned int startPos, int length, int,
|
||||
WordList *[], Accessor &styler)
|
||||
{
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
bool headerPoint = false;
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler[i+1];
|
||||
|
||||
int style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
|
||||
if (style == SCE_GC_EVENT || style == SCE_GC_GLOBAL)
|
||||
{ headerPoint = true; // fold at events and globals
|
||||
}
|
||||
|
||||
if (atEOL)
|
||||
{ int lev = SC_FOLDLEVELBASE+1;
|
||||
|
||||
if (headerPoint)
|
||||
lev = SC_FOLDLEVELBASE;
|
||||
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
|
||||
if (headerPoint)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
|
||||
if (lev != styler.LevelAt(lineCurrent)) // set level, if not already correct
|
||||
{ styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
|
||||
lineCurrent++; // re-initialize our flags
|
||||
visibleChars = 0;
|
||||
headerPoint = false;
|
||||
}
|
||||
|
||||
if (!(isspacechar(ch))) // || (style == SCE_GC_COMMENTLINE) || (style != SCE_GC_COMMENTBLOCK)))
|
||||
visibleChars++;
|
||||
}
|
||||
|
||||
int lev = headerPoint ? SC_FOLDLEVELBASE : SC_FOLDLEVELBASE+1;
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, lev | flagsNext);
|
||||
}
|
||||
|
||||
// I have no idea what these are for.. probably accessible by some message.
|
||||
static const char * const gui4cliWordListDesc[] = {
|
||||
"Globals", "Events", "Attributes", "Control", "Commands",
|
||||
0
|
||||
};
|
||||
|
||||
// Declare language & pass our function pointers to Scintilla
|
||||
LexerModule lmGui4Cli(SCLEX_GUI4CLI, ColouriseGui4CliDoc, "gui4cli", FoldGui4Cli, gui4cliWordListDesc);
|
||||
|
||||
#undef debug
|
||||
|
@@ -145,6 +145,8 @@ static inline bool isStringState(int state) {
|
||||
case SCE_HPA_STRING:
|
||||
case SCE_HPHP_HSTRING:
|
||||
case SCE_HPHP_SIMPLESTRING:
|
||||
case SCE_HPHP_HSTRING_VARIABLE:
|
||||
case SCE_HPHP_COMPLEX_VARIABLE:
|
||||
bResult = true;
|
||||
break;
|
||||
default :
|
||||
@@ -416,7 +418,21 @@ static bool isPHPStringState(int state) {
|
||||
return
|
||||
(state == SCE_HPHP_HSTRING) ||
|
||||
(state == SCE_HPHP_SIMPLESTRING) ||
|
||||
(state == SCE_HPHP_HSTRING_VARIABLE);
|
||||
(state == SCE_HPHP_HSTRING_VARIABLE) ||
|
||||
(state == SCE_HPHP_COMPLEX_VARIABLE);
|
||||
}
|
||||
|
||||
static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringDelimiterSize, int i, const int lengthDoc, Accessor &styler) {
|
||||
int j;
|
||||
phpStringDelimiter[0] = '\n';
|
||||
for (j = i; j < lengthDoc && styler[j] != '\n' && styler[j] != '\r'; j++) {
|
||||
if (j - i < phpStringDelimiterSize - 2)
|
||||
phpStringDelimiter[j-i+1] = styler[j];
|
||||
else
|
||||
i++;
|
||||
}
|
||||
phpStringDelimiter[j-i+1] = '\0';
|
||||
return j;
|
||||
}
|
||||
|
||||
static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
@@ -432,6 +448,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
styler.StartAt(startPos, STYLE_MAX);
|
||||
char prevWord[200];
|
||||
prevWord[0] = '\0';
|
||||
char phpStringDelimiter[200]; // PHP is not limited in length, we are
|
||||
phpStringDelimiter[0] = '\0';
|
||||
int StateToPrint = initStyle;
|
||||
int state = stateForPrintState(StateToPrint);
|
||||
|
||||
@@ -443,6 +461,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
state = SCE_H_DEFAULT;
|
||||
}
|
||||
// String can be heredoc, must find a delimiter first
|
||||
while (startPos > 0 && isPHPStringState(state) && state != SCE_HPHP_SIMPLESTRING) {
|
||||
startPos--;
|
||||
length++;
|
||||
state = styler.StyleAt(startPos);
|
||||
}
|
||||
styler.StartAt(startPos, STYLE_MAX);
|
||||
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
@@ -930,7 +954,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
state = SCE_H_DEFAULT;
|
||||
}
|
||||
if (ch != '#' && !(isascii(ch) && isalnum(ch))) { // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
if (ch != '#' && !(isascii(ch) && isalnum(ch)) // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
&& ch != '.' && ch != '-' && ch != '_' && ch != ':') { // valid in XML
|
||||
styler.ColourTo(i, SCE_H_TAGUNKNOWN);
|
||||
state = SCE_H_DEFAULT;
|
||||
}
|
||||
@@ -1454,6 +1479,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
state = SCE_HPHP_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_HPHP_HSTRING;
|
||||
strcpy(phpStringDelimiter, "\"");
|
||||
} else if (styler.Match(i, "<<<")) {
|
||||
state = SCE_HPHP_HSTRING;
|
||||
i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler);
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_HPHP_SIMPLESTRING;
|
||||
} else if (ch == '$' && IsPhpWordStart(chNext)) {
|
||||
@@ -1496,13 +1525,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
break;
|
||||
case SCE_HPHP_HSTRING:
|
||||
if (ch == '\\') {
|
||||
if (ch == '\\' && (phpStringDelimiter[0] == '\"' || chNext == '$' || chNext == '{')) {
|
||||
// skip the next char
|
||||
i++;
|
||||
} else if (((ch == '{' && chNext == '$') || (ch == '$' && chNext == '{'))
|
||||
&& IsPhpWordStart(chNext2)) {
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
state = SCE_HPHP_COMPLEX_VARIABLE;
|
||||
} else if (ch == '$' && IsPhpWordStart(chNext)) {
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
state = SCE_HPHP_HSTRING_VARIABLE;
|
||||
} else if (ch == '\"') {
|
||||
} else if (styler.Match(i, phpStringDelimiter)) {
|
||||
if (strlen(phpStringDelimiter) > 1)
|
||||
i += strlen(phpStringDelimiter) - 1;
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
state = SCE_HPHP_DEFAULT;
|
||||
}
|
||||
@@ -1523,6 +1558,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
state = SCE_HPHP_HSTRING;
|
||||
}
|
||||
break;
|
||||
case SCE_HPHP_COMPLEX_VARIABLE:
|
||||
if (ch == '}') {
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
state = SCE_HPHP_HSTRING;
|
||||
}
|
||||
break;
|
||||
case SCE_HPHP_OPERATOR:
|
||||
case SCE_HPHP_DEFAULT:
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
@@ -1540,6 +1581,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
state = SCE_HPHP_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_HPHP_HSTRING;
|
||||
strcpy(phpStringDelimiter, "\"");
|
||||
} else if (styler.Match(i, "<<<")) {
|
||||
state = SCE_HPHP_HSTRING;
|
||||
i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler);
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_HPHP_SIMPLESTRING;
|
||||
} else if (ch == '$' && IsPhpWordStart(chNext)) {
|
||||
@@ -1675,7 +1720,8 @@ static void ColouriseHTMLPiece(StyleContext &sc, WordList *keywordlists[]) {
|
||||
} else if (sc.state == SCE_H_ENTITY) {
|
||||
if (sc.ch == ';') {
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch)) { // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
} else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch) // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
&& sc.ch != '.' && sc.ch != '-' && sc.ch != '_' && sc.ch != ':') { // valid in XML
|
||||
sc.ChangeState(SCE_H_TAGUNKNOWN);
|
||||
sc.SetState(SCE_H_DEFAULT);
|
||||
}
|
||||
|
122
contrib/src/stc/scintilla/src/LexKix.cxx
Normal file
122
contrib/src/stc/scintilla/src/LexKix.cxx
Normal file
@@ -0,0 +1,122 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexKix.cxx
|
||||
** Lexer for KIX-Scripts.
|
||||
**/
|
||||
// Copyright 2004 by Manfred Becker <manfred@becker-trdf.de>
|
||||
// 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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
// Extended to accept accented characters
|
||||
static inline bool IsAWordChar(int ch) {
|
||||
return ch >= 0x80 || isalnum(ch) || ch == '_';
|
||||
}
|
||||
|
||||
static inline bool IsOperator(const int ch) {
|
||||
return (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '&' || ch == '|' || ch == '<' || ch == '>' || ch == '=');
|
||||
}
|
||||
|
||||
static void ColouriseKixDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
// WordList &keywords4 = *keywordlists[3];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.state == SCE_KIX_COMMENT) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_STRING1) {
|
||||
// This is a doubles quotes string
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_STRING2) {
|
||||
// This is a single quote string
|
||||
if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_NUMBER) {
|
||||
if (!IsADigit(sc.ch)) {
|
||||
sc.SetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_VAR) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_MACRO) {
|
||||
if (!IsAWordChar(sc.ch) && !IsADigit(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
|
||||
if (!keywords3.InList(&s[1])) {
|
||||
sc.ChangeState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
sc.SetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_OPERATOR) {
|
||||
if (!IsOperator(sc.ch)) {
|
||||
sc.SetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_KIX_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_KIX_KEYWORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_KIX_FUNCTIONS);
|
||||
}
|
||||
sc.SetState(SCE_KIX_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_KIX_DEFAULT) {
|
||||
if (sc.ch == ';') {
|
||||
sc.SetState(SCE_KIX_COMMENT);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_KIX_STRING1);
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_KIX_STRING2);
|
||||
} else if (sc.ch == '$') {
|
||||
sc.SetState(SCE_KIX_VAR);
|
||||
} else if (sc.ch == '@') {
|
||||
sc.SetState(SCE_KIX_MACRO);
|
||||
} else if (IsADigit(sc.ch) || ((sc.ch == '.' || sc.ch == '&') && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_KIX_NUMBER);
|
||||
} else if (IsOperator(sc.ch)) {
|
||||
sc.SetState(SCE_KIX_OPERATOR);
|
||||
} else if (IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_KIX_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
|
||||
LexerModule lmKix(SCLEX_KIX, ColouriseKixDoc, "kix");
|
||||
|
329
contrib/src/stc/scintilla/src/LexMSSQL.cxx
Normal file
329
contrib/src/stc/scintilla/src/LexMSSQL.cxx
Normal file
@@ -0,0 +1,329 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexMSSQL.cxx
|
||||
** Lexer for MSSQL.
|
||||
**/
|
||||
// Copyright 1998-2002 by Filip Yaghob <fy@eg.cz>
|
||||
|
||||
|
||||
#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"
|
||||
|
||||
#define KW_MSSQL_STATEMENTS 0
|
||||
#define KW_MSSQL_DATA_TYPES 1
|
||||
#define KW_MSSQL_SYSTEM_TABLES 2
|
||||
#define KW_MSSQL_GLOBAL_VARIABLES 3
|
||||
#define KW_MSSQL_FUNCTIONS 4
|
||||
#define KW_MSSQL_STORED_PROCEDURES 5
|
||||
#define KW_MSSQL_OPERATORS 6
|
||||
|
||||
//~ val SCE_MSSQL_DEFAULT=0
|
||||
//~ val SCE_MSSQL_COMMENT=1
|
||||
//~ val SCE_MSSQL_LINE_COMMENT=2
|
||||
//~ val SCE_MSSQL_NUMBER=3
|
||||
//~ val SCE_MSSQL_STRING=4
|
||||
//~ val SCE_MSSQL_OPERATOR=5
|
||||
//~ val SCE_MSSQL_IDENTIFIER=6
|
||||
//~ val SCE_MSSQL_VARIABLE=7
|
||||
//~ val SCE_MSSQL_COLUMN_NAME=8
|
||||
//~ val SCE_MSSQL_STATEMENT=9
|
||||
//~ val SCE_MSSQL_DATATYPE=10
|
||||
//~ val SCE_MSSQL_SYSTABLE=11
|
||||
//~ val SCE_MSSQL_GLOBAL_VARIABLE=12
|
||||
//~ val SCE_MSSQL_FUNCTION=13
|
||||
//~ val SCE_MSSQL_STORED_PROCEDURE=14
|
||||
//~ val SCE_MSSQL_DEFAULT_PREF_DATATYPE 15
|
||||
//~ val SCE_MSSQL_COLUMN_NAME_2 16
|
||||
|
||||
static bool isMSSQLOperator(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 == ',')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static char classifyWordSQL(unsigned int start,
|
||||
unsigned int end,
|
||||
WordList *keywordlists[],
|
||||
Accessor &styler,
|
||||
unsigned int actualState,
|
||||
unsigned int prevState) {
|
||||
char s[256];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
|
||||
WordList &kwStatements = *keywordlists[KW_MSSQL_STATEMENTS];
|
||||
WordList &kwDataTypes = *keywordlists[KW_MSSQL_DATA_TYPES];
|
||||
WordList &kwSystemTables = *keywordlists[KW_MSSQL_SYSTEM_TABLES];
|
||||
WordList &kwGlobalVariables = *keywordlists[KW_MSSQL_GLOBAL_VARIABLES];
|
||||
WordList &kwFunctions = *keywordlists[KW_MSSQL_FUNCTIONS];
|
||||
WordList &kwStoredProcedures = *keywordlists[KW_MSSQL_STORED_PROCEDURES];
|
||||
WordList &kwOperators = *keywordlists[KW_MSSQL_OPERATORS];
|
||||
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 128; i++) {
|
||||
s[i] = static_cast<char>(tolower(styler[start + i]));
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_MSSQL_IDENTIFIER;
|
||||
|
||||
if (actualState == SCE_MSSQL_GLOBAL_VARIABLE) {
|
||||
|
||||
if (kwGlobalVariables.InList(&s[2]))
|
||||
chAttr = SCE_MSSQL_GLOBAL_VARIABLE;
|
||||
|
||||
} else if (wordIsNumber) {
|
||||
chAttr = SCE_MSSQL_NUMBER;
|
||||
|
||||
} else if (prevState == SCE_MSSQL_DEFAULT_PREF_DATATYPE) {
|
||||
// Look first in datatypes
|
||||
if (kwDataTypes.InList(s))
|
||||
chAttr = SCE_MSSQL_DATATYPE;
|
||||
else if (kwOperators.InList(s))
|
||||
chAttr = SCE_MSSQL_OPERATOR;
|
||||
else if (kwStatements.InList(s))
|
||||
chAttr = SCE_MSSQL_STATEMENT;
|
||||
else if (kwSystemTables.InList(s))
|
||||
chAttr = SCE_MSSQL_SYSTABLE;
|
||||
else if (kwFunctions.InList(s))
|
||||
chAttr = SCE_MSSQL_FUNCTION;
|
||||
else if (kwStoredProcedures.InList(s))
|
||||
chAttr = SCE_MSSQL_STORED_PROCEDURE;
|
||||
|
||||
} else {
|
||||
if (kwOperators.InList(s))
|
||||
chAttr = SCE_MSSQL_OPERATOR;
|
||||
else if (kwStatements.InList(s))
|
||||
chAttr = SCE_MSSQL_STATEMENT;
|
||||
else if (kwSystemTables.InList(s))
|
||||
chAttr = SCE_MSSQL_SYSTABLE;
|
||||
else if (kwFunctions.InList(s))
|
||||
chAttr = SCE_MSSQL_FUNCTION;
|
||||
else if (kwStoredProcedures.InList(s))
|
||||
chAttr = SCE_MSSQL_STORED_PROCEDURE;
|
||||
else if (kwDataTypes.InList(s))
|
||||
chAttr = SCE_MSSQL_DATATYPE;
|
||||
}
|
||||
|
||||
styler.ColourTo(end, chAttr);
|
||||
|
||||
return chAttr;
|
||||
}
|
||||
|
||||
static void ColouriseMSSQLDoc(unsigned int startPos, int length,
|
||||
int initStyle, WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold") != 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int spaceFlags = 0;
|
||||
/*
|
||||
WordList &kwStatements = *keywordlists[KW_MSSQL_STATEMENTS];
|
||||
WordList &kwDataTypes = *keywordlists[KW_MSSQL_DATA_TYPES];
|
||||
WordList &kwSystemTables = *keywordlists[KW_MSSQL_SYSTEM_TABLES];
|
||||
WordList &kwGlobalVariables = *keywordlists[KW_MSSQL_GLOBAL_VARIABLES];
|
||||
WordList &kwFunctions = *keywordlists[KW_MSSQL_FUNCTIONS];
|
||||
|
||||
char s[100];
|
||||
int iixx = 0;
|
||||
s[0] = 's'; s[1] = 'e'; s[2] = 'l'; s[3] = 'e'; s[4] = 'c'; s[5] = 't'; s[6] = 0;
|
||||
if (kwStatements.InList(s))
|
||||
iixx = 1;
|
||||
s[0] = 's'; s[1] = 'e'; s[2] = 'r'; s[3] = 'v'; s[4] = 'e'; s[5] = 'r'; s[6] = 'n'; s[7] = 'a'; s[8] = 'm'; s[9] = 'e'; s[10] = 0;
|
||||
if (kwGlobalVariables.InList(s))
|
||||
iixx += 2;
|
||||
*/
|
||||
int state = initStyle;
|
||||
int prevState = initStyle;
|
||||
char chPrev = ' ';
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
for (unsigned int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
|
||||
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
|
||||
int lev = indentCurrent;
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||
// Only non whitespace lines can be headers
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
|
||||
if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
if (fold) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
}
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// When the last char isn't part of the state (have to deal with it too)...
|
||||
if ( (state == SCE_MSSQL_IDENTIFIER) ||
|
||||
(state == SCE_MSSQL_STORED_PROCEDURE) ||
|
||||
(state == SCE_MSSQL_DATATYPE) ||
|
||||
//~ (state == SCE_MSSQL_COLUMN_NAME) ||
|
||||
(state == SCE_MSSQL_FUNCTION) ||
|
||||
//~ (state == SCE_MSSQL_GLOBAL_VARIABLE) ||
|
||||
(state == SCE_MSSQL_VARIABLE)) {
|
||||
if (!iswordchar(ch)) {
|
||||
int stateTmp;
|
||||
|
||||
if ((state == SCE_MSSQL_VARIABLE) || (state == SCE_MSSQL_COLUMN_NAME)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
stateTmp = state;
|
||||
} else
|
||||
stateTmp = classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state, prevState);
|
||||
|
||||
prevState = state;
|
||||
|
||||
if (stateTmp == SCE_MSSQL_IDENTIFIER || stateTmp == SCE_MSSQL_VARIABLE)
|
||||
state = SCE_MSSQL_DEFAULT_PREF_DATATYPE;
|
||||
else
|
||||
state = SCE_MSSQL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_MSSQL_LINE_COMMENT) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_MSSQL_GLOBAL_VARIABLE) {
|
||||
if ((ch != '@') && !iswordchar(ch)) {
|
||||
classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state, prevState);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
// If is the default or one of the above succeeded
|
||||
if (state == SCE_MSSQL_DEFAULT || state == SCE_MSSQL_DEFAULT_PREF_DATATYPE) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_IDENTIFIER;
|
||||
} else if (ch == '/' && chNext == '*') {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_LINE_COMMENT;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_STRING;
|
||||
} else if (ch == '"') {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_COLUMN_NAME;
|
||||
} else if (ch == '[') {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_COLUMN_NAME_2;
|
||||
} else if (isMSSQLOperator(ch)) {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
styler.ColourTo(i, SCE_MSSQL_OPERATOR);
|
||||
//~ style = SCE_MSSQL_DEFAULT;
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT;
|
||||
} else if (ch == '@') {
|
||||
styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
|
||||
prevState = state;
|
||||
if (chNext == '@') {
|
||||
state = SCE_MSSQL_GLOBAL_VARIABLE;
|
||||
// i += 2;
|
||||
} else
|
||||
state = SCE_MSSQL_VARIABLE;
|
||||
}
|
||||
|
||||
|
||||
// When the last char is part of the state...
|
||||
} else if (state == SCE_MSSQL_COMMENT) {
|
||||
if (ch == '/' && chPrev == '*') {
|
||||
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_MSSQL_COMMENT) &&
|
||||
(styler.GetStartSegment() == startPos)))) {
|
||||
styler.ColourTo(i, state);
|
||||
//~ state = SCE_MSSQL_COMMENT;
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_MSSQL_STRING) {
|
||||
if (ch == '\'') {
|
||||
if ( chNext == '\'' ) {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
styler.ColourTo(i, state);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT;
|
||||
//i++;
|
||||
}
|
||||
//ch = chNext;
|
||||
//chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (state == SCE_MSSQL_COLUMN_NAME) {
|
||||
if (ch == '"') {
|
||||
if (chNext == '"') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
styler.ColourTo(i, state);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT_PREF_DATATYPE;
|
||||
//i++;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_MSSQL_COLUMN_NAME_2) {
|
||||
if (ch == ']') {
|
||||
styler.ColourTo(i, state);
|
||||
prevState = state;
|
||||
state = SCE_MSSQL_DEFAULT_PREF_DATATYPE;
|
||||
//i++;
|
||||
}
|
||||
}
|
||||
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
}
|
||||
|
||||
static const char * const sqlWordListDesc[] = {
|
||||
"Statements",
|
||||
"Data Types",
|
||||
"System tables",
|
||||
"Global variables",
|
||||
"Functions",
|
||||
"System Stored Procedures",
|
||||
"Operators",
|
||||
0,
|
||||
};
|
||||
|
||||
LexerModule lmMSSQL(SCLEX_MSSQL, ColouriseMSSQLDoc, "mssql", 0, sqlWordListDesc);
|
@@ -2,9 +2,9 @@
|
||||
/** @file LexNsis.cxx
|
||||
** Lexer for NSIS
|
||||
**/
|
||||
// Copyright 2003 by Angelo Mandato <angelo@spaceblue.com>
|
||||
// Copyright 2003, 2004 by Angelo Mandato <angelo [at] spaceblue [dot] com>
|
||||
// Last Updated: 02/22/2004
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "SciLexer.h"
|
||||
|
||||
/*
|
||||
// Put in SciLexer.h
|
||||
#define SCLEX_NSIS 34
|
||||
// located in SciLexer.h
|
||||
#define SCLEX_NSIS 43
|
||||
|
||||
#define SCE_NSIS_DEFAULT 0
|
||||
#define SCE_NSIS_COMMENT 1
|
||||
@@ -37,10 +37,84 @@
|
||||
#define SCE_NSIS_IFDEFINEDEF 11
|
||||
#define SCE_NSIS_MACRODEF 12
|
||||
#define SCE_NSIS_STRINGVAR 13
|
||||
#define SCE_NSIS_NUMBER 14
|
||||
*/
|
||||
|
||||
static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler)
|
||||
static bool isNsisNumber(char ch)
|
||||
{
|
||||
return (ch >= '0' && ch <= '9');
|
||||
}
|
||||
|
||||
static bool isNsisChar(char ch)
|
||||
{
|
||||
return (ch == '.' ) || (ch == '_' ) || isNsisNumber(ch) || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
|
||||
}
|
||||
|
||||
static bool isNsisLetter(char ch)
|
||||
{
|
||||
return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
|
||||
}
|
||||
|
||||
static int NsisCmp( char *s1, char *s2, bool bIgnoreCase )
|
||||
{
|
||||
if( bIgnoreCase )
|
||||
return CompareCaseInsensitive( s1, s2);
|
||||
|
||||
return strcmp( s1, s2 );
|
||||
}
|
||||
|
||||
static int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel, Accessor &styler )
|
||||
{
|
||||
// If the word is too long, it is not what we are looking for
|
||||
if( end - start > 13 )
|
||||
return foldlevel;
|
||||
|
||||
// Check the style at this point, if it is not valid, then return zero
|
||||
if( styler.StyleAt(end) != SCE_NSIS_FUNCTION && styler.StyleAt(end) != SCE_NSIS_SECTIONDEF &&
|
||||
styler.StyleAt(end) != SCE_NSIS_SUBSECTIONDEF && styler.StyleAt(end) != SCE_NSIS_IFDEFINEDEF &&
|
||||
styler.StyleAt(end) != SCE_NSIS_MACRODEF )
|
||||
return foldlevel;
|
||||
|
||||
int newFoldlevel = foldlevel;
|
||||
bool bIgnoreCase = false;
|
||||
if( styler.GetPropertyInt("nsis.ignorecase") == 1 )
|
||||
bIgnoreCase = true;
|
||||
|
||||
char s[15]; // The key word we are looking for has atmost 13 characters
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 14; i++)
|
||||
{
|
||||
s[i] = static_cast<char>( styler[ start + i ] );
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
|
||||
if( s[0] == '!' )
|
||||
{
|
||||
if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
|
||||
newFoldlevel++;
|
||||
else if( NsisCmp(s, "!endif", bIgnoreCase) == 0 || NsisCmp(s, "!macroend", bIgnoreCase ) == 0 )
|
||||
newFoldlevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SubSection", bIgnoreCase ) == 0 )
|
||||
newFoldlevel++;
|
||||
else if( NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase ) == 0 )
|
||||
newFoldlevel--;
|
||||
}
|
||||
|
||||
return newFoldlevel;
|
||||
}
|
||||
|
||||
static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler )
|
||||
{
|
||||
bool bIgnoreCase = false;
|
||||
if( styler.GetPropertyInt("nsis.ignorecase") == 1 )
|
||||
bIgnoreCase = true;
|
||||
|
||||
bool bUserVars = false;
|
||||
if( styler.GetPropertyInt("nsis.uservars") == 1 )
|
||||
bUserVars = true;
|
||||
|
||||
char s[100];
|
||||
|
||||
WordList &Functions = *keywordLists[0];
|
||||
@@ -48,27 +122,29 @@ static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keyw
|
||||
WordList &Lables = *keywordLists[2];
|
||||
WordList &UserDefined = *keywordLists[3];
|
||||
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++)
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 99; i++)
|
||||
{
|
||||
s[i] = static_cast<char>( styler[ start + i ] );
|
||||
if( bIgnoreCase )
|
||||
s[i] = static_cast<char>( tolower(styler[ start + i ] ) );
|
||||
else
|
||||
s[i] = static_cast<char>( styler[ start + i ] );
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
|
||||
// Check for special words...
|
||||
|
||||
if( strcmp(s, "!macro") == 0 || strcmp(s, "!macroend") == 0 ) // Covers !micro and !microend
|
||||
if( NsisCmp(s, "!macro", bIgnoreCase ) == 0 || NsisCmp(s, "!macroend", bIgnoreCase) == 0 ) // Covers !micro and !microend
|
||||
return SCE_NSIS_MACRODEF;
|
||||
|
||||
if( strcmp(s, "!ifdef") == 0 || strcmp(s, "!ifndef") == 0 || strcmp(s, "!endif") == 0 )
|
||||
if( NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!endif", bIgnoreCase) == 0 )
|
||||
return SCE_NSIS_IFDEFINEDEF;
|
||||
|
||||
if( strcmp(s, "Section") == 0 || strcmp(s, "SectionEnd") == 0 ) // Covers Section and SectionEnd
|
||||
if( NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase) == 0 ) // Covers Section and SectionEnd
|
||||
return SCE_NSIS_SECTIONDEF;
|
||||
|
||||
if( strcmp(s, "SubSection") == 0 || strcmp(s, "SubSectionEnd") == 0 ) // Covers SubSection and SubSectionEnd
|
||||
if( NsisCmp(s, "SubSection", bIgnoreCase) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase) == 0 ) // Covers SubSection and SubSectionEnd
|
||||
return SCE_NSIS_SUBSECTIONDEF;
|
||||
|
||||
if( strcmp(s, "Function") == 0 || strcmp(s, "FunctionEnd") == 0 ) // Covers SubSection and SubSectionEnd
|
||||
if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 ) // Covers SubSection and SubSectionEnd
|
||||
return SCE_NSIS_FUNCTION;
|
||||
|
||||
if ( Functions.InList(s) )
|
||||
@@ -83,12 +159,49 @@ static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keyw
|
||||
if( UserDefined.InList(s) )
|
||||
return SCE_NSIS_USERDEFINED;
|
||||
|
||||
if( strlen(s) > 2 )
|
||||
if( strlen(s) > 3 )
|
||||
{
|
||||
if( s[1] == '{' && s[strlen(s)-1] == '}' )
|
||||
return SCE_NSIS_VARIABLE;
|
||||
}
|
||||
|
||||
// See if the variable is a user defined variable
|
||||
if( s[0] == '$' && bUserVars )
|
||||
{
|
||||
bool bHasSimpleNsisChars = true;
|
||||
for (unsigned int j = 1; j < end - start + 1 && j < 99; j++)
|
||||
{
|
||||
if( !isNsisChar( s[j] ) )
|
||||
{
|
||||
bHasSimpleNsisChars = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( bHasSimpleNsisChars )
|
||||
return SCE_NSIS_VARIABLE;
|
||||
}
|
||||
|
||||
// To check for numbers
|
||||
if( isNsisNumber( s[0] ) )
|
||||
{
|
||||
bool bHasSimpleNsisNumber = true;
|
||||
for (unsigned int j = 1; j < end - start + 1 && j < 99; j++)
|
||||
{
|
||||
if( s[j] == '\0' || s[j] == '\r' || s[j] == '\n' )
|
||||
break;
|
||||
|
||||
if( !isNsisNumber( s[j] ) )
|
||||
{
|
||||
bHasSimpleNsisNumber = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( bHasSimpleNsisNumber )
|
||||
return SCE_NSIS_NUMBER;
|
||||
}
|
||||
|
||||
return SCE_NSIS_DEFAULT;
|
||||
}
|
||||
|
||||
@@ -102,24 +215,18 @@ static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *k
|
||||
styler.StartSegment( startPos );
|
||||
|
||||
char cCurrChar;
|
||||
bool bVarInString = true;
|
||||
bool bVarInString = false;
|
||||
bool bClassicVarInString = false;
|
||||
|
||||
unsigned int i;
|
||||
for( i = startPos; i < nLengthDoc; i++ )
|
||||
{
|
||||
cCurrChar = styler.SafeGetCharAt( i );
|
||||
char cNextChar = styler.SafeGetCharAt( i+1, EOF );
|
||||
|
||||
|
||||
char cNextChar = styler.SafeGetCharAt(i+1);
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case SCE_NSIS_DEFAULT:
|
||||
if( cNextChar == EOF )
|
||||
{
|
||||
styler.ColourTo(i,SCE_NSIS_DEFAULT);
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == ';' || cCurrChar == '#' ) // we have a comment line
|
||||
{
|
||||
styler.ColourTo(i-1, state );
|
||||
@@ -131,6 +238,7 @@ static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *k
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_STRINGDQ;
|
||||
bVarInString = false;
|
||||
bClassicVarInString = false;
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == '\'' )
|
||||
@@ -138,6 +246,7 @@ static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *k
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_STRINGRQ;
|
||||
bVarInString = false;
|
||||
bClassicVarInString = false;
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == '`' )
|
||||
@@ -145,19 +254,25 @@ static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *k
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_STRINGLQ;
|
||||
bVarInString = false;
|
||||
bClassicVarInString = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// NSIS KeyWord,Function, Variable, UserDefined:
|
||||
if( cCurrChar == '$' || iswordchar(cCurrChar) || cCurrChar == '!' )
|
||||
if( cCurrChar == '$' || isNsisChar(cCurrChar) || cCurrChar == '!' )
|
||||
{
|
||||
styler.ColourTo(i-1,state);
|
||||
state = SCE_NSIS_FUNCTION;
|
||||
|
||||
// If it is a number, we must check and set style here first...
|
||||
if( isNsisNumber(cCurrChar) && (cNextChar == '\t' || cNextChar == ' ' || cNextChar == '\r' || cNextChar == '\n' ) )
|
||||
styler.ColourTo( i, SCE_NSIS_NUMBER);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SCE_NSIS_COMMENT:
|
||||
if( cNextChar == '\n' || cNextChar == '\r' || cNextChar == EOF )
|
||||
if( cNextChar == '\n' || cNextChar == '\r' )
|
||||
{
|
||||
styler.ColourTo(i,state);
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
@@ -187,35 +302,45 @@ static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *k
|
||||
case SCE_NSIS_FUNCTION:
|
||||
|
||||
// NSIS KeyWord:
|
||||
if( (iswordchar(cCurrChar) && !iswordchar( cNextChar) && cNextChar != '}') || cCurrChar == '}' )
|
||||
if( cCurrChar == '$' )
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
else if( cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) )
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
else if( (isNsisChar(cCurrChar) && !isNsisChar( cNextChar) && cNextChar != '}') || cCurrChar == '}' )
|
||||
{
|
||||
state = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler);
|
||||
styler.ColourTo( i, state);
|
||||
state = SCE_NSIS_DEFAULT; // Everything after goes back to the default state
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
}
|
||||
else if( !iswordchar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' )
|
||||
else if( !isNsisChar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' )
|
||||
{
|
||||
if( classifyWordNsis( styler.GetStartSegment(), i-1, keywordLists, styler) == SCE_NSIS_NUMBER )
|
||||
styler.ColourTo( i-1, SCE_NSIS_NUMBER );
|
||||
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
|
||||
if( cCurrChar == '"' ) // Next
|
||||
if( cCurrChar == '"' )
|
||||
{
|
||||
state = SCE_NSIS_STRINGDQ;
|
||||
bVarInString = false;
|
||||
bClassicVarInString = false;
|
||||
}
|
||||
if( cCurrChar == '`' )
|
||||
else if( cCurrChar == '`' )
|
||||
{
|
||||
state = SCE_NSIS_STRINGLQ;
|
||||
bVarInString = false;
|
||||
bClassicVarInString = false;
|
||||
}
|
||||
if( cCurrChar == '\'' )
|
||||
else if( cCurrChar == '\'' )
|
||||
{
|
||||
state = SCE_NSIS_STRINGRQ;
|
||||
bVarInString = false;
|
||||
bClassicVarInString = false;
|
||||
}
|
||||
if( cCurrChar == '#' || cCurrChar == ';' )
|
||||
else if( cCurrChar == '#' || cCurrChar == ';' )
|
||||
{
|
||||
state = SCE_NSIS_COMMENT;
|
||||
|
||||
styler.ColourTo( i, state);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -226,25 +351,70 @@ static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *k
|
||||
}
|
||||
else if( state == SCE_NSIS_STRINGDQ || state == SCE_NSIS_STRINGLQ || state == SCE_NSIS_STRINGRQ )
|
||||
{
|
||||
// Check for var in String..
|
||||
if( bVarInString && (iswordchar(cCurrChar) || cCurrChar == '}') ) // || cCurrChar == '{' ) )
|
||||
{
|
||||
int nWordState = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler);
|
||||
bool bIngoreNextDollarSign = false;
|
||||
bool bUserVars = false;
|
||||
if( styler.GetPropertyInt("nsis.uservars") == 1 )
|
||||
bUserVars = true;
|
||||
|
||||
if( bVarInString && cCurrChar == '$' )
|
||||
{
|
||||
bVarInString = false;
|
||||
bIngoreNextDollarSign = true;
|
||||
}
|
||||
else if( bVarInString && cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) )
|
||||
{
|
||||
bVarInString = false;
|
||||
bIngoreNextDollarSign = true;
|
||||
}
|
||||
|
||||
// Covers "$INSTDIR and user vars like $MYVAR"
|
||||
else if( bVarInString && !isNsisChar(cNextChar) )
|
||||
{
|
||||
int nWordState = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler);
|
||||
if( nWordState == SCE_NSIS_VARIABLE )
|
||||
{
|
||||
styler.ColourTo( i, SCE_NSIS_STRINGVAR);
|
||||
bVarInString = false;
|
||||
}
|
||||
}
|
||||
if( cCurrChar == '$' )
|
||||
else if( bUserVars )
|
||||
styler.ColourTo( i, SCE_NSIS_STRINGVAR);
|
||||
bVarInString = false;
|
||||
}
|
||||
// Covers "${TEST}..."
|
||||
else if( bClassicVarInString && cNextChar == '}' )
|
||||
{
|
||||
styler.ColourTo( i+1, SCE_NSIS_STRINGVAR);
|
||||
bClassicVarInString = false;
|
||||
}
|
||||
|
||||
// Start of var in string
|
||||
if( !bIngoreNextDollarSign && cCurrChar == '$' && cNextChar == '{' )
|
||||
{
|
||||
styler.ColourTo( i-1, state);
|
||||
bVarInString = true;
|
||||
bClassicVarInString = true;
|
||||
bVarInString = false;
|
||||
}
|
||||
else if( !bIngoreNextDollarSign && cCurrChar == '$' )
|
||||
{
|
||||
styler.ColourTo( i-1, state);
|
||||
bVarInString = true;
|
||||
bClassicVarInString = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Colourise remaining document
|
||||
switch( state )
|
||||
{
|
||||
case SCE_NSIS_COMMENT:
|
||||
case SCE_NSIS_STRINGDQ:
|
||||
case SCE_NSIS_STRINGLQ:
|
||||
case SCE_NSIS_STRINGRQ:
|
||||
case SCE_NSIS_VARIABLE:
|
||||
case SCE_NSIS_STRINGVAR:
|
||||
styler.ColourTo(nLengthDoc-1,state); break;
|
||||
|
||||
default:
|
||||
styler.ColourTo(nLengthDoc-1,SCE_NSIS_DEFAULT); break;
|
||||
}
|
||||
}
|
||||
|
||||
static void FoldNsisDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
|
||||
{
|
||||
@@ -252,87 +422,57 @@ static void FoldNsisDoc(unsigned int startPos, int length, int, WordList *[], Ac
|
||||
if( styler.GetPropertyInt("fold") == 0 )
|
||||
return;
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
unsigned int safeStartPos = styler.LineStart( lineCurrent );
|
||||
|
||||
bool bArg1 = true;
|
||||
int nWordStart = -1;
|
||||
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style;
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++)
|
||||
for (unsigned int i = safeStartPos; i < startPos + length; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
// Functions Start: Function, Section, SubSection
|
||||
// Functions End: FunctionEnd, SectionEnd, SubSectionEnd
|
||||
// Label Start: !ifdef, !ifndef
|
||||
// Label End: !endif
|
||||
char chCurr = styler.SafeGetCharAt(i);
|
||||
|
||||
if( style == SCE_NSIS_FUNCTION )
|
||||
{
|
||||
if( styler.Match(i, "FunctionEnd") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "Function") )
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_SECTIONDEF )
|
||||
{
|
||||
if( styler.Match(i, "SectionEnd") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "Section") )
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_SUBSECTIONDEF )
|
||||
{
|
||||
if( styler.Match(i, "SubSectionEnd") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "SubSection") )
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_IFDEFINEDEF )
|
||||
{
|
||||
if( styler.Match(i, "!endif") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "!ifdef") || styler.Match(i, "!ifndef"))
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_MACRODEF )
|
||||
{
|
||||
if( styler.Match(i, "!macroend") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "!macro") )
|
||||
levelNext++;
|
||||
}
|
||||
if( bArg1 ) //&& chCurr != '\n' )
|
||||
{
|
||||
if( nWordStart == -1 && (isNsisLetter(chCurr) || chCurr == '!') )
|
||||
nWordStart = i;
|
||||
else if( !isNsisLetter(chCurr) && nWordStart > -1 )
|
||||
{
|
||||
int newLevel = calculateFoldNsis( nWordStart, i-1, levelNext, styler );
|
||||
if( newLevel != levelNext )
|
||||
levelNext = newLevel;
|
||||
bArg1 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( atEOL )
|
||||
{
|
||||
int levelUse = levelCurrent;
|
||||
if( chCurr == '\n' )
|
||||
{
|
||||
// If we are on a new line...
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent))
|
||||
{
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
}
|
||||
}
|
||||
bArg1 = true; // New line, lets look at first argument again
|
||||
nWordStart = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent))
|
||||
{
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
}
|
||||
|
||||
static const char * const nsisWordLists[] = {
|
||||
|
@@ -166,20 +166,39 @@ static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
|
||||
// comment lines before the first "diff " or "--- ". If a real
|
||||
// difference starts then each line starting with ' ' is a whitespace
|
||||
// otherwise it is considered a comment (Only in..., Binary file...)
|
||||
if (0 == strncmp(lineBuffer, "diff ", 3)) {
|
||||
if (0 == strncmp(lineBuffer, "diff ", 5)) {
|
||||
styler.ColourTo(endLine, SCE_DIFF_COMMAND);
|
||||
} else if (0 == strncmp(lineBuffer, "--- ", 3)) {
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "+++ ", 3)) {
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "--- ", 4)) {
|
||||
// In a context diff, --- appears in both the header and the position markers
|
||||
if (atoi(lineBuffer+4) && !strchr(lineBuffer, '/'))
|
||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||
else
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "+++ ", 4)) {
|
||||
// I don't know of any diff where "+++ " is a position marker, but for
|
||||
// consistency, do the same as with "--- " and "*** ".
|
||||
if (atoi(lineBuffer+4) && !strchr(lineBuffer, '/'))
|
||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||
else
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "====", 4)) { // For p4's diff
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "***", 3)) {
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "***", 3)) {
|
||||
// In a context diff, *** appears in both the header and the position markers.
|
||||
// Also ******** is a chunk header, but here it's treated as part of the
|
||||
// position marker since there is no separate style for a chunk header.
|
||||
if (lineBuffer[3] == ' ' && atoi(lineBuffer+4) && !strchr(lineBuffer, '/'))
|
||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||
else if (lineBuffer[3] == '*')
|
||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||
else
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (0 == strncmp(lineBuffer, "? ", 2)) { // For difflib
|
||||
styler.ColourTo(endLine, SCE_DIFF_HEADER);
|
||||
} else if (lineBuffer[0] == '@') {
|
||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||
} else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') {
|
||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||
} else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') {
|
||||
styler.ColourTo(endLine, SCE_DIFF_DELETED);
|
||||
} else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
|
||||
@@ -210,6 +229,37 @@ static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[
|
||||
}
|
||||
}
|
||||
|
||||
static void FoldDiffDoc(unsigned int startPos, int length, int, WordList*[], Accessor &styler) {
|
||||
int curLine = styler.GetLine(startPos);
|
||||
int prevLevel = SC_FOLDLEVELBASE;
|
||||
if (curLine > 0)
|
||||
prevLevel = styler.LevelAt(curLine-1);
|
||||
|
||||
int curLineStart = styler.LineStart(curLine);
|
||||
do {
|
||||
int nextLevel = prevLevel;
|
||||
if (prevLevel & SC_FOLDLEVELHEADERFLAG)
|
||||
nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1;
|
||||
|
||||
int lineType = styler.StyleAt(curLineStart);
|
||||
if (lineType == SCE_DIFF_COMMAND)
|
||||
nextLevel = (SC_FOLDLEVELBASE + 1) | SC_FOLDLEVELHEADERFLAG;
|
||||
else if (lineType == SCE_DIFF_HEADER) {
|
||||
nextLevel = (SC_FOLDLEVELBASE + 2) | SC_FOLDLEVELHEADERFLAG;
|
||||
} else if (lineType == SCE_DIFF_POSITION)
|
||||
nextLevel = (SC_FOLDLEVELBASE + 3) | SC_FOLDLEVELHEADERFLAG;
|
||||
|
||||
if ((nextLevel & SC_FOLDLEVELHEADERFLAG) && (nextLevel == prevLevel))
|
||||
styler.SetLevel(curLine-1, prevLevel & ~SC_FOLDLEVELHEADERFLAG);
|
||||
|
||||
styler.SetLevel(curLine, nextLevel);
|
||||
prevLevel = nextLevel;
|
||||
|
||||
curLineStart = styler.LineStart(++curLine);
|
||||
} while (static_cast<int>(startPos) + length > curLineStart);
|
||||
}
|
||||
|
||||
|
||||
static void ColourisePropsLine(
|
||||
char *lineBuffer,
|
||||
unsigned int lengthLine,
|
||||
@@ -427,14 +477,14 @@ static void ColouriseErrorListLine(
|
||||
styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION);
|
||||
} else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') {
|
||||
styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE);
|
||||
} else if (lineBuffer[0] == '-') {
|
||||
styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION);
|
||||
} else if (strstart(lineBuffer, "cf90-")) {
|
||||
// Absoft Pro Fortran 90/95 v8.2 error and/or warning message
|
||||
styler.ColourTo(endPos, SCE_ERR_ABSF);
|
||||
} else if (strstart(lineBuffer, "fortcom:")) {
|
||||
// Intel Fortran Compiler v8.0 error/warning message
|
||||
styler.ColourTo(endPos, SCE_ERR_IFORT);
|
||||
} else if (lineBuffer[0] == '-') {
|
||||
styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION);
|
||||
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
|
||||
styler.ColourTo(endPos, SCE_ERR_PYTHON);
|
||||
} else if (strstr(lineBuffer, " in ") && strstr(lineBuffer, " on line ")) {
|
||||
@@ -456,7 +506,7 @@ static void ColouriseErrorListLine(
|
||||
(strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
|
||||
strstr(lineBuffer, "file ") &&
|
||||
(strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
|
||||
// Lua error message
|
||||
// Lua 4 error message
|
||||
styler.ColourTo(endPos, SCE_ERR_LUA);
|
||||
} else if (strstr(lineBuffer, " at " ) &&
|
||||
(strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
|
||||
@@ -478,6 +528,8 @@ static void ColouriseErrorListLine(
|
||||
// Look for Microsoft <filename>(line) :message
|
||||
// Look for Microsoft <filename>(line,pos)message
|
||||
// Look for CTags \tmessage
|
||||
// Look for Lua 5 traceback \t<filename>:<line>:message
|
||||
bool initialTab = (lineBuffer[0] == '\t');
|
||||
int state = 0;
|
||||
for (unsigned int i = 0; i < lengthLine; i++) {
|
||||
char ch = lineBuffer[i];
|
||||
@@ -486,17 +538,17 @@ static void ColouriseErrorListLine(
|
||||
chNext = lineBuffer[i+1];
|
||||
if (state == 0) {
|
||||
if (ch == ':') {
|
||||
// May be GCC
|
||||
// May be GCC, or might be Lua 5 (Lua traceback same but with tab prefix)
|
||||
if ((chNext != '\\') && (chNext != '/')) {
|
||||
// This check is not completely accurate as may be on
|
||||
// GTK+ with a file name that includes ':'.
|
||||
state = 1;
|
||||
}
|
||||
} else if ((ch == '(') && Is1To9(chNext)) {
|
||||
} else if ((ch == '(') && Is1To9(chNext) && (!initialTab)) {
|
||||
// May be Microsoft
|
||||
// Check againt '0' often removes phone numbers
|
||||
// Check against '0' often removes phone numbers
|
||||
state = 10;
|
||||
} else if (ch == '\t') {
|
||||
} else if ((ch == '\t') && (!initialTab)) {
|
||||
// May be CTags
|
||||
state = 20;
|
||||
}
|
||||
@@ -520,10 +572,11 @@ static void ColouriseErrorListLine(
|
||||
state = unRecognized;
|
||||
}
|
||||
} else if (state == 12) {
|
||||
if ((ch == ' ') && (chNext == ':'))
|
||||
if ((ch == ' ') && (chNext == ':')) {
|
||||
state = 13;
|
||||
else
|
||||
} else {
|
||||
state = unRecognized;
|
||||
}
|
||||
} else if (state == 14) {
|
||||
if (ch == ')') {
|
||||
state = 15;
|
||||
@@ -548,7 +601,7 @@ static void ColouriseErrorListLine(
|
||||
styler.ColourTo(endPos, SCE_ERR_GCC);
|
||||
} else if ((state == 13) || (state == 14) || (state == 15)) {
|
||||
styler.ColourTo(endPos, SCE_ERR_MS);
|
||||
} else if (((state == 22) || (state == 24)) && (lineBuffer[0] != '\t')) {
|
||||
} else if ((state == 22) || (state == 24)) {
|
||||
styler.ColourTo(endPos, SCE_ERR_CTAG);
|
||||
} else {
|
||||
styler.ColourTo(endPos, SCE_ERR_DEFAULT);
|
||||
@@ -696,7 +749,7 @@ static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[
|
||||
}
|
||||
|
||||
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
|
||||
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", 0, emptyWordListDesc);
|
||||
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc);
|
||||
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);
|
||||
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
|
||||
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);
|
||||
|
@@ -1,26 +1,12 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexPB.cxx
|
||||
** Lexer for PowerBasic by Roland Walter, roland@rowalt.de
|
||||
** Last update: 17.10.2003 (toggling of subs/functions now until next sub/functin - this gives better results)
|
||||
**/
|
||||
// @file LexPB.cxx
|
||||
// Lexer for PowerBasic by Roland Walter, roland@rowalt.de (for PowerBasic see www.powerbasic.com)
|
||||
//
|
||||
// Necessary changes in Scintilla project:
|
||||
// - In SciLexer.h and Scintilla.iface:
|
||||
//
|
||||
// #define SCLEX_PB 51 //ID for PowerBasic lexer
|
||||
// (...)
|
||||
// #define SCE_B_DEFAULT 0 //in both VB and PB lexer
|
||||
// #define SCE_B_COMMENT 1 //in both VB and PB lexer
|
||||
// #define SCE_B_NUMBER 2 //in both VB and PB lexer
|
||||
// #define SCE_B_KEYWORD 3 //in both VB and PB lexer
|
||||
// #define SCE_B_STRING 4 //in both VB and PB lexer
|
||||
// #define SCE_B_PREPROCESSOR 5 //VB lexer only, unsupported by PB lexer
|
||||
// #define SCE_B_OPERATOR 6 //in both VB and PB lexer
|
||||
// #define SCE_B_IDENTIFIER 7 //in both VB and PB lexer
|
||||
// #define SCE_B_DATE 8 //VB lexer only, unsupported by PB lexer
|
||||
|
||||
// - Statement added to KeyWords.cxx: 'LINK_LEXER(lmPB);'
|
||||
// - Statement added to scintilla_vc6.mak: '$(DIR_O)\LexPB.obj: ...\src\LexPB.cxx $(LEX_HEADERS)'
|
||||
// Changes:
|
||||
// 17.10.2003 Toggling of subs/functions now until next sub/function - this gives better results
|
||||
// 29.10.2003 1. Bug: Toggling didn't work for subs/functions added in editor
|
||||
// 2. Own colors for PB constants and Inline Assembler SCE_B_CONSTANT and SCE_B_ASM
|
||||
// 3. Several smaller syntax coloring improvements and speed optimizations
|
||||
//
|
||||
// Copyright for Scintilla: 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
@@ -40,189 +26,239 @@
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool IsTypeCharacter(const int ch) {
|
||||
return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$';
|
||||
static inline bool IsTypeCharacter(const int ch)
|
||||
{
|
||||
return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$' || ch == '?';
|
||||
}
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
static inline bool IsAWordChar(const int ch)
|
||||
{
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
static inline bool IsAWordStart(const int ch)
|
||||
{
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
bool MatchUpperCase(Accessor &styler, int pos, const char *s) //Same as styler.Match() but uppercase comparison (a-z,A-Z and space only)
|
||||
{
|
||||
char ch;
|
||||
for (int i=0; *s; i++)
|
||||
{
|
||||
ch=styler.SafeGetCharAt(pos+i);
|
||||
if (ch > 0x60) ch -= '\x20';
|
||||
if (*s != ch) return false;
|
||||
s++;
|
||||
}
|
||||
return true;
|
||||
char ch;
|
||||
for (int i=0; *s; i++)
|
||||
{
|
||||
ch=styler.SafeGetCharAt(pos+i);
|
||||
if (ch > 0x60) ch -= '\x20';
|
||||
if (*s != ch) return false;
|
||||
s++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ColourisePBDoc(unsigned int startPos, int length, int initStyle,WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
static void ColourisePBDoc(unsigned int startPos, int length, int initStyle,WordList *keywordlists[],Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
styler.StartAt(startPos);
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
switch (sc.state)
|
||||
{
|
||||
case SCE_B_OPERATOR:
|
||||
{
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
break;
|
||||
}
|
||||
case SCE_B_KEYWORD:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch))
|
||||
{
|
||||
if (!IsTypeCharacter(sc.ch))
|
||||
{
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywords.InList(s))
|
||||
{
|
||||
if (strcmp(s, "rem") == 0)
|
||||
{
|
||||
sc.ChangeState(SCE_B_COMMENT);
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
|
||||
}
|
||||
else if (strcmp(s, "asm") == 0)
|
||||
{
|
||||
sc.ChangeState(SCE_B_ASM);
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ChangeState(SCE_B_IDENTIFIER);
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCE_B_NUMBER:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_B_STRING:
|
||||
{
|
||||
if (sc.ch == '\"'){sc.ForwardSetState(SCE_B_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_B_CONSTANT:
|
||||
{
|
||||
if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_B_COMMENT:
|
||||
{
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
case SCE_B_ASM:
|
||||
{
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
|
||||
break;
|
||||
}
|
||||
} //switch (sc.state)
|
||||
|
||||
if (sc.state == SCE_B_OPERATOR)
|
||||
{
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
else if (sc.state == SCE_B_KEYWORD)
|
||||
{
|
||||
if (!IsAWordChar(sc.ch))
|
||||
{
|
||||
if (!IsTypeCharacter(sc.ch))
|
||||
{
|
||||
if (sc.ch == ']') {sc.Forward();}
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywords.InList(s))
|
||||
{
|
||||
if (strcmp(s, "rem") == 0)
|
||||
{
|
||||
sc.ChangeState(SCE_B_COMMENT);
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ChangeState(SCE_B_IDENTIFIER);
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sc.state == SCE_B_NUMBER)
|
||||
{
|
||||
if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);}
|
||||
}
|
||||
else if (sc.state == SCE_B_STRING)
|
||||
{
|
||||
// PB doubles quotes to preserve them, so just end this string
|
||||
// state now as a following quote will start again
|
||||
if (sc.ch == '\"')
|
||||
{
|
||||
if (tolower(sc.chNext) == 'c') {sc.Forward();}
|
||||
sc.ForwardSetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
else if (sc.state == SCE_B_COMMENT)
|
||||
{
|
||||
if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_B_DEFAULT)
|
||||
{
|
||||
if (sc.ch == '\'') {sc.SetState(SCE_B_COMMENT);}
|
||||
else if (sc.ch == '\"') {sc.SetState(SCE_B_STRING);}
|
||||
else if (sc.ch == '#')
|
||||
{ int n = 1;
|
||||
int chSeek = ' ';
|
||||
while ((n < 100) && (chSeek == ' ' || chSeek == '\t'))
|
||||
{
|
||||
chSeek = sc.GetRelative(n);
|
||||
n++;
|
||||
}
|
||||
sc.SetState(SCE_B_OPERATOR);
|
||||
}
|
||||
else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (sc.ch == '&' && tolower(sc.chNext) == 'b') {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (IsAWordStart(sc.ch) || (sc.ch == '[')) {sc.SetState(SCE_B_KEYWORD);}
|
||||
else if (isoperator(static_cast<char>(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_B_OPERATOR);}
|
||||
}
|
||||
|
||||
}
|
||||
sc.Complete();
|
||||
// Determine if a new state should be entered:
|
||||
if (sc.state == SCE_B_DEFAULT)
|
||||
{
|
||||
if (sc.ch == '\'') {sc.SetState(SCE_B_COMMENT);}
|
||||
else if (sc.ch == '\"') {sc.SetState(SCE_B_STRING);}
|
||||
else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (sc.ch == '&' && tolower(sc.chNext) == 'b') {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_B_NUMBER);}
|
||||
else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_B_KEYWORD);}
|
||||
else if (sc.ch == '%') {sc.SetState(SCE_B_CONSTANT);}
|
||||
else if (sc.ch == '$') {sc.SetState(SCE_B_CONSTANT);}
|
||||
else if (sc.ch == '#') {sc.SetState(SCE_B_KEYWORD);}
|
||||
else if (sc.ch == '!') {sc.SetState(SCE_B_ASM);}
|
||||
else if (isoperator(static_cast<char>(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_B_OPERATOR);}
|
||||
}
|
||||
} //for (; sc.More(); sc.Forward())
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
//The folding routine for PowerBasic toggles SUBs and FUNCTIONs only. This was exactly what I wanted,
|
||||
//nothing more. I had worked with this kind of toggling for several years when I used the great good old
|
||||
//GFA Basic which is dead now. After testing the feature of toggling FOR-NEXT loops, WHILE-WEND loops
|
||||
//and so on too I found this is more disturbing then helping (for me). So if You think in another way
|
||||
//you can (or must) write Your own toggling routine ;-)
|
||||
static void FoldPBDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
|
||||
{
|
||||
// No folding enabled, no reason to continue...
|
||||
if( styler.GetPropertyInt("fold") == 0 )
|
||||
return;
|
||||
// No folding enabled, no reason to continue...
|
||||
if( styler.GetPropertyInt("fold") == 0 )
|
||||
return;
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
unsigned int endPos = startPos + length;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
|
||||
bool atEOL=1;
|
||||
for (unsigned int i = startPos; i < endPos; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
bool fNewLine=true;
|
||||
for (unsigned int i = startPos; i < endPos; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if( atEOL ) //Begin of a new line (The Sub/Function/Macro keywords may occur at begin of line only)
|
||||
{
|
||||
if( MatchUpperCase(styler,i,"FUNCTION") ) //else if(
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"CALLBACK FUNCTION") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"STATIC FUNCTION") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"SUB") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"STATIC SUB") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
//else if( MatchUpperCase(styler,i,"MACRO") ) //ToDo: What's with single-line macros?
|
||||
}
|
||||
if (fNewLine) //Begin of a new line (The Sub/Function/Macro keywords may occur at begin of line only)
|
||||
{
|
||||
fNewLine=false;
|
||||
|
||||
atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if( atEOL )
|
||||
{
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
}
|
||||
}
|
||||
switch (ch)
|
||||
{
|
||||
case ' ': //Most lines start with space - so check this first
|
||||
{
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
break;
|
||||
}
|
||||
case 'F':
|
||||
case 'S':
|
||||
case 'C':
|
||||
case 'f':
|
||||
case 's':
|
||||
case 'c':
|
||||
{
|
||||
if( MatchUpperCase(styler,i,"FUNCTION") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"SUB") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"CALLBACK FUNCTION") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"STATIC FUNCTION") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
else if( MatchUpperCase(styler,i,"STATIC SUB") )
|
||||
{
|
||||
styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG);
|
||||
levelNext=SC_FOLDLEVELBASE+1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
break;
|
||||
}
|
||||
} //switch (ch)
|
||||
} //if( fNewLine )
|
||||
|
||||
if (levelNext == SC_FOLDLEVELBASE)
|
||||
{
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
switch (ch)
|
||||
{
|
||||
case '\n':
|
||||
{
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
fNewLine=true;
|
||||
break;
|
||||
}
|
||||
case '\r':
|
||||
{
|
||||
if (chNext != '\n')
|
||||
{
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
fNewLine=true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} //switch (ch)
|
||||
} //for (unsigned int i = startPos; i < endPos; i++)
|
||||
}
|
||||
|
||||
static const char * const pbWordListDesc[] = {
|
||||
"Keywords",
|
||||
0
|
||||
"Keywords",
|
||||
0
|
||||
};
|
||||
|
||||
LexerModule lmPB(SCLEX_POWERBASIC, ColourisePBDoc, "powerbasic", FoldPBDoc, pbWordListDesc);
|
||||
|
@@ -2,8 +2,8 @@
|
||||
/** @file LexPerl.cxx
|
||||
** Lexer for subset of Perl.
|
||||
**/
|
||||
// Lexical analysis fixes by Kein-Hong Man <mkh@pl.jaring.my> 20031020
|
||||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Lexical analysis fixes by Kein-Hong Man <mkh@pl.jaring.my> 2003-2004
|
||||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -40,13 +40,15 @@ static bool isSingleCharOp(char ch) {
|
||||
}
|
||||
|
||||
static inline bool isPerlOperator(char ch) {
|
||||
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' ||
|
||||
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 == '.' || ch == '~')
|
||||
return true;
|
||||
// these chars are already tested before this call
|
||||
// ch == '%' || ch == '*' || ch == '<' || ch == '/' ||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,6 +70,7 @@ static inline bool isEndVar(char ch) {
|
||||
ch != '_' && ch != '\'';
|
||||
}
|
||||
|
||||
|
||||
static inline bool isNonQuote(char ch) {
|
||||
return isalnum(ch) || ch == '_';
|
||||
}
|
||||
@@ -192,6 +195,7 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
|| state == SCE_PL_BACKTICKS
|
||||
|| state == SCE_PL_CHARACTER
|
||||
|| state == SCE_PL_NUMBER
|
||||
|| state == SCE_PL_IDENTIFIER
|
||||
) {
|
||||
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
|
||||
startPos--;
|
||||
@@ -275,7 +279,15 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
numState = PERLNUM_V_VECTOR;
|
||||
}
|
||||
} else if (iswordstart(ch)) {
|
||||
if (ch == 's' && !isNonQuote(chNext)) {
|
||||
if (chPrev == '>' && styler.SafeGetCharAt(i - 2) == '-') {
|
||||
state = SCE_PL_IDENTIFIER; // part of "->" expr
|
||||
if ((!iswordchar(chNext) && chNext != '\'')
|
||||
|| (chNext == '.' && chNext2 == '.')) {
|
||||
// We need that if length of word == 1!
|
||||
styler.ColourTo(i, SCE_PL_IDENTIFIER);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (ch == 's' && !isNonQuote(chNext)) {
|
||||
state = SCE_PL_REGSUBST;
|
||||
Quote.New(2);
|
||||
} else if (ch == 'm' && !isNonQuote(chNext)) {
|
||||
@@ -391,13 +403,15 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
bk--;
|
||||
}
|
||||
if (bk == 0) {
|
||||
// position 0 won't really be checked; rarely happens
|
||||
// hard to fix due to an unsigned index i
|
||||
preferRE = true;
|
||||
} else {
|
||||
int bkstyle = styler.StyleAt(bk);
|
||||
bkch = styler.SafeGetCharAt(bk);
|
||||
switch(bkstyle) {
|
||||
case SCE_PL_OPERATOR:
|
||||
preferRE = true;
|
||||
bkch = styler.SafeGetCharAt(bk);
|
||||
if (bkch == ')' || bkch == ']') {
|
||||
preferRE = false;
|
||||
} else if (bkch == '}') {
|
||||
@@ -408,7 +422,9 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
bkstyle = styler.StyleAt(bk);
|
||||
if (bkstyle == SCE_PL_OPERATOR) {
|
||||
bkch = styler.SafeGetCharAt(bk);
|
||||
if (bkch == '}') {
|
||||
if (bkch == ';') { // early out
|
||||
break;
|
||||
} else if (bkch == '}') {
|
||||
braceCount++;
|
||||
} else if (bkch == '{') {
|
||||
if (--braceCount == 0)
|
||||
@@ -419,21 +435,68 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
if (bk == 0) {
|
||||
// at beginning, true
|
||||
} else if (braceCount == 0) {
|
||||
// balanced { found, check for variable
|
||||
bkstyle = styler.StyleAt(bk - 1);
|
||||
// balanced { found, bk>0, skip more whitespace
|
||||
if (styler.StyleAt(--bk) == SCE_PL_DEFAULT) {
|
||||
while (bk > 0) {
|
||||
bkstyle = styler.StyleAt(--bk);
|
||||
if (bkstyle != SCE_PL_DEFAULT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
bkstyle = styler.StyleAt(bk);
|
||||
if (bkstyle == SCE_PL_SCALAR
|
||||
|| bkstyle == SCE_PL_ARRAY
|
||||
|| bkstyle == SCE_PL_HASH
|
||||
|| bkstyle == SCE_PL_SYMBOLTABLE) {
|
||||
|| bkstyle == SCE_PL_SYMBOLTABLE
|
||||
|| bkstyle == SCE_PL_OPERATOR) {
|
||||
preferRE = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// other styles uses the default, preferRE=false
|
||||
case SCE_PL_IDENTIFIER:
|
||||
case SCE_PL_POD:
|
||||
preferRE = true;
|
||||
if (bkch == '>') { // inputsymbol
|
||||
preferRE = false;
|
||||
break;
|
||||
}
|
||||
// backtrack to find "->" or "::" before identifier
|
||||
while (bk > 0 && styler.StyleAt(bk) == SCE_PL_IDENTIFIER) {
|
||||
bk--;
|
||||
}
|
||||
while (bk > 0) {
|
||||
bkstyle = styler.StyleAt(bk);
|
||||
if (bkstyle == SCE_PL_DEFAULT ||
|
||||
bkstyle == SCE_PL_COMMENTLINE) {
|
||||
} else if (bkstyle == SCE_PL_OPERATOR) {
|
||||
// gcc 3.2.3 bloats if more compact form used
|
||||
bkch = styler.SafeGetCharAt(bk);
|
||||
if (bkch == '>') { // "->"
|
||||
if (styler.SafeGetCharAt(bk - 1) == '-') {
|
||||
preferRE = false;
|
||||
break;
|
||||
}
|
||||
} else if (bkch == ':') { // "::"
|
||||
if (styler.SafeGetCharAt(bk - 1) == ':') {
|
||||
preferRE = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {// bare identifier, usually a function call but Perl
|
||||
// optimizes them as pseudo-constants, then the next
|
||||
// '/' will be a divide; favour divide over regex
|
||||
// if there is a whitespace after the '/'
|
||||
if (isspacechar(chNext)) {
|
||||
preferRE = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
bk--;
|
||||
}
|
||||
break;
|
||||
// other styles uses the default, preferRE=false
|
||||
case SCE_PL_WORD:
|
||||
case SCE_PL_POD:
|
||||
case SCE_PL_HERE_Q:
|
||||
case SCE_PL_HERE_QQ:
|
||||
case SCE_PL_HERE_QX:
|
||||
@@ -451,6 +514,27 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
} else if (ch == '<' && chNext == '<') {
|
||||
state = SCE_PL_HERE_DELIM;
|
||||
HereDoc.State = 0;
|
||||
} else if (ch == '<') {
|
||||
// looks forward for matching > on same line
|
||||
unsigned int fw = i + 1;
|
||||
while (fw < lengthDoc) {
|
||||
char fwch = styler.SafeGetCharAt(fw);
|
||||
if (isEOLChar(fwch) || isspacechar(fwch))
|
||||
break;
|
||||
else if (fwch == '>') {
|
||||
if ((fw - i) == 2 && // '<=>' case
|
||||
styler.SafeGetCharAt(fw-1) == '=') {
|
||||
styler.ColourTo(fw, SCE_PL_OPERATOR);
|
||||
} else {
|
||||
styler.ColourTo(fw, SCE_PL_IDENTIFIER);
|
||||
}
|
||||
i = fw;
|
||||
ch = fwch;
|
||||
chNext = styler.SafeGetCharAt(i+1);
|
||||
}
|
||||
fw++;
|
||||
}
|
||||
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||
} else if (ch == '=' // POD
|
||||
&& isalpha(chNext)
|
||||
&& (isEOLChar(chPrev))) {
|
||||
@@ -542,8 +626,9 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
}
|
||||
} else if (state == SCE_PL_WORD) {
|
||||
if ((!iswordchar(chNext) && chNext != '\'')
|
||||
|| (chNext == '.' && chNext2 == '.')) {
|
||||
|| chNext == '.') {
|
||||
// ".." is always an operator if preceded by a SCE_PL_WORD.
|
||||
// "." never used in Perl variable names
|
||||
// Archaic Perl has quotes inside names
|
||||
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")
|
||||
|| isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) {
|
||||
@@ -555,6 +640,13 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
ch = ' ';
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_PL_IDENTIFIER) {
|
||||
if ((!iswordchar(chNext) && chNext != '\'')
|
||||
|| chNext == '.') {
|
||||
styler.ColourTo(i, SCE_PL_IDENTIFIER);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_PL_COMMENTLINE) {
|
||||
if (isEOLChar(ch)) {
|
||||
@@ -886,3 +978,4 @@ static const char * const perlWordListDesc[] = {
|
||||
};
|
||||
|
||||
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl", FoldPerlDoc, perlWordListDesc);
|
||||
|
||||
|
@@ -265,8 +265,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
} else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
|
||||
unsigned int nextIndex = 0;
|
||||
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
|
||||
while (nextIndex > (sc.currentPos + 1)) {
|
||||
sc.Forward();
|
||||
while (nextIndex > (sc.currentPos + 1) && sc.More()) { sc.Forward();
|
||||
}
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_P_IDENTIFIER);
|
||||
|
@@ -44,6 +44,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold") != 0;
|
||||
bool sqlBackslashEscapes = styler.GetPropertyInt("sql.backslash.escapes", 0) != 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int spaceFlags = 0;
|
||||
|
||||
@@ -88,6 +89,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '#') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENTLINEDOC;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_CHARACTER;
|
||||
@@ -106,6 +110,8 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '#') {
|
||||
state = SCE_C_COMMENTLINEDOC;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_C_CHARACTER;
|
||||
} else if (ch == '"') {
|
||||
@@ -123,14 +129,18 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTLINE) {
|
||||
} else if (state == SCE_C_COMMENTLINE || state == SCE_C_COMMENTLINEDOC) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_C_CHARACTER) {
|
||||
if (ch == '\'') {
|
||||
if ( chNext == '\'' ) {
|
||||
if (sqlBackslashEscapes && ch == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else if (ch == '\'') {
|
||||
if (chNext == '\'') {
|
||||
i++;
|
||||
} else {
|
||||
styler.ColourTo(i, state);
|
||||
@@ -158,6 +168,8 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '#') {
|
||||
state = SCE_C_COMMENTLINEDOC;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_C_CHARACTER;
|
||||
} else if (ch == '"') {
|
||||
|
286
contrib/src/stc/scintilla/src/LexSpecman.cxx
Normal file
286
contrib/src/stc/scintilla/src/LexSpecman.cxx
Normal file
@@ -0,0 +1,286 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexSpecman.cxx
|
||||
** Lexer for Specman E language.
|
||||
** Written by Avi Yegudin, based on C++ lexer by Neil Hodgson
|
||||
**/
|
||||
// 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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');
|
||||
}
|
||||
|
||||
static inline bool IsANumberChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '\'');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '`');
|
||||
}
|
||||
|
||||
static void ColouriseSpecmanDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler, bool caseSensitive) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
|
||||
// Do not leak onto next line
|
||||
if (initStyle == SCE_SN_STRINGEOL)
|
||||
initStyle = SCE_SN_CODE;
|
||||
|
||||
int visibleChars = 0;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.atLineStart && (sc.state == SCE_SN_STRING)) {
|
||||
// Prevent SCE_SN_STRINGEOL from leaking back to previous line
|
||||
sc.SetState(SCE_SN_STRING);
|
||||
}
|
||||
|
||||
// Handle line continuation generically.
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\n' || sc.chNext == '\r') {
|
||||
sc.Forward();
|
||||
if (sc.ch == '\r' && sc.chNext == '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_SN_OPERATOR) {
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
} else if (sc.state == SCE_SN_NUMBER) {
|
||||
if (!IsANumberChar(sc.ch)) {
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
}
|
||||
} else if (sc.state == SCE_SN_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
|
||||
char s[100];
|
||||
if (caseSensitive) {
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
} else {
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
}
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_SN_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_SN_WORD2);
|
||||
} else if (keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_SN_WORD3);
|
||||
} else if (keywords4.InList(s)) {
|
||||
sc.ChangeState(SCE_SN_USER);
|
||||
}
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
}
|
||||
} else if (sc.state == SCE_SN_PREPROCESSOR) {
|
||||
if (IsASpace(sc.ch)) {
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
}
|
||||
} else if (sc.state == SCE_SN_DEFAULT) {
|
||||
if (sc.Match('<', '\'')) {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_SN_CODE);
|
||||
}
|
||||
} else if (sc.state == SCE_SN_COMMENTLINE || sc.state == SCE_SN_COMMENTLINEBANG) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
visibleChars = 0;
|
||||
}
|
||||
} else if (sc.state == SCE_SN_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_SN_CODE);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_SN_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_SN_CODE);
|
||||
visibleChars = 0;
|
||||
}
|
||||
} else if (sc.state == SCE_SN_SIGNAL) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_SN_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_SN_CODE);
|
||||
visibleChars = 0;
|
||||
} else if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_SN_CODE);
|
||||
}
|
||||
} else if (sc.state == SCE_SN_REGEXTAG) {
|
||||
if (!IsADigit(sc.ch)) {
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_SN_CODE) {
|
||||
if (sc.ch == '$' && IsADigit(sc.chNext)) {
|
||||
sc.SetState(SCE_SN_REGEXTAG);
|
||||
sc.Forward();
|
||||
} else if (IsADigit(sc.ch)) {
|
||||
sc.SetState(SCE_SN_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_SN_IDENTIFIER);
|
||||
} else if (sc.Match('\'', '>')) {
|
||||
sc.SetState(SCE_SN_DEFAULT);
|
||||
sc.Forward(); // Eat the * so it isn't used for the end of the comment
|
||||
} else if (sc.Match('/', '/')) {
|
||||
if (sc.Match("//!")) // Nice to have a different comment style
|
||||
sc.SetState(SCE_SN_COMMENTLINEBANG);
|
||||
else
|
||||
sc.SetState(SCE_SN_COMMENTLINE);
|
||||
} else if (sc.Match('-', '-')) {
|
||||
if (sc.Match("--!")) // Nice to have a different comment style
|
||||
sc.SetState(SCE_SN_COMMENTLINEBANG);
|
||||
else
|
||||
sc.SetState(SCE_SN_COMMENTLINE);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_SN_STRING);
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_SN_SIGNAL);
|
||||
} else if (sc.ch == '#' && visibleChars == 0) {
|
||||
// Preprocessor commands are alone on their line
|
||||
sc.SetState(SCE_SN_PREPROCESSOR);
|
||||
// Skip whitespace between # and preprocessor word
|
||||
do {
|
||||
sc.Forward();
|
||||
} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_SN_CODE);
|
||||
}
|
||||
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@') {
|
||||
sc.SetState(SCE_SN_OPERATOR);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.atLineEnd) {
|
||||
// Reset states to begining of colourise so no surprises
|
||||
// if different sets of lines lexed.
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!IsASpace(sc.ch)) {
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
// Store both the current line's fold level and the next lines in the
|
||||
// level store to make it easy to pick up with each increment
|
||||
// and to make it possible to fiddle the current level for "} else {".
|
||||
static void FoldNoBoxSpecmanDoc(unsigned int startPos, int length, int,
|
||||
Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelMinCurrent = levelCurrent;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style;
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
//int stylePrev = style;
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (foldComment && (style == SCE_SN_COMMENTLINE)) {
|
||||
if (((ch == '/') && (chNext == '/')) ||
|
||||
((ch == '-') && (chNext == '-'))) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelNext++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_SN_OPERATOR) {
|
||||
if (ch == '{') {
|
||||
// Measure the minimum before a '{' to allow
|
||||
// folding on "} else {"
|
||||
if (levelMinCurrent > levelNext) {
|
||||
levelMinCurrent = levelNext;
|
||||
}
|
||||
levelNext++;
|
||||
} else if (ch == '}') {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int levelUse = levelCurrent;
|
||||
if (foldAtElse) {
|
||||
levelUse = levelMinCurrent;
|
||||
}
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
levelMinCurrent = levelCurrent;
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
|
||||
static void FoldSpecmanDoc(unsigned int startPos, int length, int initStyle, WordList *[],
|
||||
Accessor &styler) {
|
||||
FoldNoBoxSpecmanDoc(startPos, length, initStyle, styler);
|
||||
}
|
||||
|
||||
static const char * const specmanWordLists[] = {
|
||||
"Primary keywords and identifiers",
|
||||
"Secondary keywords and identifiers",
|
||||
"Sequence keywords and identifiers",
|
||||
"User defined keywords and identifiers",
|
||||
"Unused",
|
||||
0,
|
||||
};
|
||||
|
||||
static void ColouriseSpecmanDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
ColouriseSpecmanDoc(startPos, length, initStyle, keywordlists, styler, true);
|
||||
}
|
||||
|
||||
|
||||
LexerModule lmSpecman(SCLEX_SPECMAN, ColouriseSpecmanDocSensitive, "specman", FoldSpecmanDoc, specmanWordLists);
|
299
contrib/src/stc/scintilla/src/LexVerilog.cxx
Normal file
299
contrib/src/stc/scintilla/src/LexVerilog.cxx
Normal file
@@ -0,0 +1,299 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexVerilog.cxx
|
||||
** Lexer for Verilog.
|
||||
** Written by Avi Yegudin, based on C++ lexer by Neil Hodgson
|
||||
**/
|
||||
// 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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '$');
|
||||
}
|
||||
|
||||
static void ColouriseVerilogDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
|
||||
// Do not leak onto next line
|
||||
if (initStyle == SCE_V_STRINGEOL)
|
||||
initStyle = SCE_V_DEFAULT;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.atLineStart && (sc.state == SCE_V_STRING)) {
|
||||
// Prevent SCE_V_STRINGEOL from leaking back to previous line
|
||||
sc.SetState(SCE_V_STRING);
|
||||
}
|
||||
|
||||
// Handle line continuation generically.
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\n' || sc.chNext == '\r') {
|
||||
sc.Forward();
|
||||
if (sc.ch == '\r' && sc.chNext == '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_V_OPERATOR) {
|
||||
sc.SetState(SCE_V_DEFAULT);
|
||||
} else if (sc.state == SCE_V_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_V_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_V_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_V_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_V_WORD2);
|
||||
} else if (keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_V_WORD3);
|
||||
} else if (keywords4.InList(s)) {
|
||||
sc.ChangeState(SCE_V_USER);
|
||||
}
|
||||
sc.SetState(SCE_V_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_V_PREPROCESSOR) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_V_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_V_COMMENT) {
|
||||
if (sc.Match('*', '/')) {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_V_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_V_COMMENTLINE || sc.state == SCE_V_COMMENTLINEBANG) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_V_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_V_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_V_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_V_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_V_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_V_DEFAULT) {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '\'') || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_V_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_V_IDENTIFIER);
|
||||
} else if (sc.Match('/', '*')) {
|
||||
sc.SetState(SCE_V_COMMENT);
|
||||
sc.Forward(); // Eat the * so it isn't used for the end of the comment
|
||||
} else if (sc.Match('/', '/')) {
|
||||
if (sc.Match("//!")) // Nice to have a different comment style
|
||||
sc.SetState(SCE_V_COMMENTLINEBANG);
|
||||
else
|
||||
sc.SetState(SCE_V_COMMENTLINE);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_V_STRING);
|
||||
} else if (sc.ch == '`') {
|
||||
sc.SetState(SCE_V_PREPROCESSOR);
|
||||
// Skip whitespace between ` and preprocessor word
|
||||
do {
|
||||
sc.Forward();
|
||||
} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_V_DEFAULT);
|
||||
}
|
||||
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '#') {
|
||||
sc.SetState(SCE_V_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static bool IsStreamCommentStyle(int style) {
|
||||
return style == SCE_V_COMMENT;
|
||||
}
|
||||
|
||||
// Store both the current line's fold level and the next lines in the
|
||||
// level store to make it easy to pick up with each increment
|
||||
// and to make it possible to fiddle the current level for "} else {".
|
||||
static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle,
|
||||
Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
|
||||
// Verilog specific folding options:
|
||||
// fold_at_module -
|
||||
// Generally used methodology in verilog code is
|
||||
// one module per file, so folding at module definition is useless.
|
||||
// fold_at_brace/parenthese -
|
||||
// Folding of long port lists can be convenient.
|
||||
bool foldAtModule = styler.GetPropertyInt("fold.verilog.flags", 0) != 0;
|
||||
bool foldAtBrace = 1;
|
||||
bool foldAtParenthese = 1;
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelMinCurrent = levelCurrent;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style = initStyle;
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int stylePrev = style;
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (foldComment && IsStreamCommentStyle(style)) {
|
||||
if (!IsStreamCommentStyle(stylePrev)) {
|
||||
levelNext++;
|
||||
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
|
||||
// Comments don't end at end of line and the next character may be unstyled.
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
if (foldComment && (style == SCE_V_COMMENTLINE)) {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelNext++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foldPreprocessor && (style == SCE_V_PREPROCESSOR)) {
|
||||
if (ch == '`') {
|
||||
unsigned int j = i + 1;
|
||||
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
|
||||
j++;
|
||||
}
|
||||
if (styler.Match(j, "if")) {
|
||||
levelNext++;
|
||||
} else if (styler.Match(j, "end")) {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_V_OPERATOR) {
|
||||
if (foldAtParenthese) {
|
||||
if (ch == '(') {
|
||||
levelNext++;
|
||||
} else if (ch == ')') {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_V_OPERATOR) {
|
||||
if (foldAtBrace) {
|
||||
if (ch == '{') {
|
||||
levelNext++;
|
||||
} else if (ch == '}') {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_V_WORD && stylePrev != SCE_V_WORD) {
|
||||
unsigned int j = i;
|
||||
if (styler.Match(j, "case") ||
|
||||
styler.Match(j, "casex") ||
|
||||
styler.Match(j, "casez") ||
|
||||
styler.Match(j, "function") ||
|
||||
styler.Match(j, "fork") ||
|
||||
styler.Match(j, "table") ||
|
||||
styler.Match(j, "task") ||
|
||||
styler.Match(j, "specify") ||
|
||||
styler.Match(j, "primitive") ||
|
||||
styler.Match(j, "module") && foldAtModule ||
|
||||
styler.Match(j, "begin")) {
|
||||
levelNext++;
|
||||
} else if (styler.Match(j, "endcase") ||
|
||||
styler.Match(j, "endfunction") ||
|
||||
styler.Match(j, "join") ||
|
||||
styler.Match(j, "endtask") ||
|
||||
styler.Match(j, "endtable") ||
|
||||
styler.Match(j, "endspecify") ||
|
||||
styler.Match(j, "endprimitive") ||
|
||||
styler.Match(j, "endmodule") && foldAtModule ||
|
||||
styler.Match(j, "end") && !IsAWordChar(styler.SafeGetCharAt(j+3))) {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int levelUse = levelCurrent;
|
||||
if (foldAtElse) {
|
||||
levelUse = levelMinCurrent;
|
||||
}
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
levelMinCurrent = levelCurrent;
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
|
||||
static void FoldVerilogDoc(unsigned int startPos, int length, int initStyle, WordList *[],
|
||||
Accessor &styler) {
|
||||
FoldNoBoxVerilogDoc(startPos, length, initStyle, styler);
|
||||
}
|
||||
|
||||
static const char * const verilogWordLists[] = {
|
||||
"Primary keywords and identifiers",
|
||||
"Secondary keywords and identifiers",
|
||||
"System Tasks",
|
||||
"User defined tasks and identifiers",
|
||||
"Unused",
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
LexerModule lmVerilog(SCLEX_VERILOG, ColouriseVerilogDoc, "verilog", FoldVerilogDoc, verilogWordLists);
|
@@ -71,6 +71,264 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
|
||||
return 0 == CompareCaseInsensitive(a, b);
|
||||
}
|
||||
|
||||
// Since the CaseInsensitive functions declared in SString
|
||||
// are implemented here, I will for now put the non-inline
|
||||
// implementations of the SString members here as well, so
|
||||
// that I can quickly see what effect this has.
|
||||
|
||||
SString::SString(int i) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%0d", i);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
|
||||
SString::SString(double d, int precision) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%.*f", precision, d);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
|
||||
bool SString::grow(lenpos_t lenNew) {
|
||||
while (sizeGrowth * 6 < lenNew) {
|
||||
sizeGrowth *= 2;
|
||||
}
|
||||
char *sNew = new char[lenNew + sizeGrowth + 1];
|
||||
if (sNew) {
|
||||
if (s) {
|
||||
memcpy(sNew, s, sLen);
|
||||
delete []s;
|
||||
}
|
||||
s = sNew;
|
||||
s[sLen] = '\0';
|
||||
sSize = lenNew + sizeGrowth;
|
||||
}
|
||||
return sNew != 0;
|
||||
}
|
||||
|
||||
SString &SString::assign(const char *sOther, lenpos_t sSize_) {
|
||||
if (!sOther) {
|
||||
sSize_ = 0;
|
||||
} else if (sSize_ == measure_length) {
|
||||
sSize_ = strlen(sOther);
|
||||
}
|
||||
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
|
||||
if (s && sSize_) {
|
||||
memcpy(s, sOther, sSize_);
|
||||
}
|
||||
s[sSize_] = '\0';
|
||||
sLen = sSize_;
|
||||
} else {
|
||||
delete []s;
|
||||
s = StringAllocate(sOther, sSize_);
|
||||
if (s) {
|
||||
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
|
||||
sLen = strlen(s);
|
||||
} else {
|
||||
sSize = sLen = 0;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool SString::operator==(const SString &sOther) const {
|
||||
if ((s == 0) && (sOther.s == 0))
|
||||
return true;
|
||||
if ((s == 0) || (sOther.s == 0))
|
||||
return false;
|
||||
return strcmp(s, sOther.s) == 0;
|
||||
}
|
||||
|
||||
bool SString::operator==(const char *sOther) const {
|
||||
if ((s == 0) && (sOther == 0))
|
||||
return true;
|
||||
if ((s == 0) || (sOther == 0))
|
||||
return false;
|
||||
return strcmp(s, sOther) == 0;
|
||||
}
|
||||
|
||||
SString SString::substr(lenpos_t subPos, lenpos_t subLen) const {
|
||||
if (subPos >= sLen) {
|
||||
return SString(); // return a null string if start index is out of bounds
|
||||
}
|
||||
if ((subLen == measure_length) || (subPos + subLen > sLen)) {
|
||||
subLen = sLen - subPos; // can't substr past end of source string
|
||||
}
|
||||
return SString(s, subPos, subPos + subLen);
|
||||
}
|
||||
|
||||
SString &SString::lowercase(lenpos_t subPos, lenpos_t subLen) {
|
||||
if ((subLen == measure_length) || (subPos + subLen > sLen)) {
|
||||
subLen = sLen - subPos; // don't apply past end of string
|
||||
}
|
||||
for (lenpos_t i = subPos; i < subPos + subLen; i++) {
|
||||
if (s[i] < 'A' || s[i] > 'Z')
|
||||
continue;
|
||||
else
|
||||
s[i] = static_cast<char>(s[i] - 'A' + 'a');
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
SString &SString::uppercase(lenpos_t subPos, lenpos_t subLen) {
|
||||
if ((subLen == measure_length) || (subPos + subLen > sLen)) {
|
||||
subLen = sLen - subPos; // don't apply past end of string
|
||||
}
|
||||
for (lenpos_t i = subPos; i < subPos + subLen; i++) {
|
||||
if (s[i] < 'a' || s[i] > 'z')
|
||||
continue;
|
||||
else
|
||||
s[i] = static_cast<char>(s[i] - 'a' + 'A');
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
SString &SString::append(const char *sOther, lenpos_t sLenOther, char sep) {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
int lenSep = 0;
|
||||
if (sLen && sep) { // Only add a separator if not empty
|
||||
lenSep = 1;
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther + lenSep;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew < sSize) || (grow(lenNew))) {
|
||||
if (lenSep) {
|
||||
s[sLen] = sep;
|
||||
sLen++;
|
||||
}
|
||||
memcpy(&s[sLen], sOther, sLenOther);
|
||||
sLen += sLenOther;
|
||||
s[sLen] = '\0';
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
SString &SString::insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther) {
|
||||
if (!sOther || pos > sLen) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew < sSize) || grow(lenNew)) {
|
||||
lenpos_t moveChars = sLen - pos + 1;
|
||||
for (lenpos_t i = moveChars; i > 0; i--) {
|
||||
s[pos + sLenOther + i - 1] = s[pos + i - 1];
|
||||
}
|
||||
memcpy(s + pos, sOther, sLenOther);
|
||||
sLen = lenNew;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove @a len characters from the @a pos position, included.
|
||||
* Characters at pos + len and beyond replace characters at pos.
|
||||
* If @a len is 0, or greater than the length of the string
|
||||
* starting at @a pos, the string is just truncated at @a pos.
|
||||
*/
|
||||
void SString::remove(lenpos_t pos, lenpos_t len) {
|
||||
if (pos >= sLen) {
|
||||
return;
|
||||
}
|
||||
if (len < 1 || pos + len >= sLen) {
|
||||
s[pos] = '\0';
|
||||
sLen = pos;
|
||||
} else {
|
||||
for (lenpos_t i = pos; i < sLen - len + 1; i++) {
|
||||
s[i] = s[i+len];
|
||||
}
|
||||
sLen -= len;
|
||||
}
|
||||
}
|
||||
|
||||
bool SString::startswith(const char *prefix) {
|
||||
lenpos_t lenPrefix = strlen(prefix);
|
||||
if (lenPrefix > sLen) {
|
||||
return false;
|
||||
}
|
||||
return strncmp(s, prefix, lenPrefix) == 0;
|
||||
}
|
||||
|
||||
bool SString::endswith(const char *suffix) {
|
||||
lenpos_t lenSuffix = strlen(suffix);
|
||||
if (lenSuffix > sLen) {
|
||||
return false;
|
||||
}
|
||||
return strncmp(s + sLen - lenSuffix, suffix, lenSuffix) == 0;
|
||||
}
|
||||
|
||||
int SString::search(const char *sFind, lenpos_t start) const {
|
||||
if (start < sLen) {
|
||||
const char *sFound = strstr(s + start, sFind);
|
||||
if (sFound) {
|
||||
return sFound - s;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SString::substitute(char chFind, char chReplace) {
|
||||
int c = 0;
|
||||
char *t = s;
|
||||
while (t) {
|
||||
t = strchr(t, chFind);
|
||||
if (t) {
|
||||
*t = chReplace;
|
||||
t++;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int SString::substitute(const char *sFind, const char *sReplace) {
|
||||
int c = 0;
|
||||
lenpos_t lenFind = strlen(sFind);
|
||||
lenpos_t lenReplace = strlen(sReplace);
|
||||
int posFound = search(sFind);
|
||||
while (posFound >= 0) {
|
||||
remove(posFound, lenFind);
|
||||
insert(posFound, sReplace, lenReplace);
|
||||
posFound = search(sFind, posFound + lenReplace);
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
char *SContainer::StringAllocate(lenpos_t len) {
|
||||
if (len != measure_length) {
|
||||
return new char[len + 1];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
char *SContainer::StringAllocate(const char *s, lenpos_t len) {
|
||||
if (s == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (len == measure_length) {
|
||||
len = strlen(s);
|
||||
}
|
||||
char *sNew = new char[len + 1];
|
||||
if (sNew) {
|
||||
memcpy(sNew, s, len);
|
||||
sNew[len] = '\0';
|
||||
}
|
||||
return sNew;
|
||||
}
|
||||
|
||||
// End SString functions
|
||||
|
||||
PropSet::PropSet() {
|
||||
superPS = 0;
|
||||
for (int root = 0; root < hashRoots; root++)
|
||||
@@ -596,8 +854,8 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
|
||||
// Found another word
|
||||
first = pivot;
|
||||
end = pivot - 1;
|
||||
}
|
||||
else if (cond > 0)
|
||||
}
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
else if (cond <= 0)
|
||||
break;
|
||||
@@ -633,8 +891,8 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
|
||||
// Found another word
|
||||
first = pivot;
|
||||
end = pivot - 1;
|
||||
}
|
||||
else if (cond > 0)
|
||||
}
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
else if (cond <= 0)
|
||||
break;
|
||||
@@ -695,8 +953,9 @@ char *WordList::GetNearestWords(
|
||||
const char *wordStart,
|
||||
int searchLen /*= -1*/,
|
||||
bool ignoreCase /*= false*/,
|
||||
char otherSeparator /*= '\0'*/) {
|
||||
int wordlen; // length of the word part (before the '(' brace) of the api array element
|
||||
char otherSeparator /*= '\0'*/,
|
||||
bool exactLen /*=false*/) {
|
||||
unsigned int wordlen; // length of the word part (before the '(' brace) of the api array element
|
||||
SString wordsNear;
|
||||
wordsNear.setsizegrowth(1000);
|
||||
int start = 0; // lower bound of the api array block to search
|
||||
@@ -726,6 +985,8 @@ char *WordList::GetNearestWords(
|
||||
(0 == CompareNCaseInsensitive(wordStart,
|
||||
wordsNoCase[pivot], searchLen))) {
|
||||
wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1;
|
||||
if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1)
|
||||
break;
|
||||
wordsNear.append(wordsNoCase[pivot], wordlen, ' ');
|
||||
++pivot;
|
||||
}
|
||||
@@ -752,6 +1013,8 @@ char *WordList::GetNearestWords(
|
||||
(0 == strncmp(wordStart,
|
||||
words[pivot], searchLen))) {
|
||||
wordlen = LengthWord(words[pivot], otherSeparator) + 1;
|
||||
if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1)
|
||||
break;
|
||||
wordsNear.append(words[pivot], wordlen, ' ');
|
||||
++pivot;
|
||||
}
|
||||
|
@@ -297,7 +297,7 @@ void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteCharacterDeleted() {
|
||||
if (currentPos <= ac.posStart - ac.startLen) {
|
||||
if (currentPos < ac.posStart - ac.startLen) {
|
||||
ac.Cancel();
|
||||
} else if (ac.cancelAtStartPos && (currentPos <= ac.posStart)) {
|
||||
ac.Cancel();
|
||||
@@ -314,6 +314,8 @@ void ScintillaBase::AutoCompleteCompleted() {
|
||||
ac.lb->GetValue(item, selected, sizeof(selected));
|
||||
}
|
||||
ac.Cancel();
|
||||
if (item == -1)
|
||||
return;
|
||||
|
||||
if (listType > 0) {
|
||||
userListSelected = selected;
|
||||
|
@@ -67,8 +67,8 @@ Style &Style::operator=(const Style &source) {
|
||||
|
||||
void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool visible_, bool changeable_, bool hotspot_) {
|
||||
fore.desired = fore_;
|
||||
back.desired = back_;
|
||||
@@ -102,7 +102,7 @@ void Style::ClearTo(const Style &source) {
|
||||
source.eolFilled,
|
||||
source.underline,
|
||||
source.caseForce,
|
||||
source.visible,
|
||||
source.visible,
|
||||
source.changeable,
|
||||
source.hotspot);
|
||||
}
|
||||
|
@@ -44,8 +44,8 @@ public:
|
||||
void Clear(ColourDesired fore_, ColourDesired back_,
|
||||
int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool visible_, bool changeable_, bool hotspot_);
|
||||
void ClearTo(const Style &source);
|
||||
bool EquivalentFontTo(const Style *other) const;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file StyleContext.cxx
|
||||
** Lexer infrastructure.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// This file is in the public domain.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file StyleContext.cxx
|
||||
** Lexer infrastructure.
|
||||
**/
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// This file is in the public domain.
|
||||
|
||||
// All languages handled so far can treat all characters >= 0x80 as one class
|
||||
@@ -156,3 +156,13 @@ inline bool IsASpaceOrTab(unsigned int ch) {
|
||||
inline bool IsADigit(unsigned int ch) {
|
||||
return (ch >= '0') && (ch <= '9');
|
||||
}
|
||||
|
||||
inline bool IsADigit(unsigned int ch, unsigned int base) {
|
||||
if (base <= 10) {
|
||||
return (ch >= '0') && (ch < '0' + base);
|
||||
} else {
|
||||
return ((ch >= '0') && (ch <= '9')) ||
|
||||
((ch >= 'A') && (ch < 'A' + base - 10)) ||
|
||||
((ch >= 'a') && (ch < 'a' + base - 10));
|
||||
}
|
||||
}
|
||||
|
@@ -98,6 +98,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
|
||||
edgecolour.desired = source.edgecolour.desired;
|
||||
edgeState = source.edgeState;
|
||||
caretWidth = source.caretWidth;
|
||||
someStylesProtected = false;
|
||||
leftMarginWidth = source.leftMarginWidth;
|
||||
rightMarginWidth = source.rightMarginWidth;
|
||||
for (int i=0;i < margins; i++) {
|
||||
@@ -111,7 +112,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
|
||||
viewIndentationGuides = source.viewIndentationGuides;
|
||||
viewEOL = source.viewEOL;
|
||||
showMarkedLines = source.showMarkedLines;
|
||||
extraFontFlag = source.extraFontFlag;
|
||||
extraFontFlag = source.extraFontFlag;
|
||||
}
|
||||
|
||||
ViewStyle::~ViewStyle() {
|
||||
@@ -193,7 +194,7 @@ void ViewStyle::Init() {
|
||||
viewIndentationGuides = false;
|
||||
viewEOL = false;
|
||||
showMarkedLines = true;
|
||||
extraFontFlag = false;
|
||||
extraFontFlag = false;
|
||||
}
|
||||
|
||||
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
|
||||
|
@@ -89,8 +89,8 @@ public:
|
||||
int edgeState;
|
||||
int caretWidth;
|
||||
bool someStylesProtected;
|
||||
bool extraFontFlag;
|
||||
|
||||
bool extraFontFlag;
|
||||
|
||||
ViewStyle();
|
||||
ViewStyle(const ViewStyle &source);
|
||||
~ViewStyle();
|
||||
|
@@ -13,6 +13,10 @@
|
||||
#include "XPM.h"
|
||||
|
||||
static const char *NextField(const char *s) {
|
||||
// In case there are leading spaces in the string
|
||||
while (*s && *s == ' ') {
|
||||
s++;
|
||||
}
|
||||
while (*s && *s != ' ') {
|
||||
s++;
|
||||
}
|
||||
@@ -70,8 +74,10 @@ void XPM::Init(const char *textForm) {
|
||||
if ((0 == memcmp(textForm, "/* X", 4)) && (0 == memcmp(textForm, "/* XPM */", 9))) {
|
||||
// Build the lines form out of the text form
|
||||
const char **linesForm = LinesFormFromTextForm(textForm);
|
||||
Init(linesForm);
|
||||
delete []linesForm;
|
||||
if (linesForm != 0) {
|
||||
Init(linesForm);
|
||||
delete []linesForm;
|
||||
}
|
||||
} else {
|
||||
// It is really in line form
|
||||
Init(reinterpret_cast<const char * const *>(textForm));
|
||||
@@ -190,9 +196,11 @@ const char **XPM::LinesFormFromTextForm(const char *textForm) {
|
||||
const char **linesForm = 0;
|
||||
int countQuotes = 0;
|
||||
int strings=1;
|
||||
for (int j=0; countQuotes < (2*strings); j++) {
|
||||
int j=0;
|
||||
for (; countQuotes < (2*strings) && textForm[j] != '\0'; j++) {
|
||||
if (textForm[j] == '\"') {
|
||||
if (countQuotes == 0) {
|
||||
// First field: width, height, number of colors, chars per pixel
|
||||
const char *line0 = textForm + j + 1;
|
||||
// Skip width
|
||||
line0 = NextField(line0);
|
||||
@@ -202,13 +210,24 @@ const char **XPM::LinesFormFromTextForm(const char *textForm) {
|
||||
// Add 1 line for each colour
|
||||
strings += atoi(line0);
|
||||
linesForm = new const char *[strings];
|
||||
if (linesForm == 0) {
|
||||
break; // Memory error!
|
||||
}
|
||||
}
|
||||
if (linesForm && ((countQuotes & 1) == 0)) {
|
||||
if (countQuotes / 2 >= strings) {
|
||||
break; // Bad height or number of colors!
|
||||
}
|
||||
if ((countQuotes & 1) == 0) {
|
||||
linesForm[countQuotes / 2] = textForm + j + 1;
|
||||
}
|
||||
countQuotes++;
|
||||
}
|
||||
}
|
||||
if (textForm[j] == '\0' || countQuotes / 2 > strings) {
|
||||
// Malformed XPM! Height + number of colors too high or too low
|
||||
delete []linesForm;
|
||||
linesForm = 0;
|
||||
}
|
||||
return linesForm;
|
||||
}
|
||||
|
||||
|
@@ -193,7 +193,7 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
|
||||
// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
|
||||
|
||||
|
||||
// Add text to the document.
|
||||
// Add text to the document at current position.
|
||||
void wxStyledTextCtrl::AddText(const wxString& text) {
|
||||
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
|
||||
SendMsg(2001, strlen(buf), (long)(const char*)buf);
|
||||
@@ -219,7 +219,7 @@ void wxStyledTextCtrl::ClearDocumentStyle() {
|
||||
SendMsg(2005, 0, 0);
|
||||
}
|
||||
|
||||
// The number of characters in the document.
|
||||
// Returns the number of characters in the document.
|
||||
int wxStyledTextCtrl::GetLength() {
|
||||
return SendMsg(2006, 0, 0);
|
||||
}
|
||||
@@ -1514,6 +1514,36 @@ int wxStyledTextCtrl::GetWrapMode() {
|
||||
return SendMsg(2269, 0, 0);
|
||||
}
|
||||
|
||||
// Set the display mode of visual flags for wrapped lines.
|
||||
void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) {
|
||||
SendMsg(2460, wrapVisualFlags, 0);
|
||||
}
|
||||
|
||||
// Retrive the display mode of visual flags for wrapped lines.
|
||||
int wxStyledTextCtrl::GetWrapVisualFlags() {
|
||||
return SendMsg(2461, 0, 0);
|
||||
}
|
||||
|
||||
// Set the location of visual flags for wrapped lines.
|
||||
void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) {
|
||||
SendMsg(2462, wrapVisualFlagsLocation, 0);
|
||||
}
|
||||
|
||||
// Retrive the location of visual flags for wrapped lines.
|
||||
int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
|
||||
return SendMsg(2463, 0, 0);
|
||||
}
|
||||
|
||||
// Set the start indent for wrapped lines.
|
||||
void wxStyledTextCtrl::SetWrapStartIndent(int indent) {
|
||||
SendMsg(2464, indent, 0);
|
||||
}
|
||||
|
||||
// Retrive the start indent for wrapped lines.
|
||||
int wxStyledTextCtrl::GetWrapStartIndent() {
|
||||
return SendMsg(2465, 0, 0);
|
||||
}
|
||||
|
||||
// Sets the degree of caching of layout information.
|
||||
void wxStyledTextCtrl::SetLayoutCache(int mode) {
|
||||
SendMsg(2272, mode, 0);
|
||||
@@ -2345,6 +2375,11 @@ int wxStyledTextCtrl::AutoCompGetCurrent() {
|
||||
return SendMsg(2445, 0, 0);
|
||||
}
|
||||
|
||||
// Enlarge the document to a particular size of text bytes.
|
||||
void wxStyledTextCtrl::Allocate(int bytes) {
|
||||
SendMsg(2446, bytes, 0);
|
||||
}
|
||||
|
||||
// Start notifying the container of all key presses and commands.
|
||||
void wxStyledTextCtrl::StartRecord() {
|
||||
SendMsg(3001, 0, 0);
|
||||
|
Reference in New Issue
Block a user