diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index c27ea11ba..34dc7c698 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -313,8 +313,10 @@ Item { visible: false function addExpression() { - if (expressionInput.text === "" || expressionInput.text === qsTr("Expression")) + if (expressionInput.text === "") return; + expressionInput.history.unshift(expressionInput.text); + expressionInput.index = -1; webView.runJavaScript("executeJavaScript(\"" + expressionInput.text.replace(/"/g, '\\"') + "\")", function(result) { resultTextArea.text = "> " + result + "\n\n" + resultTextArea.text; expressionInput.text = ""; @@ -350,6 +352,31 @@ Item { font.italic: true font.pointSize: Style.absoluteSize(-3) anchors.verticalCenter: parent.verticalCenter + + property var history: [] + property int index: -1 + + function displayCache(incr) + { + index = index + incr; + if (history.length - 1 < index || index < 0) + { + if (incr === 1) + index = 0; + else + index = history.length - 1; + } + expressionInput.text = history[index]; + } + + Keys.onDownPressed: { + displayCache(1); + } + + Keys.onUpPressed: { + displayCache(-1); + } + Keys.onEnterPressed: { expressionPanel.addExpression(); diff --git a/mix/qml/html/WebContainer.html b/mix/qml/html/WebContainer.html index 38d82c956..3cddda377 100644 --- a/mix/qml/html/WebContainer.html +++ b/mix/qml/html/WebContainer.html @@ -39,7 +39,7 @@ init = function(url) { executeJavaScript = function(script) { var preview = document.getElementById('preview'); var obj = preview.contentWindow.eval(script); - return JSON.stringify(obj); + return JSON.stringify(obj, null, 2); }