• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ previousBlockState函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中previousBlockState函数的典型用法代码示例。如果您正苦于以下问题:C++ previousBlockState函数的具体用法?C++ previousBlockState怎么用?C++ previousBlockState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了previousBlockState函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: setCurrentBlockState

// Overrides the function from QSyntaxHighlighter;
// gets called by QTextEditor whenever
// a block (line of text) needs to be repainted
void XHTMLHighlighter::highlightBlock(const QString &text)
{
    // By default, all block states are -1;
    // in our implementation regular text is state == 1
    if (previousBlockState() == -1) {
        setCurrentBlockState(State_Text);
    }
    // Propagate previous state; needed for state tracking
    else {
        setCurrentBlockState(previousBlockState());
    }

    if (text.isEmpty()) {
        return;
    }

    SettingsStore settings;
    m_enableSpellCheck = settings.spellCheck();

    // Run spell check over the text.
    if (m_enableSpellCheck && m_checkSpelling) {
        CheckSpelling(text);
    }

    // The order of these operations is important
    // because some states format text over previous states!
    HighlightLine(text, State_Entity);
    HighlightLine(text, State_CSS);
    HighlightLine(text, State_HTML);
    HighlightLine(text, State_CSSComment);
    HighlightLine(text, State_HTMLComment);
    HighlightLine(text, State_DOCTYPE);
}
开发者ID:AmesianX,项目名称:Sigil,代码行数:36,代码来源:XHTMLHighlighter.cpp


示例2: highlightBlock

void OSyntaxHighlighter :: highlightBlock (const QString &qscText )
{
  logical                    term = NO;
  int                        iStart = 0;
  setCurrentBlockState(0);
  if(previousBlockState() > 0) // in block
    FindEndBlock(qscText,iStart,elements[previousBlockState()]);
  
  if(iStart>=0)
    FindElements(qscText,iStart);


}
开发者ID:BackupTheBerlios,项目名称:openaqua-svn,代码行数:13,代码来源:OSyntaxHighlighter.cpp


示例3: setCurrentBlockState

void Highlighter::highlightBlock(const QString &text)
{
	if (!m_syntaxer) return;
	
	if (text.isEmpty()) {
		setCurrentBlockState(previousBlockState());
		return;
	}

	setCurrentBlockState(0);
	int startCommentIndex = -1;
	int startStringIndex = -1;
	const CommentInfo * currentCommentInfo = NULL;
	int pbs = previousBlockState();
	if (pbs <= 0) {
		m_syntaxer->matchCommentStart(text, 0, startCommentIndex, currentCommentInfo);
	}
	else if (pbs >= COMMENTOFFSET) {
		currentCommentInfo = m_syntaxer->getCommentInfo(previousBlockState() - COMMENTOFFSET);
		startCommentIndex = 0;
	}
	else if (pbs == STRINGOFFSET) {
		startStringIndex = 0;
	}

	QString noComment = text;

	while (startCommentIndex >= 0) {
		int endIndex = currentCommentInfo->m_multiLine ? text.indexOf(currentCommentInfo->m_end, startCommentIndex, currentCommentInfo->m_caseSensitive) : text.length();
		int commentLength;
		if (endIndex == -1) {
			setCurrentBlockState(currentCommentInfo->m_index + COMMENTOFFSET);
			commentLength = text.length() - startCommentIndex;
		} 
		else {
			commentLength = endIndex - startCommentIndex + currentCommentInfo->m_end.length();
		}
		noComment.replace(startCommentIndex, commentLength, QString(commentLength, ' '));
		QTextCharFormat * cf = m_styleFormats.value("Comment", NULL);
		if (cf != NULL) {
			setFormat(startCommentIndex, commentLength, *cf);
		}
		m_syntaxer->matchCommentStart(text, startCommentIndex + commentLength, startCommentIndex, currentCommentInfo);
	}

	highlightStrings(startStringIndex, noComment);
	highlightTerms(noComment);
}
开发者ID:honsey,项目名称:fztaxedit,代码行数:48,代码来源:highlighter.cpp


示例4: expression

