aboutsummaryrefslogtreecommitdiff
path: root/qml/commands.js
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-08-11 21:28:46 +0200
committerAdrian Kummerlaender2015-08-11 21:28:46 +0200
commit610cc9d77f89ab106fdbfbc006934c9d192a55a8 (patch)
tree543ce901a9553b366fd0368c970eeda5c03927e7 /qml/commands.js
parentf38010b397ee60f4cf3bb1c7316eb467d3dc6108 (diff)
downloadMetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.tar
MetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.tar.gz
MetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.tar.bz2
MetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.tar.lz
MetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.tar.xz
MetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.tar.zst
MetaTerm-610cc9d77f89ab106fdbfbc006934c9d192a55a8.zip
Add command output log to UI
`output` text item reference is passed to all command implementations.
Diffstat (limited to 'qml/commands.js')
-rw-r--r--qml/commands.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/qml/commands.js b/qml/commands.js
index 7d4bdcf..b116b23 100644
--- a/qml/commands.js
+++ b/qml/commands.js
@@ -1,6 +1,6 @@
-function execute(command) {
+function execute(output, command) {
var msg = function(name) {
- console.log('"' + name + '"' + " is not implemented.");
+ output.log('"' + name + '"' + " is not implemented.");
};
var args = command.split(' ');
@@ -9,7 +9,7 @@ function execute(command) {
if ( typeof closure === "function" ) {
args.shift();
- closure(args);
+ closure(output, args);
} else {
msg(args[0]);
}
@@ -18,8 +18,18 @@ function execute(command) {
}
}
-function exec(args) {
- eval(args.join(' '));
+function exec(output, args) {
+ var result = eval(args.join(' '));
+
+ if ( typeof result !== "undefined" ) {
+ output.log(result);
+ } else {
+ output.log('');
+ }
+}
+
+function jump(output, index) {
+ terminalList.selectItem(index);
}
function next() {
@@ -30,6 +40,3 @@ function prev() {
terminalList.selectPrev();
}
-function jump(index) {
- terminalList.selectItem(index);
-}