summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-11 19:51:34 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-11 19:51:34 +0000
commit3c95dbb20859debe99edc874c57ddaa6f3acf3d2 (patch)
tree5198c578f6f4d769578676b94035824731b15771
parent0cca15c6d03991b9c169fdf4e0760f90928712a0 (diff)
downloadrockbox-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
-rw-r--r--utils/themeeditor/codeeditor.cpp2
-rw-r--r--utils/themeeditor/codeeditor.h2
-rw-r--r--utils/themeeditor/parsetreenode.cpp6
-rw-r--r--utils/themeeditor/skin_parser.c14
-rw-r--r--utils/themeeditor/skindocument.cpp21
-rw-r--r--utils/themeeditor/skindocument.h2
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)
132 if(errors.contains(blockNumber + 1)) 132 if(errors.contains(blockNumber + 1))
133 { 133 {
134 painter.fillRect(QRect(0, top, lineNumberArea->width(), 134 painter.fillRect(QRect(0, top, lineNumberArea->width(),
135 fontMetrics().height()), Qt::red); 135 fontMetrics().height()), errorColor);
136 } 136 }
137 painter.setPen(Qt::black); 137 painter.setPen(Qt::black);
138 painter.drawText(0, top, lineNumberArea->width(), 138 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:
61 int lineNumberAreaWidth(); 61 int lineNumberAreaWidth();
62 void addError(int line){ errors.append(line); } 62 void addError(int line){ errors.append(line); }
63 void clearErrors(){ errors.clear(); } 63 void clearErrors(){ errors.clear(); }
64 void setErrorColor(QColor color){ errorColor = color; }
64 65
65protected: 66protected:
66 void resizeEvent(QResizeEvent *event); 67 void resizeEvent(QResizeEvent *event);
@@ -72,6 +73,7 @@ private slots:
72private: 73private:
73 QWidget *lineNumberArea; 74 QWidget *lineNumberArea;
74 QList<int> errors; 75 QList<int> errors;
76 QColor errorColor;
75}; 77};
76 78
77//![codeeditordefinition] 79//![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)
56 } 56 }
57 break; 57 break;
58 58
59 case VIEWPORT:
60 case CONDITIONAL: 59 case CONDITIONAL:
61 for(int i = 0; i < element->params_count; i++) 60 for(int i = 0; i < element->params_count; i++)
62 children.append(new ParseTreeNode(&data->params[i], this)); 61 children.append(new ParseTreeNode(&data->params[i], this));
@@ -71,6 +70,11 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
71 } 70 }
72 break; 71 break;
73 72
73case VIEWPORT:
74 for(int i = 0; i < element->params_count; i++)
75 children.append(new ParseTreeNode(&data->params[i], this));
76 /* Deliberate fall-through here */
77
74 case LINE: 78 case LINE:
75 for(int i = 0; i < data->children_count; i++) 79 for(int i = 0; i < data->children_count; i++)
76 { 80 {
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,
249 retval = skin_alloc_element(); 249 retval = skin_alloc_element();
250 retval->type = LINE; 250 retval->type = LINE;
251 retval->line = skin_line; 251 retval->line = skin_line;
252 if(*cursor != '\0') 252 if(*cursor != '\0' && *cursor != '\n'
253 && !(conditional && (*cursor == ARGLISTSEPERATESYM
254 || *cursor == ARGLISTCLOSESYM
255 || *cursor == ENUMLISTSEPERATESYM
256 || *cursor == ENUMLISTCLOSESYM)))
257 {
253 retval->children_count = 1; 258 retval->children_count = 1;
254 else retval->children_count = 0; 259 }
260 else
261 {
262 retval->children_count = 0;
263 }
264
255 if(retval->children_count > 0) 265 if(retval->children_count > 0)
256 retval->children = skin_alloc_children(1); 266 retval->children = skin_alloc_children(1);
257 267
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()
146 palette.setColor(QPalette::All, QPalette::Text, fg); 146 palette.setColor(QPalette::All, QPalette::Text, fg);
147 editor->setPalette(palette); 147 editor->setPalette(palette);
148 148
149 errorColor = QTextCharFormat();
150 QColor highlight = settings.value("errorColor", Qt::red).value<QColor>(); 149 QColor highlight = settings.value("errorColor", Qt::red).value<QColor>();
151 errorColor.setBackground(highlight); 150 editor->setErrorColor(highlight);
152 errorColor.setProperty(QTextFormat::FullWidthSelection, true);
153 151
154 /* Setting the font */ 152 /* Setting the font */
155 QFont def("Monospace"); 153 QFont def("Monospace");
@@ -175,10 +173,19 @@ void SkinDocument::codeChanged()
175 if(skin_error_line() > 0) 173 if(skin_error_line() > 0)
176 { 174 {
177 editor->addError(skin_error_line()); 175 editor->addError(skin_error_line());
178 } 176
179 else 177 /* Now we're going to attempt parsing again at each line, until we find
180 { 178 one that won't error out
181 editor->setExtraSelections(QList<QTextEdit::ExtraSelection>()); 179 QTextDocument doc(editor->document()->toPlainText());
180 if(skin_error_line() > 0)
181 {
182 QTextCursor rest(&doc);
183
184 for(int i = 0; i < skin_error_line(); i++)
185 rest.movePosition(QTextCursor::NextBlock,
186 QTextCursor::KeepAnchor);
187 rest.clearSelection();
188 }*/
182 } 189 }
183 190
184 if(editor->document()->toPlainText() != saved) 191 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:
79 QString saved; 79 QString saved;
80 QString parseStatus; 80 QString parseStatus;
81 81
82 QTextCharFormat errorColor;
83
84 QLayout* layout; 82 QLayout* layout;
85 CodeEditor* editor; 83 CodeEditor* editor;
86 84