diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-06-11 19:51:34 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-11 19:51:34 +0000 |
commit | 3c95dbb20859debe99edc874c57ddaa6f3acf3d2 (patch) | |
tree | 5198c578f6f4d769578676b94035824731b15771 /utils | |
parent | 0cca15c6d03991b9c169fdf4e0760f90928712a0 (diff) | |
download | rockbox-3c95dbb20859debe99edc874c57ddaa6f3acf3d2.tar.gz rockbox-3c95dbb20859debe99edc874c57ddaa6f3acf3d2.zip |
Theme Editor: Fixed bug in parser handling empty lines and made ParseTreeModel handle the new VIEWPORT element properly
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26792 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/codeeditor.cpp | 2 | ||||
-rw-r--r-- | utils/themeeditor/codeeditor.h | 2 | ||||
-rw-r--r-- | utils/themeeditor/parsetreenode.cpp | 6 | ||||
-rw-r--r-- | utils/themeeditor/skin_parser.c | 14 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.cpp | 21 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.h | 2 |
6 files changed, 34 insertions, 13 deletions
diff --git a/utils/themeeditor/codeeditor.cpp b/utils/themeeditor/codeeditor.cpp index d4b46ac52e..49f441057c 100644 --- a/utils/themeeditor/codeeditor.cpp +++ b/utils/themeeditor/codeeditor.cpp @@ -132,7 +132,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) if(errors.contains(blockNumber + 1)) { painter.fillRect(QRect(0, top, lineNumberArea->width(), - fontMetrics().height()), Qt::red); + fontMetrics().height()), errorColor); } painter.setPen(Qt::black); painter.drawText(0, top, lineNumberArea->width(), diff --git a/utils/themeeditor/codeeditor.h b/utils/themeeditor/codeeditor.h index ec36d50c22..5df5b423d5 100644 --- a/utils/themeeditor/codeeditor.h +++ b/utils/themeeditor/codeeditor.h @@ -61,6 +61,7 @@ public: int lineNumberAreaWidth(); void addError(int line){ errors.append(line); } void clearErrors(){ errors.clear(); } + void setErrorColor(QColor color){ errorColor = color; } protected: void resizeEvent(QResizeEvent *event); @@ -72,6 +73,7 @@ private slots: private: QWidget *lineNumberArea; QList<int> errors; + QColor errorColor; }; //![codeeditordefinition] diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp index df4e770f9c..d3a1a71c93 100644 --- a/utils/themeeditor/parsetreenode.cpp +++ b/utils/themeeditor/parsetreenode.cpp @@ -56,7 +56,6 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent) } break; - case VIEWPORT: case CONDITIONAL: for(int i = 0; i < element->params_count; i++) children.append(new ParseTreeNode(&data->params[i], this)); @@ -71,6 +70,11 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent) } break; +case VIEWPORT: + for(int i = 0; i < element->params_count; i++) + children.append(new ParseTreeNode(&data->params[i], this)); + /* Deliberate fall-through here */ + case LINE: for(int i = 0; i < data->children_count; i++) { diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c index e6a6350d13..bf7ca8d7f6 100644 --- a/utils/themeeditor/skin_parser.c +++ b/utils/themeeditor/skin_parser.c @@ -249,9 +249,19 @@ static struct skin_element* skin_parse_line_optional(char** document, retval = skin_alloc_element(); retval->type = LINE; retval->line = skin_line; - if(*cursor != '\0') + if(*cursor != '\0' && *cursor != '\n' + && !(conditional && (*cursor == ARGLISTSEPERATESYM + || *cursor == ARGLISTCLOSESYM + || *cursor == ENUMLISTSEPERATESYM + || *cursor == ENUMLISTCLOSESYM))) + { retval->children_count = 1; - else retval->children_count = 0; + } + else + { + retval->children_count = 0; + } + if(retval->children_count > 0) retval->children = skin_alloc_children(1); diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index b67c70db61..8547aafa17 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -146,10 +146,8 @@ void SkinDocument::settingsChanged() palette.setColor(QPalette::All, QPalette::Text, fg); editor->setPalette(palette); - errorColor = QTextCharFormat(); QColor highlight = settings.value("errorColor", Qt::red).value<QColor>(); - errorColor.setBackground(highlight); - errorColor.setProperty(QTextFormat::FullWidthSelection, true); + editor->setErrorColor(highlight); /* Setting the font */ QFont def("Monospace"); @@ -175,10 +173,19 @@ void SkinDocument::codeChanged() if(skin_error_line() > 0) { editor->addError(skin_error_line()); - } - else - { - editor->setExtraSelections(QList<QTextEdit::ExtraSelection>()); + + /* Now we're going to attempt parsing again at each line, until we find + one that won't error out + QTextDocument doc(editor->document()->toPlainText()); + if(skin_error_line() > 0) + { + QTextCursor rest(&doc); + + for(int i = 0; i < skin_error_line(); i++) + rest.movePosition(QTextCursor::NextBlock, + QTextCursor::KeepAnchor); + rest.clearSelection(); + }*/ } if(editor->document()->toPlainText() != saved) diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index e8bd27067f..741359b7a7 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h @@ -79,8 +79,6 @@ private: QString saved; QString parseStatus; - QTextCharFormat errorColor; - QLayout* layout; CodeEditor* editor; |