void HEMSyntaxHighlighter::highlightBlock(const QString &text)
{
    for (const HighlightingRule &rule : highlightingRules) {
        QRegExp expression(rule.pattern);
        int index = expression.indexIn(text);
        while (index >= 0) {
            int length = expression.matchedLength();
            setFormat(index, length, rule.format);
            index = expression.indexIn(text, index + length);
        }
    }

    setCurrentBlockState(STATE_NORMAL);

    int startIndex = 0;
    QRegExp include("\\binclude\\b"), newline("\\r?\\n");
    int ilength = QString("include").length(); // 7
    if (previousBlockState() != STATE_INCLUDE)
        startIndex = include.indexIn(text) + ilength;
    while (startIndex >= ilength) {
        int endIndex = newline.indexIn(text);
        int includeLength;
        if (endIndex == -1) {
            setCurrentBlockState(STATE_INCLUDE);
            includeLength = text.length() - startIndex;
        } else {
            includeLength = endIndex - startIndex
                            + newline.matchedLength();
        }
        setFormat(startIndex, includeLength, includeFileFormat);
        startIndex = include.indexIn(text, startIndex + includeLength);
    }
}
开发者ID:hyst329,项目名称:mathproject,代码行数:33,代码来源:hemsyntaxhighlighter.cpp


示例5: foreach

    foreach (const MultilineHighlightingRule &rule, multilineHighlightingRules)
    {
        QRegExp startExpression(rule.patternStart);
        QRegExp endExpression(rule.patternEnd);

        int startIndex = 0;
        if (previousBlockState() != rule.statusCode)
        {
            startIndex = startExpression.indexIn(text);
        }

        while (startIndex >= 0)
        {
            int endIndex = endExpression.indexIn(text, startIndex);
            int matchLength;

            if (endIndex == -1)
            {
                setCurrentBlockState(rule.statusCode);
                matchLength = text.length() - startIndex;
            }
            else
            {
                matchLength = endIndex - startIndex + endExpression.matchedLength();
            }

            setFormat(startIndex, matchLength, rule.format);
            startIndex = rule.patternStart.indexIn(text, startIndex + matchLength);
        }
    }
开发者ID:lodacom,项目名称:EditeurWeb,代码行数:30,代码来源:Highlighter.cpp


示例6: setCurrentBlockState

void CodeHighlighter::highlightCommentBlocks(const QString &text)
{
    const QList<LexemeAppearance *> &lexemes = m_theme->blockLexemes();

    for (const LexemeAppearance *lexeme : lexemes) {
        const QRegExp &startPattern = lexeme->pattern();
        const QRegExp &endPattern = lexeme->endPattern();

        setCurrentBlockState(0);

        int startIndex = 0;
        if (previousBlockState() != 1)
            startIndex = startPattern.indexIn(text);

        while (startIndex >= 0) {
            int endIndex = endPattern.indexIn(text, startIndex);
            int commentLength;
            if (endIndex == -1) {
                setCurrentBlockState(1);
                commentLength = text.length() - startIndex;
            } else {
                commentLength = endIndex - startIndex + endPattern.matchedLength();
            }

            setFormat(startIndex, commentLength, *lexeme->format());
            startIndex = startPattern.indexIn(text, startIndex + commentLength);
        }
    }
}
开发者ID:yudjin87,项目名称:carousel,代码行数:29,代码来源:CodeHighlighter.cpp


示例7: delimiter

bool Highlighter::matchMultiline(const QString& text, const ::HighlightingRule& rule)
{
	QRegExp delimiter(rule.pattern);
	int start = 0;
	int add = 0;
	int end = 0;
	int length = 0;
	if (previousBlockState() != rule.index)
	{
		start = delimiter.indexIn(text);
		add = delimiter.matchedLength();
	}

	while (start >= 0)
	{
		end = delimiter.indexIn(text, start + add);
		if (end >= add)
		{
			length = end - start + add + delimiter.matchedLength();
			setCurrentBlockState(0);
		}
		else
		{
			setCurrentBlockState(rule.index);
			length = text.length() - start + add;
		}
		QTextCharFormat fmt;
		if (m_Formats.contains(rule.t))
			fmt = m_Formats[rule.t];
		setFormat(start, length, fmt);
		start = delimiter.indexIn(text, start + length);
	}
	return currentBlockState() == rule.index;
}
开发者ID:a1ext,项目名称:labeless,代码行数:34,代码来源:highlighter.cpp


示例8: previousBlockState

