Permalink
Browse files

Merge remote branch 'upstream/master' into deb-script-enhacement

  • Loading branch information...
2 parents d9feb4f + 5823c97 commit 0d4ca7d9f523b0bf177150c8fcb65a6599ad66dd @lifus committed Feb 21, 2012
@@ -130,7 +130,7 @@ void SCgSelectModeEventHandler::mouseRelease(QGraphicsSceneMouseEvent *event)
QGraphicsItem *item = it.key();
SCgContour *newParent = 0;
switch(item->type()) {
- case PointGraphicsItem::Type : {
+ case PointGraphicsItem::Type : case IncidencePointGraphicsItem::Type : {
// exclude PointGraphicsItem's object, because it always has a parent item
it.value().second.second = item->pos();
continue;
@@ -44,14 +44,34 @@ void M4SCpSyntaxHighlighter::highlightBlock(const QString &text)
setFormat(index,length, rule.format);
index = expression.indexIn(text, index + length);
}
+ setCurrentBlockState(0);
+ int startIndex = 0;
+ if (previousBlockState() != 1)
+ startIndex = commentStartExpression.indexIn(text);
+ while (startIndex >= 0) {
+ int endIndex = commentEndExpression.indexIn(text, startIndex);
+ int commentLength;
+ if (endIndex == -1) {
+ setCurrentBlockState(1);
+ commentLength = text.length() - startIndex;
+ } else {
+ commentLength = endIndex - startIndex
+ + commentEndExpression.matchedLength();
+ }
+ setFormat(startIndex, commentLength, multiLineCommentFormat);
+ startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
+ }
}
}
void M4SCpSyntaxHighlighter::createSCpOperatorFormat()
{
QTextCharFormat m4scpOperatorFormat;
- m4scpOperatorFormat.setForeground(Qt::darkGreen);
- m4scpOperatorFormat.setFontWeight(QFont::Bold);
+ QFont font("Courier New",11,true);
+ font.setBold(true);
+ m4scpOperatorFormat.setFont(font);
+ m4scpOperatorFormat.setForeground(Qt::blue);
+
QStringList m4scpOperators;
m4scpOperators
<< "\\badd\\b" << "\\badd_to_queue\\b" << "\\bcall\\b"
@@ -79,13 +99,23 @@ void M4SCpSyntaxHighlighter::createSCpOperatorFormat()
<< "\\bvarAssign\\b" << "\\bvarErase\\b"
<< "\\bwait_erase_element\\b" << "\\bwait_gen_input_arc\\b"
<< "\\bwait_input_arc\\b" << "\\bwait_output_arc\\b"
- << "\\bend\\b" << "\\label\\b"
+ << "\\bend\\b" << "\\bwait_recieve_message\\b"
<< "\\bsys_get_autosegment\\b" << "\\bsys_open_dir\\b"
<< "\\bsys_open_segment_uri\\b" << "\\bsys_set_event_handler\\b"
<< "\\bsys_wait\\b" << "\\bwaitReturn\\b"
- << "\\bwait_gen_output_arc\\b" << "\\bwait_recieve_message\\b";
+ << "\\bwait_gen_output_arc\\b";
+ M4SCpHighlightingRule rule;
saveFormat(m4scpOperatorFormat,m4scpOperators);
+ QTextCharFormat labelFormat;
+ font.setPointSize(11);
+ font.setBold(true);
+ labelFormat.setFont(font);
+ QBrush brush = QBrush(qRgb(255,0,128));
+ labelFormat.setForeground(brush);
+ rule.pattern = QRegExp("\\label\\b");
+ rule.format = labelFormat;
+ highlightingRules.append(rule);
}
void M4SCpSyntaxHighlighter::createSCpOriginsFormat()
@@ -98,8 +128,10 @@ void M4SCpSyntaxHighlighter::createSCpOriginsFormat()
<< "\\b6_\\b" << "\\bset3_\\b" << "\\bset9_\\b" ;
QTextCharFormat m4scpOrdinalsFormat;
- m4scpOrdinalsFormat.setForeground(Qt::darkBlue);
+ QFont font("Courier New",11,true);
+ m4scpOrdinalsFormat.setFont(font);
m4scpOrdinalsFormat.setFontWeight(QFont::Bold);
+ m4scpOrdinalsFormat.setForeground(Qt::black);
saveFormat(m4scpOrdinalsFormat,m4scpOrdinals);
}
@@ -108,18 +140,27 @@ void M4SCpSyntaxHighlighter::createSCpAttributesFormat()
{
QStringList m4scpAttributes;
m4scpAttributes
- << "\\barc_\\b" << "\\bassign_\\b" << "\\bconst_\\b" << "\\belse_\\b"
- << "\\bfixed_\\b" << "\\bfuz_\\b" << "\\bgoto_\\b" << "\\bin_\\b"
+ << "\\barc_\\b" << "\\bconst_\\b" << "\\belse_\\b" << "\\bsegc_9_\\b"
+ << "\\bfuz_\\b" << "\\bgoto_\\b" << "\\bin_\\b" << "\\bsegc_4_\\b"
<< "\\bmetavar_\\b" << "\\bneg_\\b" << "\\bnode_\\b" << "\\bout_\\b"
<< "\\bprm_\\b" << "\\bsegc_1_\\b" << "\\bsegc_2_\\b"<< "\\bsegc_3_\\b"
<< "\\bsegc_5_\\b" << "\\bsegc_6_\\b" << "\\bsegc_7_\\b"<< "\\bsegc_8_\\b"
<< "\\bthen_\\b" << "\\bundf_\\b" << "\\bvar_\\b" <<"\\belem_\\b"
- << "\\bf_\\b" << "\\binit_\\b" << "\\bpos_\\b" << "\\bsegc_4_\\b"
- << "\\bsegc_9_\\b";
+ << "\\bf_\\b" << "\\binit_\\b" << "\\bpos_\\b";
QTextCharFormat m4scpAttributesFormat;
- m4scpAttributesFormat.setForeground(Qt::darkMagenta);
- m4scpAttributesFormat.setFontWeight(QFont::Normal);
+ QFont font_1("Arial",10,true);
+ font_1.setBold(false);
+ m4scpAttributesFormat.setFont(font_1);
+ m4scpAttributesFormat.setForeground(QBrush(qRgb(0,128,0)));
+
+ saveFormat(m4scpAttributesFormat,m4scpAttributes);
+ m4scpAttributes.clear();
+ m4scpAttributes<< "\\bassign_\\b" << "\\bfixed_\\b"<< "\\bf_\\b";
+ QFont font_2("Courier New",10,true);
+ font_2.setBold(false);
+ m4scpAttributesFormat.setFont(font_2);
+ m4scpAttributesFormat.setForeground(Qt::red);
saveFormat(m4scpAttributesFormat,m4scpAttributes);
}
@@ -135,7 +176,7 @@ void M4SCpSyntaxHighlighter::saveFormat(QTextCharFormat format,QStringList patte
void M4SCpSyntaxHighlighter::createBracketsFormat()
{
QTextCharFormat bracketsFormat;
- QBrush brush = QBrush(qRgb(253,79,22));
+ QBrush brush = QBrush(qRgb(0,64,0));
bracketsFormat.setForeground(brush);
bracketsFormat.setFontWeight(QFont::Bold);
M4SCpHighlightingRule rule;
@@ -153,28 +194,25 @@ void M4SCpSyntaxHighlighter::createOthersFormat()
rule.format = quotationFormat;
highlightingRules.append(rule);
- rule.pattern = QRegExp("/\".*\"/");
- quotationFormat.setForeground(Qt::green);
- rule.format = quotationFormat;
- highlightingRules.append(rule);
-
QTextCharFormat includeFormat;
includeFormat.setForeground(Qt::blue);
rule.pattern = QRegExp("#include");
rule.format = includeFormat;
highlightingRules.append(rule);
QTextCharFormat comaFormat;
- QBrush brush = QBrush(qRgb(25,173,222));
- comaFormat.setForeground(brush);
- comaFormat.setFontWeight(QFont::Bold);
+ comaFormat.setForeground(Qt::black);
rule.pattern = QRegExp("[,;:]");
rule.format = comaFormat;
highlightingRules.append(rule);
QTextCharFormat singleLineCommentFormat;
- singleLineCommentFormat.setForeground(QBrush(qRgb(86,90,189)));
+ singleLineCommentFormat.setForeground(Qt::darkGray);
rule.pattern = QRegExp("//[^\n]*");
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
+
+ multiLineCommentFormat.setForeground(Qt::darkGray);
+ commentStartExpression = QRegExp("/\\*");
+ commentEndExpression = QRegExp("\\*/");
}
@@ -30,6 +30,11 @@ class M4SCpSyntaxHighlighter : public QSyntaxHighlighter
public:
M4SCpSyntaxHighlighter(QTextDocument *parent = 0);
void highlightBlock(const QString &text);
+ struct M4SCpHighlightingRule
+ {
+ QRegExp pattern;
+ QTextCharFormat format;
+ };
private:
void createSCpOperatorFormat();
void createSCpAttributesFormat();
@@ -38,15 +43,11 @@ class M4SCpSyntaxHighlighter : public QSyntaxHighlighter
void createBracketsFormat();
void saveFormat(QTextCharFormat format, QStringList patterns);
-private:
-
- struct M4SCpHighlightingRule
- {
- QRegExp pattern;
- QTextCharFormat format;
- };
+private:
QVector<M4SCpHighlightingRule> highlightingRules;
-
+ QTextCharFormat multiLineCommentFormat;
+ QRegExp commentStartExpression;
+ QRegExp commentEndExpression;
};
#endif // M4SCPSYNTAXHIGHLIGHTER_H

0 comments on commit 0d4ca7d

Please sign in to comment.