diff options
-rw-r--r-- | ethereal/assets/muted/debugger.html | 2 | ||||
-rw-r--r-- | ethereal/assets/muted/index.html | 46 | ||||
-rw-r--r-- | ethereal/assets/muted/muted.js | 61 | ||||
-rw-r--r-- | ethereal/assets/qml/muted.qml | 107 | ||||
-rw-r--r-- | ethereal/assets/qml/webapp.qml | 237 | ||||
-rw-r--r-- | ethereal/ui/ui_lib.go | 4 | ||||
-rw-r--r-- | ethereum/dev_console.go | 3 |
7 files changed, 287 insertions, 173 deletions
diff --git a/ethereal/assets/muted/debugger.html b/ethereal/assets/muted/debugger.html index 077c59bcf..b7552f030 100644 --- a/ethereal/assets/muted/debugger.html +++ b/ethereal/assets/muted/debugger.html @@ -4,7 +4,7 @@ <style type="text/css"> html, body { margin: 0; padding: 0; - min-height: 100%; + min-height: 100%; } #debugger { diff --git a/ethereal/assets/muted/index.html b/ethereal/assets/muted/index.html index c750d780b..14949b5ac 100644 --- a/ethereal/assets/muted/index.html +++ b/ethereal/assets/muted/index.html @@ -7,20 +7,63 @@ <script src="lib/codemirror.js"></script> <script src="lib/matchbrackets.js"></script> <script src="lib/go.js"></script> +<script src="muted.js"></script> <style type="text/css"> html, body { margin: 0; padding: 0; + min-height: 100%; + } + + #debugger { + height: 30%; + font-family: "Monaco"; + border-top: 5px solid grey; + } + #debugger .line { + overflow: none; + } + #debugger .col1, #debugger .col2 { + float: left; + padding: 3px; + } + #debugger .col1 { + width: 10px; + padding-left: 10px + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + #debugger .col2 { + width: 90%; + } + .prompt { + color: "#5089D4"; } .CodeMirror { - height: 100%; + height: 70%; + font-size: 14pt; } </style> </head> <body> <textarea id="editor"></textarea> + +<div id="debugger"> + <div class="line"> + <div class="col1 prompt"> + > + </div> + <div class="col2" contenteditable> + </div> + </div> +</div> + <script> var textArea = document.querySelector("#editor") var editor = CodeMirror.fromTextArea(textArea, { @@ -33,6 +76,5 @@ indentWithTabs: true, }); </script> - </body> </html> diff --git a/ethereal/assets/muted/muted.js b/ethereal/assets/muted/muted.js new file mode 100644 index 000000000..72e858d7a --- /dev/null +++ b/ethereal/assets/muted/muted.js @@ -0,0 +1,61 @@ +// Helper function for generating pseudo callbacks and sending data to the QML part of the application +function postData(data, cb) { + data._seed = Math.floor(Math.random() * 1000000) + if(cb) { + Muted._callbacks[data._seed] = cb; + } + + if(data.args === undefined) { + data.args = []; + } + + navigator.qt.postMessage(JSON.stringify(data)); +} + +window.Muted = { + prototype: Object(), +} + +window.Muted._callbacks = {} +window.Muted._onCallbacks = {} + +function debug(/**/) { + console.log("hello world") + + var args = arguments; + var msg = "" + for(var i = 0; i < args.length; i++){ + if(typeof args[i] == "object") { + msg += " " + JSON.stringify(args[i]) + } else { + msg += args[i] + } + } + + document.querySelector("#debugger").innerHTML += "<div class='line'><div class='col1'></div><div class='col2'>"+msg+"</div></div>"; +} +console.log = function() { + var args = [] + for(var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + postData({call:"log", args:args}) +} + +navigator.qt.onmessage = function(ev) { + var data = JSON.parse(ev.data) + + if(data._event !== undefined) { + Muted.trigger(data._event, data.data); + } else { + if(data._seed) { + var cb = Muted._callbacks[data._seed]; + if(cb) { + // Call the callback + cb(data.data); + // Remove the "trigger" callback + delete Muted._callbacks[ev._seed]; + } + } + } +} diff --git a/ethereal/assets/qml/muted.qml b/ethereal/assets/qml/muted.qml index dbeec2167..fac8267c4 100644 --- a/ethereal/assets/qml/muted.qml +++ b/ethereal/assets/qml/muted.qml @@ -7,59 +7,68 @@ import QtQuick.Window 2.1; import Ethereum 1.0 ApplicationWindow { - id: window - title: "muted" - width: 900 - height: 600 - minimumHeight: 300 + id: window + title: "muted" + width: 900 + height: 600 + minimumHeight: 300 - property alias url: webView.url - property alias debugUrl: debugView.url - property alias webView: webView + property alias url: webView.url + property alias webView: webView - Item { - id: root - anchors.fill: parent - WebView { - objectName: "webView" - id: webView - anchors { - top: root.top - right: root.right - left: root.left - bottom: sizeGrip.top - } - } + Item { + id: root + anchors.fill: parent + WebView { + objectName: "webView" + id: webView + anchors { + top: root.top + right: root.right + left: root.left + bottom: root.bottom + //bottom: sizeGrip.top + } - Rectangle { - id: sizeGrip - color: "gray" - height: 5 - anchors { - left: root.left - right: root.right - } - y: Math.round(root.height * 2 / 3) + experimental.preferences.javascriptEnabled: true + experimental.preferences.navigatorQtObjectEnabled: true + experimental.onMessageReceived: { + var data = JSON.parse(message.data) - MouseArea { - anchors.fill: parent - drag.target: sizeGrip - drag.minimumY: 0 - drag.maximumY: root.height - sizeGrip.height - drag.axis: Drag.YAxis - } - } + switch(data.call) { + case "log": + console.log.apply(this, data.args) + break; + } + } + function postData(seed, data) { + webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed})) + } + function postEvent(event, data) { + webview.experimental.postMessage(JSON.stringify({data: data, _event: event})) + } + } - WebView { - id: debugView - objectName: "debugView" - anchors { - left: root.left - right: root.right - bottom: root.bottom - top: sizeGrip.bottom - } - } - } + /* + Rectangle { + id: sizeGrip + color: "gray" + height: 5 + anchors { + left: root.left + right: root.right + } + y: Math.round(root.height * 2 / 3) + + MouseArea { + anchors.fill: parent + drag.target: sizeGrip + drag.minimumY: 0 + drag.maximumY: root.height - sizeGrip.height + drag.axis: Drag.YAxis + } + } + */ + } } diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml index c34e0dc55..3afc0def0 100644 --- a/ethereal/assets/qml/webapp.qml +++ b/ethereal/assets/qml/webapp.qml @@ -7,134 +7,135 @@ import QtQuick.Window 2.1; import Ethereum 1.0 ApplicationWindow { - id: window - title: "Ethereum" - width: 900 - height: 600 - minimumHeight: 300 + id: window + title: "Ethereum" + width: 900 + height: 600 + minimumHeight: 300 - property alias url: webview.url - property alias webView: webview + property alias url: webview.url + property alias webView: webview - Item { - objectName: "root" - id: root - anchors.fill: parent - state: "inspectorShown" + Item { + objectName: "root" + id: root + anchors.fill: parent + state: "inspectorShown" - WebView { - objectName: "webView" - id: webview - anchors.fill: parent - /* - anchors { - left: parent.left - right: parent.right - bottom: sizeGrip.top - top: parent.top - } - */ + WebView { + objectName: "webView" + id: webview + anchors.fill: parent + /* + anchors { + left: parent.left + right: parent.right + bottom: sizeGrip.top + top: parent.top + } + */ - onTitleChanged: { window.title = title } - experimental.preferences.javascriptEnabled: true - experimental.preferences.navigatorQtObjectEnabled: true - experimental.preferences.developerExtrasEnabled: true - experimental.userScripts: [ui.assetPath("ethereum.js")] - experimental.onMessageReceived: { - //console.log("[onMessageReceived]: ", message.data) - var data = JSON.parse(message.data) + onTitleChanged: { window.title = title } + experimental.preferences.javascriptEnabled: true + experimental.preferences.navigatorQtObjectEnabled: true + experimental.preferences.developerExtrasEnabled: true + experimental.userScripts: [ui.assetPath("ethereum.js")] + experimental.onMessageReceived: { + //console.log("[onMessageReceived]: ", message.data) + var data = JSON.parse(message.data) - switch(data.call) { - case "getBlockByNumber": - var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") - postData(data._seed, block) - break - case "getBlockByHash": - var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") - postData(data._seed, block) - break - case "createTx": - if(data.args.length < 5) { - postData(data._seed, null) - } else { - var tx = eth.createTx(data.args[0], data.args[1],data.args[2],data.args[3],data.args[4]) - postData(data._seed, tx) - } - break - case "getStorage": - if(data.args.length < 2) { - postData(data._seed, null) - } else { - var stateObject = eth.getStateObject(data.args[0]) - var storage = stateObject.getStorage(data.args[1]) - postData(data._seed, storage) - } - break - case "getKey": - var keys = eth.getKey() - postData(data._seed, keys) - break - case "watch": - if(data.args.length > 0) { - eth.watch(data.args[0]); - } - } + switch(data.call) { + case "getBlockByNumber": + var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") + postData(data._seed, block) + break + case "getBlockByHash": + var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") + postData(data._seed, block) + break + case "createTx": + if(data.args.length < 5) { + postData(data._seed, null) + } else { + var tx = eth.createTx(data.args[0], data.args[1],data.args[2],data.args[3],data.args[4]) + postData(data._seed, tx) } - function postData(seed, data) { - webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed})) - } - function postEvent(event, data) { - webview.experimental.postMessage(JSON.stringify({data: data, _event: event})) - } - - function onNewBlockCb(block) { - postEvent("block:new", block) - } - function onObjectChangeCb(stateObject) { - postEvent("object:change", stateObject) - } - } - - Rectangle { - id: sizeGrip - color: "gray" - visible: false - height: 10 - anchors { - left: root.left - right: root.right + break + case "getStorage": + if(data.args.length < 2) { + postData(data._seed, null) + } else { + var stateObject = eth.getStateObject(data.args[0]) + var storage = stateObject.getStorage(data.args[1]) + postData(data._seed, storage) } - y: Math.round(root.height * 2 / 3) - - MouseArea { - anchors.fill: parent - drag.target: sizeGrip - drag.minimumY: 0 - drag.maximumY: root.height - drag.axis: Drag.YAxis + break + case "getKey": + var keys = eth.getKey() + postData(data._seed, keys) + break + case "watch": + if(data.args.length > 0) { + eth.watch(data.args[0]); } + break } + } + function postData(seed, data) { + webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed})) + } + function postEvent(event, data) { + webview.experimental.postMessage(JSON.stringify({data: data, _event: event})) + } - WebView { - id: inspector - visible: false - url: webview.experimental.remoteInspectorUrl - anchors { - left: root.left - right: root.right - top: sizeGrip.bottom - bottom: root.bottom - } - } + function onNewBlockCb(block) { + postEvent("block:new", block) + } + function onObjectChangeCb(stateObject) { + postEvent("object:change", stateObject) + } + } - states: [ - State { - name: "inspectorShown" - PropertyChanges { - target: inspector - url: webview.experimental.remoteInspectorUrl - } - } - ] + Rectangle { + id: sizeGrip + color: "gray" + visible: false + height: 10 + anchors { + left: root.left + right: root.right + } + y: Math.round(root.height * 2 / 3) + + MouseArea { + anchors.fill: parent + drag.target: sizeGrip + drag.minimumY: 0 + drag.maximumY: root.height + drag.axis: Drag.YAxis + } } + + WebView { + id: inspector + visible: false + url: webview.experimental.remoteInspectorUrl + anchors { + left: root.left + right: root.right + top: sizeGrip.bottom + bottom: root.bottom + } + } + + states: [ + State { + name: "inspectorShown" + PropertyChanges { + target: inspector + url: webview.experimental.remoteInspectorUrl + } + } + ] + } } diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go index a9bde74b0..07cd0ac8a 100644 --- a/ethereal/ui/ui_lib.go +++ b/ethereal/ui/ui_lib.go @@ -120,8 +120,8 @@ func (ui *UiLib) Muted(content string) { go func() { path := "file://" + ui.AssetPath("muted/index.html") win.Set("url", path) - debuggerPath := "file://" + ui.AssetPath("muted/debugger.html") - win.Set("debugUrl", debuggerPath) + //debuggerPath := "file://" + ui.AssetPath("muted/debugger.html") + //win.Set("debugUrl", debuggerPath) win.Show() win.Wait() diff --git a/ethereum/dev_console.go b/ethereum/dev_console.go index 583b8bd0b..d2be43205 100644 --- a/ethereum/dev_console.go +++ b/ethereum/dev_console.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethwire" "github.com/ethereum/go-ethereum/utils" + "github.com/obscuren/mutan" "os" "strings" ) @@ -190,7 +191,7 @@ func (i *Console) ParseInput(input string) bool { case "contract": fmt.Println("Contract editor (Ctrl-D = done)") - mainInput, initInput := ethutil.PreProcess(i.Editor()) + mainInput, initInput := mutan.PreProcess(i.Editor()) mainScript, err := utils.Compile(mainInput) if err != nil { fmt.Println(err) |