void SyntaxHighlighter::highlightBlock(const QString& str)
{
    int nState = previousBlockState();
    int nStart = 0;

    for(int i = 0; i < str.length(); ++i) {
        if(nState == InsideCStyleComment) {
            if(str.mid(i, 2) == "*/") {
                nState = NormalState;
                setFormat(nStart, i - nStart + 2, Qt::darkGray);
                i++;
            }
        }
        else if(nState == InsideCString) {
            if (str.mid(i, 1) == "\"" || str.mid(i, 1) == "\'") {
                if (str.mid(i - 1, 2) != "\\\"" && str.mid(i - 1, 2) != "\\\'") {
                    nState = NormalState;
                    setFormat(nStart, i - nStart + 1, Qt::cyan);
                }
            }
        }
        else {
            if (str.mid(i, 2) == "//") {
                setFormat(i, str.length() - i, Qt::darkGray);
                break;
            }
            else if (str.mid(i, 1) == "#") {
                setFormat(i, str.length() - i, Qt::green);
                break;
            }
            else if (str.at(i).isNumber()) {
                setFormat(i, 1, Qt::cyan);
            }
            else if (str.mid(i, 2) == "/*") {
                nStart = i;
                nState = InsideCStyleComment;
            }
            else if (str.mid(i, 1) == "\"" || str.mid(i, 1) == "\'") {
                nStart = i;
                nState = InsideCString;
            }
            else {
                QString strKeyword = getKeyword(i, str);
                if (!strKeyword.isEmpty()) {
                    setFormat(i, strKeyword.length(), Qt::white);
                    i += strKeyword.length() - 1;
                }
            }
        }
    }

    if (nState == InsideCStyleComment) {
        setFormat(nStart, str.length() - nStart, Qt::darkGray);
    }
    if (nState == InsideCString) {
        setFormat(nStart, str.length() - nStart, Qt::cyan);
    }
    setCurrentBlockState(nState);
}
开发者ID:Mark5137,项目名称:homework,代码行数:59,代码来源:syntaxhighlighter.cpp


示例9: while

void LatexFileType::highlightBlock(const QString &text)
{
    //comments
    int comInd = text.indexOf('%');
    while (comInd > 0 && text.at(comInd - 1) == '\\')
        comInd = text.indexOf('%', comInd + 1);
    clearCurrentBlockSkipSegments();
    addCurrentBlockSkipSegment(comInd);
    if (comInd >= 0)
        setFormat(comInd, text.length() - comInd, QColor(Qt::darkGray));
    QString ntext = text.left(comInd);
    //commands
    QRegExp rx("(\\\\[a-zA-Z]*|\\\\#|\\\\\\$|\\\\%|\\\\&|\\\\_|\\\\\\{|\\\\\\})+");
    int pos = rx.indexIn(ntext);
    while (pos >= 0) {
        int len = rx.matchedLength();
        setFormat(pos, len, QColor(Qt::red).lighter(70));
        pos = rx.indexIn(ntext, pos + len);
    }
    //multiline (math mode)
    setCurrentBlockState(!ntext.isEmpty() ? 0 : previousBlockState());
    int startIndex = 0;
    bool firstIsStart = false;
    if (previousBlockState() != 1) {
        startIndex = indexOf(ntext, "$");
        firstIsStart = true;
    }
    while (startIndex >= 0)
    {
        int endIndex = indexOf(ntext, "$", startIndex + (firstIsStart ? 1 : 0));
        int commentLength;
        if (endIndex == -1) {
            setCurrentBlockState(1);
            commentLength = ntext.length() - startIndex;
        } else {
            commentLength = endIndex - startIndex + 1;
        }
        setFormat(startIndex, commentLength, QColor(Qt::darkGreen));
        startIndex = indexOf(ntext, "$", startIndex + commentLength);
    }
}
开发者ID:ololoepepe,项目名称:TeX-Creator,代码行数:41,代码来源:latexfiletype.cpp


示例10: setCurrentBlockState

