本文整理汇总了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();
}
示例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();
}
示例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));
}
}
示例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]);
}
}
示例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();
}