本文整理汇总了C++中Accessor::GetStartSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ Accessor::GetStartSegment方法的具体用法?C++ Accessor::GetStartSegment怎么用?C++ Accessor::GetStartSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accessor
的用法示例。
在下文中一共展示了Accessor::GetStartSegment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ColouriseBullantDoc
static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int state = initStyle;
if (state == SCE_C_STRINGEOL) // Does not leak onto next line
state = SCE_C_DEFAULT;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
styler.StartSegment(startPos);
int endFoundThisLine = 0;
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
endFoundThisLine = 0;
if (state == SCE_C_STRINGEOL) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
if (fold) {
int lev = levelPrev;
if (visibleChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
levelPrev = levelCurrent;
}
visibleChars = 0;
/* int indentBlock = GetLineIndentation(lineCurrent);
if (blockChange==1){
lineCurrent++;
int pos=SetLineIndentation(lineCurrent, indentBlock + indentSize);
} else if (blockChange==-1) {
indentBlock -= indentSize;
if (indentBlock < 0)
indentBlock = 0;
SetLineIndentation(lineCurrent, indentBlock);
lineCurrent++;
}
blockChange=0;
*/ }
if (!(IsASCII(ch) && isspace(ch)))
visibleChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_C_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i-1, state);
state = SCE_C_IDENTIFIER;
} else if (ch == '@' && chNext == 'o') {
if ((styler.SafeGetCharAt(i+2) =='f') && (styler.SafeGetCharAt(i+3) == 'f')) {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENT;
}
} else if (ch == '#') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i-1, state);
state = SCE_C_STRING;
} else if (ch == '\'') {
styler.ColourTo(i-1, state);
state = SCE_C_CHARACTER;
} else if (isoperator(ch)) {
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
}
} else if (state == SCE_C_IDENTIFIER) {
if (!iswordchar(ch)) {
int levelChange = classifyWordBullant(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
chNext = styler.SafeGetCharAt(i + 1);
if (ch == '#') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
//.........这里部分代码省略.........
示例2: ColouriseCmakeDoc
//.........这里部分代码省略.........
if ( styler.GetLine(nBack) != nCurLine )
break;
char cTemp = styler.SafeGetCharAt(nBack, 'a'); // Letter 'a' is safe here
if ( cTemp == '\\' ) {
bNextLine = true;
break;
}
if ( cTemp != '\r' && cTemp != '\n' && cTemp != '\t' && cTemp != ' ' )
break;
nBack--;
}
if ( bNextLine ) {
styler.ColourTo(i+1,state);
}
if ( bNextLine == false ) {
styler.ColourTo(i,state);
state = SCE_CMAKE_DEFAULT;
}
}
break;
case SCE_CMAKE_VARIABLE:
// CMake Variable:
if ( cCurrChar == '$' )
state = SCE_CMAKE_DEFAULT;
else if ( cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) )
state = SCE_CMAKE_DEFAULT;
else if ( (isCmakeChar(cCurrChar) && !isCmakeChar( cNextChar) && cNextChar != '}') || cCurrChar == '}' ) {
state = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler );
styler.ColourTo( i, state);
state = SCE_CMAKE_DEFAULT;
}
else if ( !isCmakeChar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' ) {
if ( classifyWordCmake( styler.GetStartSegment(), i-1, keywordLists, styler) == SCE_CMAKE_NUMBER )
styler.ColourTo( i-1, SCE_CMAKE_NUMBER );
state = SCE_CMAKE_DEFAULT;
if ( cCurrChar == '"' ) {
state = SCE_CMAKE_STRINGDQ;
bVarInString = false;
bClassicVarInString = false;
}
else if ( cCurrChar == '`' ) {
state = SCE_CMAKE_STRINGLQ;
bVarInString = false;
bClassicVarInString = false;
}
else if ( cCurrChar == '\'' ) {
state = SCE_CMAKE_STRINGRQ;
bVarInString = false;
bClassicVarInString = false;
}
else if ( cCurrChar == '#' ) {
state = SCE_CMAKE_COMMENT;
}
}
break;
}
if ( state == SCE_CMAKE_COMMENT) {
示例3: ColouriseTALDoc
static void ColouriseTALDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
styler.StartAt(startPos);
int state = initStyle;
if (state == SCE_C_CHARACTER) // Does not leak onto next line
state = SCE_C_DEFAULT;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
bool bInClassDefinition;
int currentLine = styler.GetLine(startPos);
if (currentLine > 0) {
styler.SetLineState(currentLine, styler.GetLineState(currentLine-1));
bInClassDefinition = (styler.GetLineState(currentLine) == 1);
} else {
styler.SetLineState(currentLine, 0);
bInClassDefinition = false;
}
bool bInAsm = (state == SCE_C_REGEX);
if (bInAsm)
state = SCE_C_DEFAULT;
styler.StartSegment(startPos);
int visibleChars = 0;
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
if (state == SCE_C_CHARACTER) {
ColourTo(styler, i, state, bInAsm);
state = SCE_C_DEFAULT;
}
visibleChars = 0;
currentLine++;
styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0));
}
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_C_DEFAULT) {
if (isTALwordstart(ch)) {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_IDENTIFIER;
} else if (ch == '!' && chNext != '*') {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENT;
} else if (ch == '!' && chNext == '*') {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENTDOC;
} else if (ch == '-' && chNext == '-') {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENTLINE;
} else if (ch == '"') {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_STRING;
} else if (ch == '?' && visibleChars == 0) {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_PREPROCESSOR;
} else if (isTALoperator(ch)) {
ColourTo(styler, i-1, state, bInAsm);
ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
}
} else if (state == SCE_C_IDENTIFIER) {
if (!isTALwordchar(ch)) {
int lStateChange = classifyWordTAL(styler.GetStartSegment(), i - 1, keywordlists, styler, bInAsm);
if(lStateChange == 1) {
styler.SetLineState(currentLine, 1);
bInClassDefinition = true;
} else if(lStateChange == 2) {
bInAsm = true;
} else if(lStateChange == -1) {
styler.SetLineState(currentLine, 0);
bInClassDefinition = false;
bInAsm = false;
}
state = SCE_C_DEFAULT;
chNext = styler.SafeGetCharAt(i + 1);
if (ch == '!' && chNext != '*') {
state = SCE_C_COMMENT;
} else if (ch == '!' && chNext == '*') {
ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENTDOC;
} else if (ch == '-' && chNext == '-') {
//.........这里部分代码省略.........
示例4: ColourisePlmDoc
static void ColourisePlmDoc(unsigned int startPos,
int length,
int initStyle,
WordList *keywordlists[],
Accessor &styler)
{
unsigned int endPos = startPos + length;
int state = initStyle;
styler.StartAt(startPos);
styler.StartSegment(startPos);
for (unsigned int i = startPos; i < endPos; i++) {
char ch = styler.SafeGetCharAt(i);
char chNext = styler.SafeGetCharAt(i + 1);
if (state == SCE_PLM_DEFAULT) {
if (ch == '/' && chNext == '*') {
styler.ColourTo(i - 1, state);
state = SCE_PLM_COMMENT;
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_PLM_STRING;
} else if (isdigit(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PLM_NUMBER;
} else if (isalpha(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PLM_IDENTIFIER;
} else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
ch == '=' || ch == '<' || ch == '>' || ch == ':') {
styler.ColourTo(i - 1, state);
state = SCE_PLM_OPERATOR;
} else if (ch == '$') {
styler.ColourTo(i - 1, state);
state = SCE_PLM_CONTROL;
}
} else if (state == SCE_PLM_COMMENT) {
if (ch == '*' && chNext == '/') {
i++;
styler.ColourTo(i, state);
state = SCE_PLM_DEFAULT;
}
} else if (state == SCE_PLM_STRING) {
if (ch == '\'') {
if (chNext == '\'') {
i++;
} else {
styler.ColourTo(i, state);
state = SCE_PLM_DEFAULT;
}
}
} else if (state == SCE_PLM_NUMBER) {
if (!isdigit(ch) && !isalpha(ch) && ch != '$') {
i--;
styler.ColourTo(i, state);
state = SCE_PLM_DEFAULT;
}
} else if (state == SCE_PLM_IDENTIFIER) {
if (!isdigit(ch) && !isalpha(ch) && ch != '$') {
// Get the entire identifier.
char word[1024];
int segmentStart = styler.GetStartSegment();
GetRange(segmentStart, i - 1, styler, word, sizeof(word));
i--;
if (keywordlists[0]->InList(word))
styler.ColourTo(i, SCE_PLM_KEYWORD);
else
styler.ColourTo(i, state);
state = SCE_PLM_DEFAULT;
}
} else if (state == SCE_PLM_OPERATOR) {
if (ch != '=' && ch != '>') {
i--;
styler.ColourTo(i, state);
state = SCE_PLM_DEFAULT;
}
} else if (state == SCE_PLM_CONTROL) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_PLM_DEFAULT;
}
}
}
styler.ColourTo(endPos - 1, state);
}
示例5: ColouriseMSSQLDoc
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;
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);
//.........这里部分代码省略.........
示例6: ColourisePyDoc
//.........这里部分代码省略.........
char s[100];
sc.GetCurrent(s, sizeof(s));
int style = SCE_P_IDENTIFIER;
if ((kwLast == kwImport) && (strcmp(s, "as") == 0)) {
style = SCE_P_WORD;
} else if (keywords.InList(s)) {
style = SCE_P_WORD;
} else if (kwLast == kwClass) {
style = SCE_P_CLASSNAME;
} else if (kwLast == kwDef) {
style = SCE_P_DEFNAME;
} else if (kwLast == kwCDef || kwLast == kwCPDef) {
int pos = sc.currentPos;
unsigned char ch = styler.SafeGetCharAt(pos, '\0');
while (ch != '\0') {
if (ch == '(') {
style = SCE_P_DEFNAME;
break;
} else if (ch == ':') {
style = SCE_P_CLASSNAME;
break;
} else if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') {
pos++;
ch = styler.SafeGetCharAt(pos, '\0');
} else {
break;
}
}
} else if (keywords2.InList(s)) {
if (keywords2NoSubIdentifiers) {
// We don't want to highlight keywords2
// that are used as a sub-identifier,
// i.e. not open in "foo.open".
int pos = styler.GetStartSegment() - 1;
if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.'))
style = SCE_P_WORD2;
} else {
style = SCE_P_WORD2;
}
} else if (keywords3.InList(s)) {
style = SCE_P_WORD3;
}
sc.ChangeState(style);
sc.SetState(SCE_P_DEFAULT);
if (style == SCE_P_WORD) {
if (0 == strcmp(s, "class"))
kwLast = kwClass;
else if (0 == strcmp(s, "def"))
kwLast = kwDef;
else if (0 == strcmp(s, "import"))
kwLast = kwImport;
else if (0 == strcmp(s, "cdef"))
kwLast = kwCDef;
else if (0 == strcmp(s, "cpdef"))
kwLast = kwCPDef;
else if (0 == strcmp(s, "cimport"))
kwLast = kwImport;
else if (kwLast != kwCDef && kwLast != kwCPDef)
kwLast = kwOther;
} else if (kwLast != kwCDef && kwLast != kwCPDef) {
kwLast = kwOther;
}
}
} else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) {
if (sc.ch == '\r' || sc.ch == '\n') {
sc.SetState(SCE_P_DEFAULT);
示例7: ColouriseSolDoc
//.........这里部分代码省略.........
else if (ch == '/')
{
styler.ColourTo(i - 1, state);
if(chNext == '/') state = SCE_SCRIPTOL_CSTYLE;
if(chNext == '*') state = SCE_SCRIPTOL_COMMENTBLOCK;
}
else if (IsSolStringStart(ch))
{
styler.ColourTo(i - 1, state);
state = GetSolStringState(styler, i, &nextIndex);
if(state == SCE_SCRIPTOL_STRING)
{
stringType = ch;
}
if (nextIndex != i + 1)
{
i = nextIndex - 1;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
}
}
else if (isoperator(ch))
{
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_SCRIPTOL_OPERATOR);
}
}
else if (state == SCE_SCRIPTOL_KEYWORD)
{
if (!iswordchar(ch))
{
ClassifyWordSol(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
state = SCE_SCRIPTOL_DEFAULT;
if (ch == '`')
{
state = chNext == '`' ? SCE_SCRIPTOL_PERSISTENT : SCE_SCRIPTOL_COMMENTLINE;
}
else if (IsSolStringStart(ch))
{
styler.ColourTo(i - 1, state);
state = GetSolStringState(styler, i, &nextIndex);
if (nextIndex != i + 1)
{
i = nextIndex - 1;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
}
}
else if (isoperator(ch))
{
styler.ColourTo(i, SCE_SCRIPTOL_OPERATOR);
}
}
}
else
{
if (state == SCE_SCRIPTOL_COMMENTLINE ||
state == SCE_SCRIPTOL_PERSISTENT ||
state == SCE_SCRIPTOL_CSTYLE)
{
if (ch == '\r' || ch == '\n')
{
styler.ColourTo(i - 1, state);