void SmkMarkHighlighter::_aux_multiBlockMatch(
        const QString&         text,
        const QString&         bgnFlag,
        const QString&         endFlag,
        const QTextCharFormat& format,
        const unsigned         field )
{
    if(previousBlockState() == -1)
        return;

    setCurrentBlockState(currentBlockState() & (~field));
    if(previousBlockState() & field) {
        int endid = text.indexOf(endFlag, 0);
        if(endid != -1) {
            // we find a endFlag
            setFormat(0, endid+endFlag.length(), format);
        } else {
            // we do not find a endFlag, mark this line and go on
            setFormat(0, text.length(), format);
            // if(previousBlockState() != -1)
            setCurrentBlockState(currentBlockState() | field);
        }
    }
    else {
        int bgnid = text.indexOf(bgnFlag, 0);
        while(bgnid != -1) {
            int endid = text.indexOf(endFlag, bgnid+bgnFlag.length());
            if(endid != -1) {
                // we find a endFlag
                setFormat(bgnid, endid+endFlag.length()-bgnid, format);
                bgnid = text.indexOf(bgnFlag, endid+endFlag.length());
            } else {
                // we do not find a endFlag, mark this line and go on
                setFormat(bgnid, text.length()-bgnid, format);
                setCurrentBlockState(currentBlockState() | field);
                break;
            }
        }//while(...
    }//if..else...
}
开发者ID:ShawnXUNJU,项目名称:Smark,代码行数:40,代码来源:SmkMarkHighlighter.cpp


示例11: setFormat

