forked from len0rd/rockbox
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
This commit is contained in:
parent
0cca15c6d0
commit
3c95dbb208
6 changed files with 34 additions and 13 deletions
|
@ -132,7 +132,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||||
if(errors.contains(blockNumber + 1))
|
if(errors.contains(blockNumber + 1))
|
||||||
{
|
{
|
||||||
painter.fillRect(QRect(0, top, lineNumberArea->width(),
|
painter.fillRect(QRect(0, top, lineNumberArea->width(),
|
||||||
fontMetrics().height()), Qt::red);
|
fontMetrics().height()), errorColor);
|
||||||
}
|
}
|
||||||
painter.setPen(Qt::black);
|
painter.setPen(Qt::black);
|
||||||
painter.drawText(0, top, lineNumberArea->width(),
|
painter.drawText(0, top, lineNumberArea->width(),
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
int lineNumberAreaWidth();
|
int lineNumberAreaWidth();
|
||||||
void addError(int line){ errors.append(line); }
|
void addError(int line){ errors.append(line); }
|
||||||
void clearErrors(){ errors.clear(); }
|
void clearErrors(){ errors.clear(); }
|
||||||
|
void setErrorColor(QColor color){ errorColor = color; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
@ -72,6 +73,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QWidget *lineNumberArea;
|
QWidget *lineNumberArea;
|
||||||
QList<int> errors;
|
QList<int> errors;
|
||||||
|
QColor errorColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
//![codeeditordefinition]
|
//![codeeditordefinition]
|
||||||
|
|
|
@ -56,7 +56,6 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIEWPORT:
|
|
||||||
case CONDITIONAL:
|
case CONDITIONAL:
|
||||||
for(int i = 0; i < element->params_count; i++)
|
for(int i = 0; i < element->params_count; i++)
|
||||||
children.append(new ParseTreeNode(&data->params[i], this));
|
children.append(new ParseTreeNode(&data->params[i], this));
|
||||||
|
@ -71,6 +70,11 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case LINE:
|
||||||
for(int i = 0; i < data->children_count; i++)
|
for(int i = 0; i < data->children_count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,9 +249,19 @@ static struct skin_element* skin_parse_line_optional(char** document,
|
||||||
retval = skin_alloc_element();
|
retval = skin_alloc_element();
|
||||||
retval->type = LINE;
|
retval->type = LINE;
|
||||||
retval->line = skin_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;
|
retval->children_count = 1;
|
||||||
else retval->children_count = 0;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retval->children_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(retval->children_count > 0)
|
if(retval->children_count > 0)
|
||||||
retval->children = skin_alloc_children(1);
|
retval->children = skin_alloc_children(1);
|
||||||
|
|
||||||
|
|
|
@ -146,10 +146,8 @@ void SkinDocument::settingsChanged()
|
||||||
palette.setColor(QPalette::All, QPalette::Text, fg);
|
palette.setColor(QPalette::All, QPalette::Text, fg);
|
||||||
editor->setPalette(palette);
|
editor->setPalette(palette);
|
||||||
|
|
||||||
errorColor = QTextCharFormat();
|
|
||||||
QColor highlight = settings.value("errorColor", Qt::red).value<QColor>();
|
QColor highlight = settings.value("errorColor", Qt::red).value<QColor>();
|
||||||
errorColor.setBackground(highlight);
|
editor->setErrorColor(highlight);
|
||||||
errorColor.setProperty(QTextFormat::FullWidthSelection, true);
|
|
||||||
|
|
||||||
/* Setting the font */
|
/* Setting the font */
|
||||||
QFont def("Monospace");
|
QFont def("Monospace");
|
||||||
|
@ -175,10 +173,19 @@ void SkinDocument::codeChanged()
|
||||||
if(skin_error_line() > 0)
|
if(skin_error_line() > 0)
|
||||||
{
|
{
|
||||||
editor->addError(skin_error_line());
|
editor->addError(skin_error_line());
|
||||||
}
|
|
||||||
else
|
/* 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)
|
||||||
{
|
{
|
||||||
editor->setExtraSelections(QList<QTextEdit::ExtraSelection>());
|
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)
|
if(editor->document()->toPlainText() != saved)
|
||||||
|
|
|
@ -79,8 +79,6 @@ private:
|
||||||
QString saved;
|
QString saved;
|
||||||
QString parseStatus;
|
QString parseStatus;
|
||||||
|
|
||||||
QTextCharFormat errorColor;
|
|
||||||
|
|
||||||
QLayout* layout;
|
QLayout* layout;
|
||||||
CodeEditor* editor;
|
CodeEditor* editor;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue