Make console output a textarea

This commit is contained in:
Michael Zanetti 2019-12-08 14:33:55 +01:00
parent 02036d4b46
commit eecf78ca1b
2 changed files with 17 additions and 31 deletions

View File

@ -478,18 +478,21 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
info.name.remove(QRegExp(".* ")); info.name.remove(QRegExp(".* "));
} }
qDebug() << "Block starts at" << blockStart.position() << "contents:" << blockStart.block().text();
int childBlocks = 0; int childBlocks = 0;
while (!blockStart.isNull() && blockStart.position() < position) { while (!blockStart.isNull() && blockStart.position() < position) {
QString line = blockStart.block().text(); QString line = blockStart.block().text();
if (line.endsWith("{")) { if (line.endsWith("{")) {
blockStart.movePosition(QTextCursor::NextBlock);
childBlocks++; childBlocks++;
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
break;
}
continue; continue;
} }
if (line.trimmed().startsWith("}")) { if (line.trimmed().startsWith("}")) {
blockStart.movePosition(QTextCursor::NextBlock);
childBlocks--; childBlocks--;
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
break;
}
continue; continue;
} }
// \n // \n
@ -508,7 +511,9 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
qDebug() << "inserting:" << propName << "->" << propValue; qDebug() << "inserting:" << propName << "->" << propValue;
info.properties.insert(propName, propValue); info.properties.insert(propName, propValue);
} }
blockStart.movePosition(QTextCursor::NextBlock); if (!blockStart.movePosition(QTextCursor::NextBlock)) {
break;
}
} }
return info; return info;

View File

@ -145,7 +145,8 @@ Page {
if (scriptId !== d.scriptId) { if (scriptId !== d.scriptId) {
return; return;
} }
messagesModel.append({type: type, message: message}) var str = "<font color=\"%1\">".arg(type == "ScriptMessageTypeWarning" ? app.accentColor : app.foregroundColor) + message + "</font>"
consoleOutput.append(str)
} }
} }
@ -346,32 +347,12 @@ Page {
property string title: qsTr("Console") property string title: qsTr("Console")
signal raise() signal raise()
ListView { TextArea {
id: messagesListView id: consoleOutput
model: ListModel { onTextChanged: consolePane.raise();
id: messagesModel selectByMouse: true
onCountChanged: { font: scriptEdit.font
if (count > 0) { textFormat: Qt.RichText
consolePane.raise();
}
}
}
property bool autoScroll: true
onCountChanged: {
if (autoScroll) {
messagesListView.positionViewAtEnd()
}
}
onMovementEnded: {
autoScroll = messagesListView.atYEnd;
}
delegate: Label {
width: parent.width
text: model.message
font: scriptEdit.font
color: model.type === "ScriptMessageTypeWarning" ? "red" : app.foregroundColor
}
} }
} }
} }