void SyntaxHighligther::highlightBlock(const QString& text) {
    setFormat(0, text.size(), defaultFormat_);
    std::vector<SyntaxFormater*>::iterator it;

    for (it = formaters_.begin(); it != formaters_.end(); ++it) {
        SyntaxFormater::Result res = (*it)->eval(text, previousBlockState());

        for (size_t i = 0; i < res.start.size(); i++) {
            setFormat(res.start[i], res.length[i], *res.format);
            setCurrentBlockState(res.outgoingState);
        }
    }
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:13,代码来源:syntaxhighlighter.cpp


示例12: foreach

	foreach (HighlightingRule rule, m_highlightingRules) {
		if(!rule.block) {
			QRegExp expression(rule.expression);
			int index = text.indexOf(expression);
			while (index >= 0) {
				int length = expression.matchedLength();
				/*IntervallWithFormat temp;
				temp.index = index;
				temp.length = length;
				temp.format = rule.format;
				keywords.append(temp);*/
				//setFormat(index, length, rule.format);
				applyFormat(index, length, rule.format);
				index = text.indexOf(expression, index + length);
			}
		} else {
			// mathMode
			setCurrentBlockState(0);
			
			int startIndex = 0;
			if (previousBlockState() != 1)
				//startIndex = text.indexOf(mathModeStartExpression);
				startIndex = text.indexOf(rule.startExpression);
			
			while (startIndex >= 0) {
				//int endIndex = text.indexOf(mathModeEndExpression, startIndex+1);
				int endIndex = text.indexOf(rule.endExpression, startIndex+1);
				int mathModeLength;
				if (endIndex == -1) {
					setCurrentBlockState(1);
					mathModeLength = text.length() - startIndex;
				} else {
					/*mathModeLength = endIndex - startIndex
					+ mathModeEndExpression.matchedLength();*/
					mathModeLength = endIndex - startIndex
					+ rule.endExpression.matchedLength();
				}
				/*IntervallWithFormat temp;
				temp.index = startIndex;
				temp.length = mathModeLength;
				temp.format = m_mathModeFormat;
				mathModes.append(temp);*/
				//setFormat(startIndex, mathModeLength, m_mathModeFormat);
				applyFormat(startIndex, mathModeLength, m_mathModeFormat);
				/*startIndex = text.indexOf(mathModeStartExpression,
										  startIndex + mathModeLength);*/
				startIndex = text.indexOf(rule.startExpression,
										  startIndex + mathModeLength);
			}
		}
	}
开发者ID:BackupTheBerlios,项目名称:qtex-svn,代码行数:51,代码来源:highlighter.cpp


示例13: type

void QMLHighlighter::highlightBlock(const QString &text)
{
    QTextCharFormat keywordFormat;
    keywordFormat.setForeground(QColor("#d7ffaf")); // Identifier
    QTextCharFormat typeFormat;
    typeFormat.setForeground(QColor("#afffff")); // Type
    QTextCharFormat commentFormat;
    commentFormat.setForeground(QColor("#8a8a8a")); // Comment 
    QTextCharFormat numericConstantFormat;
    numericConstantFormat.setForeground(QColor("#ffffd7")); // Constant 
    QTextCharFormat stringConstantFormat;
    stringConstantFormat.setForeground(QColor("#ffffd7")); 

    QRegExp type("\\b[A-Z][A-Za-z]+\\b");
    QRegExp numericConstant("[0-9]+\\.?[0-9]*");
    QRegExp stringConstant("['\"].*['\"]");//Not multiline strings, but they're rare
    QRegExp lineComment("//[^\n]*");
    QRegExp startComment("/\\*");
    QRegExp endComment("\\*/");

    applyBasicHighlight(text, type, typeFormat);
    applyBasicHighlight(text, numericConstant, numericConstantFormat);
    applyBasicHighlight(text, stringConstant, stringConstantFormat);
    applyBasicHighlight(text, lineComment, commentFormat);

    setCurrentBlockState(0);

    int startIndex = 0;
    if (previousBlockState() != 1)
        startIndex = text.indexOf(startComment);

    while (startIndex >= 0) {
        int endIndex = text.indexOf(endComment, startIndex);
        int commentLength;
        if (endIndex == -1) {
            setCurrentBlockState(1);
            commentLength = text.length() - startIndex;
        } else {
            commentLength = endIndex - startIndex
                + endComment.matchedLength();
        }
        setFormat(startIndex, commentLength, commentFormat);
        startIndex = text.indexOf(startComment,
                startIndex + commentLength);
    }

}
开发者ID:TanNgocDo,项目名称:terrarium-app,代码行数:47,代码来源:qmlhighlighter.cpp


示例14: matchMultiline

bool BashHighlighter::matchMultiline(const QString& text,
                                     const QRegExp& delimiter,
                                     const int inState,
                                     const QTextCharFormat& style) {

	int start = -1;
	int add = -1;
	int end = -1;
	int length = 0;

	// If inside triple-single quotes, start at 0
	if ( previousBlockState() == inState ) {
		start = 0;
		add = 0;
	}
	// Otherwise, look for the delimiter on this line
	else {
		start = delimiter.indexIn(text);
		// Move past this match
		add = delimiter.matchedLength();
	}

	// As long as there's a delimiter match on this line...
	while ( start >= 0 ) {
		// Look for the ending delimiter
		end = delimiter.indexIn(text, start + add);
		// Ending delimiter on this line?
		if ( end >= add ) {
			length = end - start + add + delimiter.matchedLength();
			setCurrentBlockState(0);
		}
		// No; multi-line string
		else {
			setCurrentBlockState(inState);
			length = text.length() - start + add;
		}
		// Apply formatting and look for next
		setFormat(start, length, style);
		start = delimiter.indexIn(text, start + length);
	}

	// Return True if still inside a multi-line string, False otherwise
	if ( currentBlockState() == inState )
		return true;
	else
		return false;
}
开发者ID:ovsm-dev,项目名称:sdp,代码行数:47,代码来源:bashhighlighter.cpp


示例15: highlightSubBlock

void SyntaxHighlighter::highlightBlock(const QString &text)
{
  //Do the main block highlighting.
  highlightSubBlock(text, 0, previousBlockState());

  //Run the set of inline rules.
  foreach (const HighlightingRule &rule, hlRules)
    {
      QRegExp expression(rule.pattern);
      int index = expression.indexIn(text);
      while(index >= 0)
      {
        int length = expression.matchedLength();
        setFormat(index, length, rule.format);
        index = expression.indexIn(text, index + length);
      }
    }
开发者ID:JourneyGo,项目名称:BHumanCodeRelease,代码行数:17,代码来源:SyntaxHighlighter.cpp


示例16: FindEndBlock

void OSyntaxHighlighter :: FindEndBlock (const QString &qscText, int32 &riStart, SyntaxElement &rsyntaxelement )
{
  int                        iLength = 0;

  if(FindElement(qscText,riStart,rsyntaxelement.rxEnd)){
    riStart += rsyntaxelement.rxEnd.cap(0).length();
    iLength = riStart;
  }
  else{
    iLength = qscText.length();
    setCurrentBlockState(previousBlockState());
  }
  AddFormatRange(rsyntaxelement.syntaxclass,0,iLength);



}
开发者ID:BackupTheBerlios,项目名称:openaqua-svn,代码行数:17,代码来源:OSyntaxHighlighter.cpp


示例17: setFormat

void SyntaxHighlighter::highlightBlock(const QString &text)
{
    int currentBlockState = STATE_NORMAL;
    QTextCharFormat f;
    f.setFontItalic(!m_approved);
    setFormat(0, text.length(), f);

    tagFormat.setFontItalic(!m_approved);
    //if (fromDocbook)
    {
        int startIndex = STATE_NORMAL;
        if (previousBlockState() != STATE_TAG)
            startIndex = text.indexOf('<');

        while (startIndex >= 0)
        {
            int endIndex = text.indexOf('>', startIndex);
            int commentLength;
            if (endIndex == -1)
            {
                currentBlockState = STATE_TAG;
                commentLength = text.length() - startIndex;
            }
            else
            {
                commentLength = endIndex - startIndex
                                +1/*+ commentEndExpression.matchedLength()*/;
            }
            setFormat(startIndex, commentLength, tagFormat);
            startIndex = text.indexOf('<', startIndex + commentLength);
        }
    }

    foreach (const HighlightingRule &rule, highlightingRules)
    {
        QRegExp expression(rule.pattern);
        int index = expression.indexIn(text);
        while (index >= 0)
        {
            int length = expression.matchedLength();
            QTextCharFormat f=rule.format;
            f.setFontItalic(!m_approved);
            setFormat(index, length, f);
            index = expression.indexIn(text, index + length);
        }
    }
开发者ID:aspotashev,项目名称:lokalize-stupids,代码行数:46,代码来源:syntaxhighlighter.cpp


示例18: previousBlockState

void QScriptSyntaxHighlighter::highlightBlock(const QString &text)
{

    // states
    enum States { StateStandard, StateCommentStart1, StateCCommentStart2,
                  StateScriptCommentStart2, StateCComment, StateScriptComment, StateCCommentEnd1,
                  StateCCommentEnd2, StateStringStart, StateString, StateStringEnd,
                  StateString2Start, StateString2, StateString2End,
                  StateNumber, StatePreProcessor, NumStates  };

    // tokens
    enum Tokens { InputAlpha, InputNumber, InputAsterix, InputSlash, InputParen,
                  InputSpace, InputHash, InputQuotation, InputApostrophe, InputSep, NumTokens };

    static uchar table[NumStates][NumTokens] = {
        { StateStandard,      StateNumber,     StateStandard,       StateCommentStart1,    StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStandard
        { StateStandard,      StateNumber,   StateCCommentStart2, StateScriptCommentStart2, StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCommentStart1
        { StateCComment,      StateCComment,   StateCCommentEnd1,   StateCComment,         StateCComment,   StateCComment,   StateCComment,     StateCComment,    StateCComment,     StateCComment }, // StateCCommentStart2
        { StateScriptComment,    StateScriptComment, StateScriptComment,     StateScriptComment,       StateScriptComment, StateScriptComment, StateScriptComment,   StateScriptComment,  StateScriptComment,   StateScriptComment }, // ScriptCommentStart2
        { StateCComment,      StateCComment,   StateCCommentEnd1,   StateCComment,         StateCComment,   StateCComment,   StateCComment,     StateCComment,    StateCComment,     StateCComment }, // StateCComment
        { StateScriptComment,    StateScriptComment, StateScriptComment,     StateScriptComment,       StateScriptComment, StateScriptComment, StateScriptComment,   StateScriptComment,  StateScriptComment,   StateScriptComment }, // StateScriptComment
        { StateCComment,      StateCComment,   StateCCommentEnd1,   StateCCommentEnd2,     StateCComment,   StateCComment,   StateCComment,     StateCComment,    StateCComment,     StateCComment }, // StateCCommentEnd1
        { StateStandard,      StateNumber,     StateStandard,       StateCommentStart1,    StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCCommentEnd2
        { StateString,        StateString,     StateString,         StateString,           StateString,     StateString,     StateString,       StateStringEnd,   StateString,       StateString }, // StateStringStart
        { StateString,        StateString,     StateString,         StateString,           StateString,     StateString,     StateString,       StateStringEnd,   StateString,       StateString }, // StateString
        { StateStandard,      StateStandard,   StateStandard,       StateCommentStart1,    StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStringEnd
        { StateString2,       StateString2,    StateString2,        StateString2,          StateString2,    StateString2,    StateString2,      StateString2,     StateString2End,   StateString2 }, // StateString2Start
        { StateString2,       StateString2,    StateString2,        StateString2,          StateString2,    StateString2,    StateString2,      StateString2,     StateString2End,   StateString2 }, // StateString2
        { StateStandard,      StateStandard,   StateStandard,       StateCommentStart1,    StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateString2End
        { StateNumber,        StateNumber,     StateStandard,       StateCommentStart1,    StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateNumber
        { StatePreProcessor,  StateStandard,   StateStandard,       StateCommentStart1,    StateStandard,   StateStandard,   StatePreProcessor, StateStringStart, StateString2Start, StateStandard } // StatePreProcessor
    };

    QString buffer;
    buffer.reserve(text.length());

    QTextCharFormat emptyFormat;

    int state = StateStandard;
    int braceDepth = 0;
    const int previousState = previousBlockState();
    if (previousState != -1) {
        state = previousState & 0xff;
        braceDepth = previousState >> 8;
    }
开发者ID:dewhisna,项目名称:emscripten-qt,代码行数:45,代码来源:qscriptsyntaxhighlighter.cpp


示例19: expression

void CodeSyntaxHighlither::highlightBlock(const QString& text)
{
	for(const CodeSyntaxHighlightRule& rule : m_CodeHighlightingRules)
	{
		QRegExp expression(rule.m_Pattern);

		int32_t index = expression.indexIn(text);

		while(index >= 0)
		{
			int32_t length = expression.matchedLength();

			setFormat(index, length, rule.m_Format);

			index = expression.indexIn(text, index + length);
		}
	}

	setCurrentBlockState(0);

	int32_t startIndex = 0;
	if(previousBlockState() != 1)
	{
		startIndex = m_CommentStartExpression.indexIn(text);
	}

	while(startIndex >= 0) 
	{
		int32_t endIndex = m_CommentEndExpression.indexIn(text, startIndex);
		int32_t commentLength = 0;

		if(endIndex == -1) 
		{
			setCurrentBlockState(1);
			commentLength = text.length() - startIndex;
		}
		else
		{
			commentLength = endIndex - startIndex + m_CommentEndExpression.matchedLength();
		}

		setFormat(startIndex, commentLength, m_MultiLineCommentFormat);
		startIndex = m_CommentStartExpression.indexIn(text, startIndex + commentLength);
	}
}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:45,代码来源:CodeSyntaxHighlighter.cpp


示例20: searchInputForAutocompleteRules

void SyntaxHighlighter::highlightBlock(const QString &text)
{
    if(languageSet)
    {
        // stops syntax highlight code running when searching for reg exp query
        // search line for any autocomplete suggestions
        autoCompleteSuggestions += searchInputForAutocompleteRules(text);

        foreach (const SyntaxHighlightingRuleSet::HighlightingRule rule, ruleSet->highlightingRules) {
            QRegExp expression(rule.pattern);
            int index = expression.indexIn(text);
            while (index >= 0) {
                int length = expression.matchedLength();
                setFormat(index, length, rule.format);
                index = expression.indexIn(text, index + length);
            }
        }
        setCurrentBlockState(0);

        int startIndex = 0;
        if (previousBlockState() != 1)
            startIndex = ruleSet->commentStartExpression.indexIn(text);

        while (startIndex >= 0) {
            int endIndex = ruleSet->commentEndExpression.indexIn(text, startIndex);
            int commentLength;
            if (endIndex == -1) {
                setCurrentBlockState(1);
                commentLength = text.length() - startIndex;
            } else {
                commentLength = endIndex - startIndex
                        + ruleSet->commentEndExpression.matchedLength();
            }
            setFormat(startIndex, commentLength, ruleSet->multiLineCommentFormat);
            startIndex = ruleSet->commentStartExpression.indexIn(text, startIndex + commentLength);
        }


        // if the search box is populated with an expression
        if(searchExpression.pattern() != "")
        {
            highlightSearchExpression(searchExpression, text);
        }
    }
}
开发者ID:JacobPlaster,项目名称:Able,代码行数:45,代码来源:syntaxhighlighter.cpp



注:本文中的previousBlockState函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ previous_object函数代码示例发布时间:2022-05-30
下一篇:
C++ previous函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap