|
|
@ -18,7 +18,7 @@ Item { |
|
|
|
function setText(text, mode) { |
|
|
|
currentText = text; |
|
|
|
currentMode = mode; |
|
|
|
if (initialized) { |
|
|
|
if (initialized && editorBrowser) { |
|
|
|
editorBrowser.runJavaScript("setTextBase64(\"" + Qt.btoa(text) + "\")"); |
|
|
|
editorBrowser.runJavaScript("setMode(\"" + mode + "\")"); |
|
|
|
} |
|
|
@ -26,7 +26,8 @@ Item { |
|
|
|
} |
|
|
|
|
|
|
|
function setFocus() { |
|
|
|
editorBrowser.forceActiveFocus(); |
|
|
|
if (editorBrowser) |
|
|
|
editorBrowser.forceActiveFocus(); |
|
|
|
} |
|
|
|
|
|
|
|
function getText() { |
|
|
@ -34,19 +35,19 @@ Item { |
|
|
|
} |
|
|
|
|
|
|
|
function syncClipboard() { |
|
|
|
if (Qt.platform.os == "osx") { |
|
|
|
if (Qt.platform.os == "osx" && editorBrowser) { |
|
|
|
var text = clipboard.text; |
|
|
|
editorBrowser.runJavaScript("setClipboardBase64(\"" + Qt.btoa(text) + "\")"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function highlightExecution(location) { |
|
|
|
if (initialized) |
|
|
|
if (initialized && editorBrowser) |
|
|
|
editorBrowser.runJavaScript("highlightExecution(" + location.start + "," + location.end + ")"); |
|
|
|
} |
|
|
|
|
|
|
|
function showWarning(content) { |
|
|
|
if (initialized) |
|
|
|
if (initialized && editorBrowser) |
|
|
|
editorBrowser.runJavaScript("showWarning('" + content + "')"); |
|
|
|
} |
|
|
|
|
|
|
@ -55,12 +56,12 @@ Item { |
|
|
|
} |
|
|
|
|
|
|
|
function toggleBreakpoint() { |
|
|
|
if (initialized) |
|
|
|
if (initialized && editorBrowser) |
|
|
|
editorBrowser.runJavaScript("toggleBreakpoint()"); |
|
|
|
} |
|
|
|
|
|
|
|
function changeGeneration() { |
|
|
|
if (initialized) |
|
|
|
if (initialized && editorBrowser) |
|
|
|
editorBrowser.runJavaScript("changeGeneration()", function(result) {}); |
|
|
|
} |
|
|
|
|
|
|
@ -81,9 +82,15 @@ Item { |
|
|
|
console.log("editor: " + sourceID + ":" + lineNumber + ":" + message); |
|
|
|
} |
|
|
|
|
|
|
|
Component.onDestruction: |
|
|
|
{ |
|
|
|
codeModel.onCompilationComplete.disconnect(compilationComplete); |
|
|
|
codeModel.onCompilationError.disconnect(compilationError); |
|
|
|
} |
|
|
|
|
|
|
|
onLoadingChanged: |
|
|
|
{ |
|
|
|
if (!loading) { |
|
|
|
if (!loading && editorBrowser) { |
|
|
|
initialized = true; |
|
|
|
setText(currentText, currentMode); |
|
|
|
runJavaScript("getTextChanged()", function(result) { }); |
|
|
@ -91,23 +98,31 @@ Item { |
|
|
|
syncClipboard(); |
|
|
|
if (currentMode === "solidity") |
|
|
|
{ |
|
|
|
codeModel.onCompilationComplete.connect(function(){ |
|
|
|
runJavaScript("compilationComplete()", function(result) { }); |
|
|
|
}); |
|
|
|
|
|
|
|
codeModel.onCompilationError.connect(function(error){ |
|
|
|
var errorInfo = ErrorLocationFormater.extractErrorInfo(error, false); |
|
|
|
if (errorInfo.line && errorInfo.column) |
|
|
|
runJavaScript("compilationError('" + errorInfo.line + "', '" + errorInfo.column + "', '" + errorInfo.errorDetail + "')", function(result) { }); |
|
|
|
else |
|
|
|
runJavaScript("compilationComplete()", function(result) { }); |
|
|
|
}); |
|
|
|
codeModel.onCompilationComplete.connect(compilationComplete); |
|
|
|
codeModel.onCompilationError.connect(compilationError); |
|
|
|
} |
|
|
|
parent.changeGeneration(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function compilationComplete() |
|
|
|
{ |
|
|
|
if (editorBrowser) |
|
|
|
editorBrowser.runJavaScript("compilationComplete()", function(result) { }); |
|
|
|
} |
|
|
|
|
|
|
|
function compilationError(error) |
|
|
|
{ |
|
|
|
if (!editorBrowser || !error) |
|
|
|
return; |
|
|
|
var errorInfo = ErrorLocationFormater.extractErrorInfo(error, false); |
|
|
|
if (errorInfo.line && errorInfo.column) |
|
|
|
editorBrowser.runJavaScript("compilationError('" + errorInfo.line + "', '" + errorInfo.column + "', '" + errorInfo.errorDetail + "')", function(result) { }); |
|
|
|
else |
|
|
|
editorBrowser.runJavaScript("compilationComplete()", function(result) { }); |
|
|
|
} |
|
|
|
|
|
|
|
Timer |
|
|
|
{ |
|
|
|
id: pollTimer |
|
|
@ -115,6 +130,8 @@ Item { |
|
|
|
running: false |
|
|
|
repeat: true |
|
|
|
onTriggered: { |
|
|
|
if (!editorBrowser) |
|
|
|
return; |
|
|
|
editorBrowser.runJavaScript("getTextChanged()", function(result) { |
|
|
|
if (result === true) { |
|
|
|
editorBrowser.runJavaScript("getText()" , function(textValue) { |
|
|
|