Make console output a textarea
This commit is contained in:
parent
02036d4b46
commit
eecf78ca1b
@ -478,18 +478,21 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
|
||||
info.name.remove(QRegExp(".* "));
|
||||
}
|
||||
|
||||
qDebug() << "Block starts at" << blockStart.position() << "contents:" << blockStart.block().text();
|
||||
int childBlocks = 0;
|
||||
while (!blockStart.isNull() && blockStart.position() < position) {
|
||||
QString line = blockStart.block().text();
|
||||
if (line.endsWith("{")) {
|
||||
blockStart.movePosition(QTextCursor::NextBlock);
|
||||
childBlocks++;
|
||||
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (line.trimmed().startsWith("}")) {
|
||||
blockStart.movePosition(QTextCursor::NextBlock);
|
||||
childBlocks--;
|
||||
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// \n
|
||||
@ -508,7 +511,9 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
|
||||
qDebug() << "inserting:" << propName << "->" << propValue;
|
||||
info.properties.insert(propName, propValue);
|
||||
}
|
||||
blockStart.movePosition(QTextCursor::NextBlock);
|
||||
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
@ -145,7 +145,8 @@ Page {
|
||||
if (scriptId !== d.scriptId) {
|
||||
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")
|
||||
signal raise()
|
||||
|
||||
ListView {
|
||||
id: messagesListView
|
||||
model: ListModel {
|
||||
id: messagesModel
|
||||
onCountChanged: {
|
||||
if (count > 0) {
|
||||
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
|
||||
}
|
||||
TextArea {
|
||||
id: consoleOutput
|
||||
onTextChanged: consolePane.raise();
|
||||
selectByMouse: true
|
||||
font: scriptEdit.font
|
||||
textFormat: Qt.RichText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user