#include "my_highlightingrule_keyWords.h"
My_Highlightingrule_KeyWords::My_Highlightingrule_KeyWords()
{
const int MAX = 51;
std::string keyWords[MAX] = {"abstract", "continue", "for", "new",
"switch", "assert", "default", "goto",
"package", "synchronized", "boolean",
"do", "if", "private", "this", "break",
"double", "implements", "protected",
"throw", "byte", "else", "import",
"public", "throws", "case", "enum",
"instanceof", "return", "transient",
"catch", "extends", "int", "short",
"try", "char", "final", "interface",
"static", "void", "class", "finally",
"long", "strictfp", "volatile", "const",
"float", "native", "super", "while"};
format.setForeground(brush);
for(int i = 0; i < MAX; i++)
{
My_Highlightingrule *rule = new My_Highlightingrule(pattern,&format);
insert(i,rule);
}
std::cout << at(49)->getPattern()->pattern()->toStdString() << std::endl; //NO SEGMENTATION FAULT
delete(pattern);
}
#include "my_highlightingrule_keyWords.h"
My_Highlightingrule_KeyWords::My_Highlightingrule_KeyWords()
{
const int MAX = 51;
std::string keyWords[MAX] = {"abstract", "continue", "for", "new",
"switch", "assert", "default", "goto",
"package", "synchronized", "boolean",
"do", "if", "private", "this", "break",
"double", "implements", "protected",
"throw", "byte", "else", "import",
"public", "throws", "case", "enum",
"instanceof", "return", "transient",
"catch", "extends", "int", "short",
"try", "char", "final", "interface",
"static", "void", "class", "finally",
"long", "strictfp", "volatile", "const",
"float", "native", "super", "while"};
QTextCharFormat format;
QBrush brush(QColor(255,0,0,127));
format.setForeground(brush);
QRegExp *pattern;
for(int i = 0; i < MAX; i++)
{
pattern = new QRegExp(QString("\\b%1\\b").arg(keyWords[i].c_str()));
My_Highlightingrule *rule = new My_Highlightingrule(pattern,&format);
insert(i,rule);
}
std::cout << at(49)->getPattern()->pattern()->toStdString() << std::endl; //NO SEGMENTATION FAULT
delete(pattern);
}
To copy to clipboard, switch view to plain text mode
Bookmarks