当前位置: 首页>>代码示例>>C++>>正文


C++ FormatToken::begin方法代码示例

本文整理汇总了C++中FormatToken::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ FormatToken::begin方法的具体用法?C++ FormatToken::begin怎么用?C++ FormatToken::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormatToken的用法示例。


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

示例1: highlightLine

int LuaHighlighter::highlightLine(QString const& text, int initialState)
{
	Scanner scanner(text.constData(),text.length());
	scanner.setState(initialState);
	
	FormatToken tk;
	bool hasOnlyWhitespace = true;
	while((tk = scanner.read()).format() != Format_EndOfBlock)
	{
		Format format = tk.format();
		if(format == Format_Keyword) {
			if(isImportKeyword(scanner.value(tk)) && hasOnlyWhitespace)
			{
				setFormat(tk.begin(), tk.length(), formatForCategory(format));
				highlightImport(scanner);
				break;
			}
		}
		
		setFormat(tk.begin(), tk.length(), formatForCategory(format));
		if(format != Format_Whitespace)
			hasOnlyWhitespace = false;
	}
	return scanner.state();
}
开发者ID:EssGeeEich,项目名称:LuaEditor,代码行数:25,代码来源:luahighlighter.cpp

示例2: highlightLine

int GoHighlighter::highlightLine(const QString &text, int initialState)
{
    GoScanner scanner(text.constData(), text.size());
    scanner.setState(initialState);

    FormatToken tk;
    while ((tk = scanner.read()).format() != Format_EndOfBlock)
        setFormat(tk.begin(), tk.length(), formatForCategory(tk.format()));
    return scanner.state();
}
开发者ID:gonboy,项目名称:qtcreator-plugins-collection,代码行数:10,代码来源:gohighlighter.cpp

示例3: highlightImport

/**
 * @brief Highlights rest of line as import directive
 */
void PythonHighlighter::highlightImport(Scanner &scanner)
{
    FormatToken tk;
    while ((tk = scanner.read()).format() != Format_EndOfBlock) {
        Format format = tk.format();
        if (tk.format() == Format_Identifier)
            format = Format_ImportedModule;
        setFormat(tk.begin(), tk.length(), formatForCategory(format));
    }
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:13,代码来源:pythonhighlighter.cpp

示例4: highlightImport

void Highlighter::highlightImport(Scanner &scanner)
{
    FormatToken tk;
    while ((tk = scanner.read()).format() != Format_EndOfBlock)
    {
        Format format = tk.format();
        if (tk.format() == Format_IDENTIFIER)
            format = Format_IMPORTED_MODULE;
        setFormat(tk.begin(), tk.length(), _formats[format]);
    }
}
开发者ID:sergey-shambir,项目名称:sergey-shambir-sandbox,代码行数:11,代码来源:highlighter.cpp

示例5: highlightLine

/**
 * @brief Highlighter::highlight_impl
 * @param text - source code to highlight
 * @param initialState - initial state of scanner, retrieved from previous block
 * @return final state of scanner, should be saved with current block
 */
int Highlighter::highlightLine(const QString &text, int initialState)
{
    Scanner scanner(text.constData(), text.size());
    scanner.setState(initialState);

    HState hstate = HState_NORMAL;

    int blockNo = currentBlock().blockNumber();
    QMap<int, QString>::iterator it = _userTypes.find(blockNo);
    if (it != _userTypes.end())
        _userTypes.erase(it);

    FormatToken tk;
    bool hasOnlyWhitespace = true;
    while ((tk = scanner.read()).format() != Format_EndOfBlock)
    {
        Format format = tk.format();
        switch (hstate)
        {
        default: // HState_NORMAL
            if (format == Format_KEYWORD) {
                QString value = scanner.value(tk);
                if (value == "class") {
                    hstate = HState_ON_CLASS;
                } else if (isImportKeyword(value) && hasOnlyWhitespace) {
                    setFormat(tk.begin(), tk.length(), _formats[format]);
                    highlightImport(scanner);
                    return scanner.getState();
                }
            }
            if (format == Format_IDENTIFIER) {
                QString value = scanner.value(tk);
                QMap<int, QString>::const_iterator it;
                for (it = _userTypes.begin(); it != _userTypes.end(); ++it) {
                    if (value == it.value()) {
                        format = Format_TYPE;
                        break;
                    }
                }
            }
            break;

        case HState_ON_CLASS:
            if (format == Format_WHITESPACE)
                hstate = HState_AFTER_CLASS;
            else
                hstate = HState_NORMAL;
            break;

        case HState_AFTER_CLASS:
            hstate = HState_NORMAL;
            if (format == Format_IDENTIFIER) {
                _userTypes[blockNo] = scanner.value(tk);
                format = Format_TYPE;
            }
            break;
        }
        setFormat(tk.begin(), tk.length(), _formats[format]);
        if (format != Format_WHITESPACE)
            hasOnlyWhitespace = false;
    }
    return scanner.getState();
}
开发者ID:sergey-shambir,项目名称:sergey-shambir-sandbox,代码行数:69,代码来源:highlighter.cpp


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